-add support for loading pluginlist
[enigma2-plugins.git] / webinterface / src / WebScreens.py
1 from enigma import eServiceReference
2 from Screens.Screen import Screen
3 from WebComponents.Sources.RequestData import RequestData
4
5 class WebScreen(Screen):
6         def __init__(self, session, request):
7                 Screen.__init__(self, session)
8                 self.stand_alone = True
9                 self.request = request
10                 self.instance = None
11
12 class DummyWebScreen(WebScreen):
13         #use it, if you dont need any source, just to can do a static file with an xml-file
14         def __init__(self, session, request):
15                 WebScreen.__init__(self, session, request)
16
17 class UpdateWebScreen(WebScreen):
18         def __init__(self, session, request):
19                 WebScreen.__init__(self, session, request)
20                 from Components.Sources.Clock import Clock
21
22                 self["CurrentTime"] = Clock()
23
24
25 class MessageWebScreen(WebScreen):
26         def __init__(self, session, request):
27                 WebScreen.__init__(self, session, request)
28                 from WebComponents.Sources.Message import Message
29
30                 self["Message"] = Message(session, func=Message.PRINT)
31                 self["GetAnswer"] = Message(session, func=Message.ANSWER)
32
33 class ServiceListReloadWebScreen(WebScreen):
34         def __init__(self, session, request):
35                 WebScreen.__init__(self, session, request)
36                 from WebComponents.Sources.ServiceListReload import ServiceListReload
37
38                 self["ServiceListReload"] = ServiceListReload(session)
39
40 class AudioWebScreen(WebScreen):
41         def __init__(self, session, request):
42                 WebScreen.__init__(self, session, request)
43                 from WebComponents.Sources.AudioTracks import AudioTracks
44
45                 self["AudioTracks"] = AudioTracks(session, func=AudioTracks.GET)
46                 self["SelectAudioTrack"] = AudioTracks(session, func=AudioTracks.SET)
47
48 class AboutWebScreen(WebScreen):
49         def __init__(self, session, request):
50                 WebScreen.__init__(self, session, request)
51                 from WebComponents.Sources.About import About
52                 from WebComponents.Sources.Frontend import Frontend
53                 from WebComponents.Sources.Hdd import Hdd
54                 from WebComponents.Sources.Network import Network
55                 from Components.config import config
56                 from Components.About import about
57                 from Components.Sources.StaticText import StaticText
58                 from Tools.DreamboxHardware import getFPVersion
59                 from Tools.HardwareInfo import HardwareInfo
60
61                 hw = HardwareInfo()
62
63                 self["About"] = About(session)
64
65                 self["Network"] = Network()
66                 self["Hdd"] = Hdd()
67                 self["Frontends"] = Frontend()
68                 self["EnigmaVersion"] = StaticText(about.getEnigmaVersionString())
69                 self["ImageVersion"] = StaticText(about.getVersionString())
70                 self["WebIfVersion"] = StaticText(config.plugins.Webinterface.version.value)
71                 self["FpVersion"] = StaticText(str(getFPVersion()))
72                 self["DeviceName"] = StaticText(hw.get_device_name())
73
74 class VolumeWebScreen(WebScreen):
75         def __init__(self, session, request):
76                 WebScreen.__init__(self, session, request)
77
78                 from WebComponents.Sources.Volume import Volume
79                 self["Volume"] = Volume(session)
80
81 class SettingsWebScreen(WebScreen):
82         def __init__(self, session, request):
83                 WebScreen.__init__(self, session, request)
84                 from WebComponents.Sources.Settings import Settings
85
86                 self["Settings"] = Settings(session)
87
88 class SubServiceWebScreen(WebScreen):
89         def __init__(self, session, request):
90                 WebScreen.__init__(self, session, request)
91                 from WebComponents.Sources.SubServices import SubServices
92
93                 self["SubServices"] = SubServices(session)
94
95 class StreamSubServiceWebScreen(WebScreen):
96         def __init__(self, session, request):
97                 WebScreen.__init__(self, session, request)
98                 from WebComponents.Sources.SubServices import SubServices
99
100                 self["StreamSubServices"] = SubServices(session, streamingScreens)
101
102 class ServiceWebScreen(WebScreen):
103         def __init__(self, session, request):
104                 WebScreen.__init__(self, session, request)
105                 from WebComponents.Sources.ServiceListRecursive import ServiceListRecursive
106                 from Components.Sources.ServiceList import ServiceList
107                 from Screens.ChannelSelection import service_types_tv
108
109                 fav = eServiceReference(service_types_tv + ' FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
110                 self["SwitchService"] = ServiceList(fav, command_func=self.zapTo, validate_commands=False)
111                 self["ServiceList"] = ServiceList(fav, command_func=self.getServiceList, validate_commands=False)
112                 self["ServiceListRecursive"] = ServiceListRecursive(session, func=ServiceListRecursive.FETCH)
113                 self["localip"] = RequestData(request, what=RequestData.HOST)
114
115         def getServiceList(self, sRef):
116                 self["ServiceList"].root = sRef
117
118         def zapTo(self, reftozap):
119                 from Components.config import config
120                 pc = config.ParentalControl.configured.value
121                 if pc:
122                         config.ParentalControl.configured.value = False
123                 if config.plugins.Webinterface.allowzapping.value:
124                         self.session.nav.playService(reftozap)
125                 if pc:
126                         config.ParentalControl.configured.value = pc
127                 """
128                 switching config.ParentalControl.configured.value
129                 ugly, but necessary :(
130                 """
131
132 class ReadPluginListWebScreen(WebScreen):
133         def __init__(self, session, request):
134                 WebScreen.__init__(self, session, request)
135                 from WebComponents.Sources.ReadPluginList import ReadPluginList
136                 self["ReadPluginList"] = ReadPluginList(session)
137
138 class LocationsAndTagsWebScreen(WebScreen):
139         def __init__(self, session, request):
140                 WebScreen.__init__(self, session, request)
141                 from WebComponents.Sources.LocationsAndTags import LocationsAndTags
142
143                 self["CurrentLocation"] = LocationsAndTags(session, LocationsAndTags.CURRLOCATION)
144                 self["Locations"] = LocationsAndTags(session, LocationsAndTags.LOCATIONS)
145                 self["AddLocation"] = LocationsAndTags(session, LocationsAndTags.ADDLOCATION)
146                 self["RemoveLocation"] = LocationsAndTags(session, LocationsAndTags.REMOVELOCATION)
147                 self["Tags"] = LocationsAndTags(session, LocationsAndTags.TAGS)
148
149 class EpgWebScreen(WebScreen):
150         def __init__(self, session, request):
151                 WebScreen.__init__(self, session, request)
152                 from WebComponents.Sources.EPG import EPG
153
154                 self["EpgSearch"] = EPG(session, func=EPG.SEARCH)
155                 self["EpgSearchSimilar"] = EPG(session, func=EPG.SEARCHSIMILAR)
156                 self["EpgService"] = EPG(session, func=EPG.SERVICE)
157                 self["EpgBouquetNow"] = EPG(session, func=EPG.BOUQUETNOW)
158                 self["EpgBouquetNext"] = EPG(session, func=EPG.BOUQUETNEXT)
159                 self["EpgServiceNow"] = EPG(session, func=EPG.SERVICENOW)
160                 self["EpgServiceNext"] = EPG(session, func=EPG.SERVICENEXT)
161                 self["EpgBouquet"] = EPG(session, func=EPG.BOUQUET)
162                 self["localip"] = RequestData(request, what=RequestData.HOST)
163
164                 self["EPGSERVICEWAP"] = EPG(session, func=EPG.SERVICE, endtm=True)
165
166         def getServiceList(self, sRef):
167                 self["ServiceList"].root = sRef
168
169 class MovieWebScreen(WebScreen):
170         def __init__(self, session, request):
171                 WebScreen.__init__(self, session, request)
172                 from Components.MovieList import MovieList
173                 from Tools.Directories import resolveFilename, SCOPE_HDD
174                 from WebComponents.Sources.Movie import Movie
175
176                 movielist = MovieList(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
177                 self["MovieList"] = Movie(session, movielist, func=Movie.LIST)
178                 self["MovieFileDel"] = Movie(session, movielist, func=Movie.DEL)
179                 self["localip"] = RequestData(request, what=RequestData.HOST)
180
181 class MediaPlayerWebScreen(WebScreen):
182         def __init__(self, session, request):
183                 WebScreen.__init__(self, session, request)
184                 from WebComponents.Sources.MP import MP
185
186                 self["FileList"] = MP(session, func=MP.LIST)
187                 self["PlayFile"] = MP(session, func=MP.PLAY)
188                 self["Command"] = MP(session, func=MP.COMMAND)
189                 self["WritePlaylist"] = MP(session, func=MP.WRITEPLAYLIST)
190
191 class AutoTimerWebScreen(WebScreen):
192         def __init__(self, session, request):
193                 WebScreen.__init__(self, session, request)
194                 from WebComponents.Sources.AT import AT
195
196                 self["AutoTimerList"] = AT(session, func=AT.LIST)
197                 self["AutoTimerWrite"] = AT(session, func=AT.WRITE)
198
199 class TimerWebScreen(WebScreen):
200         def __init__(self, session, request):
201                 WebScreen.__init__(self, session, request)
202                 from WebComponents.Sources.Timer import Timer
203
204                 self["TimerList"] = Timer(session, func=Timer.LIST)
205                 self["TimerAddEventID"] = Timer(session, func=Timer.ADDBYID)
206                 self["TimerAdd"] = Timer(session, func=Timer.ADD)
207                 self["TimerDel"] = Timer(session, func=Timer.DEL)
208                 self["TimerChange"] = Timer(session, func=Timer.CHANGE)
209                 self["TimerListWrite"] = Timer(session, func=Timer.WRITE)
210                 self["TVBrowser"] = Timer(session, func=Timer.TVBROWSER)
211                 self["RecordNow"] = Timer(session, func=Timer.RECNOW)
212                 self["TimerCleanup"] = Timer(session, func=Timer.CLEANUP)
213
214 class RemoteWebScreen(WebScreen):
215         def __init__(self, session, request):
216                 WebScreen.__init__(self, session, request)
217                 from WebComponents.Sources.RemoteControl import RemoteControl
218
219                 self["RemoteControl"] = RemoteControl(session)
220
221 class PowerWebScreen(WebScreen):
222         def __init__(self, session, request):
223                 WebScreen.__init__(self, session, request)
224                 from WebComponents.Sources.PowerState import PowerState
225
226                 self["PowerState"] = PowerState(session)
227
228 class ParentControlWebScreen(WebScreen):
229         def __init__(self, session, request):
230                 WebScreen.__init__(self, session, request)
231                 from WebComponents.Sources.ParentControl import ParentControl
232
233                 self["ParentControlList"] = ParentControl(session)
234
235 class WapWebScreen(WebScreen):
236         def __init__(self, session, request):
237                 WebScreen.__init__(self, session, request)
238                 from WebComponents.Sources.WAPfunctions import WAPfunctions
239
240                 self["WAPFillOptionListYear"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
241                 self["WAPFillOptionListDay"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
242                 self["WAPFillOptionListMonth"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
243                 self["WAPFillOptionListShour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
244                 self["WAPFillOptionListSmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
245                 self["WAPFillOptionListEhour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
246                 self["WAPFillOptionListEmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
247
248                 self["WAPFillOptionListRecord"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
249                 self["WAPFillOptionListAfterEvent"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
250
251                 self["WAPFillValueName"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
252                 self["WAPFillValueDescr"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
253                 self["WAPFillLocation"] = WAPfunctions(session, func=WAPfunctions.LOCATIONLIST)
254                 self["WAPFillTags"] = WAPfunctions(session, func=WAPfunctions.TAGLIST)
255
256                 self["WAPFillOptionListRepeated"] = WAPfunctions(session, func=WAPfunctions.REPEATED)
257                 self["WAPServiceList"] = WAPfunctions(session, func=WAPfunctions.SERVICELIST)
258
259                 self["WAPdeleteOldOnSave"] = WAPfunctions(session, func=WAPfunctions.DELETEOLD)
260
261 streamingScreens = []
262
263 class StreamingWebScreen(WebScreen):
264         def __init__(self, session, request):
265                 WebScreen.__init__(self, session, request)
266                 from Components.Sources.StreamService import StreamService
267                 self["StreamService"] = StreamService(self.session.nav)
268                 streamingScreens.append(self)
269                 self.screenIndex = len(streamingScreens) - 1
270
271         def getRecordService(self):
272                 if self.has_key("StreamService"):
273                         return self["StreamService"].getService()
274                 return None
275
276         def getRecordServiceRef(self):
277                 if self.has_key("StreamService"):
278                         return self["StreamService"].ref
279                 return None
280
281 class M3uStreamingWebScreen(WebScreen):
282         def __init__(self, session, request):
283                 WebScreen.__init__(self, session, request)
284                 from Components.Sources.StaticText import StaticText
285                 from Components.Sources.Config import Config
286                 from Components.config import config
287                 self["ref"] = StaticText()
288                 self["localip"] = RequestData(request, what=RequestData.HOST)
289
290 class M3uStreamingCurrentServiceWebScreen(WebScreen):
291         def __init__(self, session, request):
292                 WebScreen.__init__(self, session, request)
293                 from WebComponents.Sources.CurrentService import CurrentService
294
295                 self["CurrentService"] = CurrentService(session)
296                 self["localip"] = RequestData(request, what=RequestData.HOST)
297
298 class TsM3uWebScreen(WebScreen):
299         def __init__(self, session, request):
300                 WebScreen.__init__(self, session, request)
301                 from Components.Sources.StaticText import StaticText
302                 from Components.Sources.Config import Config
303                 from Components.config import config
304                 self["file"] = StaticText()
305                 self["localip"] = RequestData(request, what=RequestData.HOST)
306                 self["localport"] = RequestData(request, what=RequestData.PORT)
307
308 class RestartWebScreen(WebScreen):
309         def __init__(self, session, request):
310                 WebScreen.__init__(self, session, request)
311                 import plugin
312                 plugin.restartWebserver(session)
313
314 class GetPidWebScreen(WebScreen):
315         def __init__(self, session, request):
316                  WebScreen.__init__(self, session, request)
317                  from Components.Sources.StaticText import StaticText
318                  from enigma import iServiceInformation
319                  pids = self.session.nav.getCurrentService()
320                  if pids is not None:
321                         pidinfo = pids.info()
322                         VPID = hex(pidinfo.getInfo(iServiceInformation.sVideoPID))
323                         APID = hex(pidinfo.getInfo(iServiceInformation.sAudioPID))
324                         PPID = hex(pidinfo.getInfo(iServiceInformation.sPMTPID))
325                         self["pids"] = StaticText("%s,%s,%s" % (PPID.lstrip("0x"), VPID.lstrip("0x"), APID.lstrip("0x")))
326                  else:
327                         self["pids"] = StaticText("0x,0x,0x")
328
329                  self["localip"] = RequestData(request, what=RequestData.HOST)
330
331 class DeviceInfoWebScreen(WebScreen):
332         def __init__(self, session, request):
333                 WebScreen.__init__(self, session, request)
334                 from WebComponents.Sources.Network import Network
335                 from WebComponents.Sources.Hdd import Hdd
336                 from WebComponents.Sources.Frontend import Frontend
337                 from Components.config import config
338                 from Components.About import about
339                 from Components.Sources.StaticText import StaticText
340                 from Tools.DreamboxHardware import getFPVersion
341                 from Tools.HardwareInfo import HardwareInfo
342
343                 hw = HardwareInfo()
344
345                 self["Network"] = Network()
346                 self["Hdd"] = Hdd()
347                 self["Frontends"] = Frontend()
348                 self["EnigmaVersion"] = StaticText(about.getEnigmaVersionString())
349                 self["ImageVersion"] = StaticText(about.getVersionString())
350                 self["WebIfVersion"] = StaticText(config.plugins.Webinterface.version.value)
351                 self["FpVersion"] = StaticText(str(getFPVersion()))
352                 self["DeviceName"] = StaticText(hw.get_device_name())