Use IMDb also for event info
[enigma2-plugins.git] / merlinepg / src / plugin.py
1 #######################################################################
2 #
3 #    Merlin Programm Guide for Dreambox-Enigma2
4 #    Coded by Vali (c)2010
5 #    Support: www.dreambox-tools.info
6 #
7 #
8 #  This plugin is licensed under the Creative Commons 
9 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
10 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
11 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
12 #
13 #  Alternatively, this plugin may be distributed and executed on hardware which
14 #  is licensed by Dream Multimedia GmbH.
15 #
16 #
17 #  This plugin is NOT free software. It is open source, you are allowed to
18 #  modify it (if you keep the license), but it may not be commercially 
19 #  distributed other than under the conditions noted above.
20 #
21 #
22 #######################################################################
23
24
25
26 from Plugins.Plugin import PluginDescriptor
27 from Screens.Screen import Screen
28 from Screens.EventView import EventViewSimple
29 from Screens.MessageBox import MessageBox
30 from Screens.ChoiceBox import ChoiceBox
31 from Screens.TimerEntry import TimerEntry
32 from Screens.TimerEdit import TimerSanityConflict
33 from Components.ConfigList import ConfigListScreen
34 from Components.ActionMap import ActionMap
35 from Components.MenuList import MenuList
36 from Components.Label import Label
37 from Components.EpgList import EPGList, EPG_TYPE_SINGLE, Rect
38 from Components.config import config, ConfigSubsection, ConfigYesNo, ConfigInteger, getConfigListEntry
39 from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN, fileExists
40 from Tools.LoadPixmap import LoadPixmap
41 from enigma import eServiceReference, eServiceCenter, getDesktop, eTimer, gFont, eListboxPythonMultiContent, RT_HALIGN_LEFT, RT_WRAP
42 from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT
43 from ServiceReference import ServiceReference
44 from ShowMe import ShowMe
45 from time import localtime
46 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/AutoTimerEditor.pyo") or fileExists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/AutoTimerEditor.pyc"):
47         from Plugins.Extensions.AutoTimer.AutoTimerEditor import addAutotimerFromEvent
48         from Plugins.Extensions.AutoTimer.plugin import main as AutoTimerView
49         AutoTimerPresent=True
50 else:
51         AutoTimerPresent=False
52 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IMDb/plugin.pyo") or fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IMDb/plugin.pyc"):
53         from Plugins.Extensions.IMDb.plugin import IMDB
54         IMDbPresent=True
55 else:
56         IMDbPresent=False
57
58
59 config.plugins.MerlinEPG = ConfigSubsection()
60 config.plugins.MerlinEPG.Columns = ConfigYesNo(default=True)
61 config.plugins.MerlinEPG.StartFirst = ConfigYesNo(default=False)
62 config.plugins.MerlinEPG.Primetime  = ConfigInteger(default=20, limits=(0, 23))
63 config.plugins.MerlinEPG.PTlow  = ConfigInteger(default=10, limits=(0, 59))
64 config.plugins.MerlinEPG.PThi  = ConfigInteger(default=20, limits=(0, 59))
65 config.plugins.MerlinEPG.AutoPT  = ConfigYesNo(default=False)
66 config.plugins.MerlinEPG.ZapOnOK  = ConfigYesNo(default=False)
67 config.plugins.MerlinEPG.PageUDonBouquets  = ConfigYesNo(default=True)
68
69
70
71 def Plugins(**kwargs):
72         list = [(PluginDescriptor(name="Merlin Programm Guide", description="Merlin Programm Guide", where = PluginDescriptor.WHERE_EVENTINFO, fnc=startMerlinPG))]
73         list.append(PluginDescriptor(name="Merlin Programm Guide", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=startMerlinPGnew))
74         return list
75
76
77
78 def startMerlinPG(session, servicelist, **kwargs):
79         if config.plugins.MerlinEPG.Columns.value:
80                 session.open(Merlin_PGII, servicelist)
81         else:
82                 session.open(Merlin_PGd, servicelist)
83
84
85
86 def startMerlinPGnew(session, **kwargs):
87         if "servicelist" in kwargs:
88                 if config.plugins.MerlinEPG.Columns.value:
89                         session.open(Merlin_PGII, kwargs["servicelist"])
90                 else:
91                         session.open(Merlin_PGd, kwargs["servicelist"])
92         else:
93                 if config.plugins.MerlinEPG.Columns.value:
94                         session.open(Merlin_PGII)
95                 else:
96                         session.open(Merlin_PGd)
97
98
99
100 class MerlinPGsetup(ConfigListScreen, Screen):
101         skin = """
102                 <screen position="center,center" size="600,300" title="Merlin Programm Guide">
103                         <widget name="config" position="10,10" size="580,280" scrollbarMode="showOnDemand" />
104                 </screen>"""
105
106         def __init__(self, session):
107                 Screen.__init__(self, session)
108                 clist = []
109                 clist.append(getConfigListEntry(_("Show EPG in columns:"), config.plugins.MerlinEPG.Columns))
110                 clist.append(getConfigListEntry(_("Start allways on channel 1:"), config.plugins.MerlinEPG.StartFirst))
111                 clist.append(getConfigListEntry(_("Primetime (h):"), config.plugins.MerlinEPG.Primetime))
112                 clist.append(getConfigListEntry(_("Primetime from (m):"), config.plugins.MerlinEPG.PTlow))
113                 clist.append(getConfigListEntry(_("Primetime to (m):"), config.plugins.MerlinEPG.PThi))
114                 clist.append(getConfigListEntry(_("Auto-Primetime:"), config.plugins.MerlinEPG.AutoPT))
115                 clist.append(getConfigListEntry(_("Zap with OK button (false=EventInfo):"), config.plugins.MerlinEPG.ZapOnOK))
116                 clist.append(getConfigListEntry(_("Page-up/down with bouquet+/- :"), config.plugins.MerlinEPG.PageUDonBouquets))
117                 ConfigListScreen.__init__(self, clist)
118                 self["actions"] = ActionMap(["OkCancelActions"], {"ok": self.set, "cancel": self.exit}, -2)
119
120         def set(self):
121                 if not config.plugins.MerlinEPG.PThi.value > config.plugins.MerlinEPG.PTlow.value:
122                         return
123                 for x in self["config"].list:
124                         x[1].save()
125                 self.close()
126
127         def exit(self):
128                 for x in self["config"].list:
129                         x[1].cancel()
130                 self.close()
131
132
133
134 class MerlinEPGList(EPGList):
135         def __init__(self, type=EPG_TYPE_SINGLE, selChangedCB=None, timer = None):
136                 EPGList.__init__(self, type, selChangedCB, timer)
137                 self.l.setFont(0, gFont("Regular", 18))
138                 self.PTpicture = LoadPixmap(cached=True, path="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/primetime.png")
139                 self.evCnt = 0
140
141         def recalcEntrySize(self):
142                 esize = self.l.getItemSize()
143                 width = esize.width()
144                 height = esize.height()
145                 self.weekday_rect = Rect(120, -10, 200, 20)
146                 self.datetime_rect = Rect(0, 0, 120, 20)
147                 self.descr_rect = Rect(0, 22, width, height-23)
148                 self.evCnt = 0
149
150         def buildSingleEntry(self, service, eventId, beginTime, duration, EventName):
151                 (clock_pic, rec) = self.getPixmapForEntry(service, eventId, beginTime, duration)
152                 r1=self.weekday_rect
153                 r2=self.datetime_rect
154                 r3=self.descr_rect
155                 t = localtime(beginTime)
156                 self.evCnt = self.evCnt + 1
157                 if (t[3]==config.plugins.MerlinEPG.Primetime.value) and (t[4]>=config.plugins.MerlinEPG.PTlow.value) and (t[4]<config.plugins.MerlinEPG.PThi.value):
158                         res = [
159                                 None,
160                                 (eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, "  _________________"),
161                                 (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 100, 1, 21, 21, self.PTpicture),
162                                 (eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_LEFT, (("%02d:%02d"%(t[3],t[4]))+" - "+self.days[t[6]]))
163                         ]
164                 else:
165                         res = [
166                                 None,
167                                 (eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, "___________________"),
168                                 (eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_LEFT, (("%02d:%02d"%(t[3],t[4]))+" - "+self.days[t[6]]))
169                         ]
170                 if rec:
171                         res.extend((
172                                 (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic),
173                                 (eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT|RT_WRAP, EventName)
174                         ))
175                 else:
176                         res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT|RT_WRAP, EventName))
177                 return res
178
179         def getBgTime(self):
180                 tmp = self.l.getCurrentSelection()
181                 if tmp is None:
182                         return ( None )
183                 bt = localtime(tmp[2])
184                 return ( bt[3], bt[4] )
185
186         def foudPrimetime(self):
187                 for OneLine in range(0,self.evCnt):
188                         evBgTime, evBgMin = self.getBgTime()
189                         if evBgTime is not None:
190                                 if (evBgTime==config.plugins.MerlinEPG.Primetime.value) and (evBgMin>=config.plugins.MerlinEPG.PTlow.value) and (evBgMin<config.plugins.MerlinEPG.PThi.value):
191                                         break
192                                 self.moveDown()
193                         else:
194                                 break
195
196
197
198 class Merlin_PGII(Screen):
199         sz_w = getDesktop(0).size().width()
200         if sz_w == 1280:
201                 skin = """
202                 <screen flags="wfNoBorder" name="Merlin_PG" position="0,0" size="1280,720" title="Merlin Program Guide">
203                 <!-- DO NOT CHANGE THIS LINE !!!!!!!!!!!!!!! --><widget enableWrapAround="0" itemHeight="25" name="prg_list" position="-200,-200" size="50,125"/>
204                         <widget font="Regular;18" halign="center" valign="center" name="currCh1" position="60,40" size="231,24" transparent="1" zPosition="2"/>
205                         <widget font="Regular;18" halign="center" valign="center" name="currCh2" position="291,40" size="231,24" transparent="1" zPosition="2"/>
206                         <widget font="Regular;18" halign="center" valign="center" name="currCh3" position="522,40" size="231,24" transparent="1" zPosition="2"/>
207                         <widget font="Regular;18" halign="center" valign="center" name="currCh4" position="753,40" size="231,24" transparent="1" zPosition="2"/>
208                         <widget font="Regular;18" halign="center" valign="center" name="currCh5" position="984,40" size="231,24" transparent="1" zPosition="2"/>
209                         <widget backgroundColor="#10444649" name="Active1" position="60,80" size="225,560" transparent="0" zPosition="3"/>
210                         <widget backgroundColor="#10444649" name="Active2" position="291,80" size="225,560" transparent="0" zPosition="3"/>
211                         <widget backgroundColor="#10444649" name="Active3" position="522,80" size="225,560" transparent="0" zPosition="3"/>
212                         <widget backgroundColor="#10444649" name="Active4" position="753,80" size="225,560" transparent="0" zPosition="3"/>
213                         <widget backgroundColor="#10444649" name="Active5" position="984,80" size="225,560" transparent="0" zPosition="3"/>
214                         <widget itemHeight="70" name="epg_list1" position="60,80" scrollbarMode="showOnDemand" size="225,560" transparent="1" zPosition="4"/>
215                         <widget itemHeight="70" name="epg_list2" position="291,80" scrollbarMode="showOnDemand" size="225,560" transparent="1" zPosition="4"/>
216                         <widget itemHeight="70" name="epg_list3" position="522,80" scrollbarMode="showOnDemand" size="225,560" transparent="1" zPosition="4"/>
217                         <widget itemHeight="70" name="epg_list4" position="753,80" scrollbarMode="showOnDemand" size="225,560" transparent="1" zPosition="4"/>
218                         <widget itemHeight="70" name="epg_list5" position="984,80" scrollbarMode="showOnDemand" size="225,560" transparent="1" zPosition="4"/>
219                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/buttons.png" position="60,655" size="430,24"/>
220                         <widget backgroundColor="background" font="Regular;18" foregroundColor="#ffc000" position="500,655" render="Label" size="200,24" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">     
221                                 <convert type="ClockToText">Format:%H:%M  %a %d. %b</convert>
222                         </widget>
223                 </screen>"""
224         elif sz_w == 1024:
225                 skin = """
226                 <screen flags="wfNoBorder" name="Merlin_PG" position="0,0" size="1024,576" title="Merlin Program Guide">
227                 <!-- DO NOT CHANGE THIS LINE !!!!!!!!!!!!!!! --><widget enableWrapAround="0" itemHeight="25" name="prg_list" position="-200,-200" size="50,100"/>
228                         <widget font="Regular;18" halign="center" valign="center" name="currCh1" position="50,40" size="231,24" transparent="1" zPosition="2"/>
229                         <widget font="Regular;18" halign="center" valign="center" name="currCh2" position="281,40" size="231,24" transparent="1" zPosition="2"/>
230                         <widget font="Regular;18" halign="center" valign="center" name="currCh3" position="512,40" size="231,24" transparent="1" zPosition="2"/>
231                         <widget font="Regular;18" halign="center" valign="center" name="currCh4" position="743,40" size="231,24" transparent="1" zPosition="2"/>
232                         <widget backgroundColor="#10444649" name="Active1" position="50,80" size="225,420" transparent="0" zPosition="3"/>
233                         <widget backgroundColor="#10444649" name="Active2" position="281,80" size="225,420" transparent="0" zPosition="3"/>
234                         <widget backgroundColor="#10444649" name="Active3" position="512,80" size="225,420" transparent="0" zPosition="3"/>
235                         <widget backgroundColor="#10444649" name="Active4" position="743,80" size="225,420" transparent="0" zPosition="3"/>
236                         <widget itemHeight="70" name="epg_list1" position="50,80" scrollbarMode="showOnDemand" size="225,420" transparent="1" zPosition="4"/>
237                         <widget itemHeight="70" name="epg_list2" position="281,80" scrollbarMode="showOnDemand" size="225,420" transparent="1" zPosition="4"/>
238                         <widget itemHeight="70" name="epg_list3" position="512,80" scrollbarMode="showOnDemand" size="225,420" transparent="1" zPosition="4"/>
239                         <widget itemHeight="70" name="epg_list4" position="743,80" scrollbarMode="showOnDemand" size="225,420" transparent="1" zPosition="4"/>
240                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/buttons.png" position="50,518" size="430,24"/>
241                         <widget backgroundColor="background" font="Regular;18" foregroundColor="#ffc000" position="490,518" render="Label" size="200,24" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">     
242                                 <convert type="ClockToText">Format:%H:%M  %a %d. %b</convert>
243                         </widget>
244                         <!-- <widget font="Regular;18" name="fullEventInfo" position="300,200" size="300,200" transparent="0" zPosition="12"/> -->
245                 </screen>"""
246         else:
247                 skin = """
248                 <screen flags="wfNoBorder" name="Merlin_PG" position="0,0" size="720,576" title="Merlin Program Guide">
249                 <!-- DO NOT CHANGE THIS LINE !!!!!!!!!!!!!!! --><widget enableWrapAround="0" itemHeight="25" name="prg_list" position="-200,-200" size="50,100"/>
250                         <widget font="Regular;18" halign="center" valign="center" name="currCh1" position="50,35" size="155,36" transparent="1" zPosition="2"/>
251                         <widget font="Regular;18" halign="center" valign="center" name="currCh2" position="205,35" size="155,36" transparent="1" zPosition="2"/>
252                         <widget font="Regular;18" halign="center" valign="center" name="currCh3" position="360,35" size="155,36" transparent="1" zPosition="2"/>
253                         <widget font="Regular;18" halign="center" valign="center" name="currCh4" position="515,35" size="155,36" transparent="1" zPosition="2"/>
254                         <widget backgroundColor="#10444649" name="Active1" position="50,90" size="155,420" transparent="0" zPosition="3"/>
255                         <widget backgroundColor="#10444649" name="Active2" position="205,90" size="155,420" transparent="0" zPosition="3"/>
256                         <widget backgroundColor="#10444649" name="Active3" position="360,90" size="155,420" transparent="0" zPosition="3"/>
257                         <widget backgroundColor="#10444649" name="Active4" position="515,90" size="155,420" transparent="0" zPosition="3"/>
258                         <widget itemHeight="70" name="epg_list1" position="50,90" scrollbarMode="showOnDemand" size="155,420" transparent="1" zPosition="4"/>
259                         <widget itemHeight="70" name="epg_list2" position="205,90" scrollbarMode="showOnDemand" size="155,420" transparent="1" zPosition="4"/>
260                         <widget itemHeight="70" name="epg_list3" position="360,90" scrollbarMode="showOnDemand" size="155,420" transparent="1" zPosition="4"/>
261                         <widget itemHeight="70" name="epg_list4" position="515,90" scrollbarMode="showOnDemand" size="155,420" transparent="1" zPosition="4"/>
262                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/buttons.png" position="50,518" size="430,24"/>
263                         <widget backgroundColor="background" font="Regular;18" foregroundColor="#ffc000" position="490,518" render="Label" size="200,24" source="global.CurrentTime" transparent="1" valign="center" zPosition="3">     
264                                 <convert type="ClockToText">Format:%H:%M  %a %d. %b</convert>
265                         </widget>
266                 </screen>"""
267
268         def __init__(self, session, servicelist=None):
269                 Screen.__init__(self, session)
270                 self.session = session
271                 self.srvList = servicelist
272                 self.myServices = []
273                 self.myBqts = []
274                 self.list = []
275                 self.chCount = 0
276                 self.ActiveEPG = 1
277                 if getDesktop(0).size().width() == 1280:
278                         self.Fields = 6
279                         self["currCh5"] = Label(" ")
280                         self["Active5"] = Label(" ")
281                         self["epg_list5"] = MerlinEPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
282                 else:
283                         self.Fields = 5
284                 self.CheckForEPG = eTimer()
285                 self.CheckForEPG.callback.append(self.CheckItNow)
286                 self.AutoPrime = eTimer()
287                 self.AutoPrime.callback.append(self.go2Primetime)
288                 self["prg_list"] = MenuList(self.getChannels())
289                 self["fullEventInfo"] = Label(" ")
290                 self["currCh1"] = Label(" ")
291                 self["currCh2"] = Label(" ")
292                 self["currCh3"] = Label(" ")
293                 self["currCh4"] = Label(" ")
294                 self["Active1"] = Label(" ")
295                 self["Active2"] = Label(" ")
296                 self["Active3"] = Label(" ")
297                 self["Active4"] = Label(" ")
298                 self["epg_list1"] = MerlinEPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
299                 self["epg_list2"] = MerlinEPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
300                 self["epg_list3"] = MerlinEPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
301                 self["epg_list4"] = MerlinEPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
302                 self["actions"] = ActionMap(["OkCancelActions", "EPGSelectActions", "DirectionActions", "ColorActions", "MenuActions", "NumberActions", "HelpActions"], {
303                                                 "ok": self.UserOK, 
304                                                 "cancel": self.close,
305                                                 "nextBouquet": self.AllUp,
306                                                 "prevBouquet": self.AllDown,
307                                                 "nextService": self.NextPage,
308                                                 "prevService": self.PrevPage,
309                                                 "right": self.right,
310                                                 "rightRepeated": self.right,
311                                                 "left": self.left,
312                                                 "leftRepeated": self.left,
313                                                 "up": self.up,
314                                                 "upRepeated": self.up,
315                                                 "down": self.down,
316                                                 "downRepeated": self.down,
317                                                 "info": self.showEventInfo,
318                                                 "red": self.ZapTo,
319                                                 "green": self.timerAdd,
320                                                 "blue": self.ZapForRefresh,
321                                                 "yellow": self.go2Primetime,
322                                                 "menu": self.menuClicked,
323                                                 "displayHelp": self.myhelp,
324                                                 "0": self.go2now,
325                                                 "1": self.go2first,
326                                                 "7": self.findPrvBqt,
327                                                 "9": self.findNextBqt
328                                                 },-2)
329                 self.onLayoutFinish.append(self.onLayoutReady)
330
331         def getChannels(self):
332                 indx = 0
333                 serviceHandler = eServiceCenter.getInstance()
334                 services = serviceHandler.list(eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
335                 bouquets = services and services.getContent("SN", True)
336                 for bouquet in bouquets:
337                         services = serviceHandler.list(eServiceReference(bouquet[0]))
338                         channels = services and services.getContent("SN", True)
339                         for channel in channels:
340                                 if not channel[0].startswith("1:64:"):
341                                         indx = indx + 1
342                                         self.list.append(str(indx) + ". " + channel[1].replace('\xc2\x86', '').replace('\xc2\x87', ''))
343                                         self.myServices.append(channel)
344                                         self.myBqts.append(bouquet)
345                 self.chCount = indx - 1
346                 return self.list
347
348         def onLayoutReady(self):
349                 service = self.session.nav.getCurrentService()
350                 info = service and service.info()
351                 if (info is not None) and not(config.plugins.MerlinEPG.StartFirst.value):
352                         nameROH = info.getName().replace('\xc2\x86', '').replace('\xc2\x87', '')
353                         for idx in range(1, len(self.list)):
354                                 name = str(idx) + ". " + nameROH
355                                 if name == self.list[idx-1]:
356                                         break
357                         self["prg_list"].moveToIndex(idx-1)
358                 else:
359                         self["prg_list"].moveToIndex(0)
360                 self.updateInfos()
361
362         def updateInfos(self):
363                 if self.AutoPrime.isActive():
364                         self.AutoPrime.stop()
365                 self.displayActiveEPG()
366                 prgIndex = self["prg_list"].getSelectionIndex()
367                 CurrentPrg = self.myServices[prgIndex]
368                 self["currCh1"].setText(str(CurrentPrg[1]))
369                 l = self["epg_list1"]
370                 l.recalcEntrySize()
371                 myService = ServiceReference(CurrentPrg[0])
372                 l.fillSingleEPG(myService)
373                 prgIndex = prgIndex + 1
374                 if prgIndex < (self.chCount+1):
375                         self["epg_list2"].show()
376                         CurrentPrg = self.myServices[prgIndex]
377                         self["currCh2"].setText(str(CurrentPrg[1]))
378                         l = self["epg_list2"]
379                         l.recalcEntrySize()
380                         myService = ServiceReference(CurrentPrg[0])
381                         l.fillSingleEPG(myService)
382                 else:
383                         self["currCh2"].setText(str(" "))
384                         self["epg_list2"].hide()
385                 prgIndex = prgIndex + 1
386                 if prgIndex < (self.chCount+1):
387                         self["epg_list3"].show()
388                         CurrentPrg = self.myServices[prgIndex]
389                         self["currCh3"].setText(str(CurrentPrg[1]))
390                         l = self["epg_list3"]
391                         l.recalcEntrySize()
392                         myService = ServiceReference(CurrentPrg[0])
393                         l.fillSingleEPG(myService)
394                 else:
395                         self["currCh3"].setText(str(" "))
396                         self["epg_list3"].hide()
397                 prgIndex = prgIndex + 1
398                 if prgIndex < (self.chCount+1):
399                         self["epg_list4"].show()
400                         CurrentPrg = self.myServices[prgIndex]
401                         self["currCh4"].setText(str(CurrentPrg[1]))
402                         CurrentPrg = self.myServices[prgIndex]
403                         self["currCh4"].setText(str(CurrentPrg[1]))
404                         l = self["epg_list4"]
405                         l.recalcEntrySize()
406                         myService = ServiceReference(CurrentPrg[0])
407                         l.fillSingleEPG(myService)
408                 else:
409                         self["currCh4"].setText(str(" "))
410                         self["epg_list4"].hide()
411                 if self.Fields == 6:
412                         prgIndex = prgIndex + 1
413                         if prgIndex < (self.chCount+1):
414                                 self["epg_list5"].show()
415                                 CurrentPrg = self.myServices[prgIndex]
416                                 self["currCh5"].setText(str(CurrentPrg[1]))
417                                 l = self["epg_list5"]
418                                 l.recalcEntrySize()
419                                 myService = ServiceReference(CurrentPrg[0])
420                                 l.fillSingleEPG(myService)
421                         else:
422                                 self["currCh5"].setText(str(" "))
423                                 self["epg_list5"].hide()
424                 if config.plugins.MerlinEPG.AutoPT.value:
425                          self.AutoPrime.start(500)
426
427         def onSelectionChanged(self):           
428                 curEV = self["epg_list"+str(self.ActiveEPG)].getCurrent()
429                 event = curEV[0]
430                 ext = event and event.getExtendedDescription() or ""
431                 self["fullEventInfo"].setText(str(ext))
432
433         def NextPage(self):
434                 self["prg_list"].pageDown()
435                 self.ActiveEPG = 1
436                 self.updateInfos()
437
438         def PrevPage(self):
439                 self["prg_list"].pageUp()
440                 self.ActiveEPG = 1
441                 self.updateInfos()
442
443         def displayActiveEPG(self):
444                 for xA in range(1,self.Fields):
445                         if xA == self.ActiveEPG:
446                                 self["Active"+str(xA)].show()
447                         else:
448                                 self["Active"+str(xA)].hide()
449
450         def getActivePrg(self):
451                 return self["prg_list"].getSelectionIndex()+(self.ActiveEPG-1)
452
453         def ZapTo(self):
454                 if (self.getActivePrg() > self.chCount) or (self.srvList==None):
455                         return
456                 CurrentPrg = self.myServices[self.getActivePrg()]
457                 CurrentBqt = self.myBqts[self.getActivePrg()]
458                 myService = ServiceReference(CurrentPrg[0])
459                 myB = ServiceReference(CurrentBqt[0])
460                 self.srvList.clearPath()
461                 if self.srvList.bouquet_root != myB.ref:
462                         self.srvList.enterPath(self.srvList.bouquet_root)
463                 self.srvList.enterPath(myB.ref)
464                 self.srvList.setCurrentSelection(myService.ref)
465                 self.srvList.zap()
466                 self.close()
467
468         def ZapForRefresh(self):
469                 if (self.getActivePrg() > self.chCount) or (self.srvList==None):
470                         return
471                 CurrentPrg = self.myServices[self.getActivePrg()]
472                 myService = ServiceReference(CurrentPrg[0])
473                 self.session.nav.playService(myService.ref)
474                 self.CheckForEPG.start(4000, True)
475
476         def CheckItNow(self):
477                 self.CheckForEPG.stop()
478                 CurrentPrg = self.myServices[self.getActivePrg()]
479                 l = self["epg_list"+str(self.ActiveEPG)]
480                 l.recalcEntrySize()
481                 myService = ServiceReference(CurrentPrg[0])
482                 l.fillSingleEPG(myService)
483
484         def up(self):
485                 self["epg_list"+str(self.ActiveEPG)].moveUp()
486
487         def down(self):
488                 self["epg_list"+str(self.ActiveEPG)].moveDown()
489
490         def AllUp(self):
491                 if config.plugins.MerlinEPG.PageUDonBouquets.value:
492                         for xU in range(1,self.Fields):
493                                 self["epg_list"+str(xU)].instance.moveSelection(self["epg_list"+str(xU)].instance.pageUp)
494                 else:
495                         for xU in range(1,self.Fields):
496                                 self["epg_list"+str(xU)].moveUp()
497
498         def AllDown(self):
499                 if config.plugins.MerlinEPG.PageUDonBouquets.value:
500                         for xU in range(1,self.Fields):
501                                 self["epg_list"+str(xU)].instance.moveSelection(self["epg_list"+str(xU)].instance.pageDown)
502                 else:
503                         for xD in range(1,self.Fields):
504                                 self["epg_list"+str(xD)].moveDown()
505
506         def go2now(self):
507                 for xD in range(1,self.Fields):
508                         self["epg_list"+str(xD)].instance.moveSelection(self["epg_list"+str(xD)].instance.moveTop)
509
510         def go2first(self):
511                 self["prg_list"].moveToIndex(0)
512                 self.ActiveEPG = 1
513                 self.updateInfos()
514
515         def left(self):
516                 if self.ActiveEPG > 1:
517                         self.ActiveEPG = self.ActiveEPG - 1
518                         self.displayActiveEPG()
519                 else:
520                         self["prg_list"].pageUp()
521                         self.ActiveEPG = (self.Fields-1)
522                         self.updateInfos()
523                 self.onSelectionChanged()
524
525         def right(self):
526                 if self.ActiveEPG < (self.Fields-1):
527                         self.ActiveEPG = self.ActiveEPG + 1
528                         self.displayActiveEPG()
529                 else:
530                         self.NextPage()
531                 self.onSelectionChanged()
532                 
533         def showEventInfo(self):
534                 if not IMDbPresent:
535                         self.showConfirmedInfo([None,"Ei"])
536                 else:
537                         self.session.openWithCallback(self.showConfirmedInfo, ChoiceBox, title=_("Select Info type..."), list=[(_("Standard EPG info"), "Ei"),(_("IMBd info"), "Ii")])
538
539         def showConfirmedInfo(self,answer):
540                 curEV = self["epg_list"+str(self.ActiveEPG)].getCurrent()
541                 event = curEV[0]
542                 service = curEV[1]
543                 answer = answer and answer[1]
544                 if answer == "Ei":
545                         if event is not None:
546                                 self.session.open(EventViewSimple, event, service)
547                 if answer == "Ii":
548                         if event is not None:
549                                 IeventName=event.getEventName()
550                                 self.session.open(IMDB, IeventName)
551
552         def timerAdd(self):
553                 if not AutoTimerPresent:
554                         self.AddConfirmedTimer([None,"NT"])
555                 else:
556                         self.session.openWithCallback(self.AddConfirmedTimer, ChoiceBox, title=_("Select timer type..."), list=[(_("Standard timer"), "NT"),(_("AutoTimer"), "AT"),(_("View AutoTimers"), "ATV")])
557
558         def AddConfirmedTimer(self, answer):
559                 cur = self["epg_list"+str(self.ActiveEPG)].getCurrent()
560                 event = cur[0]
561                 serviceref = cur[1]
562                 if event is None:
563                         return
564                 eventid = event.getEventId()
565                 refstr = serviceref.ref.toString()
566                 answer = answer and answer[1]
567                 if answer == "AT":
568                         addAutotimerFromEvent(self.session,evt=event,service=serviceref)
569                 elif answer == "NT":
570                         for timer in self.session.nav.RecordTimer.timer_list:
571                                 if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
572                                         cb_func = lambda ret : not ret or self.removeTimer(timer)
573                                         self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
574                                         break
575                         else:
576                                 newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
577                                 self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
578                 elif answer == "ATV":
579                         AutoTimerView(self.session)
580
581         def removeTimer(self, timer):
582                 timer.afterEvent = AFTEREVENT.NONE
583                 self.session.nav.RecordTimer.removeEntry(timer)
584
585         def finishedAdd(self, answer):
586                 if answer[0]:
587                         entry = answer[1]
588                         simulTimerList = self.session.nav.RecordTimer.record(entry)
589                         if simulTimerList is not None:
590                                 for x in simulTimerList:
591                                         if x.setAutoincreaseEnd(entry):
592                                                 self.session.nav.RecordTimer.timeChanged(x)
593                                 simulTimerList = self.session.nav.RecordTimer.record(entry)
594                                 if simulTimerList is not None:
595                                         self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList)
596         
597         def finishSanityCorrection(self, answer):
598                 self.finishedAdd(answer)
599
600         def menuClicked(self):
601                 self.session.open(MerlinPGsetup)
602
603         def findNextBqt(self):
604                 CurrIdx = 0
605                 CurrBqt = self.myBqts[self.getActivePrg()]
606                 for CurrIdx in range(self.getActivePrg(),self.chCount):
607                         NewBqt = self.myBqts[CurrIdx]
608                         if NewBqt != CurrBqt:
609                                 break
610                 self["prg_list"].moveToIndex(CurrIdx)
611                 self.updateInfos()
612
613         def findPrvBqt(self):
614                 CurrIdx = 0
615                 CurrBqt = self.myBqts[self.getActivePrg()]
616                 for CurrIdx in range(self.getActivePrg(),-1,-1):
617                         NewBqt = self.myBqts[CurrIdx]
618                         if NewBqt != CurrBqt:
619                                 break
620                 self["prg_list"].moveToIndex(CurrIdx)
621                 self.updateInfos()
622
623         def go2Primetime(self):
624                 if self.AutoPrime.isActive():
625                         self.AutoPrime.stop()
626                 for xFL in range(1, self.Fields):
627                         self["epg_list"+str(xFL)].instance.moveSelection(self["epg_list"+str(xFL)].instance.moveTop)
628                         for i in range(0,(self.Fields*3)):
629                                 self["epg_list"+str(xFL)].foudPrimetime()
630
631         def myhelp(self):
632                 self.session.open(ShowMe, "/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/help.jpg")
633
634         def UserOK(self):
635                 if config.plugins.MerlinEPG.ZapOnOK.value:
636                         self.ZapTo()
637                 else:
638                         self.showConfirmedInfo([None,"Ei"])
639
640
641
642 class Merlin_PGd(Screen):
643         try:
644                 sz_w = getDesktop(0).size().width()
645         except:
646                 sz_w = 720
647         if sz_w == 1280:
648                 skin = """
649                 <screen backgroundColor="#ffffffff" flags="wfNoBorder" name="Merlin_PG" position="0,0" size="1280,720" title="Merlin Program Guide">
650                         <widget backgroundColor="#ffffffff" position="0,0" render="Pig" size="520,292" source="session.VideoPicture" zPosition="-1"/>
651                         <eLabel backgroundColor="#00111112" position="0,292" size="520,450" zPosition="1"/>
652                         <eLabel backgroundColor="#00111112" position="520,0" size="760,720" zPosition="1"/>
653                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/epg.png" position="1136,105" size="85,77" zPosition="5"/>
654                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/channels.png" position="395,306" size="80,80" zPosition="5"/>
655                         <ePixmap alphatest="on" name="red" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/red.png" position="70,635" size="35,25" zPosition="2"/>
656                         <ePixmap alphatest="on" name="green" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/green.png" position="275,635" size="35,25" zPosition="2"/>
657                         <eLabel backgroundColor="#00111112" font="Regular;18" position="110,635" size="131,24" text="ZAP" transparent="1" zPosition="2"/>
658                         <eLabel backgroundColor="#00111112" font="Regular;18" position="315,635" size="191,24" text="TIMERS" transparent="1" zPosition="2"/>
659                         <widget itemHeight="25" name="prg_list" position="75,306" scrollbarMode="showNever" size="400,300" transparent="1" zPosition="4"/>
660                         <widget itemHeight="27" name="epg_list" position="570,105" scrollbarMode="showNever" size="651,540" transparent="1" zPosition="4"/>
661                         <widget backgroundColor="#00111112" font="Regular;22" foregroundColor="#fcc000" halign="center" name="currCh" position="555,55" size="651,24" transparent="1" valign="center" zPosition="2"/>
662                 </screen>"""
663         elif sz_w == 1024:
664                 skin = """
665                 <screen backgroundColor="#ffffffff" flags="wfNoBorder" name="Merlin_PG" position="0,0" size="1024,576" title="Merlin Program Guide">
666                         <widget backgroundColor="#ffffffff" position="0,0" render="Pig" size="384,216" source="session.VideoPicture" zPosition="-1"/>
667                         <eLabel backgroundColor="#00111112" position="0,216" size="384,366" zPosition="1"/>
668                         <eLabel backgroundColor="#00111112" position="384,0" size="720,576" zPosition="1"/>
669                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/epg.png" position="900,80" size="85,77" zPosition="5"/>
670                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/channels.png" position="292,228" size="80,80" zPosition="5"/>
671                         <ePixmap alphatest="on" name="red" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/red.png" position="40,520" size="35,25" zPosition="3"/>
672                         <ePixmap alphatest="on" name="green" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/green.png" position="185,520" size="35,25" zPosition="3"/>
673                         <eLabel backgroundColor="#00111112" font="Regular;18" position="80,520" size="92,24" text="ZAP" transparent="1" zPosition="2"/>
674                         <eLabel backgroundColor="#00111112" font="Regular;18" position="230,520" size="141,24" text="TIMERS" transparent="1" zPosition="2"/>
675                         <widget itemHeight="25" name="prg_list" position="40,228" scrollbarMode="showNever" size="332,275" transparent="1" zPosition="4"/>
676                         <widget itemHeight="28" name="epg_list" position="395,80" scrollbarMode="showNever" size="590,448" transparent="1" zPosition="4"/>
677                         <widget backgroundColor="#00111112" font="Regular;21" foregroundColor="#fcc000" halign="center" name="currCh" position="395,40" size="590,24" transparent="1" valign="center" zPosition="4"/>
678                 </screen>"""
679         else:
680                 skin = """
681                 <screen flags="wfNoBorder" name="Merlin_PG" position="0,0" size="720,576" title="Merlin Program Guide">
682                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/mpgbgSD-fs8.png" position="0,0" size="720,576" zPosition="1"/>
683                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/red.png" position="165,90" size="35,25" zPosition="2"/>
684                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/green.png" position="165,110" size="35,25" zPosition="2"/>
685                         <eLabel backgroundColor="#1f1f1f" font="Regular;15" foregroundColor="#f0f0f0" position="205,93" size="70,20" text="ZAP" transparent="1" zPosition="2"/>
686                         <eLabel backgroundColor="#1f1f1f" font="Regular;15" foregroundColor="#f0f0f0" position="205,113" size="70,20" text="TIMERS" transparent="1" zPosition="2"/>
687                         <widget name="prg_list" position="342,63" scrollbarMode="showOnDemand" size="327,150" zPosition="2" itemHeight="25"/>
688                         <widget name="epg_list" position="57,238" scrollbarMode="showOnDemand" size="612,270" zPosition="2" itemHeight="27"/>
689                         <widget font="Regular;22" foregroundColor="#ffc000" halign="center" name="currCh" position="57,133" size="252,66" transparent="1" valign="center" zPosition="2"/>
690                         <widget font="LCD;28" halign="left" position="60,95" render="Label" size="91,32" source="global.CurrentTime" transparent="1" zPosition="3">
691                                 <convert type="ClockToText">Default</convert>
692                         </widget>       
693                         <widget font="Regular;16" position="60,65" render="Label" size="276,26" source="global.CurrentTime" transparent="1" zPosition="3">
694                                 <convert type="ClockToText">Date</convert>
695                         </widget>
696                 </screen>"""
697
698         def __init__(self, session, servicelist=None):
699                 Screen.__init__(self, session)
700                 self.session = session
701                 self.myServices = []
702                 self.myBqts = []
703                 self.list = []
704                 self.srvList = servicelist
705                 self.CheckForEPG = eTimer()
706                 self.CheckForEPG.callback.append(self.CheckItNow)
707                 self["currCh"] = Label(_("Channel"))
708                 self["fullEventInfo"] = Label(" ")
709                 self["prg_list"] = MenuList(self.getChannels())
710                 self["epg_list"] = EPGList(type = EPG_TYPE_SINGLE, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
711                 self["actions"] = ActionMap(["OkCancelActions", "EPGSelectActions", "ColorActions", "DirectionActions", "MenuActions", "HelpActions"], {
712                                                                         "ok": self.ok, 
713                                                                         "cancel": self.close,
714                                                                         "nextBouquet": self.prgDown,
715                                                                         "prevBouquet": self.prgUp,
716                                                                         "nextService": self.prgPlus,
717                                                                         "prevService": self.prgMinus,
718                                                                         "red": self.ZapTo,
719                                                                         "green": self.timerAdd,
720                                                                         "blue": self.ZapForRefresh,
721                                                                         "yellow": self.go2now,
722                                                                         "info": self.ok,
723                                                                         "menu": self.menuClicked,
724                                                                         "displayHelp": self.myhelp,
725                                                                         "right": self.right,
726                                                                         "rightRepeated": self.right,
727                                                                         "left": self.left,
728                                                                         "leftRepeated": self.left,
729                                                                         "up": self.up,
730                                                                         "upRepeated": self.up,
731                                                                         "down": self.down,
732                                                                         "downRepeated": self.down,
733                                                                         },-2)
734                 self.onLayoutFinish.append(self.onLayoutReady)
735
736         def onLayoutReady(self):
737                 service = self.session.nav.getCurrentService()
738                 info = service and service.info()
739                 if (info is not None) and not(config.plugins.MerlinEPG.StartFirst.value):
740                         nameROH = info.getName().replace('\xc2\x86', '').replace('\xc2\x87', '')
741                         for idx in range(1, len(self.list)):
742                                 name = str(idx) + ". " + nameROH
743                                 if name == self.list[idx-1]:
744                                         break
745                         self["prg_list"].moveToIndex(idx-1)
746                 else:
747                         self["prg_list"].moveToIndex(0)
748                 self.updateInfos()
749
750         def onSelectionChanged(self):
751                 curEV = self["epg_list"].getCurrent()
752                 event = curEV[0]
753                 ext = event and event.getExtendedDescription() or ""
754                 self["fullEventInfo"].setText(str(ext))
755
756         def prgUp(self):
757                 self["prg_list"].down()
758                 self.updateInfos()
759         
760         def prgDown(self):
761                 self["prg_list"].up()
762                 self.updateInfos()
763
764         def prgPlus(self):
765                 self["prg_list"].pageDown()
766                 self.updateInfos()
767
768         def prgMinus(self):
769                 self["prg_list"].pageUp()
770                 self.updateInfos()
771
772         def getChannels(self):
773                 indx = 0
774                 serviceHandler = eServiceCenter.getInstance()
775                 services = serviceHandler.list(eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
776                 bouquets = services and services.getContent("SN", True)
777                 for bouquet in bouquets:
778                         services = serviceHandler.list(eServiceReference(bouquet[0]))
779                         channels = services and services.getContent("SN", True)
780                         for channel in channels:
781                                 if not channel[0].startswith("1:64:"):
782                                         indx = indx + 1
783                                         self.list.append(str(indx) + ". " + channel[1].replace('\xc2\x86', '').replace('\xc2\x87', ''))
784                                         self.myServices.append(channel)
785                                         self.myBqts.append(bouquet)
786                 return self.list
787
788         def updateInfos(self):
789                 l = self["epg_list"]
790                 l.recalcEntrySize()
791                 CurrentPrg = self.myServices[self["prg_list"].getSelectionIndex()]
792                 self["currCh"].setText(str(CurrentPrg[1]))
793                 myService = ServiceReference(CurrentPrg[0])
794                 l.fillSingleEPG(myService)
795
796         def ok(self):
797                 curEV = self["epg_list"].getCurrent()
798                 event = curEV[0]
799                 service = curEV[1]
800                 if event is not None:
801                         self.session.open(EventViewSimple, event, service)
802                         
803         def ZapTo(self):
804                 if self.srvList==None:
805                         return
806                 CurrentPrg = self.myServices[self["prg_list"].getSelectionIndex()]
807                 CurrentBqt = self.myBqts[self["prg_list"].getSelectionIndex()]
808                 myService = ServiceReference(CurrentPrg[0])
809                 myB = ServiceReference(CurrentBqt[0])
810                 self.srvList.clearPath()
811                 if self.srvList.bouquet_root != myB.ref:
812                         self.srvList.enterPath(self.srvList.bouquet_root)
813                 self.srvList.enterPath(myB.ref)
814                 self.srvList.setCurrentSelection(myService.ref)
815                 self.srvList.zap()
816                 self.close()
817
818         def ZapForRefresh(self):
819                 if self.srvList==None:
820                         return
821                 CurrentPrg = self.myServices[self["prg_list"].getSelectionIndex()]
822                 myService = ServiceReference(CurrentPrg[0])
823                 self.session.nav.playService(myService.ref)
824                 self.CheckForEPG.start(4000, True)
825
826         def CheckItNow(self):
827                 self.CheckForEPG.stop()
828                 self.updateInfos()
829                         
830         def timerAdd(self):
831                 if not AutoTimerPresent:
832                         self.AddConfirmedTimer([None,"NT"])
833                 else:
834                         self.session.openWithCallback(self.AddConfirmedTimer, ChoiceBox, title=_("Select timer type..."), list=[(_("Standard timer"), "NT"),(_("AutoTimer"), "AT"),(_("View AutoTimers"), "ATV")])
835
836         def AddConfirmedTimer(self, answer):
837                 cur = self["epg_list"].getCurrent()
838                 event = cur[0]
839                 serviceref = cur[1]
840                 if event is None:
841                         return
842                 eventid = event.getEventId()
843                 refstr = serviceref.ref.toString()
844                 answer = answer and answer[1]
845                 if answer == "AT":
846                         addAutotimerFromEvent(self.session,evt=event,service=serviceref)
847                 elif answer == "NT":
848                         for timer in self.session.nav.RecordTimer.timer_list:
849                                 if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
850                                         cb_func = lambda ret : not ret or self.removeTimer(timer)
851                                         self.session.openWithCallback(cb_func, MessageBox, _("Do you really want to delete %s?") % event.getEventName())
852                                         break
853                         else:
854                                 newEntry = RecordTimerEntry(serviceref, checkOldTimers = True, *parseEvent(event))
855                                 self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
856                 elif answer == "ATV":
857                         AutoTimerView(self.session)
858
859         def removeTimer(self, timer):
860                 timer.afterEvent = AFTEREVENT.NONE
861                 self.session.nav.RecordTimer.removeEntry(timer)
862
863         def finishedAdd(self, answer):
864                 if answer[0]:
865                         entry = answer[1]
866                         simulTimerList = self.session.nav.RecordTimer.record(entry)
867                         if simulTimerList is not None:
868                                 for x in simulTimerList:
869                                         if x.setAutoincreaseEnd(entry):
870                                                 self.session.nav.RecordTimer.timeChanged(x)
871                                 simulTimerList = self.session.nav.RecordTimer.record(entry)
872                                 if simulTimerList is not None:
873                                         self.session.openWithCallback(self.finishSanityCorrection, TimerSanityConflict, simulTimerList)
874
875         def finishSanityCorrection(self, answer):
876                 self.finishedAdd(answer)
877
878         def menuClicked(self):
879                 self.session.open(MerlinPGsetup)
880
881         def go2now(self):
882                 self["epg_list"].instance.moveSelection(self["epg_list"].instance.moveTop)
883
884         def myhelp(self):
885                 self.session.open(ShowMe, "/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/help.jpg")
886
887         def up(self):
888                 self["epg_list"].moveUp()
889
890         def down(self):
891                 self["epg_list"].moveDown()
892
893         def left(self):
894                 self["epg_list"].instance.moveSelection(self["epg_list"].instance.pageUp)
895
896         def right(self):
897                 self["epg_list"].instance.moveSelection(self["epg_list"].instance.pageDown)
898
899
900
901
902
903
904