updated on Wed Jan 25 16:08:47 UTC 2012
[aur-mirror.git] / vdr / MainMenuHooks-v1_0_1.diff
blob4df6b7a3b22251fa39d4a90e7379f48637e2388f
1 This is a "patch" for the Video Disk Recorder (VDR).
3 * History
4 2010-10-15: Version 1.0.1
5 - return a cOsdObject instead of its subclass cOsdMenu (thanks to
6 Joe_D@vdrportal)
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
14 - Initial revision.
16 * Authors:
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>
22 * Description:
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.
31 * Installation
32 Change into the VDR source directory, then issue
33 patch -p1 < path/to/MainMenuHooks-v1_0_1.patch
34 and recompile.
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) {
45 if (menu)
46 *menu = (cOsdMenu*) MainMenuAction();
47 return true;
49 return false;
52 Since patch version 1.0.1 the service call may return a cOsdObject
53 instead of a cOsdMenu. Use "#ifdef MAINMENUHOOKSVERSION" to detect
54 version 1.0.1.
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 @@
78 // Initial submenus:
80 + cOsdObject *menu = NULL;
81 switch (State) {
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;
88 + case osSchedule:
89 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osSchedule", &menu))
90 + menu = new cMenuSchedule;
91 + break;
92 + case osChannels:
93 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osChannels", &menu))
94 + menu = new cMenuChannels;
95 + break;
96 + case osTimers:
97 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osTimers", &menu))
98 + menu = new cMenuTimers;
99 + break;
100 + case osRecordings:
101 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osRecordings", &menu))
102 + menu = new cMenuRecordings(NULL, 0, true);
103 + break;
104 + case osSetup: menu = new cMenuSetup; break;
105 + case osCommands: menu = new cMenuCommands(tr("Commands"), &Commands); break;
106 default: break;
108 + if (menu)
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;
119 switch (state) {
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));
126 + case osSchedule:
127 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osSchedule", &menu))
128 + menu = new cMenuSchedule;
129 + else
130 + state = osContinue;
131 + break;
132 + case osChannels:
133 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osChannels", &menu))
134 + menu = new cMenuChannels;
135 + else
136 + state = osContinue;
137 + break;
138 + case osTimers:
139 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osTimers", &menu))
140 + menu = new cMenuTimers;
141 + else
142 + state = osContinue;
143 + break;
144 + case osRecordings:
145 + if (!cPluginManager::CallFirstService("MainMenuHooksPatch-v1.0::osRecordings", &menu))
146 + menu = new cMenuRecordings;
147 + else
148 + state = osContinue;
149 + break;
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());
154 if (item) {
155 @@ -3154,6 +3191,12 @@
156 default: break;
159 + if (menu) {
160 + if (menu->IsMenu())
161 + return AddSubMenu((cOsdMenu *) menu);
162 + pluginOsdObject = menu;
163 + return osPlugin;
164 + }
165 if (!HasSubMenu() && Update(HadSubMenu))
166 Display();
167 if (Key != kNone) {
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
171 @@ -36,6 +36,10 @@
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