Webinterface: check fullpath in getMovieSubdirs
[enigma2-plugins.git] / webinterface / src / WebIfConfig.py
1 Version = '$Header$';
2
3 from enigma import eListboxPythonMultiContent, gFont
4 from Screens.Screen import Screen
5 from Screens.MessageBox import MessageBox
6
7 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection
8 from Components.ConfigList import ConfigListScreen
9 from Components.Sources.StaticText import StaticText
10 from Components.MenuList import MenuList
11 from Components.MultiContent import MultiContentEntryText
12
13 from Components.ActionMap import ActionMap
14
15 class WebIfConfigScreen(ConfigListScreen, Screen):
16         skin = """
17                 <screen name="WebIfConfigScreen" position="center,center" size="560,400" title="Webinterface: Main Setup">
18                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
19                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
20                         <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" />
21                         <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" />
22                         <widget name="config" position="5,50" size="550,360" scrollbarMode="showOnDemand" zPosition="1"/>
23                 </screen>"""
24
25         def __init__(self, session, args=0):
26                 Screen.__init__(self, session)
27                 ConfigListScreen.__init__(self, [])
28                 self.createSetup()
29
30                 self["key_red"] = StaticText(_("Cancel"))
31                 self["key_green"] = StaticText(_("OK"))
32                 # SKIN Compat HACK!
33                 self["key_yellow"] = StaticText("")
34                 # EO SKIN Compat HACK!
35                 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
36                 {
37                         "red": self.cancel,
38                         "green": self.save,
39                         "save": self.save,
40                         "cancel": self.cancel,
41                         "ok": self.save,
42                 }, -2)
43
44                 self.onLayoutFinish.append(self.layoutFinished)
45
46         def keyLeft(self):
47                 ConfigListScreen.keyLeft(self)
48                 self.createSetup()
49
50         def keyRight(self):
51                 ConfigListScreen.keyRight(self)
52                 self.createSetup()
53
54         def createSetup(self):
55                 list = [ getConfigListEntry(_("Start Webinterface"), config.plugins.Webinterface.enabled), ]
56
57                 if config.plugins.Webinterface.enabled.value:
58                         list.extend( [
59                                 getConfigListEntry(_("General")),
60                                 getConfigListEntry(_("Show Setup in Extensions menu"), config.plugins.Webinterface.show_in_extensionsmenu),
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(_("HTTP")),
66                                 getConfigListEntry(_("Enable HTTP Access"), config.plugins.Webinterface.http.enabled)
67                         ])
68
69                         if config.plugins.Webinterface.http.enabled.value == True:
70                                 list.extend([
71                                         getConfigListEntry(_("HTTP Port"), config.plugins.Webinterface.http.port),
72                                         getConfigListEntry(_("Enable HTTP Authentication"), config.plugins.Webinterface.http.auth)
73                                 ])
74
75                         list.extend([
76                                 getConfigListEntry(_("HTTPS")),
77                                 getConfigListEntry(_("Enable HTTPS Access"), config.plugins.Webinterface.https.enabled)
78                         ])
79                         if config.plugins.Webinterface.https.enabled.value == True:
80                                 list.extend([
81                                         getConfigListEntry(_("HTTPS Port"), config.plugins.Webinterface.https.port),
82                                         getConfigListEntry(_("Enable HTTPS Authentication"), config.plugins.Webinterface.https.auth)
83                                 ])
84
85                         list.extend([
86                                 getConfigListEntry(_("Additional Security")),
87                                 getConfigListEntry(_("Enable Streaming Authentication"), config.plugins.Webinterface.streamauth),
88                                 getConfigListEntry(_("Authentication for local clients"), config.plugins.Webinterface.localauth),
89                                 getConfigListEntry(_("Simple Anti-Hijack Measures (may break clients)"), config.plugins.Webinterface.anti_hijack),
90                                 getConfigListEntry(_("Token-based security (may break clients)"), config.plugins.Webinterface.extended_security),
91                         ])
92                 self["config"].list = list
93                 self["config"].l.setList(list)
94
95         def layoutFinished(self):
96                 self.setTitle(_("Webinterface: Main Setup"))
97
98         def save(self):
99                 print "[Webinterface] Saving Configuration"
100                 for x in self["config"].list:
101                         if len(x) > 1:
102                                 x[1].save()
103                 self.close(True, self.session)
104
105         def cancel(self):
106                 print "[Webinterface] Cancel setup changes"
107                 for x in self["config"].list:
108                         if len(x) > 1:
109                                 x[1].cancel()
110                 self.close(False, self.session)
111
112