2014-09-27 09:25:14 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "libcore/helpers.h"
|
|
|
|
#include "libcore/imageloader.h"
|
|
|
|
|
|
|
|
cDesignerConfig::cDesignerConfig() {
|
|
|
|
epgImagePathSet = false;
|
|
|
|
skinPathSet = false;
|
2014-10-03 15:54:23 +02:00
|
|
|
logoPathSet = false;
|
2014-09-27 09:25:14 +02:00
|
|
|
//Common
|
|
|
|
numLogosPerSizeInitial = 30;
|
|
|
|
limitLogoCache = 1;
|
|
|
|
numLogosMax = 200;
|
|
|
|
debugImageLoading = 0;
|
|
|
|
replaceDecPoint = false;
|
2014-10-11 10:39:41 +02:00
|
|
|
//settings for rerun display
|
|
|
|
rerunAmount = 10;
|
|
|
|
rerunDistance = 2;
|
|
|
|
rerunMaxChannel = 0;
|
2014-10-18 09:11:11 +02:00
|
|
|
//menu display style, display menu items
|
|
|
|
//one after each other or in one step
|
|
|
|
blockFlush = 1;
|
2014-10-18 10:28:38 +02:00
|
|
|
//remember current skin and theme, osd size and osd fonts
|
2014-10-18 10:05:32 +02:00
|
|
|
SetSkin();
|
|
|
|
SetOSDSize();
|
2014-10-18 10:28:38 +02:00
|
|
|
SetOSDFonts();
|
2014-11-22 12:19:13 +01:00
|
|
|
osdLanguage = Setup.OSDLanguage;
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cDesignerConfig::~cDesignerConfig() {
|
2015-01-19 09:23:15 +01:00
|
|
|
esyslog("skindesigner: config destruktor");
|
2014-09-27 09:25:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDesignerConfig::SetPathes(void) {
|
|
|
|
if (!skinPathSet)
|
|
|
|
skinPath = cString::sprintf("%s/skins/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
|
2014-10-03 15:54:23 +02:00
|
|
|
if (!logoPathSet)
|
|
|
|
logoPath = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
|
2014-09-27 09:25:14 +02:00
|
|
|
if (!epgImagePathSet)
|
|
|
|
epgImagePath = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N));
|
|
|
|
|
|
|
|
dsyslog("skindesigner: using Skin Directory %s", *skinPath);
|
2014-10-03 15:54:23 +02:00
|
|
|
dsyslog("skindesigner: using common ChannelLogo Directory %s", *logoPath);
|
2014-09-27 09:25:14 +02:00
|
|
|
dsyslog("skindesigner: using EPG Images Directory %s", *epgImagePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDesignerConfig::SetSkinPath(cString path) {
|
|
|
|
skinPath = CheckSlashAtEnd(*path);
|
|
|
|
skinPathSet = true;
|
|
|
|
}
|
|
|
|
|
2014-10-03 15:54:23 +02:00
|
|
|
void cDesignerConfig::SetLogoPath(cString path) {
|
|
|
|
logoPath = CheckSlashAtEnd(*path);
|
|
|
|
logoPathSet = true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDesignerConfig::SetEpgImagePath(cString path) {
|
|
|
|
epgImagePath = CheckSlashAtEnd(*path);
|
|
|
|
epgImagePathSet = true;
|
|
|
|
}
|
|
|
|
|
2014-10-03 15:54:23 +02:00
|
|
|
void cDesignerConfig::ReadSkins(void) {
|
|
|
|
DIR *folder = NULL;
|
|
|
|
struct dirent *dirEntry;
|
|
|
|
folder = opendir(skinPath);
|
|
|
|
if (!folder) {
|
|
|
|
esyslog("skindesigner: no skins found in %s", *skinPath);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (dirEntry = readdir(folder)) {
|
|
|
|
string dirEntryName = dirEntry->d_name;
|
|
|
|
int dirEntryType = dirEntry->d_type;
|
|
|
|
if (!dirEntryName.compare(".") || !dirEntryName.compare("..") || dirEntryType != DT_DIR)
|
|
|
|
continue;
|
|
|
|
skins.push_back(dirEntryName);
|
|
|
|
}
|
2014-12-06 10:11:02 +01:00
|
|
|
dsyslog("skindesigner %ld skins found in %s", skins.size(), *skinPath);
|
2014-10-03 15:54:23 +02:00
|
|
|
}
|
|
|
|
|
2015-01-19 09:23:15 +01:00
|
|
|
void cDesignerConfig::ReadSkinSetup(string skin) {
|
|
|
|
cSkinSetup *skinSetup = new cSkinSetup(skin);
|
|
|
|
skinSetup->ReadFromXML();
|
|
|
|
skinSetup->Debug();
|
|
|
|
}
|
|
|
|
|
2014-10-03 15:54:23 +02:00
|
|
|
bool cDesignerConfig::GetSkin(string &skin) {
|
|
|
|
if (skinIterator == skins.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
skin = *skinIterator;
|
|
|
|
skinIterator++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
void cDesignerConfig::CheckDecimalPoint(void) {
|
|
|
|
struct lconv *pLocInfo;
|
|
|
|
pLocInfo = localeconv();
|
|
|
|
string decimalPoint = pLocInfo->decimal_point;
|
|
|
|
if (decimalPoint.compare(".")) {
|
|
|
|
dsyslog("skindesigner: using decimal point %s", decimalPoint.c_str());
|
|
|
|
replaceDecPoint = true;
|
|
|
|
decPoint = decimalPoint[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-18 10:05:32 +02:00
|
|
|
void cDesignerConfig::SetSkin(void) {
|
|
|
|
osdSkin = Setup.OSDSkin;
|
|
|
|
osdTheme = Setup.OSDTheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDesignerConfig::SkinChanged(void) {
|
|
|
|
bool changed = false;
|
|
|
|
if (osdSkin.compare(Setup.OSDSkin) != 0) {
|
|
|
|
dsyslog("skindesigner: skin changed from %s to %s", osdSkin.c_str(), Setup.OSDSkin);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (osdTheme.compare(Setup.OSDTheme) != 0) {
|
|
|
|
dsyslog("skindesigner: theme changed from %s to %s", osdTheme.c_str(), Setup.OSDTheme);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (changed)
|
|
|
|
SetSkin();
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDesignerConfig::SetOSDSize(void) {
|
|
|
|
osdSize.SetWidth(cOsd::OsdWidth());
|
|
|
|
osdSize.SetHeight(cOsd::OsdHeight());
|
|
|
|
osdSize.SetX(cOsd::OsdLeft());
|
|
|
|
osdSize.SetY(cOsd::OsdTop());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDesignerConfig::OsdSizeChanged(void) {
|
|
|
|
if ((osdSize.Width() != cOsd::OsdWidth()) ||
|
|
|
|
(osdSize.Height() != cOsd::OsdHeight()) ||
|
|
|
|
(osdSize.X() != cOsd::OsdLeft()) ||
|
|
|
|
(osdSize.Y() != cOsd::OsdTop())) {
|
|
|
|
dsyslog("skindesigner: osd size changed");
|
|
|
|
dsyslog("skindesigner: old osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
|
|
|
|
SetOSDSize();
|
|
|
|
dsyslog("skindesigner: new osd size: top %d left %d size %d * %d", osdSize.X(), osdSize.Y(), osdSize.Width(), osdSize.Height());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-18 10:28:38 +02:00
|
|
|
void cDesignerConfig::SetOSDFonts(void) {
|
|
|
|
fontFix = Setup.FontFix;
|
|
|
|
fontOsd = Setup.FontOsd;
|
|
|
|
fontSml = Setup.FontSml;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDesignerConfig::OsdFontsChanged(void) {
|
|
|
|
bool changed = false;
|
|
|
|
if (fontFix.compare(Setup.FontFix) != 0) {
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (fontOsd.compare(Setup.FontOsd) != 0) {
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (fontSml.compare(Setup.FontSml) != 0) {
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (changed)
|
|
|
|
SetOSDFonts();
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2014-11-22 12:19:13 +01:00
|
|
|
bool cDesignerConfig::OsdLanguageChanged(void) {
|
|
|
|
if (osdLanguage.compare(Setup.OSDLanguage)) {
|
|
|
|
osdLanguage = Setup.OSDLanguage;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-26 11:09:09 +01:00
|
|
|
cString cDesignerConfig::GetSkinRessourcePath(void) {
|
|
|
|
return cString::sprintf("%s%s", *skinPath, osdSkin.c_str());
|
|
|
|
}
|
|
|
|
|
2014-11-15 09:47:22 +01:00
|
|
|
void cDesignerConfig::AddPlugin(string name, map < int, string > &menus) {
|
|
|
|
plugins.insert(pair< string, map < int, string > >(name, menus));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDesignerConfig::InitPluginIterator(void) {
|
|
|
|
plugIt = plugins.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
map <int,string> *cDesignerConfig::GetPluginTemplates(string &name) {
|
|
|
|
if (plugIt == plugins.end())
|
|
|
|
return NULL;
|
|
|
|
name = plugIt->first;
|
|
|
|
map <int,string> *templates = &plugIt->second;
|
|
|
|
plugIt++;
|
|
|
|
return templates;
|
|
|
|
}
|
|
|
|
|
2014-09-27 09:25:14 +02:00
|
|
|
cString cDesignerConfig::CheckSlashAtEnd(std::string path) {
|
|
|
|
try {
|
|
|
|
if (!(path.at(path.size()-1) == '/'))
|
|
|
|
return cString::sprintf("%s/", path.c_str());
|
|
|
|
} catch (...) {return path.c_str();}
|
|
|
|
return path.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDesignerConfig::SetupParse(const char *Name, const char *Value) {
|
|
|
|
if (!strcasecmp(Name, "DebugImageLoading")) debugImageLoading = atoi(Value);
|
|
|
|
else if (!strcasecmp(Name, "LimitChannelLogoCache")) limitLogoCache = atoi(Value);
|
|
|
|
else if (!strcasecmp(Name, "NumberLogosInitially")) numLogosPerSizeInitial = atoi(Value);
|
|
|
|
else if (!strcasecmp(Name, "NumberLogosMax")) numLogosMax = atoi(Value);
|
2014-10-11 10:39:41 +02:00
|
|
|
else if (!strcasecmp(Name, "RerunAmount")) rerunAmount = atoi(Value);
|
|
|
|
else if (!strcasecmp(Name, "RerunDistance")) rerunDistance = atoi(Value);
|
|
|
|
else if (!strcasecmp(Name, "RerunMaxChannel")) rerunMaxChannel = atoi(Value);
|
2014-10-18 09:11:11 +02:00
|
|
|
else if (!strcasecmp(Name, "BlockFlush")) blockFlush = atoi(Value);
|
2014-09-27 09:25:14 +02:00
|
|
|
else return false;
|
|
|
|
return true;
|
|
|
|
}
|