diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2002-12-01 18:00:00 +0100 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2002-12-01 18:00:00 +0100 |
commit | 96ebdbf4b1e495d44f8f837068af7c2d925bab62 (patch) | |
tree | 7d0283b6f2087626108a5b5a8aa9e4a32a5e47e2 /PLUGINS/src/hello/hello.c | |
parent | fe9499ba901f5c32dd0b3841a2b6e599fefc144f (diff) | |
download | vdr-patch-lnbsharing-96ebdbf4b1e495d44f8f837068af7c2d925bab62.tar.gz vdr-patch-lnbsharing-96ebdbf4b1e495d44f8f837068af7c2d925bab62.tar.bz2 |
Version 1.1.18vdr-1.1.18
- Fixed missing initialization of 'number' in cChannel (thanks to Martin Hammerschmid
for reporting this one).
- Fixed a misplaced ')' in the fix about the stale lock files (thanks again to
Oliver Endriss for pointing this out - it was my fault).
- Group delimiters in the 'channels.conf' file that have no text (like a simple ":"
or ":@201") no longer show up in the Channels menu (suggested by Guy Roussin).
- Added "Tele 5" to 'channels.conf' (thanks to Georg Hitsch).
- Changed the source directory name for plugins from 'SRC' to 'src' (suggested by
Clemens Kirchgatterer).
- Removed transponders 10788, 11739 and 12266 from 'channels.conf' (apparently they
are no longer active).
- Deactivated some templates in tools.h in case some plugin needs to use the STL
(suggested by Gerald Berwolf).
- Timers now accept channel IDs even if the 'source' is 0 (thanks to Stefan Huelswitt
for reporting this one).
- Now taking an active SVDRP connection into account when doing shutdown or
housekeeping (suggested by Emil Naepflein).
- Macros in 'keymacros.conf' can now use "@plugin" to directly access the main menu
function of a given plugin (see man vdr(5) for details).
- The new plugin 'sky' can be used to integrate a Sky Digibox into the VDR system,
using a Kfir MPEG2 encoder card (see PLUGINS/src/sky/README for details).
Diffstat (limited to 'PLUGINS/src/hello/hello.c')
-rw-r--r-- | PLUGINS/src/hello/hello.c | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/PLUGINS/src/hello/hello.c b/PLUGINS/src/hello/hello.c new file mode 100644 index 0000000..b726578 --- /dev/null +++ b/PLUGINS/src/hello/hello.c @@ -0,0 +1,150 @@ +/* + * hello.c: A plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + * $Id: hello.c 1.10 2002/11/23 15:07:28 kls Exp $ + */ + +#include <getopt.h> +#include <stdlib.h> +#include <vdr/interface.h> +#include <vdr/plugin.h> +#include "i18n.h" + +static const char *VERSION = "0.0.9"; +static const char *DESCRIPTION = "A friendly greeting"; +static const char *MAINMENUENTRY = "Hello"; + +class cPluginHello : public cPlugin { +private: + // Add any member variables or functions you may need here. + const char *option_a; + bool option_b; +public: + cPluginHello(void); + virtual ~cPluginHello(); + virtual const char *Version(void) { return VERSION; } + virtual const char *Description(void) { return tr(DESCRIPTION); } + virtual const char *CommandLineHelp(void); + virtual bool ProcessArgs(int argc, char *argv[]); + virtual bool Start(void); + virtual void Housekeeping(void); + virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); } + virtual cOsdObject *MainMenuAction(void); + virtual cMenuSetupPage *SetupMenu(void); + virtual bool SetupParse(const char *Name, const char *Value); + }; + +// Global variables that control the overall behaviour: + +int GreetingTime = 3; +int UseAlternateGreeting = false; + +// --- cMenuSetupHello ------------------------------------------------------- + +class cMenuSetupHello : public cMenuSetupPage { +private: + int newGreetingTime; + int newUseAlternateGreeting; +protected: + virtual void Store(void); +public: + cMenuSetupHello(void); + }; + +cMenuSetupHello::cMenuSetupHello(void) +{ + newGreetingTime = GreetingTime; + newUseAlternateGreeting = UseAlternateGreeting; + Add(new cMenuEditIntItem( tr("Greeting time (s)"), &newGreetingTime)); + Add(new cMenuEditBoolItem(tr("Use alternate greeting"), &newUseAlternateGreeting)); +} + +void cMenuSetupHello::Store(void) +{ + SetupStore("GreetingTime", GreetingTime = newGreetingTime); + SetupStore("UseAlternateGreeting", UseAlternateGreeting = newUseAlternateGreeting); +} + +// --- cPluginHello ---------------------------------------------------------- + +cPluginHello::cPluginHello(void) +{ + // Initialize any member variables here. + // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL + // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! + option_a = NULL; + option_b = false; +} + +cPluginHello::~cPluginHello() +{ + // Clean up after yourself! +} + +const char *cPluginHello::CommandLineHelp(void) +{ + // Return a string that describes all known command line options. + return " -a ABC, --aaa=ABC do something nice with ABC\n" + " -b, --bbb activate 'plan B'\n"; +} + +bool cPluginHello::ProcessArgs(int argc, char *argv[]) +{ + // Implement command line argument processing here if applicable. + static struct option long_options[] = { + { "aaa", required_argument, NULL, 'a' }, + { "bbb", no_argument, NULL, 'b' }, + { NULL } + }; + + int c; + while ((c = getopt_long(argc, argv, "a:b", long_options, NULL)) != -1) { + switch (c) { + case 'a': option_a = optarg; + break; + case 'b': option_b = true; + break; + default: return false; + } + } + return true; +} + +bool cPluginHello::Start(void) +{ + // Start any background activities the plugin shall perform. + RegisterI18n(Phrases); + return true; +} + +void cPluginHello::Housekeeping(void) +{ + // Perform any cleanup or other regular tasks. +} + +cOsdObject *cPluginHello::MainMenuAction(void) +{ + // Perform the action when selected from the main VDR menu. + Interface->Confirm(UseAlternateGreeting ? tr("Howdy folks!") : tr("Hello world!"), GreetingTime); + return NULL; +} + +cMenuSetupPage *cPluginHello::SetupMenu(void) +{ + // Return a setup menu in case the plugin supports one. + return new cMenuSetupHello; +} + +bool cPluginHello::SetupParse(const char *Name, const char *Value) +{ + // Parse your own setup parameters and store their values. + if (!strcasecmp(Name, "GreetingTime")) GreetingTime = atoi(Value); + else if (!strcasecmp(Name, "UseAlternateGreeting")) UseAlternateGreeting = atoi(Value); + else + return false; + return true; +} + +VDRPLUGINCREATOR(cPluginHello); // Don't touch this! |