-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.c
92 lines (76 loc) · 2.51 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
/*
* setup.c: RSS Reader plugin for the Video Disk Recorder
*
*/
#include <vdr/menu.h>
#include "config.h"
#include "menu.h"
#include "setup.h"
cRssReaderSetup::cRssReaderSetup()
: hideMenuM(RssReaderConfig.IsHideMenu()),
hideElemM(RssReaderConfig.IsHideElem()),
useProxyM(RssReaderConfig.IsUseProxy())
{
strn0cpy(httpProxyM, RssReaderConfig.GetHttpProxy(), sizeof(httpProxyM));
SetMenuCategory(mcSetupPlugins);
Setup();
SetHelp(tr("Button$Load"), NULL, NULL, NULL);
}
cRssReaderSetup::~cRssReaderSetup()
{
}
void cRssReaderSetup::Setup(void)
{
int current = Current();
Clear();
helpM.Clear();
Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &hideMenuM));
helpM.Append(tr("Define whether the main manu entry is hidden."));
Add(new cMenuEditBoolItem(tr("Hide non-existent elements"), &hideElemM));
helpM.Append(tr("Define whether all non-existent RSS stream elements are hidden."));
Add(new cMenuEditBoolItem(tr("Use HTTP proxy server"), &useProxyM));
helpM.Append(tr("Define whether a HTTP proxy server is used."));
if (useProxyM) {
Add(new cMenuEditStrItem( tr("HTTP proxy server"), httpProxyM, sizeof(httpProxyM), tr(FileNameChars)));
helpM.Append(tr("Define an address and port of the HTTP proxy server:\n\n\"proxy.domain.com:8000\""));
}
SetCurrent(Get(current));
Display();
}
eOSState cRssReaderSetup::ProcessKey(eKeys keyP)
{
int oldUseProxy = useProxyM;
eOSState state = cMenuSetupPage::ProcessKey(keyP);
if (keyP != kNone && (useProxyM != oldUseProxy))
Setup();
if (state == osUnknown) {
switch (keyP) {
case kRed:
Skins.Message(mtInfo, tr("Loading configuration file..."));
RssItems.Load(RssReaderConfig.GetConfigFile());
Skins.Message(mtInfo, NULL);
state = osContinue;
break;
case kInfo:
if (Current() < helpM.Size())
return AddSubMenu(new cMenuText(cString::sprintf("%s - %s '%s'", tr("Help"), trVDR("Plugin"), PLUGIN_NAME_I18N), helpM[Current()]));
break;
default:
break;
}
}
return state;
}
void cRssReaderSetup::Store(void)
{
// Store values into setup.conf
SetupStore("HideMenu", hideMenuM);
SetupStore("HideElem", hideElemM);
SetupStore("UseProxy", useProxyM);
SetupStore("HttpProxy", httpProxyM);
// Update global config
RssReaderConfig.SetHideMenu(hideMenuM);
RssReaderConfig.SetHideElem(hideElemM);
RssReaderConfig.SetUseProxy(useProxyM);
RssReaderConfig.SetHttpProxy(httpProxyM);
}