vdr  2.0.4
plugin.h
Go to the documentation of this file.
1 /*
2  * plugin.h: The VDR plugin interface
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: plugin.h 2.2 2012/09/01 13:08:54 kls Exp $
8  */
9 
10 #ifndef __PLUGIN_H
11 #define __PLUGIN_H
12 
13 #include "i18n.h"
14 #include "menuitems.h"
15 #include "osdbase.h"
16 #include "tools.h"
17 
18 #define VDRPLUGINCREATOR(PluginClass) extern "C" void *VDRPluginCreator(void) { return new PluginClass; }
19 
20 class cPlugin {
21  friend class cDll;
22  friend class cPluginManager;
23 private:
27  const char *name;
28  bool started;
29  void SetName(const char *s);
30 public:
31  cPlugin(void);
32  virtual ~cPlugin();
33 
34  const char *Name(void) { return name; }
35  virtual const char *Version(void) = 0;
36  virtual const char *Description(void) = 0;
37  virtual const char *CommandLineHelp(void);
38 
39  virtual bool ProcessArgs(int argc, char *argv[]);
40  virtual bool Initialize(void);
41  virtual bool Start(void);
42  virtual void Stop(void);
43  virtual void Housekeeping(void);
44  virtual void MainThreadHook(void);
45  virtual cString Active(void);
46  virtual time_t WakeupTime(void);
47 
48  virtual const char *MainMenuEntry(void);
49  virtual cOsdObject *MainMenuAction(void);
50 
51  virtual cMenuSetupPage *SetupMenu(void);
52  virtual bool SetupParse(const char *Name, const char *Value);
53  void SetupStore(const char *Name, const char *Value = NULL);
54  void SetupStore(const char *Name, int Value);
55 
56  virtual bool Service(const char *Id, void *Data = NULL);
57  virtual const char **SVDRPHelpPages(void);
58  virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
59 
60  static void SetConfigDirectory(const char *Dir);
61  static const char *ConfigDirectory(const char *PluginName = NULL);
62  static void SetCacheDirectory(const char *Dir);
63  static const char *CacheDirectory(const char *PluginName = NULL);
64  static void SetResourceDirectory(const char *Dir);
65  static const char *ResourceDirectory(const char *PluginName = NULL);
66  };
67 
68 class cDll : public cListObject {
69 private:
70  char *fileName;
71  char *args;
72  void *handle;
74 public:
75  cDll(const char *FileName, const char *Args);
76  virtual ~cDll();
77  bool Load(bool Log = false);
78  cPlugin *Plugin(void) { return plugin; }
79  };
80 
81 class cDlls : public cList<cDll> {};
82 
84 private:
86  char *directory;
90 public:
91  cPluginManager(const char *Directory);
92  virtual ~cPluginManager();
93  void SetDirectory(const char *Directory);
94  void AddPlugin(const char *Args);
95  bool LoadPlugins(bool Log = false);
96  bool InitializePlugins(void);
97  bool StartPlugins(void);
98  void Housekeeping(void);
99  void MainThreadHook(void);
100  static bool Active(const char *Prompt = NULL);
101  static cPlugin *GetNextWakeupPlugin(void);
102  static bool HasPlugins(void);
103  static cPlugin *GetPlugin(int Index);
104  static cPlugin *GetPlugin(const char *Name);
105  static cPlugin *CallFirstService(const char *Id, void *Data = NULL);
106  static bool CallAllServices(const char *Id, void *Data = NULL);
107  void StopPlugins(void);
108  void Shutdown(bool Log = false);
109  };
110 
111 #endif //__PLUGIN_H
112