allow to remove files from mp playlist, also fixes dl-link in playlist and actually...
[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["RemoveFile"] = MP(session, func=MP.REMOVE)
189                 self["Command"] = MP(session, func=MP.COMMAND)
190                 self["WritePlaylist"] = MP(session, func=MP.WRITEPLAYLIST)
191
192 class AutoTimerWebScreen(WebScreen):
193         def __init__(self, session, request):
194                 WebScreen.__init__(self, session, request)
195                 from WebComponents.Sources.AT import AT
196
197                 self["AutoTimerList"] = AT(session, func=AT.LIST)
198                 self["AutoTimerWrite"] = AT(session, func=AT.WRITE)
199
200 class TimerWebScreen(WebScreen):
201         def __init__(self, session, request):
202                 WebScreen.__init__(self, session, request)
203                 from WebComponents.Sources.Timer import Timer
204
205                 self["TimerList"] = Timer(session, func=Timer.LIST)
206                 self["TimerAddEventID"] = Timer(session, func=Timer.ADDBYID)
207                 self["TimerAdd"] = Timer(session, func=Timer.ADD)
208                 self["TimerDel"] = Timer(session, func=Timer.DEL)
209                 self["TimerChange"] = Timer(session, func=Timer.CHANGE)
210                 self["TimerListWrite"] = Timer(session, func=Timer.WRITE)
211                 self["TVBrowser"] = Timer(session, func=Timer.TVBROWSER)
212                 self["RecordNow"] = Timer(session, func=Timer.RECNOW)
213                 self["TimerCleanup"] = Timer(session, func=Timer.CLEANUP)
214
215 class RemoteWebScreen(WebScreen):
216         def __init__(self, session, request):
217                 WebScreen.__init__(self, session, request)
218                 from WebComponents.Sources.RemoteControl import RemoteControl
219
220                 self["RemoteControl"] = RemoteControl(session)
221
222 class PowerWebScreen(WebScreen):
223         def __init__(self, session, request):
224                 WebScreen.__init__(self, session, request)
225                 from WebComponents.Sources.PowerState import PowerState
226
227                 self["PowerState"] = PowerState(session)
228
229 class ParentControlWebScreen(WebScreen):
230         def __init__(self, session, request):
231                 WebScreen.__init__(self, session, request)
232                 from WebComponents.Sources.ParentControl import ParentControl
233
234                 self["ParentControlList"] = ParentControl(session)
235
236 class WapWebScreen(WebScreen):
237         def __init__(self, session, request):
238                 WebScreen.__init__(self, session, request)
239                 from WebComponents.Sources.WAPfunctions import WAPfunctions
240
241                 self["WAPFillOptionListYear"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
242                 self["WAPFillOptionListDay"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
243                 self["WAPFillOptionListMonth"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
244                 self["WAPFillOptionListShour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
245                 self["WAPFillOptionListSmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
246                 self["WAPFillOptionListEhour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
247                 self["WAPFillOptionListEmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
248
249                 self["WAPFillOptionListRecord"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
250                 self["WAPFillOptionListAfterEvent"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
251
252                 self["WAPFillValueName"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
253                 self["WAPFillValueDescr"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
254                 self["WAPFillLocation"] = WAPfunctions(session, func=WAPfunctions.LOCATIONLIST)
255                 self["WAPFillTags"] = WAPfunctions(session, func=WAPfunctions.TAGLIST)
256
257                 self["WAPFillOptionListRepeated"] = WAPfunctions(session, func=WAPfunctions.REPEATED)
258                 self["WAPServiceList"] = WAPfunctions(session, func=WAPfunctions.SERVICELIST)
259
260                 self["WAPdeleteOldOnSave"] = WAPfunctions(session, func=WAPfunctions.DELETEOLD)
261
262 streamingScreens = []
263
264 class StreamingWebScreen(WebScreen):
265         def __init__(self, session, request):
266                 WebScreen.__init__(self, session, request)
267                 from Components.Sources.StreamService import StreamService
268                 self["StreamService"] = StreamService(self.session.nav)
269                 streamingScreens.append(self)
270                 self.screenIndex = len(streamingScreens) - 1
271
272         def getRecordService(self):
273                 if self.has_key("StreamService"):
274                         return self["StreamService"].getService()
275                 return None
276
277         def getRecordServiceRef(self):
278                 if self.has_key("StreamService"):
279                         return self["StreamService"].ref
280                 return None
281
282 class M3uStreamingWebScreen(WebScreen):
283         def __init__(self, session, request):
284                 WebScreen.__init__(self, session, request)
285                 from Components.Sources.StaticText import StaticText
286                 from Components.Sources.Config import Config
287                 from Components.config import config
288                 self["ref"] = StaticText()
289                 self["localip"] = RequestData(request, what=RequestData.HOST)
290
291 class M3uStreamingCurrentServiceWebScreen(WebScreen):
292         def __init__(self, session, request):
293                 WebScreen.__init__(self, session, request)
294                 from WebComponents.Sources.CurrentService import CurrentService
295
296                 self["CurrentService"] = CurrentService(session)
297                 self["localip"] = RequestData(request, what=RequestData.HOST)
298
299 class TsM3uWebScreen(WebScreen):
300         def __init__(self, session, request):
301                 WebScreen.__init__(self, session, request)
302                 from Components.Sources.StaticText import StaticText
303                 from Components.Sources.Config import Config
304                 from Components.config import config
305                 self["file"] = StaticText()
306                 self["localip"] = RequestData(request, what=RequestData.HOST)
307                 self["localport"] = RequestData(request, what=RequestData.PORT)
308
309 class RestartWebScreen(WebScreen):
310         def __init__(self, session, request):
311                 WebScreen.__init__(self, session, request)
312                 import plugin
313                 plugin.restartWebserver(session)
314
315 class GetPidWebScreen(WebScreen):
316         def __init__(self, session, request):
317                  WebScreen.__init__(self, session, request)
318                  from Components.Sources.StaticText import StaticText
319                  from enigma import iServiceInformation
320                  pids = self.session.nav.getCurrentService()
321                  if pids is not None:
322                         pidinfo = pids.info()
323                         VPID = hex(pidinfo.getInfo(iServiceInformation.sVideoPID))
324                         APID = hex(pidinfo.getInfo(iServiceInformation.sAudioPID))
325                         PPID = hex(pidinfo.getInfo(iServiceInformation.sPMTPID))
326                         self["pids"] = StaticText("%s,%s,%s" % (PPID.lstrip("0x"), VPID.lstrip("0x"), APID.lstrip("0x")))
327                  else:
328                         self["pids"] = StaticText("0x,0x,0x")
329
330                  self["localip"] = RequestData(request, what=RequestData.HOST)
331
332 class DeviceInfoWebScreen(WebScreen):
333         def __init__(self, session, request):
334                 WebScreen.__init__(self, session, request)
335                 from WebComponents.Sources.Network import Network
336                 from WebComponents.Sources.Hdd import Hdd
337                 from WebComponents.Sources.Frontend import Frontend
338                 from Components.config import config
339                 from Components.About import about
340                 from Components.Sources.StaticText import StaticText
341                 from Tools.DreamboxHardware import getFPVersion
342                 from Tools.HardwareInfo import HardwareInfo
343
344                 hw = HardwareInfo()
345
346                 self["Network"] = Network()
347                 self["Hdd"] = Hdd()
348                 self["Frontends"] = Frontend()
349                 self["EnigmaVersion"] = StaticText(about.getEnigmaVersionString())
350                 self["ImageVersion"] = StaticText(about.getVersionString())
351                 self["WebIfVersion"] = StaticText(config.plugins.Webinterface.version.value)
352                 self["FpVersion"] = StaticText(str(getFPVersion()))
353                 self["DeviceName"] = StaticText(hw.get_device_name())