vdr-plugin-scraper2vdr/setup.c

86 lines
3.3 KiB
C
Raw Normal View History

2014-05-09 01:05:21 +02:00
#include "lib/config.h"
2014-04-12 17:10:43 +02:00
#include "setup.h"
extern cScraper2VdrConfig config;
cScraper2VdrSetup::cScraper2VdrSetup(cUpdate *update) {
this->update = update;
tmpConfig = config;
strn0cpy(host, tmpConfig.mysqlHost.c_str(), sizeof(host));
strn0cpy(dbname, tmpConfig.mysqlDBName.c_str(), sizeof(dbname));
strn0cpy(user, tmpConfig.mysqlDBUser.c_str(), sizeof(user));
strn0cpy(password, tmpConfig.mysqlDBPass.c_str(), sizeof(password));
Setup();
}
cScraper2VdrSetup::~cScraper2VdrSetup() {
}
void cScraper2VdrSetup::Setup(void) {
int currentItem = Current();
Clear();
Add(new cMenuEditBoolItem(tr("Show Main Menu Entry"), &tmpConfig.mainMenuEntry));
2014-04-27 12:39:56 +02:00
Add(new cMenuEditBoolItem(tr("Debug Mode"), &tmpConfig.debug));
2014-04-12 17:10:43 +02:00
Add(new cMenuEditStrItem(tr("MySQL Host"), host, sizeof(host), tr(FileNameChars)));
Add(new cMenuEditIntItem(tr("MySQL Port"), &tmpConfig.mysqlPort, 1, 99999));
Add(new cMenuEditStrItem(tr("MySQL Database Name"), dbname, sizeof(dbname), tr(FileNameChars)));
Add(new cMenuEditStrItem(tr("MySQL User"), user, sizeof(user), tr(FileNameChars)));
Add(new cMenuEditStrItem(tr("MySQL Password"), password, sizeof(password), tr(FileNameChars)));
Add(new cOsdItem(tr("Update Scraper Information from Database")));
Add(new cOsdItem(tr("Update Scraper Recordings Information from Database")));
Add(new cOsdItem(tr("Scan for new recordings in video directory")));
Add(new cOsdItem(tr("Scan for new or updated scrapinfo files")));
Add(new cOsdItem(tr("Cleanup Recordings in Database")));
SetCurrent(Get(currentItem));
Display();
}
eOSState cScraper2VdrSetup::ProcessKey(eKeys Key) {
2014-05-09 01:05:21 +02:00
// bool hadSubMenu = HasSubMenu();
2014-04-12 17:10:43 +02:00
eOSState state = cMenuSetupPage::ProcessKey(Key);
if (Key == kOk) {
tmpConfig.mysqlHost = host;
tmpConfig.mysqlDBName = dbname;
tmpConfig.mysqlDBUser = user;
tmpConfig.mysqlDBPass = password;
Store();
2014-05-10 12:57:31 +02:00
if (Current() == 7) {
2014-04-12 17:10:43 +02:00
Skins.Message(mtInfo, tr("Updating Scraper EPG Information from Database"));
update->ForceUpdate();
2014-05-10 12:57:31 +02:00
} else if (Current() == 8) {
2014-04-12 17:10:43 +02:00
Skins.Message(mtInfo, tr("Updating Scraper Recordings Information from Database"));
update->ForceRecordingUpdate();
2014-05-10 12:57:31 +02:00
} else if (Current() == 9) {
2014-04-12 17:10:43 +02:00
Skins.Message(mtInfo, tr("Scanning for new recordings in video directory"));
update->ForceVideoDirUpdate();
2014-05-10 12:57:31 +02:00
} else if (Current() == 10 ) {
2014-04-12 17:10:43 +02:00
Skins.Message(mtInfo, tr("Scanning for new or updated scrapinfo files"));
update->ForceScrapInfoUpdate();
2014-05-10 12:57:31 +02:00
} else if (Current() == 11) {
2014-04-12 17:10:43 +02:00
Skins.Message(mtInfo, tr("Cleaning up Recordings in Database"));
update->TriggerCleanRecordingsDB();
}
return osEnd;
}
return state;
}
void cScraper2VdrSetup::Store(void) {
config = tmpConfig;
SetupStore("mainMenuEntry", tmpConfig.mainMenuEntry);
SetupStore("mysqlHost", tmpConfig.mysqlHost.c_str());
SetupStore("mysqlPort", tmpConfig.mysqlPort);
SetupStore("mysqlDBName", tmpConfig.mysqlDBName.c_str());
SetupStore("mysqlDBUser", tmpConfig.mysqlDBUser.c_str());
SetupStore("mysqlDBPass", tmpConfig.mysqlDBPass.c_str());
2014-04-27 12:39:56 +02:00
SetupStore("debug", tmpConfig.debug);
2014-05-09 01:05:21 +02:00
EPG2VDRConfig.loglevel = tmpConfig.debug ? 2 : 1;
2014-04-12 17:10:43 +02:00
}