adding similar event epg search
[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 LocationsAndTagsWebScreen(WebScreen):
133         def __init__(self, session, request):
134                 WebScreen.__init__(self, session, request)
135                 from WebComponents.Sources.LocationsAndTags import LocationsAndTags
136
137                 self["CurrentLocation"] = LocationsAndTags(session, LocationsAndTags.CURRLOCATION)
138                 self["Locations"] = LocationsAndTags(session, LocationsAndTags.LOCATIONS)
139                 self["Tags"] = LocationsAndTags(session, LocationsAndTags.TAGS)
140
141 class EpgWebScreen(WebScreen):
142         def __init__(self, session, request):
143                 WebScreen.__init__(self, session, request)
144                 from WebComponents.Sources.EPG import EPG
145
146                 self["EpgSearch"] = EPG(session, func=EPG.SEARCH)
147                 self["EpgSearchSimilar"] = EPG(session, func=EPG.SEARCHSIMILAR)
148                 self["EpgService"] = EPG(session, func=EPG.SERVICE)
149                 self["EpgBouquetNow"] = EPG(session, func=EPG.BOUQUETNOW)
150                 self["EpgBouquetNext"] = EPG(session, func=EPG.BOUQUETNEXT)
151                 self["EpgServiceNow"] = EPG(session, func=EPG.SERVICENOW)
152                 self["EpgServiceNext"] = EPG(session, func=EPG.SERVICENEXT)
153                 self["EpgBouquet"] = EPG(session, func=EPG.BOUQUET)
154                 self["localip"] = RequestData(request, what=RequestData.HOST)
155
156                 self["EPGSERVICEWAP"] = EPG(session, func=EPG.SERVICE, endtm=True)
157
158         def getServiceList(self, sRef):
159                 self["ServiceList"].root = sRef
160
161 class MovieWebScreen(WebScreen):
162         def __init__(self, session, request):
163                 WebScreen.__init__(self, session, request)
164                 from Components.MovieList import MovieList
165                 from Tools.Directories import resolveFilename, SCOPE_HDD
166                 from WebComponents.Sources.Movie import Movie
167
168                 movielist = MovieList(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
169                 self["MovieList"] = Movie(session, movielist, func=Movie.LIST)
170                 self["MovieFileDel"] = Movie(session, movielist, func=Movie.DEL)
171                 self["localip"] = RequestData(request, what=RequestData.HOST)
172
173 class MediaPlayerWebScreen(WebScreen):
174         def __init__(self, session, request):
175                 WebScreen.__init__(self, session, request)
176                 from WebComponents.Sources.MP import MP
177
178                 self["FileList"] = MP(session, func=MP.LIST)
179                 self["PlayFile"] = MP(session, func=MP.PLAY)
180                 self["Command"] = MP(session, func=MP.COMMAND)
181                 self["WritePlaylist"] = MP(session, func=MP.WRITEPLAYLIST)
182
183 class AutoTimerWebScreen(WebScreen):
184         def __init__(self, session, request):
185                 WebScreen.__init__(self, session, request)
186                 from WebComponents.Sources.AT import AT
187
188                 self["AutoTimerList"] = AT(session, func=AT.LIST)
189                 self["AutoTimerWrite"] = AT(session, func=AT.WRITE)
190
191 class TimerWebScreen(WebScreen):
192         def __init__(self, session, request):
193                 WebScreen.__init__(self, session, request)
194                 from WebComponents.Sources.Timer import Timer
195
196                 self["TimerList"] = Timer(session, func=Timer.LIST)
197                 self["TimerAddEventID"] = Timer(session, func=Timer.ADDBYID)
198                 self["TimerAdd"] = Timer(session, func=Timer.ADD)
199                 self["TimerDel"] = Timer(session, func=Timer.DEL)
200                 self["TimerChange"] = Timer(session, func=Timer.CHANGE)
201                 self["TimerListWrite"] = Timer(session, func=Timer.WRITE)
202                 self["TVBrowser"] = Timer(session, func=Timer.TVBROWSER)
203                 self["RecordNow"] = Timer(session, func=Timer.RECNOW)
204                 self["TimerCleanup"] = Timer(session, func=Timer.CLEANUP)
205
206 class RemoteWebScreen(WebScreen):
207         def __init__(self, session, request):
208                 WebScreen.__init__(self, session, request)
209                 from WebComponents.Sources.RemoteControl import RemoteControl
210
211                 self["RemoteControl"] = RemoteControl(session)
212
213 class PowerWebScreen(WebScreen):
214         def __init__(self, session, request):
215                 WebScreen.__init__(self, session, request)
216                 from WebComponents.Sources.PowerState import PowerState
217
218                 self["PowerState"] = PowerState(session)
219
220 class ParentControlWebScreen(WebScreen):
221         def __init__(self, session, request):
222                 WebScreen.__init__(self, session, request)
223                 from WebComponents.Sources.ParentControl import ParentControl
224
225                 self["ParentControlList"] = ParentControl(session)
226
227 class WapWebScreen(WebScreen):
228         def __init__(self, session, request):
229                 WebScreen.__init__(self, session, request)
230                 from WebComponents.Sources.WAPfunctions import WAPfunctions
231
232                 self["WAPFillOptionListYear"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
233                 self["WAPFillOptionListDay"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
234                 self["WAPFillOptionListMonth"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
235                 self["WAPFillOptionListShour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
236                 self["WAPFillOptionListSmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
237                 self["WAPFillOptionListEhour"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
238                 self["WAPFillOptionListEmin"] = WAPfunctions(session, func=WAPfunctions.LISTTIME)
239
240                 self["WAPFillOptionListRecord"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
241                 self["WAPFillOptionListAfterEvent"] = WAPfunctions(session, func=WAPfunctions.OPTIONLIST)
242
243                 self["WAPFillValueName"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
244                 self["WAPFillValueDescr"] = WAPfunctions(session, func=WAPfunctions.FILLVALUE)
245                 self["WAPFillLocation"] = WAPfunctions(session, func=WAPfunctions.LOCATIONLIST)
246                 self["WAPFillTags"] = WAPfunctions(session, func=WAPfunctions.TAGLIST)
247
248                 self["WAPFillOptionListRepeated"] = WAPfunctions(session, func=WAPfunctions.REPEATED)
249                 self["WAPServiceList"] = WAPfunctions(session, func=WAPfunctions.SERVICELIST)
250
251                 self["WAPdeleteOldOnSave"] = WAPfunctions(session, func=WAPfunctions.DELETEOLD)
252
253 streamingScreens = []
254
255 class StreamingWebScreen(WebScreen):
256         def __init__(self, session, request):
257                 WebScreen.__init__(self, session, request)
258                 from Components.Sources.StreamService import StreamService
259                 self["StreamService"] = StreamService(self.session.nav)
260                 streamingScreens.append(self)
261                 self.screenIndex = len(streamingScreens) - 1
262
263         def getRecordService(self):
264                 if self.has_key("StreamService"):
265                         return self["StreamService"].getService()
266                 return None
267
268         def getRecordServiceRef(self):
269                 if self.has_key("StreamService"):
270                         return self["StreamService"].ref
271                 return None
272
273 class M3uStreamingWebScreen(WebScreen):
274         def __init__(self, session, request):
275                 WebScreen.__init__(self, session, request)
276                 from Components.Sources.StaticText import StaticText
277                 from Components.Sources.Config import Config
278                 from Components.config import config
279                 self["ref"] = StaticText()
280                 self["localip"] = RequestData(request, what=RequestData.HOST)
281
282 class M3uStreamingCurrentServiceWebScreen(WebScreen):
283         def __init__(self, session, request):
284                 WebScreen.__init__(self, session, request)
285                 from WebComponents.Sources.CurrentService import CurrentService
286
287                 self["CurrentService"] = CurrentService(session)
288                 self["localip"] = RequestData(request, what=RequestData.HOST)
289
290 class TsM3uWebScreen(WebScreen):
291         def __init__(self, session, request):
292                 WebScreen.__init__(self, session, request)
293                 from Components.Sources.StaticText import StaticText
294                 from Components.Sources.Config import Config
295                 from Components.config import config
296                 self["file"] = StaticText()
297                 self["localip"] = RequestData(request, what=RequestData.HOST)
298
299 class RestartWebScreen(WebScreen):
300         def __init__(self, session, request):
301                 WebScreen.__init__(self, session, request)
302                 import plugin
303                 plugin.restartWebserver(session)
304
305 class GetPidWebScreen(WebScreen):
306         def __init__(self, session, request):
307                  WebScreen.__init__(self, session, request)
308                  from Components.Sources.StaticText import StaticText
309                  from enigma import iServiceInformation
310                  pids = self.session.nav.getCurrentService()
311                  if pids is not None:
312                         pidinfo = pids.info()
313                         VPID = hex(pidinfo.getInfo(iServiceInformation.sVideoPID))
314                         APID = hex(pidinfo.getInfo(iServiceInformation.sAudioPID))
315                         PPID = hex(pidinfo.getInfo(iServiceInformation.sPMTPID))
316                         self["pids"] = StaticText("%s,%s,%s" % (PPID.lstrip("0x"), VPID.lstrip("0x"), APID.lstrip("0x")))
317                  else:
318                         self["pids"] = StaticText("0x,0x,0x")
319
320                  self["localip"] = RequestData(request, what=RequestData.HOST)
321
322 class DeviceInfoWebScreen(WebScreen):
323         def __init__(self, session, request):
324                 WebScreen.__init__(self, session, request)
325                 from WebComponents.Sources.Network import Network
326                 from WebComponents.Sources.Hdd import Hdd
327                 from WebComponents.Sources.Frontend import Frontend
328                 from Components.config import config
329                 from Components.About import about
330                 from Components.Sources.StaticText import StaticText
331                 from Tools.DreamboxHardware import getFPVersion
332                 from Tools.HardwareInfo import HardwareInfo
333
334                 hw = HardwareInfo()
335
336                 self["Network"] = Network()
337                 self["Hdd"] = Hdd()
338                 self["Frontends"] = Frontend()
339                 self["EnigmaVersion"] = StaticText(about.getEnigmaVersionString())
340                 self["ImageVersion"] = StaticText(about.getVersionString())
341                 self["WebIfVersion"] = StaticText(config.plugins.Webinterface.version.value)
342                 self["FpVersion"] = StaticText(str(getFPVersion()))
343                 self["DeviceName"] = StaticText(hw.get_device_name())