1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Changed the cPlugin::Start() function to return a boolean value

This commit is contained in:
Klaus Schmidinger 2002-05-12 09:24:45 +02:00
parent 7993e4c06f
commit 01c68def34
10 changed files with 52 additions and 23 deletions

View File

@ -130,6 +130,8 @@ Stefan Huelswitt <huels@iname.com>
doing shutdown or housekeeping doing shutdown or housekeeping
for making the cList template class avoid ambiguities in case one defines a "list of for making the cList template class avoid ambiguities in case one defines a "list of
lists" lists"
for suggesting to make the cPlugin::Start() function return a boolean value that
indicates if the plugin will not be able to perform its task
Ulrich Röder <roeder@efr-net.de> Ulrich Röder <roeder@efr-net.de>
for pointing out that there are channels that have a symbol rate higher than for pointing out that there are channels that have a symbol rate higher than

View File

@ -1269,3 +1269,8 @@ Video Disk Recorder Revision History
- Fixed logging error message for unknown config parameters in plugins. - Fixed logging error message for unknown config parameters in plugins.
- Rearranged cleanup sequence at the end of the main program. - Rearranged cleanup sequence at the end of the main program.
- Adapted PLUGINS.html to use the actual code examples from the 'hello' plugin. - Adapted PLUGINS.html to use the actual code examples from the 'hello' plugin.
2002-05-12: Version 1.1.2
- Changed the cPlugin::Start() function to return a boolean value that indicates
if the plugin will not be able to perform its task (suggested by Stefan Huelswitt).

View File

@ -16,9 +16,12 @@ This document describes the "outside" interface of the plugin system.
It handles everything necessary for a plugin to get hooked into the core It handles everything necessary for a plugin to get hooked into the core
VDR program and present itself to the user. VDR program and present itself to the user.
<p> <p>
<!--X1.1.1--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%> <!--X1.1.1--><table width=100%><tr><td bgcolor=cyan>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.1.1 are marked like this. Important modifications introduced in version 1.1.1 are marked like this.
<!--X1.1.1--></td></tr></table> <!--X1.1.1--></td></tr></table>
<!--X1.1.2--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%>
Important modifications introduced in version 1.1.2 are marked like this.
<!--X1.1.2--></td></tr></table>
<!--<p>TODO: Link to the document about VDR base classes to use when implementing actual functionality (yet to be written).--> <!--<p>TODO: Link to the document about VDR base classes to use when implementing actual functionality (yet to be written).-->
<hr><h2>Quick start</h2> <hr><h2>Quick start</h2>
@ -184,7 +187,7 @@ its memory. You don't need to worry about the details behind all this.
If your plugin requires additional source files, simply add them to your plugin's If your plugin requires additional source files, simply add them to your plugin's
source directory and adjust the <tt>Makefile</tt> accordingly. source directory and adjust the <tt>Makefile</tt> accordingly.
<p> <p>
<!--X1.1.1--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%> <!--X1.1.1--><table width=100%><tr><td bgcolor=cyan>&nbsp;</td><td width=100%>
Header files usually contain preprocessor statements that prevent the same Header files usually contain preprocessor statements that prevent the same
file (or rather its contents, to be precise) from being included more than once, like file (or rather its contents, to be precise) from being included more than once, like
@ -403,9 +406,11 @@ If a plugin implements a function that runs in the background (presumably in a
thread of its own), or wants to make use of <a href="#Internationalization">internationalization</a>, thread of its own), or wants to make use of <a href="#Internationalization">internationalization</a>,
it needs to implement the function it needs to implement the function
<!--X1.1.2--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%>
<p><table><tr><td bgcolor=#F0F0F0><pre><br> <p><table><tr><td bgcolor=#F0F0F0><pre><br>
virtual void Start(void); virtual bool Start(void);
</pre></td></tr></table><p> </pre></td></tr></table><p>
<!--X1.1.2--></td></tr></table>
which is called once for each plugin at program startup. which is called once for each plugin at program startup.
Inside this function the plugin must set up everything necessary to perform Inside this function the plugin must set up everything necessary to perform
@ -413,6 +418,13 @@ its task. This may, for instance, be a thread that collects data from the DVB
stream, which is later presented to the user via a function that is available stream, which is later presented to the user via a function that is available
from the main menu. from the main menu.
<p> <p>
<!--X1.1.2--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%>
A return value of <i>false</i> indicates that something has gone wrong and the
plugin will not be able to perform its task. In that case, the plugin should
write a proper error message to the log file. The first plugin that returns
<i>false</i> from its <tt>Start()</tt> function will cause VDR to exit.
<!--X1.1.2--></td></tr></table>
<p>
If the plugin doesn't implement any background functionality or internationalized If the plugin doesn't implement any background functionality or internationalized
texts, it doesn't need to implement this function. texts, it doesn't need to implement this function.
@ -490,7 +502,7 @@ previously stored in the global setup data (see below). It shall return
<i>true</i> if the parameter was parsed correctly, <i>false</i> in case of <i>true</i> if the parameter was parsed correctly, <i>false</i> in case of
an error. If <i>false</i> is returned, an error message will be written to an error. If <i>false</i> is returned, an error message will be written to
the log file (and program execution will continue). the log file (and program execution will continue).
<!--X1.1.1--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%> <!--X1.1.1--><table width=100%><tr><td bgcolor=cyan>&nbsp;</td><td width=100%>
A possible implementation of <tt>SetupParse()</tt> could look like this: A possible implementation of <tt>SetupParse()</tt> could look like this:
<p><table><tr><td bgcolor=#F0F0F0><pre><br> <p><table><tr><td bgcolor=#F0F0F0><pre><br>
@ -545,7 +557,7 @@ needs setup parameters that are not directly user adjustable. It can use
<tt>SetupStore()</tt> and <tt>SetupParse()</tt> without presenting these <tt>SetupStore()</tt> and <tt>SetupParse()</tt> without presenting these
parameters to the user. parameters to the user.
<!--X1.1.1--><table width=100%><tr><td bgcolor=red>&nbsp;</td><td width=100%> <!--X1.1.1--><table width=100%><tr><td bgcolor=cyan>&nbsp;</td><td width=100%>
<a name="The Setup menu"><hr><h2>The Setup menu</h2> <a name="The Setup menu"><hr><h2>The Setup menu</h2>
<center><i><b>Have it your way!</b></i></center><p> <center><i><b>Have it your way!</b></i></center><p>

