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