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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
|
#include <vdr/interface.h>
#include "extensions/curlfuncs.h"
#include <vdr/menu.h>
#include "setup.h"
// --- cInstallManager -----------------------------------------------------------
cInstallManager::cInstallManager(void) {
installing = false;
updating = false;
runningInst = NULL;
installationStart = 0;
lastInstallDuration = -1;
timeout = 120; //2 Minutes timeout
currentSkin = "";
}
cInstallManager::~cInstallManager(void) {
}
bool cInstallManager::StartInstallation(string skin) {
runningInst = config.GetSkinRepo(skin);
if (!runningInst) {
return false;
}
installing = true;
installationStart = cTimeMs::Now();
runningInst->Install(*config.installerSkinPath, config.vdrThemesPath);
return true;
}
bool cInstallManager::StartUpdate(string skin) {
runningInst = config.GetSkinRepo(skin);
if (!runningInst || runningInst->Type() != rtGit) {
return false;
}
updating = true;
installationStart = cTimeMs::Now();
runningInst->Update(*config.installerSkinPath);
return true;
}
bool cInstallManager::Finished(void) {
if (!runningInst)
return true;
if (runningInst->InstallationFinished()) {
installing = false;
updating = false;
return true;
}
return false;
}
bool cInstallManager::SuccessfullyInstalled(void) {
if (!runningInst)
return false;
bool ok = runningInst->SuccessfullyInstalled();
runningInst = NULL;
return ok;
}
bool cInstallManager::SuccessfullyUpdated(void) {
if (!runningInst)
return false;
bool ok = runningInst->SuccessfullyUpdated();
runningInst = NULL;
return ok;
}
int cInstallManager::Duration(void) {
return (cTimeMs::Now() - installationStart) / 1000;
}
eOSState cInstallManager::ProcessInstallationStatus(void) {
if (Installing()) {
if (Finished()) {
if (SuccessfullyInstalled()) {
config.AddNewSkinRef(currentSkin);
Skins.Message(mtStatus, tr("Skin successfully installed"));
} else {
Skins.Message(mtError, tr("Skin NOT successfully installed"));
}
cCondWait::SleepMs(1000);
return osEnd;
} else {
int duration = Duration();
if (duration > timeout) {
Skins.Message(mtError, tr("Timeout"));
cCondWait::SleepMs(1000);
return osEnd;
} else if (duration != lastInstallDuration) {
Skins.Message(mtStatus, *cString::sprintf("%s (%d %s)...", tr("Installing Skin"), duration, tr("sec")));
lastInstallDuration = duration;
}
}
} else if (Updating()) {
if (Finished()) {
if (SuccessfullyUpdated()) {
Skins.Message(mtStatus, tr("Skin successfully updated"));
cCondWait::SleepMs(1000);
return osEnd;
} else {
Skins.Message(mtStatus, tr("Skin already up to date"));
return osContinue;
}
} else {
int duration = Duration();
if (duration > timeout) {
Skins.Message(mtError, tr("Timeout"));
cCondWait::SleepMs(1000);
return osEnd;
} else if (duration != lastInstallDuration) {
Skins.Message(mtStatus, *cString::sprintf("%s (%d %s)...", tr("Updating Skin from Git"), duration, tr("sec")));
lastInstallDuration = duration;
}
}
}
return osContinue;
}
// --- cSkinDesignerSetup -----------------------------------------------------------
cSkinDesignerSetup::cSkinDesignerSetup(skindesignerapi::cPluginStructure *skinPreviewStruct) {
this->skinPreviewStruct = skinPreviewStruct;
numLogosPerSizeInitial = config.numLogosPerSizeInitial;
cacheImagesInitial = config.cacheImagesInitial;
limitLogoCache = config.limitLogoCache;
numLogosMax = config.numLogosMax;
debugImageLoading = config.debugImageLoading;
rerunAmount = config.rerunAmount;
rerunDistance = config.rerunDistance;
rerunMaxChannel = config.rerunMaxChannel;
numCustomTokens = config.numCustomTokens;
menuDisplayStyle[0] = tr("after one another");
menuDisplayStyle[1] = tr("at one go");
Setup();
}
cSkinDesignerSetup::~cSkinDesignerSetup(void) {
config.setupCloseDoReload = true;
}
void cSkinDesignerSetup::Setup(void) {
int current = Current();
Clear();
SkinSetup();
InstallSkins();
PluginSetup();
ImageCacheStatistics();
SetCurrent(Get(current));
Display();
}
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
bool hadSubMenu = HasSubMenu();
state = cMenuSetupPage::ProcessKey(Key);
if (hadSubMenu && Key == kOk) {
Store();
}
if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed || Key == kYellow)) {
SetHelp(NULL, NULL, NULL, NULL);
cOsdItem *current = Get(Current());
cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current);
if (!skinMenuItem)
return state;
eItemType type = skinMenuItem->Type();
currentSkin = skinMenuItem->GetSkinName();
// KEY OK
if ((Key == kOk)) {
if (type == itSkinSetup) {
state = AddSubMenu(new cSkindesignerSkinSetup(currentSkin, "", ""));
} else if (type == itNoSkinSetup) {
state = osContinue;
} else if (type == itSkinRepo) {
Skins.Message(mtStatus, tr("Downloading Skin Screenshots..."));
cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin, skinPreviewStruct);
Skins.Message(mtStatus, NULL);
state = AddSubMenu(prev);
}
}
// Menu Moves
if (Key == kUp || Key == kDown || Key == kLeft || Key == kRight) {
if (type == itSkinRepo) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *repo = config.GetSkinRepo(currentSkin);
if (repo) {
if (repo->Type() == rtGit)
SetHelp(tr("Update"), NULL, tr("Delete Skin"), NULL);
else
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
}
}
}
// KEY RED
if (Key == kRed) {
string versionNeeded = "";
bool versionOk = config.CheckVersion(currentSkin, versionNeeded);
if (type == itSkinRepo) {
if (!versionOk) {
cString error = cString::sprintf("%s %s %s %s %s",
tr("Skin Designer"),
tr("version"),
versionNeeded.c_str(),
tr("or higher"),
tr("needed"));
Skins.Message(mtError, *error);
return state;
}
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Installing Skin")));
StartInstallation(currentSkin);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
bool gitAvailable = StartUpdate(currentSkin);
if (gitAvailable) {
if (!versionOk) {
cString error = cString::sprintf("%s %s %s %s %s",
tr("Skin Designer"),
tr("version"),
versionNeeded.c_str(),
tr("or higher"),
tr("needed"));
Skins.Message(mtError, *error);
return state;
}
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
} else {
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
}
}
}
// KEY YELLOW
if (Key == kYellow) {
if (type == itSkinSetup || type == itNoSkinSetup) {
if (config.SkinActive(currentSkin)) {
Skins.Message(mtError, tr("Skin is running and can't be deleted"));
} else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) {
config.DeleteSkin(currentSkin);
Skins.Message(mtStatus, tr("Skin deleted"));
cCondWait::SleepMs(1000);
return osEnd;
}
state = osContinue;
}
}
}
return state;
}
void cSkinDesignerSetup::Store(void) {
config.numLogosPerSizeInitial = numLogosPerSizeInitial;
config.cacheImagesInitial = cacheImagesInitial;
config.limitLogoCache = limitLogoCache;
config.numLogosMax = numLogosMax;
config.debugImageLoading = debugImageLoading;
config.rerunAmount = rerunAmount;
config.rerunDistance = rerunDistance;
config.rerunMaxChannel = rerunMaxChannel;
config.numCustomTokens = numCustomTokens;
config.InitSetupIterator();
cSkinSetup *skinSetup = NULL;
while (skinSetup = config.GetNextSkinSetup()) {
string skin = skinSetup->GetSkin();
skinSetup->InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = skinSetup->GetNextParameter()) {
cString paramName = cString::sprintf("%s.%s", skin.c_str(), param->name.c_str());
SetupStore(*paramName, param->value);
config.UpdateSkinSetupParameter(*paramName, param->value);
}
}
config.UpdateGlobals();
SetupStore("DebugImageLoading", debugImageLoading);
SetupStore("CacheImagesInitial", cacheImagesInitial);
SetupStore("LimitChannelLogoCache", limitLogoCache);
SetupStore("NumberLogosInitially", numLogosPerSizeInitial);
SetupStore("NumberLogosMax", numLogosMax);
SetupStore("RerunAmount", rerunAmount);
SetupStore("RerunDistance", rerunDistance);
SetupStore("RerunMaxChannel", rerunMaxChannel);
SetupStore("NumCustomTokens", numCustomTokens);
}
cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) {
cOsdItem *item;
item = new cOsdItem(cString::sprintf("---------------- %s ----------------", tr(label)));
item->SetSelectable(false);
return item;
}
void cSkinDesignerSetup::PluginSetup(void) {
Add(InfoItem(tr("Plugin Setup")));
Add(new cMenuEditIntItem(tr("Maximum number of custom tokens"), &numCustomTokens, 0, 100));
Add(InfoItem(tr("Reruns")));
Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &rerunAmount, 1, 100));
Add(new cMenuEditIntItem(tr("Minimum timely distance of rerun (in hours)"), &rerunDistance, 0, 1000));
Add(new cMenuEditIntItem(tr("Limit Channel Numbers"), &rerunMaxChannel, 0, 1000, tr("no limit")));
Add(InfoItem(tr("Image Loading")));
Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &debugImageLoading));
Add(new cMenuEditBoolItem(tr("Cache icons, skinparts and logos at start"), &cacheImagesInitial));
Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &limitLogoCache));
Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &numLogosPerSizeInitial, 0, 1000));
Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &numLogosMax, 0, 1000));
}
void cSkinDesignerSetup::ImageCacheStatistics(void) {
if (!imgCache) {
return;
}
Add(InfoItem(tr("Cache Statistics")));
float sizeIconCacheInt = 0;
float sizeIconCacheExt = 0;
int numIcons = 0;
imgCache->GetIconCacheSize(numIcons, sizeIconCacheInt, sizeIconCacheExt);
cString iconCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s, %.2f%s %s", tr("cached"), numIcons, tr("icons"), tr("size"), sizeIconCacheInt, tr("MB"), tr("int. memory"), sizeIconCacheExt, tr("MB"), tr("high level memory"));
Add(new cOsdItem(*iconCacheInfo));
cList<cOsdItem>::Last()->SetSelectable(false);
float sizeLogoCache = 0;
int numLogos = 0;
imgCache->GetLogoCacheSize(numLogos, sizeLogoCache);
cString logoCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s", tr("cached"), numLogos, tr("logos"), tr("size"), sizeLogoCache, tr("MB"), tr("int. memory"));
Add(new cOsdItem(*logoCacheInfo));
cList<cOsdItem>::Last()->SetSelectable(false);
float sizeSkinpartCacheInt = 0;
float sizeSkinpartCacheExt = 0;
int numSkinparts = 0;
imgCache->GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCacheInt, sizeSkinpartCacheExt);
cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s, %.2f%s %s", tr("cached"), numSkinparts, tr("skinparts"), tr("MB"), sizeSkinpartCacheInt, tr("MB"), tr("int. memory"), sizeSkinpartCacheExt, tr("MB"), tr("high level memory"));
Add(new cOsdItem(*skinpartCacheInfo));
cList<cOsdItem>::Last()->SetSelectable(false);
}
void cSkinDesignerSetup::SkinSetup(void) {
Add(InfoItem(tr("Skin Setup")));
config.InitSkinIterator();
string skin = "";
while (config.GetSkin(skin)) {
cSkinSetup *skinSetup = config.GetSkinSetup(skin);
if (!skinSetup) {
Add(new cSkinMenuItem(skin.c_str(), *cString::sprintf("%s %s\t(%s)", tr("Skin"), skin.c_str(), tr("has no setup")), itNoSkinSetup));
} else {
Add(new cSkinMenuItem(skin.c_str(), *cString::sprintf("%s %s", tr("Skin"), skin.c_str()), itSkinSetup));
}
}
}
void cSkinDesignerSetup::InstallSkins(void) {
#ifndef DO_NOT_USE_SKININSTALLER
Add(InfoItem(tr("Install new skins")));
config.InitSkinRepoIterator();
cSkinRepo *repo = NULL;
while (repo = config.GetNextSkinRepo()) {
if (config.SkinInstalled(repo->Name()))
continue;
Add(new cSkinMenuItem(repo->Name(), *cString::sprintf("%s %s", tr("Preview Skin"), repo->Name().c_str()), itSkinRepo));
}
#endif
}
// --- cSkinMenuItem -----------------------------------------------------------
cSkinMenuItem::cSkinMenuItem(string skinName, string displayText, eItemType type) : cOsdItem(displayText.c_str()) {
this->skinName = skinName;
this->type = type;
}
// --- cSkinSetupSubMenu -----------------------------------------------------------
cSkinSetupSubMenu::cSkinSetupSubMenu(string name, string displayText) : cOsdItem(displayText.c_str()) {
this->name = name;
this->displayText = displayText;
}
// --- cSkindesignerSkinSetup -----------------------------------------------------------
cSkindesignerSkinSetup::cSkindesignerSkinSetup(string skin, string menu, string header) :
cOsdMenu(*cString::sprintf("%s: %s \"%s\" %s", trVDR("Setup"), tr("Skin"), skin.c_str(), header.c_str()), 30) {
SetMenuCategory(mcPluginSetup);
this->skin = skin;
this->menu = menu;
buttonRed = tr("Update");
buttonGreen = tr("Help");
buttonYellow = tr("Delete Skin");
showRed = false;
showYellow = false;
hadHelp = false;
Set();
}
cSkindesignerSkinSetup::~cSkindesignerSkinSetup() {
}
eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
state = cOsdMenu::ProcessKey(Key);
if (Key == kUp || Key == kDown) {
ShowButtons(Current());
}
if (state == osUnknown) {
switch (Key) {
case kOk: {
cOsdItem *current = Get(Current());
cSkinSetupSubMenu *subMenuItem = dynamic_cast<cSkinSetupSubMenu*>(current);
if (subMenuItem) {
state = AddSubMenu(new cSkindesignerSkinSetup(skin, subMenuItem->GetName(), subMenuItem->GetDisplayText()));
break;
} else {
return osBack;
}
}
case kRed: {
string versionNeeded = "";
bool versionOk = config.CheckVersion(skin, versionNeeded);
bool gitAvailable = StartUpdate(skin);
if (gitAvailable) {
if (!versionOk) {
cString error = cString::sprintf("%s %s %s %s %s",
tr("Skin Designer"),
tr("version"),
versionNeeded.c_str(),
tr("or higher"),
tr("needed"));
Skins.Message(mtError, *error);
return osContinue;
}
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
} else {
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
}
break;
}
// KEY YELLOW
case kYellow: {
if (config.SkinActive(skin)) {
Skins.Message(mtError, tr("Skin is running and can't be deleted"));
} else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) {
config.DeleteSkin(skin);
Skins.Message(mtStatus, tr("Skin deleted"));
cCondWait::SleepMs(1000);
return osEnd;
}
state = osContinue;
break;
}
case kGreen: {
string helpText = helpTexts[Current()];
if (helpText.size() == 0) {
state = osContinue;
break;
}
const char* ItemText = Get(Current())->Text();
string title = *cString::sprintf("%s - %s", buttonGreen.c_str(), ItemText);
state = AddSubMenu(new cMenuText(title.c_str(), helpText.c_str()));
break;
}
default:
break;
}
}
return state;
}
void cSkindesignerSkinSetup::Set(void) {
cSkinSetupMenu *setupMenu = config.GetSkinSetupMenu(skin, menu);
if (!setupMenu) {
return;
}
cSkinRepo *repo = config.GetSkinRepo(skin);
if (repo && repo->Type() == rtGit)
showRed = true;
if (repo)
showYellow = true;
setupMenu->InitParameterIterator();
cSkinSetupParameter *param = NULL;
while (param = setupMenu->GetNextParameter(false)) {
if (param->type == sptInt) {
Add(new cMenuEditIntItem(param->displayText.c_str(), ¶m->value, param->min, param->max));
} else if (param->type == sptBool) {
Add(new cMenuEditBoolItem(param->displayText.c_str(), ¶m->value));
} else if (param->type == sptString) {
Add(new cMenuEditStraItem(param->displayText.c_str(), ¶m->value, param->numOptions, param->optionsTranslated));
}
helpTexts.push_back(param->helpText);
}
setupMenu->InitSubmenuIterator();
cSkinSetupMenu *subMenu = NULL;
while (subMenu = setupMenu->GetNextSubMenu(false)) {
Add(new cSkinSetupSubMenu(subMenu->GetName(), subMenu->GetDisplayText()));
helpTexts.push_back("");
}
ShowButtons(0, true);
}
void cSkindesignerSkinSetup::ShowButtons(int current, bool force) {
bool showGreen = helpTexts[current].size() > 0 ? true : false;
bool changed = false;
if ((hadHelp && !showGreen) || (!hadHelp && showGreen))
changed = true;
hadHelp = showGreen;
if (changed || force)
SetHelp(showRed ? buttonRed.c_str() : "", showGreen ? buttonGreen.c_str() : "", showYellow ? buttonYellow.c_str() : "", NULL);
}
// --- cSkindesignerSkinPreview -----------------------------------------------------------
cSkindesignerSkinPreview::cSkindesignerSkinPreview(string skin, skindesignerapi::cPluginStructure *plugStruct) :
cSkindesignerOsdMenu(plugStruct, *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skin.c_str())) {
currentSkin = skin;
FirstCallCleared();
Set();
}
cSkindesignerSkinPreview::~cSkindesignerSkinPreview() {
}
eOSState cSkindesignerSkinPreview::ProcessKey(eKeys Key) {
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
state = cOsdMenu::ProcessKey(Key);
switch (Key) {
case kOk:
case kBack:
state = osBack;
break;
case kLeft: {
TextKeyLeft();
state = osContinue;
break;
} case kRight: {
TextKeyRight();
state = osContinue;
break;
} case kUp: {
TextKeyUp();
state = osContinue;
break;
} case kDown: {
TextKeyDown();
state = osContinue;
break;
} case kRed: {
string versionNeeded = "";
bool versionOk = config.CheckVersion(currentSkin, versionNeeded);
if (!versionOk) {
cString error = cString::sprintf("%s %s %s %s %s",
tr("Skin Designer"),
tr("version"),
versionNeeded.c_str(),
tr("or higher"),
tr("needed"));
Skins.Message(mtError, *error);
} else {
StartInstallation(currentSkin);
}
state = osContinue;
break;
} default:
break;
}
return state;
}
void cSkindesignerSkinPreview::Display(void) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
skindesignerapi::cSkindesignerOsdMenu::Display();
}
void cSkindesignerSkinPreview::Set(void) {
SetPluginMenu(0, skindesignerapi::mtText);
Clear();
skindesignerapi::cTokenContainer *tk = GetTokenContainer(0);
SetTokenContainer(tk);
ClearTokens();
cSkinRepo *skinRepo = config.GetSkinRepo(currentSkin);
if (!skinRepo) {
esyslog("skindesigner: no valid skin repository found for skin %s", currentSkin.c_str());
return;
}
int fontsIndex = GetLoopIndex("fonts");
int pluginIndex = GetLoopIndex("plugins");
int screenshotIndex = GetLoopIndex("screenshots");
vector<string> *specialFonts = skinRepo->SpecialFonts();
vector<string> *supportedPlugins = skinRepo->SupportedPlugins();
vector< pair < string, string > > *screenshots = skinRepo->Screenshots();
vector<int> loopInfo;
loopInfo.push_back((int)specialFonts->size());
loopInfo.push_back((int)supportedPlugins->size());
loopInfo.push_back((int)screenshots->size());
SetLoop(loopInfo);
AddStringToken((int)eDmSkinPreviewST::menuheader, *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str()));
AddStringToken((int)eDmSkinPreviewST::skinname, currentSkin.c_str());
AddStringToken((int)eDmSkinPreviewST::author, skinRepo->Author().c_str());
stringstream plainText;
plainText << *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str()) << "\n\n";
plainText << tr("Author") << ": " << skinRepo->Author() << "\n";
plainText << tr("Used Fonts") << ": \n";
int i = 0;
for (vector<string>::iterator it = specialFonts->begin(); it != specialFonts->end(); it++) {
AddLoopToken(fontsIndex, i, (int)eDmSkinPreviewFontsLT::name, (*it).c_str());
AddLoopToken(fontsIndex, i, (int)eDmSkinPreviewFontsLT::installed, CheckFontInstalled(*it));
plainText << *it << "\n";
i++;
}
plainText << tr("Supported Plugins") << ": \n";
i = 0;
for (vector<string>::iterator it = supportedPlugins->begin(); it != supportedPlugins->end(); it++) {
AddLoopToken(pluginIndex, i, (int)eDmSkinPreviewPluginsLT::name, (*it).c_str());
plainText << *it << "\n";
i++;
}
SetText(plainText.str().c_str());
i = 0;
for (vector< pair < string, string > >::iterator it = screenshots->begin(); it != screenshots->end(); it++) {
string url = it->second;
string imgType = ".jpg";
if (url.find(".png") != string::npos)
imgType = ".png";
cString tempName = cString::sprintf("/tmp/screenshot_%s_%d%s", currentSkin.c_str(), i, imgType.c_str());
dsyslog("skindesigner: download screenshot name %s url %s", *tempName, url.c_str());
CurlGetUrlFile(url.c_str(), *tempName);
AddLoopToken(screenshotIndex, i, (int)eDmSkinPreviewScreenshotsLT::desc, (it->first).c_str());
AddLoopToken(screenshotIndex, i, (int)eDmSkinPreviewScreenshotsLT::path, *tempName);
i++;
}
}
void cSkindesignerSkinPreview::DefineTokens(skindesignerapi::cTokenContainer *tk) {
tk->DefineStringToken("{menuheader}", (int)eDmSkinPreviewST::menuheader);
tk->DefineStringToken("{skinname}", (int)eDmSkinPreviewST::skinname);
tk->DefineStringToken("{author}", (int)eDmSkinPreviewST::author);
tk->DefineLoopToken("{fonts[name]}", (int)eDmSkinPreviewFontsLT::name);
tk->DefineLoopToken("{fonts[installed]}", (int)eDmSkinPreviewFontsLT::installed);
tk->DefineLoopToken("{plugins[name]}", (int)eDmSkinPreviewPluginsLT::name);
tk->DefineLoopToken("{screenshots[desc]}", (int)eDmSkinPreviewScreenshotsLT::desc);
tk->DefineLoopToken("{screenshots[path]}", (int)eDmSkinPreviewScreenshotsLT::path);
}
const char *cSkindesignerSkinPreview::CheckFontInstalled(string fontName) {
if (fontManager->FontInstalled(fontName))
return "1";
return "0";
}
|