View File

@ -8,3 +8,7 @@ VDR Plugin 'hello' Revision History
2002-05-11: Version 0.0.2 2002-05-11: Version 0.0.2
- Added setup parameters and a Setup menu to adjust them. - Added setup parameters and a Setup menu to adjust them.
2002-05-12: Version 0.0.3
- Changed return type of cPluginHello::Start().

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: hello.c 1.2 2002/05/11 14:17:20 kls Exp $ * $Id: hello.c 1.3 2002/05/12 09:24:08 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -11,7 +11,7 @@
#include <vdr/plugin.h> #include <vdr/plugin.h>
#include "i18n.h" #include "i18n.h"
static const char *VERSION = "0.0.2"; static const char *VERSION = "0.0.3";
static const char *DESCRIPTION = "A friendly greeting"; static const char *DESCRIPTION = "A friendly greeting";
static const char *MAINMENUENTRY = "Hello"; static const char *MAINMENUENTRY = "Hello";
@ -27,7 +27,7 @@ public:
virtual const char *Description(void) { return tr(DESCRIPTION); } virtual const char *Description(void) { return tr(DESCRIPTION); }
virtual const char *CommandLineHelp(void); virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]); virtual bool ProcessArgs(int argc, char *argv[]);
virtual void Start(void); virtual bool Start(void);
virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); } virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); }
virtual cOsdMenu *MainMenuAction(void); virtual cOsdMenu *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void); virtual cMenuSetupPage *SetupMenu(void);
@ -110,10 +110,11 @@ bool cPluginHello::ProcessArgs(int argc, char *argv[])
return true; return true;
} }
void cPluginHello::Start(void) bool cPluginHello::Start(void)
{ {
// Start any background activities the plugin shall perform. // Start any background activities the plugin shall perform.
RegisterI18n(Phrases); RegisterI18n(Phrases);
return true;
} }
cOsdMenu *cPluginHello::MainMenuAction(void) cOsdMenu *cPluginHello::MainMenuAction(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: config.h 1.114 2002/05/10 13:48:00 kls Exp $ * $Id: config.h 1.115 2002/05/12 09:18:44 kls Exp $
*/ */
#ifndef __CONFIG_H #ifndef __CONFIG_H
@ -19,7 +19,7 @@
#include "eit.h" #include "eit.h"
#include "tools.h" #include "tools.h"
#define VDRVERSION "1.1.1" #define VDRVERSION "1.1.2"
#define MAXPRIORITY 99 #define MAXPRIORITY 99
#define MAXLIFETIME 99 #define MAXLIFETIME 99

View File

@ -12,7 +12,7 @@
# See the main source file 'vdr.c' for copyright information and # See the main source file 'vdr.c' for copyright information and
# how to reach the author. # how to reach the author.
# #
# $Id: newplugin 1.1 2002/05/09 15:12:26 kls Exp $ # $Id: newplugin 1.2 2002/05/12 09:06:43 kls Exp $
$PLUGIN_NAME = $ARGV[0] || die "Usage: newplugin <name>\n"; $PLUGIN_NAME = $ARGV[0] || die "Usage: newplugin <name>\n";
@ -158,7 +158,7 @@ public:
virtual const char *Description(void) { return DESCRIPTION; } virtual const char *Description(void) { return DESCRIPTION; }
virtual const char *CommandLineHelp(void); virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]); virtual bool ProcessArgs(int argc, char *argv[]);
virtual void Start(void); virtual bool Start(void);
virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; } virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }
virtual cOsdMenu *MainMenuAction(void); virtual cOsdMenu *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void); virtual cMenuSetupPage *SetupMenu(void);
@ -189,9 +189,10 @@ bool cPlugin${PLUGIN_CLASS}::ProcessArgs(int argc, char *argv[])
return true; return true;
} }
void cPlugin${PLUGIN_CLASS}::Start(void) bool cPlugin${PLUGIN_CLASS}::Start(void)
{ {
// Start any background activities the plugin shall perform. // Start any background activities the plugin shall perform.
return true;
} }
cOsdMenu *cPlugin${PLUGIN_CLASS}::MainMenuAction(void) cOsdMenu *cPlugin${PLUGIN_CLASS}::MainMenuAction(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: plugin.c 1.1 2002/05/09 16:26:56 kls Exp $ * $Id: plugin.c 1.2 2002/05/12 09:04:51 kls Exp $
*/ */
#include "plugin.h" #include "plugin.h"
@ -45,8 +45,9 @@ bool cPlugin::ProcessArgs(int argc, char *argv[])
return true; return true;
} }
void cPlugin::Start(void) bool cPlugin::Start(void)
{ {
return true;
} }
const char *cPlugin::MainMenuEntry(void) const char *cPlugin::MainMenuEntry(void)
@ -268,7 +269,7 @@ bool cPluginManager::LoadPlugins(bool Log)
return true; return true;
} }
void cPluginManager::StartPlugins(void) bool cPluginManager::StartPlugins(void)
{ {
for (cDll *dll = dlls.First(); dll; dll = dlls.Next(dll)) { for (cDll *dll = dlls.First(); dll; dll = dlls.Next(dll)) {
cPlugin *p = dll->Plugin(); cPlugin *p = dll->Plugin();
@ -277,9 +278,11 @@ void cPluginManager::StartPlugins(void)
Setup.OSDLanguage = 0; // the i18n texts are only available _after_ Start() Setup.OSDLanguage = 0; // the i18n texts are only available _after_ Start()
isyslog(LOG_INFO, "starting plugin: %s (%s): %s", p->Name(), p->Version(), p->Description()); isyslog(LOG_INFO, "starting plugin: %s (%s): %s", p->Name(), p->Version(), p->Description());
Setup.OSDLanguage = Language; Setup.OSDLanguage = Language;
dll->Plugin()->Start(); if (!dll->Plugin()->Start())
return false;
} }
} }
return true;
} }
bool cPluginManager::HasPlugins(void) bool cPluginManager::HasPlugins(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: plugin.h 1.1 2002/05/09 10:16:09 kls Exp $ * $Id: plugin.h 1.2 2002/05/12 09:05:06 kls Exp $
*/ */
#ifndef __PLUGIN_H #ifndef __PLUGIN_H
@ -32,7 +32,7 @@ public:
virtual const char *CommandLineHelp(void); virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]); virtual bool ProcessArgs(int argc, char *argv[]);
virtual void Start(void); virtual bool Start(void);
virtual const char *MainMenuEntry(void); virtual const char *MainMenuEntry(void);
virtual cOsdMenu *MainMenuAction(void); virtual cOsdMenu *MainMenuAction(void);
@ -71,7 +71,7 @@ public:
void SetDirectory(const char *Directory); void SetDirectory(const char *Directory);
void AddPlugin(const char *Args); void AddPlugin(const char *Args);
bool LoadPlugins(bool Log = false); bool LoadPlugins(bool Log = false);
void StartPlugins(void); bool StartPlugins(void);
static bool HasPlugins(void); static bool HasPlugins(void);
static cPlugin *GetPlugin(int Index); static cPlugin *GetPlugin(int Index);
static cPlugin *GetPlugin(const char *Name); static cPlugin *GetPlugin(const char *Name);

5
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.105 2002/05/11 11:46:40 kls Exp $ * $Id: vdr.c 1.106 2002/05/12 09:05:37 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -324,7 +324,8 @@ int main(int argc, char *argv[])
// Start plugins: // Start plugins:
PluginManager.StartPlugins(); if (!PluginManager.StartPlugins())
return 2;
// Channel: // Channel: