aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/net/builtinServices.inl8
-rw-r--r--src/net/serviceFactory.cpp6
-rw-r--r--src/net/serviceRegistration.inl98
3 files changed, 108 insertions, 4 deletions
diff --git a/src/net/builtinServices.inl b/src/net/builtinServices.inl
index 803371ac..d8d4ea91 100644
--- a/src/net/builtinServices.inl
+++ b/src/net/builtinServices.inl
@@ -21,12 +21,12 @@
// the GNU General Public License cover the whole combination.
//
-#ifndef VMIME_BUILDING_DOC
+
+// Include registration helpers
+#include "src/net/serviceRegistration.inl"
-#define REGISTER_SERVICE(p_class, p_name, p_type) \
- vmime::net::service::initializer <vmime::net::p_class> \
- p_name(#p_name, vmime::net::service::p_type)
+#ifndef VMIME_BUILDING_DOC
#if VMIME_BUILTIN_MESSAGING_PROTO_POP3
diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp
index 222f3da2..e98e0e4c 100644
--- a/src/net/serviceFactory.cpp
+++ b/src/net/serviceFactory.cpp
@@ -122,5 +122,11 @@ const std::vector <ref <const serviceFactory::registeredService> > serviceFactor
}
+void serviceFactory::registerService(ref <registeredService> reg)
+{
+ m_services.push_back(reg);
+}
+
+
} // net
} // vmime
diff --git a/src/net/serviceRegistration.inl b/src/net/serviceRegistration.inl
new file mode 100644
index 00000000..104e4d72
--- /dev/null
+++ b/src/net/serviceRegistration.inl
@@ -0,0 +1,98 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Linking this library statically or dynamically with other modules is making
+// a combined work based on this library. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+//
+
+#include "vmime/net/serviceFactory.hpp"
+
+
+#ifndef VMIME_BUILDING_DOC
+
+
+namespace vmime {
+namespace net {
+
+
+template <class S>
+class registeredServiceImpl : public serviceFactory::registeredService
+{
+public:
+
+ registeredServiceImpl(const string& name, const int type)
+ : m_type(type), m_name(name), m_servInfos(S::getInfosInstance())
+ {
+ }
+
+ ref <service> create
+ (ref <session> sess,
+ ref <security::authenticator> auth) const
+ {
+ return vmime::create <S>(sess, auth);
+ }
+
+ const serviceInfos& getInfos() const
+ {
+ return (m_servInfos);
+ }
+
+ const string& getName() const
+ {
+ return (m_name);
+ }
+
+ const int getType() const
+ {
+ return (m_type);
+ }
+
+private:
+
+ const int m_type;
+ const string m_name;
+ const serviceInfos& m_servInfos;
+};
+
+
+// Basic service registerer
+template <class S>
+class serviceRegisterer
+{
+public:
+
+ serviceRegisterer(const string& protocol, const service::Type type)
+ {
+ serviceFactory::getInstance()->registerService
+ (vmime::create <vmime::net::registeredServiceImpl <S> >(protocol, type));
+ }
+};
+
+
+} // net
+} // vmime
+
+
+#define REGISTER_SERVICE(p_class, p_name, p_type) \
+ vmime::net::serviceRegisterer <vmime::net::p_class> \
+ p_name(#p_name, vmime::net::service::p_type)
+
+
+#endif // VMIME_BUILDING_DOC
+