summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/setup.c b/setup.c
new file mode 100644
index 0000000..0415d31
--- /dev/null
+++ b/setup.c
@@ -0,0 +1,111 @@
+#include "setup.h"
+
+using namespace std;
+
+/* cTVScraperSetup */
+
+cTVScraperSetup::cTVScraperSetup(cTVScraperWorker *workerThread) {
+ worker = workerThread;
+ int numChannels = Channels.Count();
+ for (int i=0; i<numChannels; i++) {
+ int akt = 0;
+ if (config.ChannelActive(i+1))
+ akt = 1;
+ channelsScrap.push_back(akt);
+ }
+ Setup();
+}
+
+cTVScraperSetup::~cTVScraperSetup() {
+}
+
+
+void cTVScraperSetup::Setup(void) {
+ int currentItem = Current();
+ Clear();
+ Add(new cOsdItem(tr("Configure channels to be scrapped")));
+ Add(new cOsdItem(tr("Trigger scrapping Video Directory")));
+ Add(new cOsdItem(tr("Trigger EPG scrapping")));
+ Add(new cMenuEditBoolItem(tr("Enable Debug Logging"), &config.enableDebug));
+
+ SetCurrent(Get(currentItem));
+ Display();
+}
+
+eOSState cTVScraperSetup::ProcessKey(eKeys Key) {
+ bool hadSubMenu = HasSubMenu();
+ if (hadSubMenu && Key == kOk)
+ Store();
+ eOSState state = cMenuSetupPage::ProcessKey(Key);
+ if (!hadSubMenu && (Key == kOk)) {
+ const char* ItemText = Get(Current())->Text();
+ if (strcmp(ItemText, tr("Configure channels to be scrapped")) == 0)
+ state = AddSubMenu(new cTVScraperChannelSetup(&channelsScrap));
+ else if (strcmp(ItemText, tr("Trigger scrapping Video Directory")) == 0) {
+ Skins.Message(mtInfo, "Scrapping Video Directory started");
+ worker->InitVideoDirScan();
+ state = osContinue;
+ } else if (strcmp(ItemText, tr("Trigger EPG scrapping")) == 0) {
+ Skins.Message(mtInfo, "EPG Scrapping started");
+ worker->InitManualScan();
+ state = osContinue;
+ }
+ }
+ return state;
+}
+
+void cTVScraperSetup::Store(void) {
+ config.ClearChannels();
+ stringstream channelsToScrap;
+ int numChannels = channelsScrap.size();
+ for (int i=0; i<numChannels; i++) {
+ if (channelsScrap[i] == 1) {
+ cChannel *channel = Channels.GetByNumber(i+1);
+ if (channel) {
+ string channelID = *(channel->GetChannelID().ToString());
+ channelsToScrap << channelID << ";";
+ config.AddChannel(channelID);
+ }
+ }
+ }
+ SetupStore("ScrapChannels", channelsToScrap.str().c_str());
+ SetupStore("enableDebug", config.enableDebug);
+}
+
+
+/* cTVScraperChannelSetup */
+
+cTVScraperChannelSetup ::cTVScraperChannelSetup (vector<int> *channelsScrap) : cOsdMenu(tr("Configure channels to be scrapped"), 30) {
+ this->channelsScrap = channelsScrap;
+ SetMenuCategory(mcSetupPlugins);
+ Setup();
+}
+
+cTVScraperChannelSetup ::~cTVScraperChannelSetup () {
+}
+
+
+void cTVScraperChannelSetup ::Setup(void) {
+ int currentItem = Current();
+ Clear();
+ int i=0;
+ for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
+ if (!channel->GroupSep()) {
+ Add(new cMenuEditBoolItem(channel->Name(), &channelsScrap->at(i), tr("don't scrap"), tr("scrap")));
+ i++;
+ }
+ }
+ SetCurrent(Get(currentItem));
+ Display();
+}
+
+eOSState cTVScraperChannelSetup ::ProcessKey(eKeys Key) {
+ eOSState state = cOsdMenu::ProcessKey(Key);
+ switch (Key) {
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
+ return state;
+} \ No newline at end of file