SASC
DVBSoftCAM

plugin.h

Go to the documentation of this file.
00001 /*
00002  * plugin.h: The VDR plugin interface
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: plugin.h 1.14 2007/02/24 13:45:28 kls Exp $
00008  */
00009 
00010 #ifndef __PLUGIN_H
00011 #define __PLUGIN_H
00012 
00013 #include "i18n.h"
00014 #include "menuitems.h"
00015 #include "osdbase.h"
00016 #include "tools.h"
00017 
00018 #define VDRPLUGINCREATOR(PluginClass) extern "C" void *VDRPluginCreator(void) { return new PluginClass; }
00019 
00020 class cPlugin {
00021   friend class cDll;
00022   friend class cPluginManager;
00023 private:
00024   static char *configDirectory;
00025   const char *name;
00026   bool started;
00027   void SetName(const char *s);
00028 public:
00029   cPlugin(void);
00030   virtual ~cPlugin();
00031 
00032   const char *Name(void) { return name; }
00033   virtual const char *Version(void) = 0;
00034   virtual const char *Description(void) = 0;
00035   virtual const char *CommandLineHelp(void);
00036 
00037   virtual bool ProcessArgs(int argc, char *argv[]);
00038   virtual bool Initialize(void);
00039   virtual bool Start(void);
00040   virtual void Stop(void);
00041   virtual void Housekeeping(void);
00042   virtual void MainThreadHook(void);
00043   virtual cString Active(void);
00044   virtual time_t WakeupTime(void);
00045 
00046   virtual const char *MainMenuEntry(void);
00047   virtual cOsdObject *MainMenuAction(void);
00048 
00049   virtual cMenuSetupPage *SetupMenu(void);
00050   virtual bool SetupParse(const char *Name, const char *Value);
00051   void SetupStore(const char *Name, const char *Value = NULL);
00052   void SetupStore(const char *Name, int Value);
00053 
00054   void RegisterI18n(const tI18nPhrase * const Phrases);
00055 
00056   virtual bool Service(const char *Id, void *Data = NULL);
00057   virtual const char **SVDRPHelpPages(void);
00058   virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
00059 
00060   static void SetConfigDirectory(const char *Dir);
00061   static const char *ConfigDirectory(const char *PluginName = NULL);
00062   };
00063 
00064 class cDll : public cListObject {
00065 private:
00066   char *fileName;
00067   char *args;
00068   void *handle;
00069   cPlugin *plugin;
00070 public:
00071   cDll(const char *FileName, const char *Args);
00072   virtual ~cDll();
00073   bool Load(bool Log = false);
00074   cPlugin *Plugin(void) { return plugin; }
00075   };
00076 
00077 class cDlls : public cList<cDll> {};
00078 
00079 class cPluginManager {
00080 private:
00081   static cPluginManager *pluginManager;
00082   char *directory;
00083   time_t lastHousekeeping;
00084   int nextHousekeeping;
00085   cDlls dlls;
00086 public:
00087   cPluginManager(const char *Directory);
00088   virtual ~cPluginManager();
00089   void SetDirectory(const char *Directory);
00090   void AddPlugin(const char *Args);
00091   bool LoadPlugins(bool Log = false);
00092   bool InitializePlugins(void);
00093   bool StartPlugins(void);
00094   void Housekeeping(void);
00095   void MainThreadHook(void);
00096   static bool Active(const char *Prompt = NULL);
00097   static cPlugin *GetNextWakeupPlugin(void);
00098   static bool HasPlugins(void);
00099   static cPlugin *GetPlugin(int Index);
00100   static cPlugin *GetPlugin(const char *Name);
00101   static cPlugin *CallFirstService(const char *Id, void *Data = NULL);
00102   static bool CallAllServices(const char *Id, void *Data = NULL);
00103   void StopPlugins(void);
00104   void Shutdown(bool Log = false);
00105   };
00106 
00107 #endif //__PLUGIN_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines