libqutim
0.3.2.0
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef MODULEMANAGER_H 00027 #define MODULEMANAGER_H 00028 00029 #include "libqutim_global.h" 00030 #include "plugin.h" 00031 #include <QStringList> 00032 #include <QMultiMap> 00033 #include "event.h" 00034 00035 namespace qutim_sdk_0_3 00036 { 00037 class ModuleManagerPrivate; 00038 00043 class LIBQUTIM_EXPORT ModuleManager : public QObject 00044 { 00045 Q_OBJECT 00046 protected: 00047 // Constructor 00048 ModuleManager(QObject *parent = 0); 00049 // Destructor 00050 virtual ~ModuleManager(); 00051 00052 ExtensionInfoList extensions(const char *interfaceId) const; 00053 ExtensionInfoList extensions(const QMetaObject *meta) const; 00054 00055 // Methods 00056 void loadPlugins(const QStringList &additional_paths = QStringList()); 00057 QObject *initExtension(const QMetaObject *service_meta); 00058 00059 // Virtual Methods 00060 virtual ExtensionInfoList coreExtensions() const = 0; 00061 virtual void initExtensions(); 00062 00063 // Inline Methods 00064 template<typename T> 00065 inline QMultiMap<Plugin *, ExtensionInfo> getExtensions() 00066 { 00067 return getExtensions(&T::staticMetaObject); 00068 } 00069 00070 template<typename T> 00071 inline T *initExtension() 00072 { 00073 return static_cast<T *>(initExtension(&T::staticMetaObject)); 00074 } 00075 protected slots: 00076 void onQuit(); 00077 void _q_protocolDestroyed(QObject *obj); //TODO remove me 00078 void _q_messageReceived(const QString &); 00079 protected: 00080 virtual void virtual_hook(int id, void *data); 00081 private: 00082 friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const QMetaObject *); 00083 friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const char *); 00084 }; 00085 00086 // LIBQUTIM_EXPORT void registerModule(const char *name, const char *description, const char *face, const QMetaObject *meta, int min = 0, int max = -1); 00087 // inline void registerModule(const char *name, const char *description, const char *face, int min = 0, int max = -1) 00088 // { registerModule(name, description, face, NULL, min, max); } 00089 // inline void registerModule(const char *name, const char *description, const QMetaObject *meta, int min = 0, int max = -1) 00090 // { registerModule(name, description, NULL, meta, min, max); } 00091 // 00092 // template<typename T, int Min, int Max> 00093 // class ModuleHelper 00094 // { 00095 // public: 00096 // inline ModuleHelper(const char *name, const char *description) 00097 // { 00098 // registerModule(name, description, qobject_interface_iid<T *>(), meta_helper<T>(reinterpret_cast<T *>(0)), Min, Max); 00099 // } 00100 // private: 00101 // template <typename F> 00102 // inline const QMetaObject *meta_helper(const QObject *obj) 00103 // { return &F::staticMetaObject; } 00104 // template <typename F> 00105 // inline const QMetaObject *meta_helper(const void *obj) 00106 // { return NULL; } 00107 // }; 00108 // 00109 // template <typename T> 00110 // class SingleModuleHelper : public ModuleHelper<T, 1, 1> 00111 // { 00112 // public: 00113 // inline SingleModuleHelper(const char *name, const char *description) : ModuleHelper<T, 1, 1>(name, description) {} 00114 // }; 00115 // 00116 // template <typename T> 00117 // class MultiModuleHelper : public ModuleHelper<T, 0, -1> 00118 // { 00119 // public: 00120 // inline MultiModuleHelper(const char *name, const char *description) : ModuleHelper<T, 0, -1>(name, description) {} 00121 // }; 00122 } 00123 00124 #endif // MODULEMANAGER_H 00125