20#define LIBVDR_PREFIX "libvdr-"
21#define SO_INDICATOR ".so."
23#define MAXPLUGINARGS 1024
24#define HOUSEKEEPINGDELTA 10
144 esyslog(
"ERROR: plugin '%s' called cPlugin::ConfigDirectory(), which is not thread safe!", PluginName ? PluginName :
"<no name given>");
146 return MakeDirs(buffer,
true) ? *buffer : NULL;
158 esyslog(
"ERROR: plugin '%s' called cPlugin::CacheDirectory(), which is not thread safe!", PluginName ? PluginName :
"<no name given>");
160 return MakeDirs(buffer,
true) ? *buffer : NULL;
172 esyslog(
"ERROR: plugin '%s' called cPlugin::ResourceDirectory(), which is not thread safe!", PluginName ? PluginName :
"<no name given>");
174 return MakeDirs(buffer,
true) ? *buffer : NULL;
182 args = Args ? strdup(Args) : NULL;
203 memmove(s, s + 1, strlen(s));
204 while (*s && *s != c) {
206 memmove(s, s + 1, strlen(s));
211 memmove(s, s + 1, strlen(s));
214 esyslog(
"ERROR: missing closing %c", c);
215 fprintf(stderr,
"vdr: missing closing %c\n", c);
228 const char *error = dlerror();
230 typedef cPlugin *create_t(
void);
231 create_t *create = (create_t *)dlsym(
handle,
"VDRPluginCreator");
233 if (!error && create) {
239 isyslog(
"plugin %s: missing symbol VDRPluginDestroyer(), please rebuild",
fileName);
254 case '\\': memmove(p, p + 1, strlen(p));
258 esyslog(
"ERROR: missing character after \\");
259 fprintf(stderr,
"vdr: missing character after \\\n");
264 case '\'':
if ((p =
SkipQuote(p)) == NULL)
267 default:
if (!*p || isspace(*p)) {
274 esyslog(
"ERROR: plugin argument list too long");
275 fprintf(stderr,
"vdr: plugin argument list too long\n");
289 return !Log || !argc ||
plugin->ProcessArgs(argc, argv);
294 fprintf(stderr,
"vdr: %s\n", error);
309 fprintf(stderr,
"vdr: attempt to create more than one plugin manager - exiting!\n");
327 directory = Directory ? strdup(Directory) : NULL;
332 if (strcmp(Args,
"*") == 0) {
334 for (
int i = 0; i < Files.
Size(); i++) {
335 char *FileName = Files.
At(i);
343 if (strcmp(name,
"*") != 0) {
353 char *p = strchr(s,
' ');
358 esyslog(
"WARN: missing plugin '%s'", s);
359 fprintf(stderr,
"vdr: missing plugin '%s'\n", s);
368 for (
cDll *dll =
dlls.First(); dll; dll =
dlls.Next(dll)) {
377 for (
cDll *dll =
dlls.First(); dll; dll =
dlls.Next(dll)) {
390 for (
cDll *dll =
dlls.First(); dll; dll =
dlls.Next(dll)) {
448 time_t Now = time(NULL);
454 if (t > Now && (!Next || t < Next)) {
472 return dll ? dll->
Plugin() : NULL;
480 if (p && strcmp(p->
Name(), Name) == 0)
514 for (
cDll *dll =
dlls.Last(); dll; dll =
dlls.Prev(dll)) {
527 while ((dll =
dlls.Last()) != NULL) {
void destroy_t(cPlugin *)
cDll(const char *FileName, const char *Args)
bool Load(bool Log=false)
static cPluginManager * pluginManager
static cPlugin * GetNextWakeupPlugin(void)
void MainThreadHook(void)
cPluginManager(const char *Directory)
void SetDirectory(const char *Directory)
bool InitializePlugins(void)
void AddPlugin(const char *Args)
static bool Active(const char *Prompt=NULL)
static bool HasPlugins(void)
static bool CallAllServices(const char *Id, void *Data=NULL)
bool LoadPlugins(bool Log=false)
void Shutdown(bool Log=false)
static cPlugin * CallFirstService(const char *Id, void *Data=NULL)
virtual ~cPluginManager()
static cPlugin * GetPlugin(int Index)
virtual time_t WakeupTime(void)
virtual bool Initialize(void)
virtual cMenuSetupPage * SetupMenu(void)
virtual const char * CommandLineHelp(void)
virtual const char * Version(void)=0
virtual void Housekeeping(void)
static cString cacheDirectory
void SetName(const char *s)
void SetupStore(const char *Name, const char *Value=NULL)
virtual const char * MainMenuEntry(void)
static cString resourceDirectory
static void SetCacheDirectory(const char *Dir)
virtual bool Service(const char *Id, void *Data=NULL)
virtual cOsdObject * MainMenuAction(void)
static void SetConfigDirectory(const char *Dir)
static void SetResourceDirectory(const char *Dir)
static const char * CacheDirectory(const char *PluginName=NULL)
static const char * ResourceDirectory(const char *PluginName=NULL)
static const char * ConfigDirectory(const char *PluginName=NULL)
virtual void MainThreadHook(void)
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
virtual cString Active(void)
virtual const char * Description(void)=0
virtual const char ** SVDRPHelpPages(void)
static cString configDirectory
virtual bool SetupParse(const char *Name, const char *Value)
virtual bool ProcessArgs(int argc, char *argv[])
static cString sprintf(const char *fmt,...) __attribute__((format(printf
static tThreadId IsMainThread(void)
void I18nRegister(const char *Plugin)
Registers the named plugin, so that it can use internationalized texts.
#define HOUSEKEEPINGDELTA
static char * SkipQuote(char *s)