2002-05-09 16:26:56 +02:00
|
|
|
/*
|
|
|
|
* plugin.h: The VDR plugin interface
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2006-04-14 11:51:13 +02:00
|
|
|
* $Id: plugin.h 1.11 2006/04/14 11:42:48 kls Exp $
|
2002-05-09 16:26:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLUGIN_H
|
|
|
|
#define __PLUGIN_H
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
#include "menuitems.h"
|
2004-05-16 10:35:36 +02:00
|
|
|
#include "osdbase.h"
|
2002-05-09 16:26:56 +02:00
|
|
|
#include "tools.h"
|
|
|
|
|
|
|
|
#define VDRPLUGINCREATOR(PluginClass) extern "C" void *VDRPluginCreator(void) { return new PluginClass; }
|
|
|
|
|
|
|
|
class cPlugin {
|
|
|
|
friend class cDll;
|
2005-01-30 14:23:01 +01:00
|
|
|
friend class cPluginManager;
|
2002-05-09 16:26:56 +02:00
|
|
|
private:
|
2002-05-13 16:11:19 +02:00
|
|
|
static char *configDirectory;
|
2002-05-09 16:26:56 +02:00
|
|
|
const char *name;
|
2005-01-30 14:23:01 +01:00
|
|
|
bool started;
|
2002-05-09 16:26:56 +02:00
|
|
|
void SetName(const char *s);
|
|
|
|
public:
|
|
|
|
cPlugin(void);
|
|
|
|
virtual ~cPlugin();
|
|
|
|
|
|
|
|
const char *Name(void) { return name; }
|
|
|
|
virtual const char *Version(void) = 0;
|
|
|
|
virtual const char *Description(void) = 0;
|
|
|
|
virtual const char *CommandLineHelp(void);
|
|
|
|
|
|
|
|
virtual bool ProcessArgs(int argc, char *argv[]);
|
2003-05-09 15:27:46 +02:00
|
|
|
virtual bool Initialize(void);
|
2002-05-12 09:24:45 +02:00
|
|
|
virtual bool Start(void);
|
2005-01-30 14:23:01 +01:00
|
|
|
virtual void Stop(void);
|
2002-05-12 10:20:17 +02:00
|
|
|
virtual void Housekeeping(void);
|
2002-05-09 16:26:56 +02:00
|
|
|
|
|
|
|
virtual const char *MainMenuEntry(void);
|
2002-11-24 10:45:39 +01:00
|
|
|
virtual cOsdObject *MainMenuAction(void);
|
2002-05-09 16:26:56 +02:00
|
|
|
|
|
|
|
virtual cMenuSetupPage *SetupMenu(void);
|
|
|
|
virtual bool SetupParse(const char *Name, const char *Value);
|
|
|
|
void SetupStore(const char *Name, const char *Value = NULL);
|
|
|
|
void SetupStore(const char *Name, int Value);
|
|
|
|
|
|
|
|
void RegisterI18n(const tI18nPhrase * const Phrases);
|
2002-05-13 16:11:19 +02:00
|
|
|
|
2005-08-21 10:44:29 +02:00
|
|
|
virtual bool Service(const char *Id, void *Data = NULL);
|
2005-08-27 16:42:28 +02:00
|
|
|
virtual const char **SVDRPHelpPages(void);
|
|
|
|
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
|
2005-08-21 10:44:29 +02:00
|
|
|
|
2002-05-13 16:11:19 +02:00
|
|
|
static void SetConfigDirectory(const char *Dir);
|
|
|
|
static const char *ConfigDirectory(const char *PluginName = NULL);
|
2002-05-09 16:26:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class cDll : public cListObject {
|
|
|
|
private:
|
|
|
|
char *fileName;
|
|
|
|
char *args;
|
|
|
|
void *handle;
|
|
|
|
cPlugin *plugin;
|
|
|
|
public:
|
|
|
|
cDll(const char *FileName, const char *Args);
|
|
|
|
virtual ~cDll();
|
|
|
|
bool Load(bool Log = false);
|
|
|
|
cPlugin *Plugin(void) { return plugin; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class cDlls : public cList<cDll> {};
|
|
|
|
|
|
|
|
class cPluginManager {
|
|
|
|
private:
|
|
|
|
static cPluginManager *pluginManager;
|
|
|
|
char *directory;
|
2002-05-12 10:20:17 +02:00
|
|
|
time_t lastHousekeeping;
|
|
|
|
int nextHousekeeping;
|
2002-05-09 16:26:56 +02:00
|
|
|
cDlls dlls;
|
|
|
|
public:
|
|
|
|
cPluginManager(const char *Directory);
|
|
|
|
virtual ~cPluginManager();
|
|
|
|
void SetDirectory(const char *Directory);
|
|
|
|
void AddPlugin(const char *Args);
|
|
|
|
bool LoadPlugins(bool Log = false);
|
2003-05-09 15:27:46 +02:00
|
|
|
bool InitializePlugins(void);
|
2002-05-12 09:24:45 +02:00
|
|
|
bool StartPlugins(void);
|
2002-05-12 10:20:17 +02:00
|
|
|
void Housekeeping(void);
|
2002-05-09 16:26:56 +02:00
|
|
|
static bool HasPlugins(void);
|
|
|
|
static cPlugin *GetPlugin(int Index);
|
|
|
|
static cPlugin *GetPlugin(const char *Name);
|
2005-08-21 10:44:29 +02:00
|
|
|
static cPlugin *CallFirstService(const char *Id, void *Data = NULL);
|
|
|
|
static bool CallAllServices(const char *Id, void *Data = NULL);
|
2005-01-30 14:23:01 +01:00
|
|
|
void StopPlugins(void);
|
2006-04-14 11:51:13 +02:00
|
|
|
void Shutdown(bool Log = false);
|
2002-05-09 16:26:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__PLUGIN_H
|