Remove unused fields from control files.
[vuplus_dvbapp-plugin] / webinterface / src / WebIfConfig.py
1 Version = '$Header$';
2
3 from __init__ import _
4
5 from enigma import eListboxPythonMultiContent, gFont
6 from Screens.Screen import Screen
7 from Screens.MessageBox import MessageBox
8
9 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection
10 from Components.ConfigList import ConfigListScreen
11 from Components.Sources.StaticText import StaticText
12 from Components.MenuList import MenuList
13 from Components.MultiContent import MultiContentEntryText
14
15 from Components.ActionMap import ActionMap
16                         
17 class WebIfConfigScreen(ConfigListScreen, Screen):
18         skin = """
19                 <screen name="WebIfConfigScreen" position="center,center" size="560,400" title="Webinterface: Main Setup">
20                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
21                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
22                         <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
23                         <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
24                         <widget name="config" position="5,50" size="550,360" scrollbarMode="showOnDemand" zPosition="1"/>
25                 </screen>"""
26
27         def __init__(self, session, args=0):
28                 Screen.__init__(self, session)
29                 
30
31                 ConfigListScreen.__init__(self, [])             
32                 self.createSetup()
33                 
34                 self["key_red"] = StaticText(_("Cancel"))
35                 self["key_green"] = StaticText(_("OK"))
36                 # SKIN Compat HACK!
37                 self["key_yellow"] = StaticText("")
38                 # EO SKIN Compat HACK!
39                 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
40                 {
41                         "red": self.cancel,
42                         "green": self.save,
43                         "save": self.save,
44                         "cancel": self.cancel,
45                         "ok": self.save,
46                 }, -2)
47                                 
48                 self.onLayoutFinish.append(self.layoutFinished)
49         
50         def keyLeft(self):
51                 ConfigListScreen.keyLeft(self)
52                 self.createSetup()
53
54         def keyRight(self):
55                 ConfigListScreen.keyRight(self)
56                 self.createSetup()
57                 
58         def createSetup(self):
59                 list = [
60                         getConfigListEntry(_("Start Webinterface"), config.plugins.Webinterface.enabled),
61                         getConfigListEntry(_("Enable /media"), config.plugins.Webinterface.includemedia),
62                         getConfigListEntry(_("Allow zapping via Webinterface"), config.plugins.Webinterface.allowzapping),
63                         getConfigListEntry(_("Autowrite timer"), config.plugins.Webinterface.autowritetimer),
64                         getConfigListEntry(_("Load movie-length"), config.plugins.Webinterface.loadmovielength),
65                         getConfigListEntry(_("Enable HTTP Access"), config.plugins.Webinterface.http.enabled)
66                 ]
67                 
68                 if config.plugins.Webinterface.http.enabled.value == True:
69                         sublist = [
70                                 getConfigListEntry(_("HTTP Port"), config.plugins.Webinterface.http.port),
71                                 getConfigListEntry(_("Enable HTTP Authentication"), config.plugins.Webinterface.http.auth)                              
72                         ]
73                         
74                         list.extend(sublist)
75                 
76                 list.append( getConfigListEntry(_("Enable HTTPS Access"), config.plugins.Webinterface.https.enabled) )
77                 
78                 if config.plugins.Webinterface.https.enabled.value == True:
79                         sublist = [
80                                 getConfigListEntry(_("HTTPS Port"), config.plugins.Webinterface.https.port),
81                                 getConfigListEntry(_("Enable HTTPS Authentication"), config.plugins.Webinterface.https.auth)                            
82                         ]
83                         
84                         list.extend(sublist)
85                 
86                 #Auth for Streaming (127.0.0.1 Listener)
87                 list.append(getConfigListEntry(_("Enable Streaming Authentication"), config.plugins.Webinterface.streamauth))
88                 
89                 self["config"].list = list
90                 self["config"].l.setList(list)
91                 
92         def layoutFinished(self):
93                 self.setTitle(_("Webinterface: Main Setup"))
94
95         def save(self):
96                 print "[Webinterface] Saving Configuration"             
97                 for x in self["config"].list:
98                         x[1].save()
99                 self.close(True, self.session)
100
101         def cancel(self):
102                 print "[Webinterface] Cancel setup changes"
103                 for x in self["config"].list:
104                         x[1].cancel()
105                 self.close(False, self.session)
106
107