-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.c
162 lines (120 loc) · 3.26 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
* osd2web plugin for the Video Disk Recorder
*
* setup.c
*
* (c) 2017 Jörg Wendel
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
**/
!!!! FILE UNUSED !!!
//***************************************************************************
// Plugin Setup Menu
//***************************************************************************
class cSetupMenuOsd2Web : public cMenuSetupPage
{
public:
cSetupMenuOsd2Web();
~cSetupMenuOsd2Web();
protected:
virtual eOSState ProcessKey(eKeys Key);
virtual void Store();
virtual void Setup();
private:
cEpg2VdrConfig data;
cMenuDb* menuDb;
long int webLoginEnabled;
char** userList;
int userCount;
cStringList interfaceList;
int interfaceIndex;
};
cSetupMenuOsd2Web::cSetupMenuOsd2Web()
{
data = Epg2VdrConfig;
menuDb = new cMenuDb;
webLoginEnabled = no;
userList = 0;
userCount = 0;
interfaceIndex = 0;
Setup();
}
cSetupMenuOsd2Web::~cSetupMenuOsd2Web()
{
if (userList)
{
for (int i = 0; i < userCount; i++)
free(userList[i]);
delete userList;
}
delete menuDb;
}
void cSetupMenuOsd2Web::Setup()
{
int current = Current();
// Network Interfaces
int i = 0;
char* interfaces;
interfaces = strdup(getInterfaces());
interfaceList.Clear();
for (char* p = strtok(interfaces, " "); p; p = strtok(0, " "))
{
interfaceList.Append(strdup(p));
if (!isEmpty(data.netDevice) && strncmp(p, data.netDevice, strlen(data.netDevice)) == 0)
{
tell(0, "Index of '%s' is %d", p, i);
interfaceIndex = i;
}
i++;
}
free(interfaces);
// ...
Clear();
Add(new cOsdItem(cString::sprintf("--------------------- %s ---------------------------------", tr("Technical Stuff"))));
cList<cOsdItem>::Last()->SetSelectable(false);
Add(new cMenuEditIntItem(tr("Log level"), &data.loglevel, 0, 4));
SetCurrent(Get(current));
Display();
}
eOSState cSetupMenuOsd2Web::ProcessKey(eKeys Key)
{
eOSState state = cMenuSetupPage::ProcessKey(Key);
switch (state)
{
case osContinue:
{
if (NORMALKEY(Key) == kUp || NORMALKEY(Key) == kDown)
{
cOsdItem* item = Get(Current());
if (item)
item->ProcessKey(kNone);
}
break;
}
default: break;
}
return state;
}
void cSetupMenuOsd2Web::Store()
{
int useCommonRecFolderOptionChanged = no;
if (Epg2VdrConfig.useCommonRecFolder != data.useCommonRecFolder)
useCommonRecFolderOptionChanged = yes;
if (data.hasDbLoginChanged(&Epg2VdrConfig))
oUpdate->triggerDbReconnect();
Epg2VdrConfig = data;
SetupStore("LogLevel", Epg2VdrConfig.loglevel);
if (userCount && Epg2VdrConfig.userIndex >= 0)
{
sstrcpy(Epg2VdrConfig.user, userList[Epg2VdrConfig.userIndex], sizeof(Epg2VdrConfig.user));
SetupStore("User", Epg2VdrConfig.user);
}
char* device = strdup(interfaceList[interfaceIndex]);
char* ip = strchr(device, ':');
free(device);
SetupStore("NetDevice", Epg2VdrConfig.netDevice);
if (useCommonRecFolderOptionChanged)
oUpdate->commonRecFolderOptionChanged();
}