This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.c
126 lines (110 loc) · 3.63 KB
/
setup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "setup.h"
using namespace std;
/* cTVScraperSetup */
cTVScraperSetup::cTVScraperSetup(cTVScraperWorker *workerThread) {
worker = workerThread;
#if APIVERSNUM < 20301
int numChannels = Channels.Count();
#else
LOCK_CHANNELS_READ;
int numChannels = Channels->Count();
#endif
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 scraped")));
Add(new cOsdItem(tr("Trigger scraping Video Directory")));
Add(new cOsdItem(tr("Trigger EPG scraping")));
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 scraped")) == 0)
state = AddSubMenu(new cTVScraperChannelSetup(&channelsScrap));
else if (strcmp(ItemText, tr("Trigger scraping Video Directory")) == 0) {
Skins.Message(mtInfo, "Scraping Video Directory started");
worker->InitVideoDirScan();
state = osContinue;
} else if (strcmp(ItemText, tr("Trigger EPG scraping")) == 0) {
Skins.Message(mtInfo, "EPG Scraping 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) {
#if APIVERSNUM < 20301
cChannel *channel = Channels.GetByNumber(i+1);
#else
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByNumber(i+1);
#endif
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 scraped"), 30) {
this->channelsScrap = channelsScrap;
SetMenuCategory(mcSetupPlugins);
Setup();
}
cTVScraperChannelSetup ::~cTVScraperChannelSetup () {
}
void cTVScraperChannelSetup ::Setup(void) {
int currentItem = Current();
Clear();
int i=0;
#if APIVERSNUM < 20301
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
#else
LOCK_CHANNELS_READ;
for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel)) {
#endif
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;
}