diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2006-04-15 11:18:36 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2006-04-15 11:18:36 +0200 |
commit | 4ba450b7372709507a8602ae5c80b47ef39b6d38 (patch) | |
tree | 325667a6b015156e4e25c5f14bf6b02959bff064 | |
parent | 3d8a9c965366f35ceeadcceb9744ef0fc8f26455 (diff) | |
download | vdr-4ba450b7372709507a8602ae5c80b47ef39b6d38.tar.gz vdr-4ba450b7372709507a8602ae5c80b47ef39b6d38.tar.bz2 |
Implemented cPlugin::Active()
-rw-r--r-- | CONTRIBUTORS | 3 | ||||
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | PLUGINS.html | 68 | ||||
-rw-r--r-- | i18n.c | 24 | ||||
-rw-r--r-- | menu.c | 6 | ||||
-rwxr-xr-x | newplugin | 9 | ||||
-rw-r--r-- | plugin.c | 25 | ||||
-rw-r--r-- | plugin.h | 4 | ||||
-rw-r--r-- | vdr.c | 6 |
9 files changed, 124 insertions, 24 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3648e7a6..8345303e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1827,3 +1827,6 @@ Richard Lithvall <richard@lithvall.se> Tobias Grimm <listaccount@e-tobi.net> for suggesting to use geteuid() to check whether VDR is running as user 'root' + +Peter Dittmann <peter.dittmann@philips.com> + for a patch that was used as a base to implement cPlugin::Active() @@ -4523,3 +4523,6 @@ Video Disk Recorder Revision History - Fixed the vdr.1 man page (a single DVB card can record and do live tv). - The preferred audio language is now automatically selected when starting replay. - Updated the Danish OSD texts (thanks to Mogens Elneff). +- The new function cPlugin::Active() can be used by a plugin to indicate that it + is still busy and the system should not shut down or restart (based on a patch + from Peter Dittmann). See PLUGINS.html for details. diff --git a/PLUGINS.html b/PLUGINS.html index 9515174f..8f0e12ef 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -14,18 +14,18 @@ Copyright © 2006 Klaus Schmidinger<br> <a href="http://www.cadsoft.de/vdr">www.cadsoft.de/vdr</a> </center> <p> -<!--X1.3.30--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> -Important modifications introduced in version 1.3.30 are marked like this. -<!--X1.3.30--></td></tr></table> -<!--X1.3.31--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> +<!--X1.3.31--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> Important modifications introduced in version 1.3.31 are marked like this. <!--X1.3.31--></td></tr></table> -<!--X1.3.37--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> +<!--X1.3.37--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> Important modifications introduced in version 1.3.37 are marked like this. <!--X1.3.37--></td></tr></table> -<!--X1.3.38--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<!--X1.3.38--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> Important modifications introduced in version 1.3.38 are marked like this. <!--X1.3.38--></td></tr></table> +<!--X1.3.47--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +Important modifications introduced in version 1.3.46 are marked like this. +<!--X1.3.47--></td></tr></table> <p> VDR provides an easy to use plugin interface that allows additional functionality to be added to the program by implementing a dynamically loadable library file. @@ -62,14 +62,15 @@ structures and allows it to hook itself into specific areas to perform special a <li><a href="#Main menu entry">Main menu entry</a> <li><a href="#User interaction">User interaction</a> <li><a href="#Housekeeping">Housekeeping</a> +<!--X1.3.47--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<li><a href="#Activity">Activity</a> +<!--X1.3.47--></td></tr></table> <li><a href="#Setup parameters">Setup parameters</a> <li><a href="#The Setup menu">The Setup menu</a> <li><a href="#Configuration files">Configuration files</a> <li><a href="#Internationalization">Internationalization</a> -<!--X1.3.30--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> <li><a href="#Custom services">Custom services</a> -<!--X1.3.30--></td></tr></table> -<!--X1.3.31--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> +<!--X1.3.31--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> <li><a href="#SVDRP commands">SVDRP commands</a> <!--X1.3.31--></td></tr></table> <li><a href="#Loading plugins into VDR">Loading plugins into VDR</a> @@ -609,6 +610,44 @@ interaction is possible. If a specific action takes longer than a few seconds, the plugin should launch a separate thread to do this. </b> +<!--X1.3.47--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<a name="Activity"><hr><h2>Activity</h2> + +<center><i><b>Now is not a good time!</b></i></center><p> + +If a plugin is running a background task that should be finished before shutting +down the system, it can implement the function + +<p><table><tr><td bgcolor=#F0F0F0><pre> +virtual cString Active(void); +</pre></td></tr></table><p> + +which shall return an empty string if it is ok to shut down, and a proper message +if not: + +<p><table><tr><td bgcolor=#F0F0F0><pre> +cString cDoSomethingPlugin::Active(void) +{ + if (busy) + return tr("Doing something"); + return NULL; +} +</pre></td></tr></table><p> + +The message should be short and should indicate what is currently going on. +It will be presented to the user as a confirmation message, followed by a +hyphen and a "shut down anyway?" prompt, as in +<p> +<b>Doing something - shut down anyway?</b> +<p> +All plugins will be queried, and the first one that returns a non empty +string will cause the confirmation message to be shown. If the user confirms +the prompt by pressing the "Ok" button, the rest of the plugins will also +be queried, and further prompts may show up. If all prompts have been confirmed, +the shutdown will take place. As soon as one prompt is not confirmed, no +further plugins will be queried and no shutdown will be done. +<!--X1.3.47--></td></tr></table> + <a name="Setup parameters"><hr><h2>Setup parameters</h2> <center><i><b>Remember me...</b></i></center><p> @@ -864,7 +903,6 @@ Texts are first searched for in the <i>Phrases</i> registered for this plugin (i and then in the global VDR texts. So a plugin can make use of texts defined by the core VDR code. -<!--X1.3.30--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> <a name="Custom services"><hr><h2>Custom services</h2> <center><i><b>What can I do for you?</b></i></center><p> @@ -933,9 +971,7 @@ To send a message to all plugins, a plugin can call the function <tt>cPluginManager::CallAllServices()</tt>. This function returns <tt>true</tt> if any plugin handled the request, or <tt>false</tt> if no plugin handled the request. -<!--X1.3.30--></td></tr></table> - -<!--X1.3.31--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> +<!--X1.3.31--><table width=100%><tr><td bgcolor=#0000AA> </td><td width=100%> <a name="SVDRP commands"><hr><h2>SVDRP commands</h2> <center><i><b>Infinite Diversity in Infinite Combinations</b></i></center><p> @@ -1262,7 +1298,7 @@ public: cMyControl(void); virtual ~cMyControl(); virtual void Hide(void); -<!--X1.3.38--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<!--X1.3.38--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> virtual cOsdObject *GetInfo(void); <!--X1.3.38--></td></tr></table> virtual eOSState ProcessKey(eKeys Key); @@ -1294,7 +1330,7 @@ A derived <tt>cControl</tt> <b>must</b> implement the <tt>Hide()</tt> function, it has to hide itself from the OSD, in case it uses it. <tt>Hide()</tt> may be called at any time, and it may be called even if the <tt>cControl</tt> is not visible at the moment. <p> -<!--X1.3.38--><table width=100%><tr><td bgcolor=#FF0000> </td><td width=100%> +<!--X1.3.38--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> The <tt>GetInfo()</tt> function is called when the user presses the <tt>Info</tt> button, and shall return a pointer to a <tt>cOsdObject</tt> that contains information about the currently played programme. The caller takes ownership of the returned @@ -1522,7 +1558,7 @@ with the full required resolution. Only if this fails shall it use alternate areas. Drawing areas are always rectangular and may not overlap (but do not need to be adjacent). -<!--X1.3.37--><table width=100%><tr><td bgcolor=#AA0000> </td><td width=100%> +<!--X1.3.37--><table width=100%><tr><td bgcolor=#00AA00> </td><td width=100%> <p> Directly accessing the OSD is only allowed from the foreground thread, which restricts this to a <tt>cOsdObject</tt> returned from the plugin's <tt>MainMenuAction()</tt> @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: i18n.c 1.257 2006/04/15 09:22:37 kls Exp $ + * $Id: i18n.c 1.258 2006/04/15 11:05:27 kls Exp $ * * Translations provided by: * @@ -1275,6 +1275,28 @@ const tI18nPhrase Phrases[] = { "Vil du virkelig genstarte?", "Opravdu restartovat?", }, + { "shut down anyway?", + "trotzdem ausschalten?", + "zares izklopi?", + "spengo comunque?", + "toch uitschakelen?", + "quer mesmo desligar?", + "confirmez l'arrêt", + "slå av likevel?", + "sammutetaanko?", + "wy³±czyæ mimo to?", + "¿apagar igualmente?", + "ÔåëéêÜ íá ãßíåé ôåñìáôéóìüò?", + "vill du ändå avbryta?", + "închid, totuºi?", + "mégis kikapcsolni?", + "Apagar de totes maneres?", + "ÔÕÙáâÒØâÕÛìÝÞ ÒëÚÛîçØâì?", + "svejedno iskljuèiti?", + "lülitan välja?", + "sluk alligevel?", + "pøesto vypnout?", + }, { "Recording - restart anyway?", "Aufnahme läuft - trotzdem neu starten?", "Snemanje - zares ponoven zagon?", @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.429 2006/04/14 14:28:34 kls Exp $ + * $Id: menu.c 1.430 2006/04/15 10:30:52 kls Exp $ */ #include "menu.h" @@ -2696,7 +2696,9 @@ void cMenuSetup::Set(void) eOSState cMenuSetup::Restart(void) { - if (Interface->Confirm(cRecordControls::Active() ? tr("Recording - restart anyway?") : tr("Really restart?"))) { + if (Interface->Confirm(tr("Really restart?")) + && (!cRecordControls::Active() || Interface->Confirm(tr("Recording - restart anyway?"))) + && !cPluginManager::Active(tr("Really restart?"))) { cThread::EmergencyExit(true); return osEnd; } @@ -12,7 +12,7 @@ # See the main source file 'vdr.c' for copyright information and # how to reach the author. # -# $Id: newplugin 1.22 2005/11/11 13:20:14 kls Exp $ +# $Id: newplugin 1.23 2006/04/15 11:18:36 kls Exp $ $PLUGIN_NAME = $ARGV[0] || die "Usage: newplugin <name>\n"; @@ -166,6 +166,7 @@ public: virtual bool Start(void); virtual void Stop(void); virtual void Housekeeping(void); + virtual cString Active(void); virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; } virtual cOsdObject *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); @@ -221,6 +222,12 @@ void cPlugin${PLUGIN_CLASS}::Housekeeping(void) // Perform any cleanup or other regular tasks. } +cString cPlugin${PLUGIN_CLASS}::Active(void) +{ + // Return a message string if shutdown should be postponed + return NULL; +} + cOsdObject *cPlugin${PLUGIN_CLASS}::MainMenuAction(void) { // Perform the action when selected from the main VDR menu. @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: plugin.c 1.19 2006/04/14 11:45:43 kls Exp $ + * $Id: plugin.c 1.20 2006/04/15 11:17:03 kls Exp $ */ #include "plugin.h" @@ -14,6 +14,7 @@ #include <stdlib.h> #include <time.h> #include "config.h" +#include "interface.h" #define LIBVDR_PREFIX "libvdr-" #define SO_INDICATOR ".so." @@ -69,6 +70,11 @@ void cPlugin::Housekeeping(void) { } +cString cPlugin::Active(void) +{ + return NULL; +} + const char *cPlugin::MainMenuEntry(void) { return NULL; @@ -364,6 +370,23 @@ void cPluginManager::Housekeeping(void) } } +bool cPluginManager::Active(const char *Prompt) +{ + if (pluginManager) { + for (cDll *dll = pluginManager->dlls.First(); dll; dll = pluginManager->dlls.Next(dll)) { + cPlugin *p = dll->Plugin(); + if (p) { + cString s = p->Active(); + if (!isempty(*s)) { + if (!Prompt || !Interface->Confirm(cString::sprintf("%s - %s", *s, Prompt))) + return true; + } + } + } + } + return false; +} + bool cPluginManager::HasPlugins(void) { return pluginManager && pluginManager->dlls.Count(); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: plugin.h 1.11 2006/04/14 11:42:48 kls Exp $ + * $Id: plugin.h 1.12 2006/04/15 10:30:33 kls Exp $ */ #ifndef __PLUGIN_H @@ -39,6 +39,7 @@ public: virtual bool Start(void); virtual void Stop(void); virtual void Housekeeping(void); + virtual cString Active(void); virtual const char *MainMenuEntry(void); virtual cOsdObject *MainMenuAction(void); @@ -89,6 +90,7 @@ public: bool InitializePlugins(void); bool StartPlugins(void); void Housekeeping(void); + static bool Active(const char *Prompt = NULL); static bool HasPlugins(void); static cPlugin *GetPlugin(int Index); static cPlugin *GetPlugin(const char *Name); @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/vdr * - * $Id: vdr.c 1.256 2006/04/14 11:45:05 kls Exp $ + * $Id: vdr.c 1.257 2006/04/15 11:05:49 kls Exp $ */ #include <getopt.h> @@ -980,6 +980,8 @@ int main(int argc, char *argv[]) if (Interface->Confirm(tr("Recording - shut down anyway?"))) ForceShutdown = true; } + if (cPluginManager::Active(tr("shut down anyway?"))) + ForceShutdown = true; LastActivity = 1; // not 0, see below! UserShutdown = true; break; @@ -1093,7 +1095,7 @@ int main(int argc, char *argv[]) Skins.Message(mtInfo, tr("Editing process finished")); } } - if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) { + if (!Interact && ((!cRecordControls::Active() && !cCutter::Active() && !cPluginManager::Active() && (!Interface->HasSVDRPConnection() || UserShutdown)) || ForceShutdown)) { time_t Now = time(NULL); if (Now - LastActivity > ACTIVITYTIMEOUT) { // Shutdown: |