changed skin installation that VDR main loop is not blocked

This commit is contained in:
louis 2015-06-04 10:57:25 +02:00
parent d2947bfcfd
commit 664b71daee
7 changed files with 247 additions and 143 deletions

View File

@ -354,3 +354,7 @@ Version 0.5.0
- adapted README
Version 0.5.1
- changed skin installation that VDR main loop is not blocked
- use shallow clone when cloning git

View File

@ -195,6 +195,7 @@ bool cSDDisplayMenu::SetItemPlugin(map<string,string> *stringTokens, map<string,
void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) {
if (!doOutput)
return;
//esyslog("skindesigner: %s %d - %s", Current ? "----->" : "", Index, Text);
cDisplayMenuListView *list = rootView->GetListView();
if (!list) {
return;

View File

@ -32,7 +32,7 @@ void cSkinRepo::Install(string path, string themesPath) {
this->themesPath = themesPath;
if (repoType == rtGit) {
command = *cString::sprintf("git clone --progress %s %s", url.c_str(), skinPath.c_str());
command = *cString::sprintf("git clone --depth=1 --progress %s %s", url.c_str(), skinPath.c_str());
tempfile = *cString::sprintf("gitclone_%s_%ld.out", name.c_str(), time(0));
dsyslog("skindesigner: installing skin from Git, command: %s, logfile: %s", command.c_str(), tempfile.c_str());

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.0.1\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-05-29 18:13+0200\n"
"POT-Creation-Date: 2015-06-04 10:40+0200\n"
"PO-Revision-Date: 2014-09-27 11:02+0200\n"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n"
@ -15,6 +15,30 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Skin successfully installed"
msgstr "Skin installiert"
msgid "Skin NOT successfully installed"
msgstr "Skin NICHT installiert"
msgid "Timeout"
msgstr ""
msgid "Installing Skin"
msgstr ""
msgid "sec"
msgstr ""
msgid "Skin successfully updated"
msgstr "Skin erfolgreich aktualisiert"
msgid "Skin already up to date"
msgstr "Skin ist auf aktuellem Stand"
msgid "Updating Skin from Git"
msgstr ""
msgid "after one another"
msgstr "eines nach dem anderen"
@ -30,27 +54,9 @@ msgstr "Installiere Skin"
msgid "Update from Git"
msgstr "Aus Git aktualisieren"
msgid "Installing Skin..."
msgstr "Installiere Skin..."
msgid "Skin successfully installed"
msgstr "Skin installiert"
msgid "Skin NOT successfully installed"
msgstr "Skin NICHT installiert"
msgid "No Git Repsoitory available"
msgstr "Kein Git Repository verfügbar"
msgid "Updating Skin from Git..."
msgstr "Aktualisiere Skin aus Git..."
msgid "Skin successfully updated"
msgstr "Skin erfolgreich aktualisiert"
msgid "Skin already up to date"
msgstr "Skin ist auf aktuellem Stand"
msgid "Plugin Setup"
msgstr ""
@ -137,3 +143,9 @@ msgstr "Unterstützte Plugins"
msgid "Skin Designer"
msgstr "Skin Designer"
#~ msgid "Updating Skin from Git..."
#~ msgstr "Aktualisiere Skin aus Git..."
#~ msgid "Installing Skin..."
#~ msgstr "Installiere Skin..."

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.2.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-05-29 18:13+0200\n"
"POT-Creation-Date: 2015-06-04 10:40+0200\n"
"PO-Revision-Date: 2015-01-25 01:25+0200\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish\n"
@ -15,6 +15,30 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Skin successfully installed"
msgstr ""
msgid "Skin NOT successfully installed"
msgstr ""
msgid "Timeout"
msgstr ""
msgid "Installing Skin"
msgstr ""
msgid "sec"
msgstr ""
msgid "Skin successfully updated"
msgstr ""
msgid "Skin already up to date"
msgstr ""
msgid "Updating Skin from Git"
msgstr ""
msgid "after one another"
msgstr "yksi kerrallaan"
@ -30,27 +54,9 @@ msgstr ""
msgid "Update from Git"
msgstr ""
msgid "Installing Skin..."
msgstr ""
msgid "Skin successfully installed"
msgstr ""
msgid "Skin NOT successfully installed"
msgstr ""
msgid "No Git Repsoitory available"
msgstr ""
msgid "Updating Skin from Git..."
msgstr ""
msgid "Skin successfully updated"
msgstr ""
msgid "Skin already up to date"
msgstr ""
msgid "Plugin Setup"
msgstr "Yleiset"

251
setup.c
View File

@ -1,6 +1,122 @@
#include "libcore/curlfuncs.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"));
} else {
Skins.Message(mtStatus, tr("Skin already up to date"));
}
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("Updating Skin from Git"), duration, tr("sec")));
lastInstallDuration = duration;
}
}
}
return osContinue;
}
// --- cSkinDesignerSetup -----------------------------------------------------------
cSkinDesignerSetup::cSkinDesignerSetup() {
numLogosPerSizeInitial = config.numLogosPerSizeInitial;
limitLogoCache = config.limitLogoCache;
@ -16,7 +132,7 @@ cSkinDesignerSetup::cSkinDesignerSetup() {
Setup();
}
cSkinDesignerSetup::~cSkinDesignerSetup() {
cSkinDesignerSetup::~cSkinDesignerSetup(void) {
config.setupCloseDoReload = true;
}
@ -35,11 +151,16 @@ void cSkinDesignerSetup::Setup(void) {
}
eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
bool hadSubMenu = HasSubMenu();
eOSState state = cMenuSetupPage::ProcessKey(Key);
state = cMenuSetupPage::ProcessKey(Key);
if (hadSubMenu && Key == kOk) {
Store();
}
if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed)) {
SetHelp(NULL, NULL, NULL, NULL);
cOsdItem *current = Get(Current());
@ -47,16 +168,16 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
if (!skinMenuItem)
return state;
eItemType type = skinMenuItem->Type();
string skinName = skinMenuItem->GetSkinName();
currentSkin = skinMenuItem->GetSkinName();
// KEY OK
if ((Key == kOk)) {
if (type == itSkinSetup) {
state = AddSubMenu(new cSkindesignerSkinSetup(skinName, ""));
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(skinName);
cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin);
Skins.Message(mtStatus, NULL);
state = AddSubMenu(prev);
}
@ -66,7 +187,7 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
if (type == itSkinRepo) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *repo = config.GetSkinRepo(skinName);
cSkinRepo *repo = config.GetSkinRepo(currentSkin);
if (repo && repo->Type() == rtGit) {
SetHelp(tr("Update from Git"), NULL, NULL, NULL);
}
@ -75,44 +196,14 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
// KEY RED
if (Key == kRed) {
if (type == itSkinRepo) {
Skins.Message(mtStatus, tr("Installing Skin..."));
cSkinRepo *skinRepo = config.GetSkinRepo(skinName);
if (!skinRepo) {
return state;
}
skinRepo->Install(*config.installerSkinPath, config.vdrThemesPath);
while (!skinRepo->InstallationFinished()) {
cCondWait::SleepMs(50);
}
bool ok = skinRepo->SuccessfullyInstalled();
if (ok) {
config.AddNewSkinRef(skinName);
Skins.Message(mtStatus, tr("Skin successfully installed"));
cCondWait::SleepMs(1000);
state = osEnd;
} else {
Skins.Message(mtStatus, tr("Skin NOT successfully installed"));
state = osContinue;
}
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Installing Skin")));
StartInstallation(currentSkin);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *skinRepo = config.GetSkinRepo(skinName);
if (!skinRepo || skinRepo->Type() != rtGit) {
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
return state;
}
Skins.Message(mtStatus, tr("Updating Skin from Git..."));
skinRepo->Update(*config.installerSkinPath);
while (!skinRepo->InstallationFinished()) {
cCondWait::SleepMs(50);
}
bool ok = skinRepo->SuccessfullyUpdated();
if (ok) {
Skins.Message(mtStatus, tr("Skin successfully updated"));
cCondWait::SleepMs(1000);
state = osEnd;
bool gitAvailable = StartUpdate(currentSkin);
if (gitAvailable) {
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
} else {
Skins.Message(mtStatus, tr("Skin already up to date"));
state = osContinue;
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
}
}
}
@ -261,7 +352,10 @@ cSkindesignerSkinSetup::~cSkindesignerSkinSetup() {
}
eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
eOSState state = cOsdMenu::ProcessKey(Key);
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kOk: {
@ -275,24 +369,11 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
}
}
case kRed: {
cSkinRepo *skinRepo = config.GetSkinRepo(skin);
if (!skinRepo) {
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
return state;
}
Skins.Message(mtStatus, tr("Updating Skin from Git..."));
skinRepo->Update(*config.installerSkinPath);
while (!skinRepo->InstallationFinished()) {
cCondWait::SleepMs(50);
}
bool ok = skinRepo->SuccessfullyUpdated();
if (ok) {
Skins.Message(mtStatus, tr("Skin successfully updated"));
cCondWait::SleepMs(1000);
state = osEnd;
bool gitAvailable = StartUpdate(skin);
if (gitAvailable) {
Skins.Message(mtStatus, *cString::sprintf("%s ...", tr("Updating Skin from Git")));
} else {
Skins.Message(mtStatus, tr("Skin already up to date"));
state = osContinue;
Skins.Message(mtStatus, tr("No Git Repsoitory available"));
}
}
default:
@ -334,7 +415,7 @@ void cSkindesignerSkinSetup::Set(void) {
cSkindesignerSkinPreview::cSkindesignerSkinPreview(string skinName) :
cSkindesignerOsdMenu(*cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skinName.c_str())) {
this->skinName = skinName;
currentSkin = skinName;
SetPluginName("setup");
FirstCallCleared();
Set();
@ -344,7 +425,10 @@ cSkindesignerSkinPreview::~cSkindesignerSkinPreview() {
}
eOSState cSkindesignerSkinPreview::ProcessKey(eKeys Key) {
eOSState state = cOsdMenu::ProcessKey(Key);
eOSState state = ProcessInstallationStatus();
if (state == osEnd)
return osEnd;
state = cOsdMenu::ProcessKey(Key);
switch (Key) {
case kOk:
case kBack:
@ -367,14 +451,8 @@ eOSState cSkindesignerSkinPreview::ProcessKey(eKeys Key) {
state = osContinue;
break;
} case kRed: {
Skins.Message(mtStatus, tr("Installing Skin..."));
bool ok = InstallSkin();
if (ok)
Skins.Message(mtStatus, tr("Skin successfully installed"));
else
Skins.Message(mtStatus, tr("Skin NOT successfully installed"));
cCondWait::SleepMs(1000);
state = osEnd;
StartInstallation(currentSkin);
state = osContinue;
break;
} default:
break;
@ -384,7 +462,7 @@ eOSState cSkindesignerSkinPreview::ProcessKey(eKeys Key) {
void cSkindesignerSkinPreview::Display(void) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
skindesignerapi::cSkindesignerOsdMenu::Display();
skindesignerapi::cSkindesignerOsdMenu::Display();
}
void cSkindesignerSkinPreview::Set(void) {
@ -392,18 +470,18 @@ void cSkindesignerSkinPreview::Set(void) {
ClearTokens();
Clear();
cSkinRepo *skinRepo = config.GetSkinRepo(skinName);
cSkinRepo *skinRepo = config.GetSkinRepo(currentSkin);
if (!skinRepo) {
esyslog("skindesigner: no valid skin repository found for skin %s", skinName.c_str());
esyslog("skindesigner: no valid skin repository found for skin %s", currentSkin.c_str());
return;
}
AddStringToken("menuheader", *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skinName.c_str()));
AddStringToken("skinname", skinName);
AddStringToken("menuheader", *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str()));
AddStringToken("skinname", currentSkin);
AddStringToken("author", skinRepo->Author());
stringstream plainText;
plainText << *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skinName.c_str()) << "\n\n";
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";
@ -435,7 +513,7 @@ void cSkindesignerSkinPreview::Set(void) {
if (url.find(".png") != string::npos)
imgType = ".png";
stringstream tempName;
tempName << "/tmp/screenshot_" << skinName << "_" << i++ << imgType;
tempName << "/tmp/screenshot_" << currentSkin << "_" << i++ << imgType;
dsyslog("skindesigner: download screenshot name %s url %s", tempName.str().c_str(), url.c_str());
CurlGetUrlFile(url.c_str(), tempName.str().c_str());
map<string,string> img;
@ -445,23 +523,6 @@ void cSkindesignerSkinPreview::Set(void) {
}
}
bool cSkindesignerSkinPreview::InstallSkin(void) {
cSkinRepo *skinRepo = config.GetSkinRepo(skinName);
if (!skinRepo) {
esyslog("skindesigner: no valid skin repository found for skin %s", skinName.c_str());
return false;
}
skinRepo->Install(*config.installerSkinPath, config.vdrThemesPath);
while (!skinRepo->InstallationFinished()) {
cCondWait::SleepMs(50);
}
bool ok = skinRepo->SuccessfullyInstalled();
if (ok) {
config.AddNewSkinRef(skinName);
}
return ok;
}
string cSkindesignerSkinPreview::CheckFontInstalled(string fontName) {
if (fontManager->FontInstalled(fontName))
return "1";

38
setup.h
View File

@ -10,9 +10,33 @@ enum eItemType {
itSkinRepo
};
// --- cSkinDesignerSetup -----------------------------------------------------------
// --- cInstallManager -----------------------------------------------------------
class cInstallManager {
private:
uint64_t installationStart;
int lastInstallDuration;
int timeout;
bool installing;
bool updating;
cSkinRepo *runningInst;
protected:
string currentSkin;
bool StartInstallation(string skin);
bool StartUpdate(string skin);
bool Installing(void) { return installing; };
bool Updating(void) { return updating; };
bool Finished(void);
bool SuccessfullyInstalled(void);
bool SuccessfullyUpdated(void);
int Duration(void);
eOSState ProcessInstallationStatus(void);
public:
cInstallManager(void);
virtual ~cInstallManager(void);
};
class cSkinDesignerSetup : public cMenuSetupPage {
// --- cSkinDesignerSetup -----------------------------------------------------------
class cSkinDesignerSetup : public cMenuSetupPage, cInstallManager {
private:
int numLogosPerSizeInitial;
int limitLogoCache;
@ -24,7 +48,6 @@ private:
int blockFlush;
int framesPerSecond;
const char *menuDisplayStyle[2];
void Setup(void);
virtual void Store(void);
virtual eOSState ProcessKey(eKeys Key);
@ -35,7 +58,7 @@ private:
void InstallSkins(void);
public:
cSkinDesignerSetup(void);
virtual ~cSkinDesignerSetup();
virtual ~cSkinDesignerSetup(void);
};
// --- cSkinMenuItem -----------------------------------------------------------
@ -64,7 +87,7 @@ public:
// --- cSkindesignerSkinSetup -----------------------------------------------------------
class cSkindesignerSkinSetup : public cOsdMenu {
class cSkindesignerSkinSetup : public cOsdMenu, cInstallManager {
private:
string skin;
string name;
@ -78,13 +101,10 @@ public:
// --- cSkindesignerSkinPreview -----------------------------------------------------------
class cSkindesignerSkinPreview : public skindesignerapi::cSkindesignerOsdMenu {
private:
string skinName;
class cSkindesignerSkinPreview : public skindesignerapi::cSkindesignerOsdMenu, cInstallManager {
protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
bool InstallSkin(void);
string CheckFontInstalled(string fontName);
public:
cSkindesignerSkinPreview(string skin);