-
Notifications
You must be signed in to change notification settings - Fork 0
/
skyselectfeeds.c
308 lines (271 loc) · 9.17 KB
/
skyselectfeeds.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
* director.c: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include <vdr/menuitems.h>
#include <vdr/plugin.h>
#include <vdr/status.h>
#include <vdr/remote.h>
#include <vdr/tools.h>
#include "menudirector.h"
#include "osdproxy.h"
static const char *VERSION = "0.2.8_pre20130316";
#define DESCRIPTION tr("skin-aware plugin to use the Sky Select (Germany) linked feeds option")
#define MAINMENUENTRY tr("SkySelect Feeds")
const char* allowedButtonNames[] = {
"Ok",
"Red",
"Green",
"Yellow",
"Blue",
"User1",
"User2",
"User3",
"User4",
"User5",
"User6",
"User7",
"User8",
"User9",
};
eKeys allowedButtons[] =
{
kOk,
kRed,
kGreen,
kYellow,
kBlue,
kUser1,
kUser2,
kUser3,
kUser4,
kUser5,
kUser6,
kUser7,
kUser8,
kUser9
};
#define NOOFALLOWEDBUTTONS 14
int hide = 0;
int portalmode = 1;
int swapKeys = 0;
int swapKeysInMenu = 0;
int displayChannelInfo = 1;
int switchChannelOnItemSelect = 1;
int hidePluginAfterChannelSwitch = 0;
int displayShortcutNumbers = 1;
int displayEpgInfo = 1;
int showPluginButton = 0;
int autoStart = 1;
int autoStartRef = 1;
int autoStartAsk = 1;
int avoidStartOnNoLinkChannels = 1;
int calledByChannelSwitch = 0;
class cDirectorStatus : public cStatus
{
private:
cPlugin* parent;
protected:
virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView);
public:
cDirectorStatus(cPlugin* plugin);
};
class cPluginDirector : public cPlugin
{
private:
// Add any member variables or functions you may need here.
cDirectorStatus *directorStatus;
public:
cPluginDirector(void);
virtual ~cPluginDirector();
virtual const char *Version(void) { return VERSION; }
virtual const char *Description(void) { return 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 (hide ? NULL : MAINMENUENTRY); }
virtual cOsdObject *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *Name, const char *Value);
};
cDirectorStatus::cDirectorStatus(cPlugin* plugin)
{
parent = plugin;
}
void cDirectorStatus::ChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView)
{
// pre-channel-switch - we are not interested
if (ChannelNumber == 0)
return;
// channel switch not ffor live view
if (!LiveView)
return;
// channelno not no of primdevice - puuh no thx
if (cDevice::CurrentChannel() != ChannelNumber)
return;
// all autostarts turned off - go away dude!
if ((!autoStart) && (!autoStartRef))
return;
const cChannel* Channel = Channels.GetByNumber(ChannelNumber);//Device->CurrentChannel());
if (!Channel)
return;
bool wAutoStart = false;
if (autoStart)
{
if ((Channel->LinkChannels() != NULL) && (Channel->LinkChannels()->Count() > 1) && parent)
wAutoStart = true;
}
if (autoStartRef)
{
if ((Channel->RefChannel() != NULL) && (Channel->RefChannel()->LinkChannels() != NULL) && (Channel->RefChannel()->LinkChannels()->Count() >= 1) && parent)
wAutoStart = true;
}
if (wAutoStart)
{
calledByChannelSwitch = 1;
cRemote::CallPlugin(parent->Name());
}
}
cPluginDirector::cPluginDirector(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!
directorStatus = NULL;
}
cPluginDirector::~cPluginDirector()
{
// Clean up after yourself!
if (directorStatus)
delete directorStatus;
}
const char *cPluginDirector::CommandLineHelp(void)
{
// Return a string that describes all known command line options.
return NULL;
}
bool cPluginDirector::ProcessArgs(int argc, char *argv[])
{
// Implement command line argument processing here if applicable.
return true;
}
bool cPluginDirector::Start(void)
{
// Start any background activities the plugin shall perform.
//if(autoStart == 1)
directorStatus = new cDirectorStatus(this);
// Default values for setup
return true;
}
void cPluginDirector::Housekeeping(void)
{
// Perform any cleanup or other regular tasks.
}
cOsdObject *cPluginDirector::MainMenuAction(void)
{
cMenuDirectorData* config = new cMenuDirectorData();
config->mHidePluginEntryInMainMenu = hide;
config->mPortalmode = portalmode;
config->mSwapKeys = swapKeys;
config->mDisplayChannelInfo = displayChannelInfo;
config->mSwitchChannelOnItemSelect = switchChannelOnItemSelect;
config->mHidePluginAfterChannelSwitch = hidePluginAfterChannelSwitch;
config->mDisplayShortcutNumbers = displayShortcutNumbers;
config->mDisplayEpgInfo = displayEpgInfo;
config->mSwapKeysInMenu = swapKeysInMenu;
config->mHideButton = allowedButtons[showPluginButton];
config->mAskOnStart = autoStartAsk;
config->mAvoidStartOnSingleChannels = avoidStartOnNoLinkChannels ;
config->mCalledByChannelSwitch = calledByChannelSwitch;
// directly reset
calledByChannelSwitch = 0;
return new cOsdProxy(cMenuDirector::Create,cMenuDirector::KeyHandlerFunction,cMenuDirector::Release,MAINMENUENTRY,config, allowedButtons[showPluginButton],true);
}
bool cPluginDirector::SetupParse(const char *Name, const char *Value)
{
// Parse your own setup parameters and store their values.
if (!strcasecmp(Name, "HideMenu"))
hide = atoi(Value);
else if (!strcasecmp(Name, "SwapKeys"))
swapKeys = atoi(Value);
else if (!strcasecmp(Name, "SwapKeysInMenu"))
swapKeysInMenu = atoi(Value);
else if (!strcasecmp(Name, "PortalMode"))
portalmode = atoi(Value);
else if (!strcasecmp(Name, "DisplayChannelInfo"))
displayChannelInfo = atoi(Value);
else if (!strcasecmp(Name, "SwitchChannelOnItemSelect"))
switchChannelOnItemSelect = atoi(Value);
else if (!strcasecmp(Name, "HidePluginAfterChannelSwitch"))
hidePluginAfterChannelSwitch = atoi(Value);
else if (!strcasecmp(Name, "DisplayShortcutNumbers"))
displayShortcutNumbers= atoi(Value);
else if (!strcasecmp(Name, "DisplayEpgInfo"))
displayEpgInfo= atoi(Value);
else if (!strcasecmp(Name, "ShowPluginButton"))
showPluginButton = atoi(Value);
else if (!strcasecmp(Name, "AutoStart"))
autoStart = atoi(Value);
else if (!strcasecmp(Name, "AutoStartRef"))
autoStartRef = atoi(Value);
else if (!strcasecmp(Name, "AutoStartAsk"))
autoStartAsk = atoi(Value);
else if (!strcasecmp(Name, "AvoidStartOnNoLinkChannels"))
avoidStartOnNoLinkChannels = atoi(Value);
return true;
}
//the setup part
class cMenuSetupDirector : public cMenuSetupPage
{
public:
cMenuSetupDirector();
protected:
virtual void Store(void);
private:
int new_hide;
};
cMenuSetupDirector::cMenuSetupDirector()
{
new_hide = hide;
Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &hide, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Swap up and down"), &swapKeys, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Swap up and down in menu"), &swapKeysInMenu, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Portal Mode"), &portalmode, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Display info on channel change"), &displayChannelInfo, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Switch channel on linkchannel selection"), &switchChannelOnItemSelect, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Hide plugin after channel switch"), &hidePluginAfterChannelSwitch, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Display channel shortcut numbers"), &displayShortcutNumbers, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Display EPG information"), &displayEpgInfo, tr("no"), tr("yes")));
Add(new cMenuEditStraItem(tr("Show plugin again on button"), &showPluginButton, NOOFALLOWEDBUTTONS, allowedButtonNames));
Add(new cMenuEditBoolItem(tr("Autostart plugin"), &autoStart, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Autostart plugin on referenced channels"), &autoStartRef, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Ask before autostart plugin"), &autoStartAsk, tr("no"), tr("yes")));
Add(new cMenuEditBoolItem(tr("Avoid start on nonlink channels"), &avoidStartOnNoLinkChannels, tr("no"), tr("yes")));
}
void cMenuSetupDirector::Store(void)
{
SetupStore("HideMenu", new_hide = hide);
SetupStore("SwapKeys", swapKeys);
SetupStore("SwapKeysInMenu", swapKeysInMenu);
SetupStore("PortalMode", portalmode);
SetupStore("DisplayChannelInfo", displayChannelInfo);
SetupStore("SwitchChannelOnItemSelect", switchChannelOnItemSelect);
SetupStore("DisplayShortcutNumbers", hidePluginAfterChannelSwitch);
SetupStore("HidePluginAfterChannelSwitch", displayShortcutNumbers);
SetupStore("DisplayEpgInfo", displayEpgInfo);
SetupStore("ShowPluginButton", showPluginButton);
SetupStore("AutoStart", autoStart);
SetupStore("AutoStartRef", autoStartRef);
SetupStore("AutoStartAsk", autoStartAsk);
SetupStore("AvoidStartOnNoLinkChannels", avoidStartOnNoLinkChannels);
}
cMenuSetupPage *cPluginDirector::SetupMenu(void)
{
// Return a setup menu in case the plugin supports one.
return new cMenuSetupDirector();
}
VDRPLUGINCREATOR(cPluginDirector); // Don't touch this!