From cce1c28bcecec87f34983599441ce16f7c2cf829 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 1 Nov 2012 18:20:06 +0100 Subject: Migrated build system to CMake. Conditional file compilation. Automatic selection of platform handler. --- src/platform.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/platform.cpp') diff --git a/src/platform.cpp b/src/platform.cpp index d1d23de0..ff6a9965 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -22,6 +22,10 @@ // #include "vmime/platform.hpp" +#include "vmime/config.hpp" + +#include "vmime/platforms/posix/posixHandler.hpp" +#include "vmime/platforms/windows/windowsHandler.hpp" namespace vmime @@ -36,4 +40,40 @@ platform::handler::~handler() } +// static +ref platform::getDefaultHandler() +{ + +#if VMIME_PLATFORM_IS_WINDOWS + return vmime::create (); +#elif VMIME_PLATFORM_IS_POSIX + return vmime::create (); +#else + return NULL; +#endif + +} + + +// static +ref platform::getHandler() +{ + // If a custom platform handler is installed, return it + if (sm_handler) + return sm_handler; + + // Else, use the default handler for this platform + ref defaultHandler = getDefaultHandler(); + + if (defaultHandler) + { + sm_handler = defaultHandler; + return sm_handler; + } + + // Oops... no platform handler! + throw exceptions::no_platform_handler(); +} + + } // vmime -- cgit v1.2.3