summaryrefslogtreecommitdiffstats
path: root/src/include/plugins.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/plugins.h')
-rw-r--r--src/include/plugins.h192
1 files changed, 192 insertions, 0 deletions
diff --git a/src/include/plugins.h b/src/include/plugins.h
new file mode 100644
index 0000000..c39b65e
--- /dev/null
+++ b/src/include/plugins.h
@@ -0,0 +1,192 @@
+/***************************************************************************
+ plugins.h - description
+ -------------------
+ begin : Mon M�r 10 2003
+ copyright : (C) 2003 by Martin Witte
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef KRADIO_PLUGINS_INTERFACES_H
+#define KRADIO_PLUGINS_INTERFACES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tdeglobal.h>
+
+#include "errorlog-interfaces.h"
+#include <tqstring.h>
+#include <tqobject.h>
+#include <tqptrlist.h>
+
+class PluginManager;
+class PluginBase;
+class TQWidget;
+class TDEConfig;
+
+typedef TQPtrList<PluginBase> PluginList;
+typedef TQPtrListIterator<PluginBase> PluginIterator;
+
+/* PluginBase must be inherited from Interface so that a plugin can be used
+ in Interface::connect functions.
+
+ PluginBase must not be inherited from TQObject, because derived classes may
+ be inherited e.g. from TQWidget (multiple inheritance is not possible with
+ OBjects). But we must be able to receive destroy messages e.g. from
+ configuration pages. Thus we need the special callback member
+ m_destroyNotifier.
+
+ PluginBase is derived from Interface to provide connection facilities.
+ In case of multiple inheritance from interface classes, connect and disconnect
+ methods have to be reimplemented in order to call all inherited
+ connect/disconnect methods.
+
+*/
+
+
+class WidgetPluginBase;
+
+struct ConfigPageInfo
+{
+ ConfigPageInfo () : page(NULL) {}
+ ConfigPageInfo (TQWidget *p,
+ const TQString &in,
+ const TQString &ph,
+ const TQString &icon)
+ : page (p),
+ itemName(in),
+ pageHeader(ph),
+ iconName(icon)
+ {}
+
+ TQWidget *page;
+ TQString itemName,
+ pageHeader,
+ iconName;
+};
+
+typedef ConfigPageInfo AboutPageInfo;
+
+
+class PluginBase : public IErrorLogClient
+{
+friend class PluginManager;
+public :
+ PluginBase(const TQString &name, const TQString &description);
+ virtual ~PluginBase();
+
+ virtual TQString pluginClassName() const = 0;
+
+ const TQString &name() const { return m_name; }
+ TQString &name() { return m_name; }
+
+ const TQString &description() const { return m_description; }
+
+ // workaround for compiler bugs
+ bool destructorCalled() const { return m_destructorCalled; }
+
+ // interaction with pluginmanager
+protected:
+ bool setManager (PluginManager *);
+ void unsetManager ();
+ bool isManagerSet () const;
+
+public:
+
+ // these two methods will request a configuration page or
+ // plugin page from plugin manager
+ // they will be deleted automatically when this plugin
+ // is deleted, because we disconnect from pluginmanager
+ // and the plugin manager will delete all associated gui elements
+ virtual ConfigPageInfo createConfigurationPage () = 0;
+ virtual AboutPageInfo createAboutPage () = 0;
+
+ // save/restore status, window position, etc...
+
+ virtual void saveState (TDEConfig *) const = 0;
+ virtual void restoreState (TDEConfig *) = 0;
+ virtual void startPlugin();
+
+ virtual void aboutToQuit();
+
+ //
+
+ virtual void noticeWidgetPluginShown(WidgetPluginBase *, bool /*shown*/) {}
+ virtual void noticePluginsChanged(const PluginList &) {}
+
+protected :
+ TQString m_name;
+ TQString m_description;
+ PluginManager *m_manager;
+ bool m_destructorCalled;
+};
+
+
+#define PLUGIN_LIBRARY_FUNCTIONS(class_name, i18nName, description) \
+extern "C" void TDERadioPlugin_LoadLibrary() \
+{ \
+ TDEGlobal::locale()->insertCatalogue(i18nName); \
+} \
+ \
+extern "C" void TDERadioPlugin_UnloadLibrary() \
+{ \
+ TDEGlobal::locale()->removeCatalogue(i18nName); \
+} \
+ \
+extern "C" void TDERadioPlugin_GetAvailablePlugins(TQMap<TQString, TQString> &info) \
+{ \
+ info.insert(#class_name, (description)); \
+} \
+ \
+extern "C" PluginBase *TDERadioPlugin_CreatePlugin(const TQString &type, const TQString &object_name) \
+{ \
+ if (type == #class_name) { \
+ return new class_name(object_name); \
+ } else { \
+ return NULL; \
+ } \
+}
+
+
+#define PLUGIN_LIBRARY_FUNCTIONS2(class_name1, i18nName, description1, class_name2, description2) \
+extern "C" void TDERadioPlugin_LoadLibrary() \
+{ \
+ TDEGlobal::locale()->insertCatalogue(i18nName); \
+} \
+ \
+extern "C" void TDERadioPlugin_UnloadLibrary() \
+{ \
+ TDEGlobal::locale()->removeCatalogue(i18nName); \
+} \
+ \
+extern "C" void TDERadioPlugin_GetAvailablePlugins(TQMap<TQString, TQString> &info) \
+{ \
+ info.insert(#class_name1, (description1)); \
+ info.insert(#class_name2, (description2)); \
+} \
+ \
+extern "C" PluginBase *TDERadioPlugin_CreatePlugin(const TQString &type, const TQString &object_name) \
+{ \
+ if (type == #class_name1) { \
+ return new class_name1(object_name); \
+ } else if (type == #class_name2) { \
+ return new class_name2(object_name); \
+ } else { \
+ return NULL; \
+ } \
+}
+
+
+#endif