Added Partnerbox Plugin (Remote Timer and Remote TV Player)
[enigma2-plugins.git] / partnerbox / src / RemoteTimerEntry.py
1 #
2 #  Partnerbox E2
3 #  Release: 0.93
4 #  Coded by Dr.Best (c) 2009
5 #  Support: www.dreambox-tools.info
6 #
7 #  This program is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU General Public License
9 #  as published by the Free Software Foundation; either version 2
10 #  of the License, or (at your option) any later version.
11 #
12 #  This program is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #  GNU General Public License for more details.
16 #
17
18 from Screens.Screen import Screen
19 import Screens.ChannelSelection
20 from ServiceReference import ServiceReference
21 from Components.config import config, ConfigSelection, ConfigText, ConfigSubList, ConfigDateTime, ConfigClock, ConfigYesNo, getConfigListEntry
22 from Components.ActionMap import NumberActionMap
23 from Components.ConfigList import ConfigListScreen
24 from Components.MenuList import MenuList
25 from Components.Button import Button
26 from Components.Label import Label
27 from Components.Pixmap import Pixmap
28 from Screens.MovieSelection import getPreferredTagEditor
29 from Screens.LocationBox import MovieLocationBox
30 from Screens.ChoiceBox import ChoiceBox
31 from RecordTimer import AFTEREVENT
32 from Tools.Directories import resolveFilename, SCOPE_HDD
33 from enigma import eEPGCache
34 from time import localtime, mktime, time, strftime
35 from datetime import datetime
36 from Screens.TimerEntry import TimerEntry
37 from Screens.MessageBox import MessageBox
38 from Tools.BoundFunction import boundFunction
39 import urllib
40
41 from twisted.internet import reactor
42 from twisted.web import client
43 from twisted.web.client import HTTPClientFactory
44 from base64 import encodestring
45 import xml.dom.minidom
46
47
48
49 class myHTTPClientFactory(HTTPClientFactory):
50         def __init__(self, url, method='GET', postdata=None, headers=None,
51         agent="Twisted Remotetimer", timeout=0, cookies=None,
52         followRedirect=1, lastModified=None, etag=None):
53                 HTTPClientFactory.__init__(self, url, method=method, postdata=postdata,
54                 headers=headers, agent=agent, timeout=timeout, cookies=cookies,followRedirect=followRedirect)
55
56
57 def sendPartnerBoxWebCommand(url, contextFactory=None, timeout=60, username = "root", password = "", *args, **kwargs):
58         scheme, host, port, path = client._parse(url)
59         basicAuth = encodestring(("%s:%s")%(username,password))
60         authHeader = "Basic " + basicAuth.strip()
61         AuthHeaders = {"Authorization": authHeader}
62         if kwargs.has_key("headers"):
63                 kwargs["headers"].update(AuthHeaders)
64         else:
65                 kwargs["headers"] = AuthHeaders
66         factory = myHTTPClientFactory(url, *args, **kwargs)
67         reactor.connectTCP(host, port, factory, timeout=timeout)
68         return factory.deferred
69
70 class PlaylistEntry:
71
72         PlaylistEntry=1                 # normal PlaylistEntry (no Timerlist entry)
73         SwitchTimerEntry=2              #simple service switch timer
74         RecTimerEntry=4                 #timer do recording
75         
76         recDVR=8                                #timer do DVR recording
77         recVCR=16                               #timer do VCR recording (LIRC) not used yet
78         recNgrab=131072                 #timer do record via Ngrab Server
79
80         stateWaiting=32                 #timer is waiting
81         stateRunning=64                 #timer is running
82         statePaused=128                 #timer is paused
83         stateFinished=256               #timer is finished
84         stateError=512                  #timer has error state(s)
85
86         errorNoSpaceLeft=1024   #HDD no space Left ( recDVR )
87         errorUserAborted=2048   #User Action aborts this event
88         errorZapFailed=4096             #Zap to service failed
89         errorOutdated=8192              #Outdated event
90
91         boundFile=16384                 #Playlistentry have an bounded file
92         isSmartTimer=32768              #this is a smart timer (EIT related) not uses Yet
93         isRepeating=262144              #this timer is repeating
94         doFinishOnly=65536              #Finish an running event/action
95
96         doShutdown=67108864             #timer shutdown the box
97         doGoSleep=134217728             #timer set box to standby
98
99         Su=524288
100         Mo=1048576
101         Tue=2097152
102         Wed=4194304
103         Thu=8388608
104         Fr=16777216
105         Sa=33554432
106
107 class RemoteTimerEntry(Screen, ConfigListScreen):
108         skin = """
109                 <screen name="RemoteTimerEntry" position="90,95" size="560,430" title="Timer entry">
110                         <widget name="cancel" pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
111                         <widget name="ok" pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
112                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
113                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
114                         <widget name="canceltext" position="0,0" zPosition="2" size="140,40" halign="center" valign="center" font="Regular;21" backgroundColor="#9f1313" transparent="1" />
115                         <widget name="oktext" position="140,0" zPosition="2" size="140,40" halign="center" valign="center" font="Regular;21" backgroundColor="#1f771f" transparent="1" />
116                         <widget name="config" position="10,45" size="540,385" scrollbarMode="showOnDemand" />
117                 </screen>"""
118
119         def __init__(self, session, timer, Locations):
120                 self.session = session
121                 Screen.__init__(self, session)
122                 self.timer = timer
123                 self.Locations = Locations
124                 self.entryDate = None
125                 self.entryService = None
126                 self["oktext"] = Label(_("OK"))
127                 self["canceltext"] = Label(_("Cancel"))
128                 self["ok"] = Pixmap()
129                 self["cancel"] = Pixmap()
130                 self.createConfig()
131                 self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions"],
132                 {
133                         "save": self.keyGo,
134                         "cancel": self.keyCancel,
135                         "volumeUp": self.incrementStart,
136                         "volumeDown": self.decrementStart,
137                         "size+": self.incrementEnd,
138                         "size-": self.decrementEnd
139                 }, -2)
140                 self.list = []
141                 ConfigListScreen.__init__(self, self.list, session = session)
142                 self.createSetup("config")
143
144         def createConfig(self):
145                 
146                 if self.timer.type == 0:
147                         justplay = self.timer.justplay
148                         afterevent = {
149                                 0: "nothing",
150                                 2: "deepstandby",
151                                 1: "standby",
152                                 3: "auto"
153                                 }[self.timer.afterevent]
154                 else:
155                         if self.timer.type & PlaylistEntry.doShutdown:
156                                 afterevent = PlaylistEntry.doShutdown
157                         elif self.timer.type & PlaylistEntry.doGoSleep:
158                                 afterevent = PlaylistEntry.doGoSleep
159                         else:
160                                 afterevent = 0
161                 
162                         if self.timer.type & PlaylistEntry.RecTimerEntry:
163                                 if self.timer.type & PlaylistEntry.recDVR:
164                                         justplay = PlaylistEntry.recDVR
165                                 elif self.timer.type & PlaylistEntry.recNgrab:
166                                         justplay = PlaylistEntry.recNgrab
167                         elif self.timer.type & PlaylistEntry.SwitchTimerEntry:
168                                 justplay = PlaylistEntry.SwitchTimerEntry
169                 
170                 weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun")
171                 day = []
172                 weekday = 0
173                 for x in (0, 1, 2, 3, 4, 5, 6):
174                         day.append(0)
175                 begin = self.timer.timebegin
176                 end = self.timer.timeend
177                 weekday = (int(strftime("%w", localtime(begin))) - 1) % 7
178                 day[weekday] = 1
179                 name = self.timer.name 
180                 description = self.timer.description
181                 if self.timer.type == 0:
182                         self.timerentry_justplay = ConfigSelection(choices = [("1", _("zap")), ("0", _("record"))], default = str(justplay))
183                         self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby")), ("auto", _("auto"))], default = afterevent)
184                         self.timerentry_name = ConfigText(default = name, visible_width = 50, fixed_size = False)
185                 else:
186                         self.timerentry_justplay = ConfigSelection(choices = [(str(PlaylistEntry.SwitchTimerEntry), _("zap")), (str(PlaylistEntry.recNgrab), _("NGRAB")),(str(PlaylistEntry.recDVR), _("DVR"))], default = str(justplay))
187                         self.timerentry_afterevent = ConfigSelection(choices = [("0", _("do nothing")), (str(PlaylistEntry.doGoSleep), _("go to standby")), (str(PlaylistEntry.doShutdown), _("go to deep standby"))], default = str(afterevent))
188                 self.timerentry_description = ConfigText(default = description, visible_width = 50, fixed_size = False)
189                 self.timerentry_date = ConfigDateTime(default = begin, formatstring = _("%d.%B %Y"), increment = 86400)
190                 self.timerentry_starttime = ConfigClock(default = begin)
191                 self.timerentry_endtime = ConfigClock(default = end)
192                 if self.timer.type == 0:
193                         default = self.timer.dirname
194                         if default not in self.Locations:
195                                 self.Locations.append(default)
196                         self.timerentry_dirname = ConfigSelection(default = default, choices = self.Locations)
197                 self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))])
198                 self.timerentry_day = ConfigSubList()
199                 for x in (0, 1, 2, 3, 4, 5, 6):
200                         self.timerentry_day.append(ConfigYesNo(default = day[x]))
201                 servicename = self.timer.servicename
202                 self.timerentry_service = ConfigSelection([servicename])
203
204         def createSetup(self, widget):
205                 self.list = []
206                 if self.timer.type == 0:
207                         self.list.append(getConfigListEntry(_("Name"), self.timerentry_name))
208                 self.list.append(getConfigListEntry(_("Description"), self.timerentry_description))
209                 self.timerJustplayEntry = getConfigListEntry(_("Timer Type"), self.timerentry_justplay)
210                 self.list.append(self.timerJustplayEntry)
211                 self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date)
212                 self.list.append(self.entryDate)
213                 self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime)
214                 self.list.append(self.entryStartTime)
215                 if self.timer.type == 0:
216                         if int(self.timerentry_justplay.value) != 1:
217                                 self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime)
218                                 self.list.append(self.entryEndTime)
219                         else:
220                                 self.entryEndTime = None
221                 else:
222                         self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime)
223                         self.list.append(self.entryEndTime)
224                 self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service)
225                 self.list.append(self.channelEntry)
226                 if self.timer.type == 0:
227                         self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname)
228                         if int(self.timerentry_justplay.value) != 1:
229                                 self.list.append(self.dirname)
230                                 self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent))
231                 else:
232                         self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent))
233                 self[widget].list = self.list
234                 self[widget].l.setList(self.list)
235                 
236         def newConfig(self):
237                 if self["config"].getCurrent() == self.timerJustplayEntry:
238                         self.createSetup("config")
239                         
240         def keyLeft(self):
241                 ConfigListScreen.keyLeft(self)
242                 self.newConfig()
243
244         def keyRight(self):
245                 ConfigListScreen.keyRight(self)
246                 self.newConfig()
247                 
248         def getTimestamp(self, date, mytime):
249                 d = localtime(date)
250                 dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1])
251                 return int(mktime(dt.timetuple()))
252
253         def getBeginEnd(self):
254                 date = self.timerentry_date.value
255                 endtime = self.timerentry_endtime.value
256                 starttime = self.timerentry_starttime.value
257                 begin = self.getTimestamp(date, starttime)
258                 end = self.getTimestamp(date, endtime)
259                 if end < begin:
260                         end += 86400
261                 return begin, end
262
263         def keyCancel(self):
264                 self.close((False,))
265                 
266         def keyGo(self):
267                 if self.timer.type == 0:
268                         self.timer.name = self.timerentry_name.value
269                         self.timer.dirname = self.timerentry_dirname.value
270                         self.timer.afterevent = {
271                         "nothing": 0,
272                         "deepstandby": 2,
273                         "standby": 1,
274                         "auto": 3
275                         }[self.timerentry_afterevent.value]
276                 else:
277                         self.timer.afterevent = int(self.timerentry_afterevent.value)
278                 self.timer.description = self.timerentry_description.value
279                 self.timer.justplay = int(self.timerentry_justplay.value)
280                 
281                 self.timer.timebegin, self.timer.timeend = self.getBeginEnd()
282                 self.close((True, self.timer))
283
284         def incrementStart(self):
285                 self.timerentry_starttime.increment()
286                 self["config"].invalidate(self.entryStartTime)
287
288         def decrementStart(self):
289                 self.timerentry_starttime.decrement()
290                 self["config"].invalidate(self.entryStartTime)
291
292         def incrementEnd(self):
293                 if self.entryEndTime is not None:
294                         self.timerentry_endtime.increment()
295                         self["config"].invalidate(self.entryEndTime)
296
297         def decrementEnd(self):
298                 if self.entryEndTime is not None:
299                         self.timerentry_endtime.decrement()
300                         self["config"].invalidate(self.entryEndTime)
301                         
302                         
303                         
304 # ##########################################
305 # TimerEntry
306 # ##########################################
307 baseTimerEntrySetup = None
308 baseTimerEntryGo = None
309 baseTimerEntrynewConfig = None
310 baseTimerkeyLeft = None
311 baseTimerkeyRight = None
312 baseTimercreateConfig = None
313
314 def RemoteTimerInit():
315         global baseTimerEntrySetup, baseTimerEntryGo, baseTimerEntrynewConfig, baseTimerkeyLeft, baseTimerkeyRight, baseTimercreateConfig
316         if baseTimerEntrySetup is None:
317                 baseTimerEntrySetup = TimerEntry.createSetup
318         if baseTimerEntryGo is None:
319                 baseTimerEntryGo = TimerEntry.keyGo
320         if baseTimerEntrynewConfig is None:
321                 baseTimerEntrynewConfig = TimerEntry.newConfig
322         if baseTimerkeyLeft is None:
323                 baseTimerkeyLeft = TimerEntry.keyLeft
324         if baseTimerkeyRight is None:
325                 baseTimerkeyRight = TimerEntry.keyRight
326         if baseTimercreateConfig is None:
327                 baseTimercreateConfig  = TimerEntry.createConfig
328         
329         TimerEntry.createConfig = RemoteTimerCreateConfig
330         TimerEntry.keyLeft = RemoteTimerkeyLeft 
331         TimerEntry.keyRight = RemoteTimerkeyRight
332         TimerEntry.createSetup = createRemoteTimerSetup
333         TimerEntry.keyGo = RemoteTimerGo
334         TimerEntry.newConfig = RemoteTimernewConfig
335         
336 def RemoteTimerCreateConfig(self):
337         
338         self.password = config.plugins.partnerbox.password.value
339         self.username = "root"
340         self.ip = "%d.%d.%d.%d" % tuple(config.plugins.partnerbox.ip.value)
341         port = config.plugins.partnerbox.port.value
342         self.http = "http://%s:%d" % (self.ip,port)
343         self.Locations = []
344         self.enigmatype = int(config.plugins.partnerbox.enigma.value) # E2 = 0 | E1 = 1
345         self.timerentry_remote = ConfigYesNo()
346         baseTimercreateConfig(self)
347
348 #def getLocationsError(self, error):
349 #       RemoteTimercreateConfig(self)
350 #       RemoteTimerCreateSetup(self,"config")
351         
352 def getLocationsCallback(self, xmlstring):
353         self.Locations = []
354         dom = xml.dom.minidom.parseString(xmlstring)
355         for node in dom.firstChild.childNodes:
356                 dirname = ""
357                 if node.nodeName == "e2simplexmlitem":
358                         dirname = str(node.firstChild.data.strip().encode("utf-8"))
359                         self.Locations.append(dirname)
360         RemoteTimercreateConfig(self)
361         RemoteTimerCreateSetup(self,"config")
362                 
363 def createRemoteTimerSetup(self, widget):
364         baseTimerEntrySetup(self, widget)
365         self.display = _("Remote Timer (%s)") % (self.ip)
366         self.timerRemoteEntry = getConfigListEntry(self.display, self.timerentry_remote)
367         self.list.insert(0, self.timerRemoteEntry)
368         self[widget].list = self.list
369         
370 def RemoteTimerkeyLeft(self):
371         if self.timerentry_remote.value:
372                 ConfigListScreen.keyLeft(self)
373                 RemoteTimernewConfig(self)
374         else:
375                 baseTimerkeyLeft(self)
376
377 def RemoteTimerkeyRight(self):
378         if self.timerentry_remote.value:
379                 ConfigListScreen.keyRight(self)
380                 RemoteTimernewConfig(self)
381         else:
382                 baseTimerkeyRight(self)
383         
384 def RemoteTimernewConfig(self):
385         if self["config"].getCurrent() == self.timerRemoteEntry:
386                 if self.timerentry_remote.value:
387                         if self.enigmatype == 1: # E1
388                                 self.timertype = PlaylistEntry.RecTimerEntry|PlaylistEntry.recDVR
389                         else: # E2
390                                 self.timertype = 0
391                                 sCommand = "http://" + self.username + ":" + self.password + "@" + self.ip + "/web/getlocations"
392                                 #sCommand = self.http + "/web/getlocations"
393                                 #sendPartnerBoxWebCommand(sCommand, None,3, self.username, self.password).addCallback(boundFunction(getLocationsCallback,self)).addErrback(boundFunction(getLocationsError,self))
394                                 # ich mach das besser synchron, falls die Partnerbox aus ist ( dann koennte man hier schon abbrechen und eine Meldung bringen...)
395                                 try:
396                                         f = urllib.urlopen(sCommand)
397                                         sxml = f.read()
398                                         getLocationsCallback(self,sxml)
399                                 except: pass
400                         RemoteTimercreateConfig(self)
401                         RemoteTimerCreateSetup(self,"config")
402                 else:
403                         baseTimercreateConfig(self)
404                         createRemoteTimerSetup(self, "config")
405         elif self["config"].getCurrent() == self.timerJustplayEntry:
406                 if self.timerentry_remote.value:
407                         RemoteTimerCreateSetup(self,"config")
408                 else:
409                         baseTimerEntrynewConfig(self)
410         else:
411                         if not self.timerentry_remote.value:
412                                 baseTimerEntrynewConfig(self)
413         
414 def  RemoteTimercreateConfig(self):
415         if self.enigmatype == 0:
416                 justplay = self.timer.justplay
417                 afterevent = {
418                         AFTEREVENT.NONE: "nothing",
419                         AFTEREVENT.DEEPSTANDBY: "deepstandby",
420                          AFTEREVENT.STANDBY: "standby",
421                          AFTEREVENT.AUTO: "auto"
422                         }[self.timer.afterEvent]
423         else:
424                 if self.timertype & PlaylistEntry.doShutdown:
425                         afterevent = PlaylistEntry.doShutdown
426                 elif self.timertype & PlaylistEntry.doGoSleep:
427                         afterevent = PlaylistEntry.doGoSleep
428                 else:
429                         afterevent = 0
430                 if self.timertype & PlaylistEntry.RecTimerEntry:
431                         if self.timertype & PlaylistEntry.recDVR:
432                                 justplay = PlaylistEntry.recDVR
433                         elif self.timertype & PlaylistEntry.recNgrab:
434                                 justplay = PlaylistEntry.recNgrab
435                 elif self.timertype & PlaylistEntry.SwitchTimerEntry:
436                         justplay = PlaylistEntry.SwitchTimerEntry
437         weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun")
438         day = []
439         weekday = 0
440         for x in (0, 1, 2, 3, 4, 5, 6):
441                 day.append(0)
442         begin = self.timer.begin
443         end = self.timer.end
444         weekday = (int(strftime("%w", localtime(begin))) - 1) % 7
445         day[weekday] = 1
446         if self.enigmatype == 0:
447                 name = self.timer.name 
448                 description = self.timer.description
449                 self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[justplay])
450                 self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby")), ("auto", _("auto"))], default = afterevent)
451                 self.timerentry_name = ConfigText(default = name, visible_width = 50, fixed_size = False)
452         else:
453                 description = self.timer.name 
454                 self.timerentry_justplay = ConfigSelection(choices = [(str(PlaylistEntry.SwitchTimerEntry), _("zap")), (str(PlaylistEntry.recNgrab), _("NGRAB")),(str(PlaylistEntry.recDVR), _("DVR"))], default = str(justplay))
455                 self.timerentry_afterevent = ConfigSelection(choices = [("0", _("do nothing")), (str(PlaylistEntry.doGoSleep), _("go to standby")), (str(PlaylistEntry.doShutdown), _("go to deep standby"))], default = str(afterevent))
456         self.timerentry_description = ConfigText(default = description, visible_width = 50, fixed_size = False)
457         self.timerentry_date = ConfigDateTime(default = begin, formatstring = _("%d.%B %Y"), increment = 86400)
458         self.timerentry_starttime = ConfigClock(default = begin)
459         self.timerentry_endtime = ConfigClock(default = end)
460         if self.enigmatype == 0:
461                 default = "/hdd/movie/"
462                 if default not in self.Locations:
463                         self.Locations.append(default)
464                 self.timerentry_dirname = ConfigSelection(default = default, choices = self.Locations)
465         self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))])
466         self.timerentry_day = ConfigSubList()
467         for x in (0, 1, 2, 3, 4, 5, 6):
468                 self.timerentry_day.append(ConfigYesNo(default = day[x]))
469         # FIXME some service-chooser needed here
470         servicename = "N/A"
471         try: # no current service available?
472                 servicename = str(self.timer.service_ref.getServiceName())
473         except:
474                 pass
475         self.timerentry_service_ref = self.timer.service_ref
476         self.timerentry_service = ConfigSelection([servicename])
477
478 def RemoteTimerCreateSetup(self, widget):
479         self.list = []
480         self.timerRemoteEntry = getConfigListEntry(self.display, self.timerentry_remote)
481         self.list.append(self.timerRemoteEntry)
482         if self.enigmatype == 0:
483                 self.list.append(getConfigListEntry(_("Name"), self.timerentry_name))
484         self.list.append(getConfigListEntry(_("Description"), self.timerentry_description))
485         self.timerJustplayEntry = getConfigListEntry(_("Timer Type"), self.timerentry_justplay)
486         self.list.append(self.timerJustplayEntry)
487         self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date)
488         self.list.append(self.entryDate)
489         self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime)
490         self.list.append(self.entryStartTime)
491         if self.enigmatype == 0:
492                 if self.timerentry_justplay.value != "zap":
493                         self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime)
494                         self.list.append(self.entryEndTime)
495                 else:
496                         self.entryEndTime = None
497         else:
498                 self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime)
499                 self.list.append(self.entryEndTime)
500         self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service)
501         self.list.append(self.channelEntry)
502         if self.enigmatype == 0:
503                 self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname)
504                 if self.timerentry_justplay.value != "zap":
505                         self.list.append(self.dirname)
506                         self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent))
507         else:
508                 self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent))
509         self[widget].list = self.list
510         self[widget].l.setList(self.list)
511
512 def RemoteTimerGo(self):
513         if not self.timerentry_remote.value:
514                 baseTimerEntryGo(self)
515         else:
516                 service_ref = self.timerentry_service_ref
517                 descr = urllib.quote(self.timerentry_description.value)
518                 begin, end = self.getBeginEnd()
519                 if self.enigmatype == 1:
520                         # E1
521                         afterevent = self.timerentry_afterevent.value
522                         justplay = int(self.timerentry_justplay.value)
523                         if justplay & PlaylistEntry.SwitchTimerEntry:
524                                 action = "zap"
525                         elif justplay & PlaylistEntry.recNgrab:
526                                 action = "ngrab"
527                         else:
528                                 action = ""
529                         # FIXME some service-chooser needed here
530                         servicename = "N/A"
531                         try: # no current service available?
532                                 servicename = str(service_ref .getServiceName())
533                         except:
534                                 pass
535                         channel = urllib.quote(servicename)
536                         sCommand = "%s/addTimerEvent?ref=%s&start=%d&duration=%d&descr=%s&channel=%s&after_event=%s&action=%s" % (self.http, service_ref , begin, end - begin, descr, channel, afterevent, action)
537                         sendPartnerBoxWebCommand(sCommand, None,3, self.username, self.password).addCallback(boundFunction(AddTimerE1Callback,self, self.session)).addErrback(boundFunction(AddTimerError,self, self.session))
538                 else:
539                         # E2
540                         name = urllib.quote(self.timerentry_name.value)
541                         self.timer.tags = self.timerentry_tags
542                         if self.timerentry_justplay.value == "zap":
543                                 justplay = 1
544                                 dirname = ""
545                         else:
546                                 justplay = 0
547                                 dirname = self.timerentry_dirname.value
548                         afterevent = {
549                         "deepstandby": AFTEREVENT.DEEPSTANDBY,
550                         "standby": AFTEREVENT.STANDBY,
551                         }.get(self.timerentry_afterevent.value, AFTEREVENT.NONE)
552                         sCommand = "%s/web/timeradd?sRef=%s&begin=%d&end=%d&name=%s&description=%s&dirname=%s&eit=0&justplay=%d&afterevent=%s" % (self.http, service_ref,begin,end,name,descr,dirname,justplay,afterevent)
553                         sendPartnerBoxWebCommand(sCommand, None,3, self.username, self.password).addCallback(boundFunction(AddTimerE2Callback,self, self.session)).addErrback(boundFunction(AddTimerError,self,self.session))
554
555 def AddTimerE2Callback(self, session, answer):
556         text = ""
557         dom = xml.dom.minidom.parseString(answer)
558         for node in dom.firstChild.childNodes:
559                 dirname = ""
560                 if node.nodeName == "e2statetext":
561                         text = str(node.firstChild.data.strip().encode("utf-8"))
562         ok = text == "Timer added successfully!"
563         session.open(MessageBox,_("Partnerbox Answer: \n%s") % (text),MessageBox.TYPE_INFO)
564         if ok:
565                 self.keyCancel()
566
567 def AddTimerE1Callback(self, session, answer):
568         ok = answer == "Timer event was created successfully."
569         session.open(MessageBox,_("Partnerbox Answer: \n%s") % (answer),MessageBox.TYPE_INFO)
570         if ok:
571                 self.keyCancel()
572                 
573 def AddTimerError(self, session, error):
574         session.open(MessageBox,str(error.getErrorMessage()),MessageBox.TYPE_INFO)
575