00001 #ifndef MYTHPLUGIN_H_ 00002 #define MYTHPLUGIN_H_ 00003 00004 #include <qlibrary.h> 00005 #include <qdict.h> 00006 #include <qmap.h> 00007 #include <qptrlist.h> 00008 00009 #include "mythexp.h" 00010 00011 class QSqlDatabase; 00012 class MythContext; 00013 class QPainter; 00014 00015 typedef enum { 00016 kPluginType_Module = 0, 00017 kPluginType_MenuPlugin 00018 } MythPluginType; 00019 00020 class MythPlugin : public QLibrary 00021 { 00022 public: 00023 MythPlugin(const QString &); 00024 virtual ~MythPlugin(); 00025 00026 // This method will call the mythplugin_init() function of the library. 00027 int init(const char *libversion); 00028 00029 // This method will call the mythplugin_run() function of the library. 00030 void run(void); 00031 00032 // This method will call the mythplugin_config() function of the library. 00033 void config(void); 00034 00035 // This method will call the mythplugin_type() function of the library. 00036 // If such a function doesn't exist, it's a main module plugin. 00037 MythPluginType type(void); 00038 00039 // This method will call the mythplugin_destroy() function of the library, 00040 // if such a function exists. 00041 void destroy(void); 00042 00043 bool isEnabled() { return enabled; } 00044 void setEnabled(bool enable) { enabled = enable; } 00045 00046 int getPosition() { return position; } 00047 void setPosition(int pos) { position = pos; } 00048 00049 // mainmenu plugins, probably should separate out 00050 00051 // setup the plugin -- returns how often (in ms) the plugin wants updated 00052 int setupMenuPlugin(void); 00053 00054 // draw the plugin 00055 void drawMenuPlugin(QPainter *painter, int x, int y, int w, int h); 00056 00057 private: 00058 bool enabled; 00059 int position; 00060 }; 00061 00062 // this should only be instantiated through MythContext. 00063 class MPUBLIC MythPluginManager 00064 { 00065 public: 00066 MythPluginManager(); 00067 ~MythPluginManager(); 00068 00069 bool init_plugin(const QString &plugname); 00070 bool run_plugin(const QString &plugname); 00071 bool config_plugin(const QString &plugname); 00072 bool destroy_plugin(const QString &plugname); 00073 00074 MythPlugin *GetPlugin(const QString &plugname); 00075 MythPlugin *GetMenuPlugin(const QString &plugname); 00076 MythPlugin *GetMenuPluginAt(int pos); 00077 00078 void DestroyAllPlugins(); 00079 00080 private: 00081 QDict<MythPlugin> m_dict; 00082 00083 QMap<QString, MythPlugin *> moduleMap; 00084 QMap<QString, MythPlugin *> menuPluginMap; 00085 QPtrList<MythPlugin> menuPluginList; 00086 00087 void orderMenuPlugins(); 00088 }; 00089 00090 #endif 00091
1.5.5