vdr-plugin-skindesigner/libcore/skinrepo.h

99 lines
2.9 KiB
C
Raw Normal View History

2015-05-22 13:35:01 +02:00
#ifndef __SKINREPO_H
#define __SKINREPO_H
#include <string>
#include <vector>
#include <map>
#include <set>
#include "../libcore/libxmlwrapper.h"
2015-05-22 13:35:01 +02:00
#include <vdr/plugin.h>
using namespace std;
enum eRepoType {
rtUndefined,
rtGit,
rtZipUrl
};
2015-05-30 16:43:59 +02:00
enum eAction {
eaUndefined,
eaInstall,
eaUpdate
};
2015-05-22 13:35:01 +02:00
// --- cSkinRepo -------------------------------------------------------------
class cSkinRepo : public cThread {
private:
string name;
eRepoType repoType;
2015-05-30 16:43:59 +02:00
eAction action;
2015-05-22 13:35:01 +02:00
string url;
2015-05-30 16:43:59 +02:00
string author;
string minSDVersion;
2015-05-22 13:35:01 +02:00
vector<string> specialFonts;
vector<string> supportedPlugins;
vector< pair < string, string > > screenshots;
//helpers for execution
string command;
2015-05-30 16:43:59 +02:00
string command2;
2015-05-22 13:35:01 +02:00
string tempfile;
int result;
2015-05-30 16:43:59 +02:00
string skinPath;
string themesPath;
2015-05-22 13:35:01 +02:00
virtual void Action(void);
2015-05-30 16:43:59 +02:00
void CreateThemeFiles(void);
2015-05-22 13:35:01 +02:00
public:
cSkinRepo(void);
virtual ~cSkinRepo(void);
void SetName(string name) { this->name = name; };
void SetRepoType(eRepoType type) { this->repoType = type; };
void SetUrl(string url) { this->url = url; };
2015-05-30 16:43:59 +02:00
void SetAuthor(string author) { this->author = author; };
void SetMinSDVersion(string minSDVersion) { this->minSDVersion = minSDVersion; };
2015-05-22 13:35:01 +02:00
void SetSpecialFont(string font) { specialFonts.push_back(font); };
void SetSupportedPlugin(string plugin) { supportedPlugins.push_back(plugin); };
void SetScreenshot(string desc, string url) { screenshots.push_back(pair<string, string>(desc, url)); };
bool Valid(void);
2015-05-30 16:43:59 +02:00
eRepoType Type(void) { return repoType; };
2015-05-22 13:35:01 +02:00
string Name(void) { return name; };
2015-05-30 16:43:59 +02:00
string Author(void) { return author; };
string MinSDVersion(void) { return minSDVersion; };
2015-05-30 16:43:59 +02:00
string Url(void) { return url; };
vector<string> SpecialFonts(void) { return specialFonts; };
vector<string> SupportedPlugins(void) { return supportedPlugins; };
vector< pair < string, string > > Screenshots(void) { return screenshots; };
void Install(string path, string themesPath);
void Update(string path);
2015-05-22 13:35:01 +02:00
bool InstallationFinished(void) { return !(Running()); };
2015-05-30 16:43:59 +02:00
bool SuccessfullyInstalled(void) { if (result == 0) return true; return false; };
bool SuccessfullyUpdated(void);
2015-05-22 13:35:01 +02:00
void Debug(void);
};
// --- cSkinRepos -------------------------------------------------------------
class cSkinRepos : public cLibXMLWrapper {
2015-05-22 13:35:01 +02:00
private:
string skinRepoUrl;
string repoFolder;
2015-05-22 13:35:01 +02:00
vector<cSkinRepo*> repos;
2015-05-30 16:43:59 +02:00
vector<cSkinRepo*>::iterator repoIt;
bool ParseRepository(void);
void InitRepoGit(string path);
void PullRepoGit(string path);
2015-05-22 13:35:01 +02:00
public:
cSkinRepos(void);
virtual ~cSkinRepos(void);
void Init(string path);
2015-05-22 13:35:01 +02:00
void Read(string path);
2015-05-30 16:43:59 +02:00
int Count(void) { return repos.size(); };
2015-05-22 13:35:01 +02:00
cSkinRepo *GetRepo(string name);
2015-05-30 16:43:59 +02:00
void InitRepoIterator(void) { repoIt = repos.begin(); };
cSkinRepo *GetNextRepo(void);
2015-05-22 13:35:01 +02:00
void Debug(void);
};
#endif //__SKINREPO_H