summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-06-04 16:29:25 +0200
committerlouis <louis.braun@gmx.de>2015-06-04 16:29:25 +0200
commit872320b921bbfd735e980b3960ccc0a74f69fcf6 (patch)
treea399e9ab52ece50bc32455dd57e4ce97a2c824d9
parentecf8c75323281816ddc282437dcaa8a216e70ae4 (diff)
downloadvdr-plugin-skindesigner-872320b921bbfd735e980b3960ccc0a74f69fcf6.tar.gz
vdr-plugin-skindesigner-872320b921bbfd735e980b3960ccc0a74f69fcf6.tar.bz2
implemented possibility to delete skins
-rw-r--r--HISTORY1
-rw-r--r--config.c58
-rw-r--r--config.h2
-rw-r--r--po/de_DE.po15
-rw-r--r--po/fi_FI.po14
-rw-r--r--setup.c48
6 files changed, 128 insertions, 10 deletions
diff --git a/HISTORY b/HISTORY
index 05f3d5d..38e3cc0 100644
--- a/HISTORY
+++ b/HISTORY
@@ -357,4 +357,5 @@ Version 0.5.1
- changed skin installation that VDR main loop is not blocked
- use shallow clone when cloning git
+- implemented possibility to delete skins
diff --git a/config.c b/config.c
index 803c390..8521df0 100644
--- a/config.c
+++ b/config.c
@@ -177,6 +177,64 @@ void cDesignerConfig::AddNewSkinRef(string skin) {
(hit->second)->TranslateSetup();
}
+bool cDesignerConfig::SkinActive(string skin) {
+ cSkin *activeSkin = Skins.Current();
+ if (activeSkin && !skin.compare(activeSkin->Name()))
+ return true;
+ return false;
+}
+
+
+void cDesignerConfig::DeleteSkin(string skin) {
+ dsyslog("skindesigner: deleting skin %s", skin.c_str());
+ cSkin *deleteSkin = NULL;
+ bool found = false;
+ for (deleteSkin = Skins.First(); deleteSkin; deleteSkin = Skins.Next(deleteSkin)) {
+ if (!skin.compare(deleteSkin->Name())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found || !deleteSkin) {
+ esyslog("skindesigner: skin %s to delete not found", skin.c_str());
+ return;
+ }
+ vector<cSkinDesigner*>::iterator delIt;
+ for (delIt = skinRefs.begin(); delIt != skinRefs.end(); delIt++) {
+ if (*delIt == deleteSkin)
+ break;
+ }
+ if (delIt != skinRefs.end())
+ skinRefs.erase(delIt);
+
+ vector<string>::iterator delIt2;
+ for (delIt2 = installerSkins.begin(); delIt2 != installerSkins.end(); delIt2++) {
+ if (!skin.compare(*delIt2))
+ break;
+ }
+ if (delIt2 != installerSkins.end())
+ installerSkins.erase(delIt2);
+
+ vector<string>::iterator delIt3;
+ for (delIt3 = skins.begin(); delIt3 != skins.end(); delIt3++) {
+ if (!skin.compare(*delIt3))
+ break;
+ }
+ if (delIt3 != skins.end())
+ skins.erase(delIt3);
+
+ Skins.Del(deleteSkin);
+
+ stringstream deletePath;
+ deletePath << *installerSkinPath << skin;
+ string delPath = deletePath.str();
+ if (FolderExists(delPath)) {
+ dsyslog("skindesigner: deleting skin %s", delPath.c_str());
+ cString command = cString::sprintf("rm -rf %s", delPath.c_str());
+ system(*command);
+ }
+}
+
cSkinDesigner* cDesignerConfig::GetNextSkinRef(void) {
if (skinRefsIterator == skinRefs.end()) {
return NULL;
diff --git a/config.h b/config.h
index f4bebfc..9b6d884 100644
--- a/config.h
+++ b/config.h
@@ -65,6 +65,8 @@ public:
cString GetSkinPath(string skin);
void AddSkin(cSkinDesigner *skin) { skinRefs.push_back(skin); };
void AddNewSkinRef(string skin);
+ bool SkinActive(string skin);
+ void DeleteSkin(string skin);
void InitSkinRefsIterator(void) { skinRefsIterator = skinRefs.begin(); };
cSkinDesigner *GetNextSkinRef(void);
void ClearSkinSetups(void);
diff --git a/po/de_DE.po b/po/de_DE.po
index f227fb4..a43a33a 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -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-06-04 10:40+0200\n"
+"POT-Creation-Date: 2015-06-04 16:05+0200\n"
"PO-Revision-Date: 2014-09-27 11:02+0200\n"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n"
@@ -54,9 +54,21 @@ msgstr "Installiere Skin"
msgid "Update from Git"
msgstr "Aus Git aktualisieren"
+msgid "Delete Skin"
+msgstr "Skin löschen"
+
msgid "No Git Repsoitory available"
msgstr "Kein Git Repository verfügbar"
+msgid "Skin is running and can't be deleted"
+msgstr "Skin ist aktiv und kann nicht gelöscht werden"
+
+msgid "Really delete skin"
+msgstr "Skin wirklich löschen"
+
+msgid "Skin deleted"
+msgstr "Skin gelöscht"
+
msgid "Plugin Setup"
msgstr ""
@@ -143,4 +155,3 @@ msgstr "Unterstützte Plugins"
msgid "Skin Designer"
msgstr "Skin Designer"
-
diff --git a/po/fi_FI.po b/po/fi_FI.po
index 2db4d70..604b7c4 100644
--- a/po/fi_FI.po
+++ b/po/fi_FI.po
@@ -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-06-04 10:40+0200\n"
+"POT-Creation-Date: 2015-06-04 16:05+0200\n"
"PO-Revision-Date: 2015-01-25 01:25+0200\n"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish\n"
@@ -54,9 +54,21 @@ msgstr ""
msgid "Update from Git"
msgstr ""
+msgid "Delete Skin"
+msgstr ""
+
msgid "No Git Repsoitory available"
msgstr ""
+msgid "Skin is running and can't be deleted"
+msgstr ""
+
+msgid "Really delete skin"
+msgstr ""
+
+msgid "Skin deleted"
+msgstr ""
+
msgid "Plugin Setup"
msgstr "Yleiset"
diff --git a/setup.c b/setup.c
index bd53a06..f14b378 100644
--- a/setup.c
+++ b/setup.c
@@ -1,3 +1,4 @@
+#include <vdr/interface.h>
#include "libcore/curlfuncs.h"
#include "setup.h"
@@ -115,7 +116,6 @@ eOSState cInstallManager::ProcessInstallationStatus(void) {
return osContinue;
}
-
// --- cSkinDesignerSetup -----------------------------------------------------------
cSkinDesignerSetup::cSkinDesignerSetup() {
numLogosPerSizeInitial = config.numLogosPerSizeInitial;
@@ -161,7 +161,7 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
Store();
}
- if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed)) {
+ 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);
@@ -188,8 +188,11 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *repo = config.GetSkinRepo(currentSkin);
- if (repo && repo->Type() == rtGit) {
- SetHelp(tr("Update from Git"), NULL, NULL, NULL);
+ if (repo) {
+ if (repo->Type() == rtGit)
+ SetHelp(tr("Update from Git"), NULL, tr("Delete Skin"), NULL);
+ else
+ SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
}
}
}
@@ -207,6 +210,20 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
}
}
}
+ // 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;
}
@@ -366,7 +383,7 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
break;
} else {
return osBack;
- }
+ }
}
case kRed: {
bool gitAvailable = StartUpdate(skin);
@@ -375,6 +392,20 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
} 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;
}
default:
break;
@@ -390,8 +421,11 @@ void cSkindesignerSkinSetup::Set(void) {
}
cSkinRepo *repo = config.GetSkinRepo(skin);
- if (repo && repo->Type() == rtGit) {
- SetHelp(tr("Update from Git"), NULL, NULL, NULL);
+ if (repo) {
+ if (repo->Type() == rtGit)
+ SetHelp(tr("Update from Git"), NULL, tr("Delete Skin"), NULL);
+ else
+ SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
}
menu->InitParameterIterator();