summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-05-12 09:24:45 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-05-12 09:24:45 +0200
commit01c68def34bc8b1d2a2b5ac0a21c6eb4a13e04e3 (patch)
treebce1156fd51546cb0909f3c5f88ffdef563d177e
parent7993e4c06f845e0a884bb68015e39f549f202ad2 (diff)
downloadvdr-01c68def34bc8b1d2a2b5ac0a21c6eb4a13e04e3.tar.gz
vdr-01c68def34bc8b1d2a2b5ac0a21c6eb4a13e04e3.tar.bz2
Changed the cPlugin::Start() function to return a boolean value
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY5
-rw-r--r--PLUGINS.html22
-rw-r--r--PLUGINS/src/hello/HISTORY4
-rw-r--r--PLUGINS/src/hello/hello.c9
-rw-r--r--config.h4
-rwxr-xr-xnewplugin7
-rw-r--r--plugin.c11
-rw-r--r--plugin.h6
-rw-r--r--vdr.c5
10 files changed, 52 insertions, 23 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index ce0ffaa5..fb42367c 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -130,6 +130,8 @@ Stefan Huelswitt <huels@iname.com>
doing shutdown or housekeeping
for making the cList template class avoid ambiguities in case one defines a "list of
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>
for pointing out that there are channels that have a symbol rate higher than
diff --git a/HISTORY b/HISTORY
index 20cbf529..406aac9d 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1269,3 +1269,8 @@ Video Disk Recorder Revision History
- Fixed logging error message for unknown config parameters in plugins.
- Rearranged cleanup sequence at the end of the main program.
- 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).
diff --git a/PLUGINS.html b/PLUGINS.html
index bbe1a1de..b2af135b 100644
--- a/PLUGINS.html
+++ b/PLUGINS.html
@@ -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
VDR program and present itself to the user.
<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.
<!--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).-->
<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
source directory and adjust the <tt>Makefile</tt> accordingly.
<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
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>,
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>
-virtual void Start(void);
+virtual bool Start(void);
</pre></td></tr></table><p>
+<!--X1.1.2--></td></tr></table>
which is called once for each plugin at program startup.
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
from the main menu.
<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
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
an error. If <i>false</i> is returned, an error message will be written to
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:
<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
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>
<center><i><b>Have it your way!</b></i></center><p>
diff --git a/PLUGINS/src/hello/HISTORY b/PLUGINS/src/hello/HISTORY
index dff114d5..9abd4971 100644
--- a/PLUGINS/src/hello/HISTORY
+++ b/PLUGINS/src/hello/HISTORY
@@ -8,3 +8,7 @@ VDR Plugin 'hello' Revision History
2002-05-11: Version 0.0.2
- Added setup parameters and a Setup menu to adjust them.
+
+2002-05-12: Version 0.0.3
+
+- Changed return type of cPluginHello::Start().
diff --git a/PLUGINS/src/hello/hello.c b/PLUGINS/src/hello/hello.c
index 65d03c8b..55e6bcbb 100644
--- a/PLUGINS/src/hello/hello.c
+++ b/PLUGINS/src/hello/hello.c
@@ -3,7 +3,7 @@
*
* 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>
@@ -11,7 +11,7 @@
#include <vdr/plugin.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 *MAINMENUENTRY = "Hello";
@@ -27,7 +27,7 @@ public:
virtual const char *Description(void) { return tr(DESCRIPTION); }
virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]);
- virtual void Start(void);
+ virtual bool Start(void);
virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); }
virtual cOsdMenu *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
@@ -110,10 +110,11 @@ bool cPluginHello::ProcessArgs(int argc, char *argv[])
return true;
}
-void cPluginHello::Start(void)
+bool cPluginHello::Start(void)
{
// Start any background activities the plugin shall perform.
RegisterI18n(Phrases);
+ return true;
}
cOsdMenu *cPluginHello::MainMenuAction(void)
diff --git a/config.h b/config.h
index a11f1fa3..518c3f53 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -19,7 +19,7 @@
#include "eit.h"
#include "tools.h"
-#define VDRVERSION "1.1.1"
+#define VDRVERSION "1.1.2"
#define MAXPRIORITY 99
#define MAXLIFETIME 99
diff --git a/newplugin b/newplugin
index 7100bcd5..b1e51ca1 100755
--- a/newplugin
+++ b/newplugin
@@ -12,7 +12,7 @@
# See the main source file 'vdr.c' for copyright information and
# 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";
@@ -158,7 +158,7 @@ public:
virtual const char *Description(void) { return DESCRIPTION; }
virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]);
- virtual void Start(void);
+ virtual bool Start(void);
virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }
virtual cOsdMenu *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
@@ -189,9 +189,10 @@ bool cPlugin${PLUGIN_CLASS}::ProcessArgs(int argc, char *argv[])
return true;
}
-void cPlugin${PLUGIN_CLASS}::Start(void)
+bool cPlugin${PLUGIN_CLASS}::Start(void)
{
// Start any background activities the plugin shall perform.
+ return true;
}
cOsdMenu *cPlugin${PLUGIN_CLASS}::MainMenuAction(void)
diff --git a/plugin.c b/plugin.c
index ecae317e..00dfb7d4 100644
--- a/plugin.c
+++ b/plugin.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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"
@@ -45,8 +45,9 @@ bool cPlugin::ProcessArgs(int argc, char *argv[])
return true;
}
-void cPlugin::Start(void)
+bool cPlugin::Start(void)
{
+ return true;
}
const char *cPlugin::MainMenuEntry(void)
@@ -268,7 +269,7 @@ bool cPluginManager::LoadPlugins(bool Log)
return true;
}
-void cPluginManager::StartPlugins(void)
+bool cPluginManager::StartPlugins(void)
{
for (cDll *dll = dlls.First(); dll; dll = dlls.Next(dll)) {
cPlugin *p = dll->Plugin();
@@ -277,9 +278,11 @@ void cPluginManager::StartPlugins(void)
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());
Setup.OSDLanguage = Language;
- dll->Plugin()->Start();
+ if (!dll->Plugin()->Start())
+ return false;
}
}
+ return true;
}
bool cPluginManager::HasPlugins(void)
diff --git a/plugin.h b/plugin.h
index 99f330d4..827df23e 100644
--- a/plugin.h
+++ b/plugin.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@@ -32,7 +32,7 @@ public:
virtual const char *CommandLineHelp(void);
virtual bool ProcessArgs(int argc, char *argv[]);
- virtual void Start(void);
+ virtual bool Start(void);
virtual const char *MainMenuEntry(void);
virtual cOsdMenu *MainMenuAction(void);
@@ -71,7 +71,7 @@ public:
void SetDirectory(const char *Directory);
void AddPlugin(const char *Args);
bool LoadPlugins(bool Log = false);
- void StartPlugins(void);
+ bool StartPlugins(void);
static bool HasPlugins(void);
static cPlugin *GetPlugin(int Index);
static cPlugin *GetPlugin(const char *Name);
diff --git a/vdr.c b/vdr.c
index cd3e528c..26f4ea6f 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* 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>
@@ -324,7 +324,8 @@ int main(int argc, char *argv[])
// Start plugins:
- PluginManager.StartPlugins();
+ if (!PluginManager.StartPlugins())
+ return 2;
// Channel: