2015-06-04 16:29:25 +02:00
|
|
|
#include <vdr/interface.h>
|
2016-01-26 18:32:38 +01:00
|
|
|
#include "extensions/curlfuncs.h"
|
2015-08-14 17:23:12 +02:00
|
|
|
#include <vdr/menu.h>
|
2014-09-27 09:25:14 +02:00
|
|
|
#include "setup.h"
|
|
|
|
|
2015-06-04 10:57:25 +02:00
|
|
|
// --- 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"));
|
2015-06-05 07:34:45 +02:00
|
|
|
cCondWait::SleepMs(1000);
|
|
|
|
return osEnd;
|
2015-06-04 10:57:25 +02:00
|
|
|
} else {
|
|
|
|
Skins.Message(mtStatus, tr("Skin already up to date"));
|
2015-06-05 07:34:45 +02:00
|
|
|
return osContinue;
|
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
} 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 -----------------------------------------------------------
|
2016-01-26 18:32:38 +01:00
|
|
|
cSkinDesignerSetup::cSkinDesignerSetup(skindesignerapi::cPluginStructure *skinPreviewStruct) {
|
|
|
|
this->skinPreviewStruct = skinPreviewStruct;
|
2015-01-20 09:29:16 +01:00
|
|
|
numLogosPerSizeInitial = config.numLogosPerSizeInitial;
|
2016-01-26 18:32:38 +01:00
|
|
|
cacheImagesInitial = config.cacheImagesInitial;
|
2015-01-20 09:29:16 +01:00
|
|
|
limitLogoCache = config.limitLogoCache;
|
|
|
|
numLogosMax = config.numLogosMax;
|
|
|
|
debugImageLoading = config.debugImageLoading;
|
|
|
|
rerunAmount = config.rerunAmount;
|
|
|
|
rerunDistance = config.rerunDistance;
|
|
|
|
rerunMaxChannel = config.rerunMaxChannel;
|
2016-01-26 18:32:38 +01:00
|
|
|
numCustomTokens = config.numCustomTokens;
|
2014-10-18 09:11:11 +02:00
|
|
|
menuDisplayStyle[0] = tr("after one another");
|
|
|
|
menuDisplayStyle[1] = tr("at one go");
|
2014-09-27 09:25:14 +02:00
|
|
|
Setup();
|
|
|
|
}
|
|
|
|
|
2015-06-04 10:57:25 +02:00
|
|
|
cSkinDesignerSetup::~cSkinDesignerSetup(void) {
|
2015-01-31 11:46:06 +01:00
|
|
|
config.setupCloseDoReload = true;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cSkinDesignerSetup::Setup(void) {
|
|
|
|
int current = Current();
|
|
|
|
Clear();
|
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
SkinSetup();
|
2015-05-30 16:43:59 +02:00
|
|
|
InstallSkins();
|
2015-01-20 09:29:16 +01:00
|
|
|
PluginSetup();
|
|
|
|
ImageCacheStatistics();
|
2014-10-18 09:11:11 +02:00
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
SetCurrent(Get(current));
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
|
2015-06-04 10:57:25 +02:00
|
|
|
eOSState state = ProcessInstallationStatus();
|
|
|
|
if (state == osEnd)
|
|
|
|
return osEnd;
|
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
bool hadSubMenu = HasSubMenu();
|
2015-06-04 10:57:25 +02:00
|
|
|
state = cMenuSetupPage::ProcessKey(Key);
|
2015-01-20 09:29:16 +01:00
|
|
|
if (hadSubMenu && Key == kOk) {
|
2015-01-20 14:26:28 +01:00
|
|
|
Store();
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
|
2015-06-04 16:29:25 +02:00
|
|
|
if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed || Key == kYellow)) {
|
2015-05-30 16:43:59 +02:00
|
|
|
SetHelp(NULL, NULL, NULL, NULL);
|
|
|
|
cOsdItem *current = Get(Current());
|
|
|
|
cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current);
|
|
|
|
if (!skinMenuItem)
|
|
|
|
return state;
|
|
|
|
eItemType type = skinMenuItem->Type();
|
2015-06-04 10:57:25 +02:00
|
|
|
currentSkin = skinMenuItem->GetSkinName();
|
2015-05-30 16:43:59 +02:00
|
|
|
// KEY OK
|
|
|
|
if ((Key == kOk)) {
|
|
|
|
if (type == itSkinSetup) {
|
2015-07-09 00:14:42 +02:00
|
|
|
state = AddSubMenu(new cSkindesignerSkinSetup(currentSkin, "", ""));
|
2015-05-30 16:43:59 +02:00
|
|
|
} else if (type == itNoSkinSetup) {
|
|
|
|
state = osContinue;
|
|
|
|
} else if (type == itSkinRepo) {
|
|
|
|
Skins.Message(mtStatus, tr("Downloading Skin Screenshots..."));
|
2016-01-26 18:32:38 +01:00
|
|
|
cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin, skinPreviewStruct);
|
2015-05-30 16:43:59 +02:00
|
|
|
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) {
|
2015-06-04 10:57:25 +02:00
|
|
|
cSkinRepo *repo = config.GetSkinRepo(currentSkin);
|
2015-06-04 16:29:25 +02:00
|
|
|
if (repo) {
|
|
|
|
if (repo->Type() == rtGit)
|
2015-06-13 15:10:34 +02:00
|
|
|
SetHelp(tr("Update"), NULL, tr("Delete Skin"), NULL);
|
2015-06-04 16:29:25 +02:00
|
|
|
else
|
|
|
|
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// KEY RED
|
|
|
|
if (Key == kRed) {
|
2015-07-17 17:37:16 +02:00
|
|
|
string versionNeeded = "";
|
|
|
|
bool versionOk = config.CheckVersion(currentSkin, versionNeeded);
|
2015-05-30 16:43:59 +02:00
|
|
|
if (type == itSkinRepo) {
|
2015-07-29 18:32:03 +02:00
|
|
|
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;
|
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Installing Skin")));
|
|
|
|
StartInstallation(currentSkin);
|
2015-05-30 16:43:59 +02:00
|
|
|
} else if (type == itSkinSetup || type == itNoSkinSetup) {
|
2015-06-04 10:57:25 +02:00
|
|
|
bool gitAvailable = StartUpdate(currentSkin);
|
|
|
|
if (gitAvailable) {
|
2015-07-29 18:32:03 +02:00
|
|
|
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;
|
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
|
2015-05-30 16:43:59 +02:00
|
|
|
} else {
|
2015-06-04 10:57:25 +02:00
|
|
|
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
|
|
|
}
|
2015-06-04 16:29:25 +02:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSkinDesignerSetup::Store(void) {
|
|
|
|
config.numLogosPerSizeInitial = numLogosPerSizeInitial;
|
2016-01-26 18:32:38 +01:00
|
|
|
config.cacheImagesInitial = cacheImagesInitial;
|
2015-01-20 09:29:16 +01:00
|
|
|
config.limitLogoCache = limitLogoCache;
|
|
|
|
config.numLogosMax = numLogosMax;
|
|
|
|
config.debugImageLoading = debugImageLoading;
|
|
|
|
config.rerunAmount = rerunAmount;
|
|
|
|
config.rerunDistance = rerunDistance;
|
|
|
|
config.rerunMaxChannel = rerunMaxChannel;
|
2016-01-26 18:32:38 +01:00
|
|
|
config.numCustomTokens = numCustomTokens;
|
2015-01-20 09:29:16 +01:00
|
|
|
|
|
|
|
config.InitSetupIterator();
|
|
|
|
cSkinSetup *skinSetup = NULL;
|
2015-01-31 11:46:06 +01:00
|
|
|
while (skinSetup = config.GetNextSkinSetup()) {
|
2015-01-20 09:29:16 +01:00
|
|
|
string skin = skinSetup->GetSkin();
|
|
|
|
skinSetup->InitParameterIterator();
|
|
|
|
cSkinSetupParameter *param = NULL;
|
2015-01-31 11:46:06 +01:00
|
|
|
while (param = skinSetup->GetNextParameter()) {
|
2015-01-20 14:26:28 +01:00
|
|
|
cString paramName = cString::sprintf("%s.%s", skin.c_str(), param->name.c_str());
|
|
|
|
SetupStore(*paramName, param->value);
|
|
|
|
config.UpdateSkinSetupParameter(*paramName, param->value);
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
config.UpdateGlobals();
|
|
|
|
|
|
|
|
SetupStore("DebugImageLoading", debugImageLoading);
|
2016-01-26 18:32:38 +01:00
|
|
|
SetupStore("CacheImagesInitial", cacheImagesInitial);
|
2015-01-20 09:29:16 +01:00
|
|
|
SetupStore("LimitChannelLogoCache", limitLogoCache);
|
|
|
|
SetupStore("NumberLogosInitially", numLogosPerSizeInitial);
|
|
|
|
SetupStore("NumberLogosMax", numLogosMax);
|
|
|
|
SetupStore("RerunAmount", rerunAmount);
|
|
|
|
SetupStore("RerunDistance", rerunDistance);
|
|
|
|
SetupStore("RerunMaxChannel", rerunMaxChannel);
|
2016-01-26 18:32:38 +01:00
|
|
|
SetupStore("NumCustomTokens", numCustomTokens);
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
2014-10-11 10:39:41 +02:00
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) {
|
|
|
|
cOsdItem *item;
|
|
|
|
item = new cOsdItem(cString::sprintf("---------------- %s ----------------", tr(label)));
|
|
|
|
item->SetSelectable(false);
|
|
|
|
return item;
|
|
|
|
}
|
2014-10-11 10:39:41 +02:00
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
void cSkinDesignerSetup::PluginSetup(void) {
|
2015-01-27 17:46:21 +01:00
|
|
|
Add(InfoItem(tr("Plugin Setup")));
|
2014-10-11 10:39:41 +02:00
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
Add(new cMenuEditIntItem(tr("Maximum number of custom tokens"), &numCustomTokens, 0, 100));
|
2014-09-27 09:25:14 +02:00
|
|
|
|
2015-01-27 17:46:21 +01:00
|
|
|
Add(InfoItem(tr("Reruns")));
|
2015-01-20 09:29:16 +01:00
|
|
|
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));
|
2015-01-27 17:46:21 +01:00
|
|
|
Add(new cMenuEditIntItem(tr("Limit Channel Numbers"), &rerunMaxChannel, 0, 1000, tr("no limit")));
|
2015-01-20 09:29:16 +01:00
|
|
|
|
2015-01-27 17:46:21 +01:00
|
|
|
Add(InfoItem(tr("Image Loading")));
|
2015-01-20 09:29:16 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &debugImageLoading));
|
2016-01-26 18:32:38 +01:00
|
|
|
Add(new cMenuEditBoolItem(tr("Cache icons, skinparts and logos at start"), &cacheImagesInitial));
|
2015-01-20 09:29:16 +01:00
|
|
|
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));
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
void cSkinDesignerSetup::ImageCacheStatistics(void) {
|
2014-10-04 10:10:04 +02:00
|
|
|
if (!imgCache) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-27 17:46:21 +01:00
|
|
|
Add(InfoItem(tr("Cache Statistics")));
|
2016-01-26 18:32:38 +01:00
|
|
|
float sizeIconCacheInt = 0;
|
|
|
|
float sizeIconCacheExt = 0;
|
2014-09-27 09:25:14 +02:00
|
|
|
int numIcons = 0;
|
2016-01-26 18:32:38 +01:00
|
|
|
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"));
|
2014-09-27 09:25:14 +02:00
|
|
|
Add(new cOsdItem(*iconCacheInfo));
|
|
|
|
cList<cOsdItem>::Last()->SetSelectable(false);
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
float sizeLogoCache = 0;
|
2014-09-27 09:25:14 +02:00
|
|
|
int numLogos = 0;
|
|
|
|
imgCache->GetLogoCacheSize(numLogos, sizeLogoCache);
|
2016-01-26 18:32:38 +01:00
|
|
|
cString logoCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s", tr("cached"), numLogos, tr("logos"), tr("size"), sizeLogoCache, tr("MB"), tr("int. memory"));
|
2014-09-27 09:25:14 +02:00
|
|
|
Add(new cOsdItem(*logoCacheInfo));
|
|
|
|
cList<cOsdItem>::Last()->SetSelectable(false);
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
float sizeSkinpartCacheInt = 0;
|
|
|
|
float sizeSkinpartCacheExt = 0;
|
2014-09-27 09:25:14 +02:00
|
|
|
int numSkinparts = 0;
|
2016-01-26 18:32:38 +01:00
|
|
|
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"));
|
2014-09-27 09:25:14 +02:00
|
|
|
Add(new cOsdItem(*skinpartCacheInfo));
|
|
|
|
cList<cOsdItem>::Last()->SetSelectable(false);
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
|
2015-05-30 16:43:59 +02:00
|
|
|
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) {
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cSkinMenuItem -----------------------------------------------------------
|
|
|
|
cSkinMenuItem::cSkinMenuItem(string skinName, string displayText, eItemType type) : cOsdItem(displayText.c_str()) {
|
|
|
|
this->skinName = skinName;
|
|
|
|
this->type = type;
|
|
|
|
}
|
2015-01-31 11:46:06 +01:00
|
|
|
|
2015-05-30 16:43:59 +02:00
|
|
|
// --- cSkinSetupSubMenu -----------------------------------------------------------
|
2015-01-31 11:46:06 +01:00
|
|
|
cSkinSetupSubMenu::cSkinSetupSubMenu(string name, string displayText) : cOsdItem(displayText.c_str()) {
|
|
|
|
this->name = name;
|
2015-07-09 00:14:42 +02:00
|
|
|
this->displayText = displayText;
|
2015-01-31 11:46:06 +01:00
|
|
|
}
|
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
// --- cSkindesignerSkinSetup -----------------------------------------------------------
|
|
|
|
|
2015-07-09 00:14:42 +02:00
|
|
|
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) {
|
2015-04-29 18:25:38 +02:00
|
|
|
SetMenuCategory(mcPluginSetup);
|
2015-01-20 09:29:16 +01:00
|
|
|
this->skin = skin;
|
2015-07-09 00:14:42 +02:00
|
|
|
this->menu = menu;
|
2015-08-14 17:23:12 +02:00
|
|
|
buttonRed = tr("Update");
|
|
|
|
buttonGreen = tr("Help");
|
|
|
|
buttonYellow = tr("Delete Skin");
|
|
|
|
showRed = false;
|
|
|
|
showYellow = false;
|
|
|
|
hadHelp = false;
|
2015-01-20 09:29:16 +01:00
|
|
|
Set();
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
cSkindesignerSkinSetup::~cSkindesignerSkinSetup() {
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
|
2015-06-04 10:57:25 +02:00
|
|
|
eOSState state = ProcessInstallationStatus();
|
|
|
|
if (state == osEnd)
|
|
|
|
return osEnd;
|
|
|
|
state = cOsdMenu::ProcessKey(Key);
|
2015-08-14 17:23:12 +02:00
|
|
|
if (Key == kUp || Key == kDown) {
|
|
|
|
ShowButtons(Current());
|
|
|
|
}
|
2015-01-20 09:29:16 +01:00
|
|
|
if (state == osUnknown) {
|
|
|
|
switch (Key) {
|
2015-01-31 11:46:06 +01:00
|
|
|
case kOk: {
|
|
|
|
cOsdItem *current = Get(Current());
|
|
|
|
cSkinSetupSubMenu *subMenuItem = dynamic_cast<cSkinSetupSubMenu*>(current);
|
|
|
|
if (subMenuItem) {
|
2015-07-09 00:14:42 +02:00
|
|
|
state = AddSubMenu(new cSkindesignerSkinSetup(skin, subMenuItem->GetName(), subMenuItem->GetDisplayText()));
|
2015-01-31 11:46:06 +01:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
return osBack;
|
2015-06-04 16:29:25 +02:00
|
|
|
}
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
case kRed: {
|
2015-07-17 17:37:16 +02:00
|
|
|
string versionNeeded = "";
|
|
|
|
bool versionOk = config.CheckVersion(skin, versionNeeded);
|
2015-06-04 10:57:25 +02:00
|
|
|
bool gitAvailable = StartUpdate(skin);
|
|
|
|
if (gitAvailable) {
|
2015-07-29 18:32:03 +02:00
|
|
|
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);
|
|
|
|
break;
|
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
|
2015-05-30 16:43:59 +02:00
|
|
|
} else {
|
2015-06-04 10:57:25 +02:00
|
|
|
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
|
2015-01-31 11:46:06 +01:00
|
|
|
}
|
2015-06-04 16:29:25 +02:00
|
|
|
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;
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
2015-08-14 17:23:12 +02:00
|
|
|
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;
|
|
|
|
}
|
2015-05-30 16:43:59 +02:00
|
|
|
default:
|
2015-01-20 09:29:16 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2015-01-20 09:29:16 +01:00
|
|
|
void cSkindesignerSkinSetup::Set(void) {
|
2015-07-09 00:14:42 +02:00
|
|
|
cSkinSetupMenu *setupMenu = config.GetSkinSetupMenu(skin, menu);
|
|
|
|
if (!setupMenu) {
|
2015-01-20 09:29:16 +01:00
|
|
|
return;
|
2015-01-31 11:46:06 +01:00
|
|
|
}
|
2015-05-30 16:43:59 +02:00
|
|
|
|
|
|
|
cSkinRepo *repo = config.GetSkinRepo(skin);
|
2015-08-14 17:23:12 +02:00
|
|
|
if (repo && repo->Type() == rtGit)
|
|
|
|
showRed = true;
|
|
|
|
if (repo)
|
|
|
|
showYellow = true;
|
|
|
|
|
2015-07-09 00:14:42 +02:00
|
|
|
setupMenu->InitParameterIterator();
|
2015-01-20 09:29:16 +01:00
|
|
|
cSkinSetupParameter *param = NULL;
|
2015-07-09 00:14:42 +02:00
|
|
|
while (param = setupMenu->GetNextParameter(false)) {
|
2015-01-20 09:29:16 +01:00
|
|
|
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));
|
2015-08-08 11:04:15 +02:00
|
|
|
} else if (param->type == sptString) {
|
|
|
|
Add(new cMenuEditStraItem(param->displayText.c_str(), ¶m->value, param->numOptions, param->optionsTranslated));
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
2015-08-14 17:23:12 +02:00
|
|
|
helpTexts.push_back(param->helpText);
|
2015-01-20 09:29:16 +01:00
|
|
|
}
|
|
|
|
|
2015-07-09 00:14:42 +02:00
|
|
|
setupMenu->InitSubmenuIterator();
|
2015-01-31 11:46:06 +01:00
|
|
|
cSkinSetupMenu *subMenu = NULL;
|
2015-07-09 00:14:42 +02:00
|
|
|
while (subMenu = setupMenu->GetNextSubMenu(false)) {
|
2015-01-31 11:46:06 +01:00
|
|
|
Add(new cSkinSetupSubMenu(subMenu->GetName(), subMenu->GetDisplayText()));
|
2015-08-14 17:23:12 +02:00
|
|
|
helpTexts.push_back("");
|
2015-01-31 11:46:06 +01:00
|
|
|
}
|
2015-08-14 17:23:12 +02:00
|
|
|
|
|
|
|
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);
|
2015-01-27 17:46:21 +01:00
|
|
|
}
|
2015-05-30 16:43:59 +02:00
|
|
|
|
|
|
|
// --- cSkindesignerSkinPreview -----------------------------------------------------------
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
cSkindesignerSkinPreview::cSkindesignerSkinPreview(string skin, skindesignerapi::cPluginStructure *plugStruct) :
|
|
|
|
cSkindesignerOsdMenu(plugStruct, *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skin.c_str())) {
|
|
|
|
currentSkin = skin;
|
2015-05-30 16:43:59 +02:00
|
|
|
FirstCallCleared();
|
|
|
|
Set();
|
|
|
|
}
|
|
|
|
|
|
|
|
cSkindesignerSkinPreview::~cSkindesignerSkinPreview() {
|
|
|
|
}
|
|
|
|
|
|
|
|
eOSState cSkindesignerSkinPreview::ProcessKey(eKeys Key) {
|
2015-06-04 10:57:25 +02:00
|
|
|
eOSState state = ProcessInstallationStatus();
|
|
|
|
if (state == osEnd)
|
|
|
|
return osEnd;
|
|
|
|
state = cOsdMenu::ProcessKey(Key);
|
2015-05-30 16:43:59 +02:00
|
|
|
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: {
|
2015-07-17 17:37:16 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-06-04 10:57:25 +02:00
|
|
|
state = osContinue;
|
2015-05-30 16:43:59 +02:00
|
|
|
break;
|
|
|
|
} default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cSkindesignerSkinPreview::Display(void) {
|
|
|
|
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
|
2015-06-04 10:57:25 +02:00
|
|
|
skindesignerapi::cSkindesignerOsdMenu::Display();
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cSkindesignerSkinPreview::Set(void) {
|
|
|
|
SetPluginMenu(0, skindesignerapi::mtText);
|
|
|
|
Clear();
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cTokenContainer *tk = GetTokenContainer(0);
|
|
|
|
SetTokenContainer(tk);
|
|
|
|
ClearTokens();
|
|
|
|
|
2015-06-04 10:57:25 +02:00
|
|
|
cSkinRepo *skinRepo = config.GetSkinRepo(currentSkin);
|
2015-05-30 16:43:59 +02:00
|
|
|
if (!skinRepo) {
|
2015-06-04 10:57:25 +02:00
|
|
|
esyslog("skindesigner: no valid skin repository found for skin %s", currentSkin.c_str());
|
2015-05-30 16:43:59 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
|
|
|
|
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());
|
2015-06-04 10:57:25 +02:00
|
|
|
|
2015-05-30 16:43:59 +02:00
|
|
|
stringstream plainText;
|
2015-06-04 10:57:25 +02:00
|
|
|
plainText << *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str()) << "\n\n";
|
2015-05-30 16:43:59 +02:00
|
|
|
plainText << tr("Author") << ": " << skinRepo->Author() << "\n";
|
|
|
|
plainText << tr("Used Fonts") << ": \n";
|
2016-01-26 18:32:38 +01:00
|
|
|
|
|
|
|
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));
|
2015-05-30 16:43:59 +02:00
|
|
|
plainText << *it << "\n";
|
2016-01-26 18:32:38 +01:00
|
|
|
i++;
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
plainText << tr("Supported Plugins") << ": \n";
|
2016-01-26 18:32:38 +01:00
|
|
|
i = 0;
|
|
|
|
for (vector<string>::iterator it = supportedPlugins->begin(); it != supportedPlugins->end(); it++) {
|
|
|
|
AddLoopToken(pluginIndex, i, (int)eDmSkinPreviewPluginsLT::name, (*it).c_str());
|
2015-05-30 16:43:59 +02:00
|
|
|
plainText << *it << "\n";
|
2016-01-26 18:32:38 +01:00
|
|
|
i++;
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetText(plainText.str().c_str());
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
i = 0;
|
|
|
|
for (vector< pair < string, string > >::iterator it = screenshots->begin(); it != screenshots->end(); it++) {
|
2015-05-30 16:43:59 +02:00
|
|
|
string url = it->second;
|
|
|
|
string imgType = ".jpg";
|
|
|
|
if (url.find(".png") != string::npos)
|
|
|
|
imgType = ".png";
|
2016-01-26 18:32:38 +01:00
|
|
|
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++;
|
2015-05-30 16:43:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
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) {
|
2015-05-30 16:43:59 +02:00
|
|
|
if (fontManager->FontInstalled(fontName))
|
|
|
|
return "1";
|
|
|
|
return "0";
|
|
|
|
}
|
2016-01-26 18:32:38 +01:00
|
|
|
|