1 This is a "patch" for the Video Disk Recorder (VDR).
4 2010-10-15: Version 1.0.1
5 - return a cOsdObject instead of its subclass cOsdMenu (thanks to
7 - version number defines in config.h now follow the ususal conventions:
8 MAINMENUHOOKSVERSNUM is now a number, the newly added define
9 MAINMENUHOOKSVERSION is a string (suggested by gnapheus@vdrportal)
10 - patch is now based on VDR 1.6.0
11 - updated documentation
13 2007-02-26: Version 1.0
17 Tobias Grimm <vdr at e-tobi dot net>
18 Martin Prochnow <nordlicht at martins-kabuff dot de>
19 Frank Schmirler <vdrdev at schmirler dot de>
20 Christian Wieninger <cwieninger at gmx dot de>
23 This patch allows plugins to replace the VDR mainmenus "Schedule",
24 "Channels", "Timers" and "Recordings" by a different implementation.
26 The patch is based on a suggestion of Christian Wieninger back in 2006
27 (http://www.linuxtv.org/pipermail/vdr/2006-March/008234.html). It is
28 meant to be an interim solution for VDR 1.4 until (maybe) VDR 1.5
29 introduces an official API for this purpose.
32 Change into the VDR source directory, then issue
33 patch -p1 < path/to/MainMenuHooks-v1_0_1.patch
36 * Notes for plugin authors
37 The following code sample shows the required plugin code for replacing
38 the original Schedule menu:
40 bool cMyPlugin::Service(const char *Id, void *Data)
42 cOsdMenu **menu = (cOsdMenu**) Data;
43 if (MySetup.replaceSchedule &&
44 strcmp(Id, "MainMenuHooksPatch-v1.0::osSchedule") == 0) {
46 *menu = (cOsdMenu*) MainMenuAction();
52 Since patch version 1.0.1 the service call may return a cOsdObject
53 instead of a cOsdMenu. Use "#ifdef MAINMENUHOOKSVERSION" to detect
56 A plugin can replace more than one menu at a time. Simply replace the
57 call to MainMenuAction() in the sample above by appropriate code.
59 Note that a plugin *should* offer a setup option which allows the user
60 to enable or disable the replacement. "Disabled" would be a reasonable
61 default setting. By testing for define MAINMENUHOOKSVERSNUM, a plugin
62 can leave the setup option out at compiletime.
64 In case there is an internal problem when trying to open the replacement
65 menu, it is safe to return true even though Data is NULL. However an
66 OSD message should indicate the problem to the user.
68 Feel free to ship this patch along with your plugin. However if you
69 think you need to modify the patch, we'd encourage you to contact the
70 authors first or at least use a service id which differs in more than
71 just the version number.
73 diff -ru vdr-1.6.0.orig/menu.c vdr-1.6.0/menu.c
74 --- vdr-1.6.0.orig/menu.c 2008-03-16 12:15:28.000000000 +0100
75 +++ vdr-1.6.0/menu.c 2010-10-11 20:32:25.000000000 +0200
76 @@ -2973,15 +2973,31 @@
80 + cOsdObject *menu = NULL;
82 - case osSchedule: AddSubMenu(new cMenuSchedule); break;
83 - case osChannels: AddSubMenu(new cMenuChannels); break;
84 - case osTimers: AddSubMenu(new cMenuTimers); break;
85 - case osRecordings: AddSubMenu(new cMenuRecordings(NULL, 0, true)); break;
86 - case osSetup: AddSubMenu(new cMenuSetup); break;
87 - case osCommands: AddSubMenu(new cMenuCommands(tr("Commands"), &Commands)); break;
89 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osSchedule", &menu))
90 + menu = new cMenuSchedule;
93 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osChannels", &menu))
94 + menu = new cMenuChannels;
97 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osTimers", &menu))
98 + menu = new cMenuTimers;
101 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osRecordings", &menu))
102 + menu = new cMenuRecordings(NULL, 0, true);
104 + case osSetup: menu = new cMenuSetup; break;
105 + case osCommands: menu = new cMenuCommands(tr("Commands"), &Commands); break;
109 + if (menu->IsMenu())
110 + AddSubMenu((cOsdMenu *) menu);
113 cOsdObject *cMenuMain::PluginOsdObject(void)
114 @@ -3096,13 +3112,34 @@
115 eOSState state = cOsdMenu::ProcessKey(Key);
116 HadSubMenu |= HasSubMenu();
118 + cOsdObject *menu = NULL;
120 - case osSchedule: return AddSubMenu(new cMenuSchedule);
121 - case osChannels: return AddSubMenu(new cMenuChannels);
122 - case osTimers: return AddSubMenu(new cMenuTimers);
123 - case osRecordings: return AddSubMenu(new cMenuRecordings);
124 - case osSetup: return AddSubMenu(new cMenuSetup);
125 - case osCommands: return AddSubMenu(new cMenuCommands(tr("Commands"), &Commands));
127 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osSchedule", &menu))
128 + menu = new cMenuSchedule;
130 + state = osContinue;
133 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osChannels", &menu))
134 + menu = new cMenuChannels;
136 + state = osContinue;
139 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osTimers", &menu))
140 + menu = new cMenuTimers;
142 + state = osContinue;
145 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osRecordings", &menu))
146 + menu = new cMenuRecordings;
148 + state = osContinue;
150 + case osSetup: menu = new cMenuSetup; break;
151 + case osCommands: menu = new cMenuCommands(tr("Commands"), &Commands); break;
152 case osStopRecord: if (Interface->Confirm(tr("Stop recording?"))) {
153 cOsdItem *item = Get(Current());
155 @@ -3154,6 +3191,12 @@
160 + if (menu->IsMenu())
161 + return AddSubMenu((cOsdMenu *) menu);
162 + pluginOsdObject = menu;
165 if (!HasSubMenu() && Update(HadSubMenu))
168 diff -ru vdr-1.6.0.orig/config.h vdr-1.6.0/config.h
169 --- vdr-1.6.0.orig/config.h 2008-03-23 11:26:10.000000000 +0100
170 +++ vdr-1.6.0/config.h 2010-10-11 20:32:25.000000000 +0200
172 // plugins to work with newer versions of the core VDR as long as no
173 // VDR header files have changed.
175 +// The MainMenuHook Patch's version number:
176 +#define MAINMENUHOOKSVERSION "1.0.1"
177 +#define MAINMENUHOOKSVERSNUM 10001 // Version * 10000 + Major * 100 + Minor
179 #define MAXPRIORITY 99
180 #define MAXLIFETIME 99