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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
/*
* skindesigner.c: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
* $Id$
*/
#include <getopt.h>
#include <vdr/plugin.h>
#include <vdr/device.h>
#define DEFINE_CONFIG 1
#include "config.h"
#include "designer.h"
#include "setup.h"
#include "libskindesignerapi/skindesignerapi.h"
#include "extensions/globaltimers.h"
#if defined(APIVERSNUM) && APIVERSNUM < 20200
#error "VDR-2.2.0 API version or greater is required!"
#endif
static const char *VERSION = "1.2.18";
static const char *DESCRIPTION = trNOOP("Skin Designer");
class cPluginSkinDesigner : public cPlugin, public skindesignerapi::SkindesignerAPI {
private:
string libskindesignerApiVersion;
skindesignerapi::cPluginStructure *skinPreviewStruct;
protected:
bool ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure);
skindesignerapi::ISDDisplayMenu *ServiceGetDisplayMenu(void);
skindesignerapi::ISkinDisplayPlugin *ServiceGetDisplayPlugin(int plugId);
public:
cPluginSkinDesigner(void);
virtual ~cPluginSkinDesigner();
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 Initialize(void);
virtual bool Start(void);
virtual void Stop(void);
virtual void Housekeeping(void);
virtual void MainThreadHook(void);
virtual cString Active(void);
virtual time_t WakeupTime(void);
virtual const char *MainMenuEntry(void) {return NULL;}
virtual cOsdObject *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *Name, const char *Value);
virtual bool Service(const char *Id, void *Data = NULL);
virtual const char **SVDRPHelpPages(void);
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
};
cPluginSkinDesigner::cPluginSkinDesigner(void) {
libskindesignerApiVersion = "undefined";
config.SetVersion(VERSION);
skinPreviewStruct = NULL;
}
cPluginSkinDesigner::~cPluginSkinDesigner() {
delete skinPreviewStruct;
}
const char *cPluginSkinDesigner::CommandLineHelp(void) {
return
" -s <SKINPATH>, --skinpath=<SKINPATH> Set directory where xml skins are stored by Package Manager\n"
" -i <INSTALLERPATH>, --installerpath=<INSTALLERPATH> Set directory where xml skins are stored by Installer\n"
" -l <LOGOPATH>, --logopath=<LOGOPATH> Set directory where a common logo set for all skins is stored\n"
" -e <EPGIMAGESPATH>, --epgimages=<IMAGESPATH> Set directory where epgimages are stored\n";
}
bool cPluginSkinDesigner::ProcessArgs(int argc, char *argv[]) {
// Implement command line argument processing here if applicable.
static const struct option long_options[] = {
{ "epgimages", required_argument, NULL, 'e' },
{ "logopath", required_argument, NULL, 'l' },
{ "skinpath", required_argument, NULL, 's' },
{ "installerpath", required_argument, NULL, 'i' },
{ 0, 0, 0, 0 }
};
int c;
while ((c = getopt_long(argc, argv, "e:s:l:i:", long_options, NULL)) != -1) {
switch (c) {
case 'e':
config.SetEpgImagePath(cString(optarg));
break;
case 'l':
config.SetLogoPath(cString(optarg));
break;
case 's':
config.SetSkinPath(cString(optarg));
break;
case 'i':
config.SetInstallerSkinPath(cString(optarg));
break;
default:
return false;
}
}
return true;
}
bool cPluginSkinDesigner::Initialize(void) {
plgManager = new cSDPluginManager();
return true;
}
bool cPluginSkinDesigner::Start(void) {
cXmlParser::InitLibXML();
cImageImporterSVG::InitLibRSVG();
cGlobalTimers::StartRefreshThread();
bool trueColorAvailable = true;
if (!cOsdProvider::SupportsTrueColor()) {
esyslog("skindesigner: No TrueColor OSD found! Using default Skin LCARS!");
trueColorAvailable = false;
} else
dsyslog("skindesigner: TrueColor OSD found");
libskindesignerApiVersion = LIBSKINDESIGNERAPIVERSION;
dsyslog("skindesigner: using libskindesigner API Version %s", libskindesignerApiVersion.c_str());
skinPreviewStruct = new skindesignerapi::cPluginStructure();
skinPreviewStruct->name = "setup";
skinPreviewStruct->libskindesignerAPIVersion = LIBSKINDESIGNERAPIVERSION;
skindesignerapi::cTokenContainer *tkSkinPreview = new skindesignerapi::cTokenContainer();
cSkindesignerSkinPreview::DefineTokens(tkSkinPreview);
skinPreviewStruct->RegisterMenu(0, skindesignerapi::mtText, "skinpreview.xml", tkSkinPreview);
if (RegisterPlugin(skinPreviewStruct)) {
dsyslog("skindesigner: skinsetup template successfully registered at skindesigner, id %d", skinPreviewStruct->id);
}
config.SetOsdLanguage();
config.SetPathes();
config.ReadSkins();
config.InitSkinIterator();
string skin = "";
bool skinAvailable = false;
while (config.GetSkin(skin)) {
config.ReadSkinSetup(skin);
cTheme *theme = new cTheme();
config.StoreTheme(theme);
cSkinDesigner *newSkin = new cSkinDesigner(skin, theme);
config.AddSkin(newSkin);
skinAvailable = true;
if (!trueColorAvailable) {
newSkin->ActivateBackupSkin();
}
}
config.TranslateSetup();
config.SetSkinSetupParameters();
if (!skinAvailable) {
esyslog("skindesigner: no skins found! Using default Skin LCARS!");
}
#ifdef USE_ZAPCOCKPIT
dsyslog("skindesigner: zapcockpit patch available");
#endif
return true;
}
void cPluginSkinDesigner::Stop(void) {
delete imgCache;
delete fontManager;
delete plgManager;
cXmlParser::CleanupLibXML();
cGlobalTimers::StopRefreshThread();
}
void cPluginSkinDesigner::Housekeeping(void) {
}
void cPluginSkinDesigner::MainThreadHook(void) {
int w, h;
double a;
static int mode;
cDevice::PrimaryDevice()->GetVideoSize(w, h, a);
if (!w && !h && !mode) {
mode = 1;
config.mode_changed = 1;
dsyslog("skindesigner: w %d h %d mode changed to %d\n", w, h, mode);
}
else if (w && h && mode) {
mode = 0;
config.mode_changed = 1;
dsyslog("skindesigner: w %d h %d mode changed to %d\n", w, h, mode);
}
}
cString cPluginSkinDesigner::Active(void) {
return NULL;
}
time_t cPluginSkinDesigner::WakeupTime(void) {
return 0;
}
cOsdObject *cPluginSkinDesigner::MainMenuAction(void) {
return NULL;
}
cMenuSetupPage *cPluginSkinDesigner::SetupMenu(void) {
return new cSkinDesignerSetup(skinPreviewStruct);
}
bool cPluginSkinDesigner::SetupParse(const char *Name, const char *Value) {
return config.SetupParse(Name, Value);
}
bool cPluginSkinDesigner::Service(const char *Id, void *Data) {
return false;
}
const char **cPluginSkinDesigner::SVDRPHelpPages(void) {
static const char *HelpPages[] = {
"RELD\n"
" force reload of templates and caches",
"DLIC\n"
" delete image cache",
"SCIT\n"
" Set custom Integer Token key = value",
"SCST\n"
" Set custom String Token key = value",
"LCTK\n"
" List custom Tokens",
"LSTF\n"
" List available Fonts",
0
};
return HelpPages;
}
cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) {
cSkinDesigner *activeSkin = NULL;
cSkinDesigner *availableSkin = NULL;
config.InitSkinRefsIterator();
int result = 0;
while (availableSkin = config.GetNextSkinRef()) {
string activeSkinName = Setup.OSDSkin;
string currentSkinName = availableSkin->Description();
if (!currentSkinName.compare(activeSkinName)) {
activeSkin = availableSkin;
break;
}
}
if (!activeSkin) {
ReplyCode = 550;
return "SKINDESIGNER not active.";
}
if (strcasecmp(Command, "RELD") == 0) {
if (!activeSkin->Initialized()) {
ReplyCode = 503;
return "SKINDESIGNER reload of templates and caches failed: initialization not finished.";
}
config.ClearSkinSetups();
config.InitSkinIterator();
string skin = "";
while (config.GetSkin(skin)) {
config.ReadSkinSetup(skin);
}
config.TranslateSetup();
config.SetSkinSetupParameters();
result = activeSkin->Reload();
switch (result) {
case 0:
ReplyCode = 250;
return "SKINDESIGNER reload of templates and caches forced.";
case 1:
ReplyCode = 501;
return "SKINDESIGNER reload of templates and caches failed: error during loading - using LCARS as backup.";
case 2:
ReplyCode = 503;
return "SKINDESIGNER reload of templates and caches failed: OSD is open, close first.";
default:
ReplyCode = 500;
return "SKINDESIGNER reload of templates and caches failed: unknown reason (check code).";
};
} else if (strcasecmp(Command, "DLIC") == 0) {
if (imgCache)
delete imgCache;
imgCache = new cImageCache();
imgCache->SetPathes();
ReplyCode = 250;
return "SKINDESIGNER Image Cache deleted.";
} else if (strcasecmp(Command, "LSTF") == 0) {
activeSkin->ListAvailableFonts();
ReplyCode = 250;
return "SKINDESIGNER available fonts listed in syslog.";
} else if (strcasecmp(Command, "SCIT") == 0) {
if (!Option) {
ReplyCode = 501;
return "SKINDESIGNER SCIK Error: no Token name = value set";
}
bool optionOk = activeSkin->SetCustomIntToken(Option);
if (optionOk) {
ReplyCode = 250;
return cString::sprintf("SKINDESIGNER Set custom Int Token %s", Option);
} else {
ReplyCode = 501;
return cString::sprintf("SKINDESIGNER Invalid custom Int Token %s", Option);
}
} else if (strcasecmp(Command, "SCST") == 0) {
if (!Option) {
ReplyCode = 501;
return "SKINDESIGNER SCSK Error: no Token name = value set";
}
bool optionOk = activeSkin->SetCustomStringToken(Option);
if (optionOk) {
ReplyCode = 250;
return cString::sprintf("SKINDESIGNER Set custom String Token %s", Option);
} else {
ReplyCode = 501;
return cString::sprintf("SKINDESIGNER Invalid custom String Token %s", Option);
}
} else if (strcasecmp(Command, "LCTK") == 0) {
activeSkin->ListCustomTokens();
ReplyCode = 250;
return "SKINDESIGNER Custom Tokens listed in Log";
}
ReplyCode = 502;
return "SKINDESIGNER invalid SVDRP command.";
}
bool cPluginSkinDesigner::ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure) {
if (plugStructure->menus.size() < 1 && plugStructure->rootview.size() < 1) {
esyslog("skindesigner: error - plugin without menus or views registered");
return false;
}
//basic plugin interface
if (plugStructure->menus.size() > 0)
plgManager->RegisterBasicPlugin(plugStructure);
//advanced plugin interface
if (plugStructure->rootview.size() > 0)
plgManager->RegisterAdvancedPlugin(plugStructure);
return true;
}
skindesignerapi::ISDDisplayMenu *cPluginSkinDesigner::ServiceGetDisplayMenu(void) {
cSkin *current = Skins.Current();
cSkinDesigner *availableSkin = NULL;
config.InitSkinRefsIterator();
while (availableSkin = config.GetNextSkinRef()) {
if (availableSkin == current) {
cSDDisplayMenu *displayMenu = availableSkin->GetDisplayMenu();
if (displayMenu) {
return displayMenu;
} else {
return NULL;
}
}
}
return NULL;
}
skindesignerapi::ISkinDisplayPlugin *cPluginSkinDesigner::ServiceGetDisplayPlugin(int plugId) {
cSkin *current = Skins.Current();
cSkinDesigner *availableSkin = NULL;
config.InitSkinRefsIterator();
while (availableSkin = config.GetNextSkinRef()) {
if (availableSkin == current) {
return availableSkin->GetDisplayPlugin(plugId);
}
}
return NULL;
}
VDRPLUGINCREATOR(cPluginSkinDesigner); // Don't touch this!
|