[EasyInfo] add primetime3-value for second row in primetime-look
[enigma2-plugins.git] / easyinfo / src / plugin.py
1 #######################################################################
2 #
3 #    EasyInfo for Dreambox-Enigma2
4 #    Coded by Vali (c)2011
5 #    Support: www.dreambox-tools.info
6 #
7 #  This plugin is licensed under the Creative Commons 
8 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
9 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
10 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
11 #
12 #  Alternatively, this plugin may be distributed and executed on hardware which
13 #  is licensed by Dream Multimedia GmbH.
14 #
15 #  This plugin is NOT free software. It is open source, you are allowed to
16 #  modify it (if you keep the license), but it may not be commercially 
17 #  distributed other than under the conditions noted above.
18 #
19 #######################################################################
20
21
22
23 from Plugins.Plugin import PluginDescriptor
24 from Screens.Screen import Screen
25 from Screens.MessageBox import MessageBox
26 from Screens.InfoBarGenerics import InfoBarPlugins
27 from Screens.ChoiceBox import ChoiceBox
28 from Screens.TimerEdit import TimerEditList
29 from Screens.EpgSelection import EPGSelection
30 from Screens.EventView import EventViewSimple, EventViewBase
31 from Screens.ServiceInfo import ServiceInfo
32 from Screens.ChannelSelection import BouquetSelector
33 from Screens.TimeDateInput import TimeDateInput
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_MULTI
38 from Components.ConfigList import ConfigListScreen
39 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigClock
40 from Components.Sources.StaticText import StaticText
41 from Tools.Directories import fileExists, pathExists
42 from Tools.LoadPixmap import LoadPixmap
43 from Tools.HardwareInfo import HardwareInfo
44 from ServiceReference import ServiceReference
45 from enigma import eListboxPythonMultiContent, gFont, getDesktop, eTimer, eServiceReference, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, RT_HALIGN_RIGHT, RT_VALIGN_TOP
46 from time import localtime, time, mktime
47
48
49
50 EINbaseInfoBarPlugins__init__ = None
51 EINStartOnlyOneTime = False
52 EINsession = None
53 EINposition = 0
54 InfoBar_instance = None
55 mepg_config_initialized = False
56 sz_w = getDesktop(0).size().width()
57 if sz_w == 1280:
58         SKINTYPE = 3
59 elif sz_w == 1024:
60         SKINTYPE = 2
61 else:
62         SKINTYPE = 1
63
64
65
66 CHOICELIST=[("no", _("Disabled")),
67                         ("eventinfo", _("Event info")),
68                         ("singleepg", _("Single EPG")),
69                         ("multiepg", _("Multi EPG")),
70                         ("easypg", _("Easy-PG")),
71                         ("easysel", _("Easy-Selection")),
72                         ("graphepg", _("Graphik multi-EPG")),
73                         ("merlinepg", _("Merlin EPG")),
74                         ("cooltv", _("Cool-TV")),
75                         ("timers", _("Timerlist")),
76                         ("epgsearch", _("EPG search")),
77                         ("autotimer", _("Autotimer")),
78                         ("channelinfo", _("Channel info")),
79                         ("imdbinfo", _("IMDB info")),
80                         ("primetime", _("Prime Time Manager")),
81                         ("epgrefresh", _("EPG refresh")),
82                         ("sleep", _("Sleep timer")),
83                         ("sysinfo", _("Sherlock"))
84                         ]
85 config.plugins.EasyInfo  = ConfigSubsection()
86 config.plugins.EasyInfo.pos1 = ConfigSelection(default="eventinfo", choices = CHOICELIST)
87 config.plugins.EasyInfo.pos2 = ConfigSelection(default="singleepg", choices = CHOICELIST)
88 config.plugins.EasyInfo.pos3 = ConfigSelection(default="merlinepg", choices = CHOICELIST)
89 config.plugins.EasyInfo.pos4 = ConfigSelection(default="timers", choices = CHOICELIST)
90 config.plugins.EasyInfo.pos5 = ConfigSelection(default="channelinfo", choices = CHOICELIST)
91 config.plugins.EasyInfo.pos6 = ConfigSelection(default="no", choices = CHOICELIST)
92 config.plugins.EasyInfo.pos7 = ConfigSelection(default="no", choices = CHOICELIST)
93 config.plugins.EasyInfo.pos8 = ConfigSelection(default="no", choices = CHOICELIST)
94 config.plugins.EasyInfo.pos9 = ConfigSelection(default="no", choices = CHOICELIST)
95 config.plugins.EasyInfo.pos10 = ConfigSelection(default="no", choices = CHOICELIST)
96 config.plugins.EasyInfo.pos11 = ConfigSelection(default="no", choices = CHOICELIST)
97 config.plugins.EasyInfo.EvInStart = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
98 config.plugins.EasyInfo.bEvInYellow = ConfigSelection(default="singleepg", choices=[("singleepg", _("Single EPG")),("multiepg", _("Multi EPG")),("easypg", _("Easy-PG")),("graphepg", _("Graphik multi-EPG")),("merlinepg", _("Merlin EPG")),("cooltv", _("Cool-TV")),("imdbinfo", _("IMDB info"))])
99 config.plugins.EasyInfo.bEvInBlue = ConfigSelection(default="multiepg", choices=[("singleepg", _("Single EPG")),("multiepg", _("Multi EPG")),("easypg", _("Easy-PG")),("graphepg", _("Graphik multi-EPG")),("merlinepg", _("Merlin EPG")),("cooltv", _("Cool-TV")),("imdbinfo", _("IMDB info"))])
100 config.plugins.EasyInfo.myPicons = ConfigSelection(default="/media/usb/epgpicon/", choices = [("/media/usb/epgpicon/", "/media/usb/epgpicon/"), ("/media/cf/epgpicon/", "/media/cf/epgpicon/"), ("/media/hdd/epgpicon/", "/media/hdd/epgpicon/")])
101 config.plugins.EasyInfo.epgOKFunc = ConfigSelection(default="info", choices = [("info", _("Event info")), ("zap", _("Just zap")),("exitzap", _("Zap and Exit"))])
102 config.plugins.EasyInfo.Primetime1 = ConfigClock(default = 63000)
103 config.plugins.EasyInfo.Primetime2 = ConfigClock(default = 69300)
104 config.plugins.EasyInfo.Primetime3 = ConfigClock(default = 75600)
105 config.plugins.EasyInfo.buttTV = ConfigSelection(default="easysel", choices = [("no", _("Disabled")), ("easysel", _("Easy-Selection")), ("easypg", _("Easy-PG"))])
106
107
108
109 def Plugins(**kwargs):
110         return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = EasyInfoAutostart)]
111
112
113
114 def EasyInfoAutostart(reason, **kwargs):
115         global EINbaseInfoBarPlugins__init__
116         if "session" in kwargs:
117                 global EINsession
118                 EINsession = kwargs["session"]
119                 if EINbaseInfoBarPlugins__init__ is None:
120                         EINbaseInfoBarPlugins__init__ = InfoBarPlugins.__init__
121                 InfoBarPlugins.__init__ = InfoBarPlugins__init__
122                 InfoBarPlugins.info = info
123                 if config.plugins.EasyInfo.buttTV.value != "no":
124                         InfoBarPlugins.tvbut = tvbut
125
126
127
128 def InfoBarPlugins__init__(self):
129         global EINStartOnlyOneTime
130         if not EINStartOnlyOneTime: 
131                 EINStartOnlyOneTime = True
132                 global InfoBar_instance
133                 InfoBar_instance = self
134                 if config.plugins.EasyInfo.buttTV.value != "no":
135                         self["EasyInfoActions"] = ActionMap(["EasyInfoActions"],
136                                 {"info_but": self.info, "tv_but": self.tvbut}, -1)
137                 else:
138                         self["EasyInfoActions"] = ActionMap(["EasyInfoActionsALT"],
139                                 {"info_but": self.info}, -1)
140         else:
141                 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
142                 InfoBarPlugins.info = None
143                 if config.plugins.EasyInfo.buttTV.value != "no":
144                         InfoBarPlugins.tvbut = None
145         EINbaseInfoBarPlugins__init__(self)
146
147
148
149 def info(self):
150         if config.plugins.EasyInfo.EvInStart.value == "yes":
151                 epglist = [ ]
152                 self.epglist = epglist
153                 service = self.session.nav.getCurrentService()
154                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
155                 info = service.info()
156                 ptr=info.getEvent(0)
157                 if ptr:
158                         epglist.append(ptr)
159                 ptr=info.getEvent(1)
160                 if ptr:
161                         epglist.append(ptr)
162                 if epglist:
163                         self.session.open(EasyEvent, epglist[0], ServiceReference(ref))
164                 else:
165                         self.session.open(EasyInfo)
166         else:
167                 self.session.open(EasyInfo)
168
169
170
171 def tvbut(self):
172         myService = self.session.nav.getCurrentService()
173         myTS = myService and myService.timeshift()
174         if myTS is not None:
175                 if myTS.isTimeshiftActive():
176                         InfoBar_instance.stopTimeshift()
177                         return
178         if InfoBar_instance.servicelist.mode == 1:
179                 InfoBar_instance.showTv()
180                 return
181         bouquets = InfoBar_instance.servicelist.getBouquetList()
182         if bouquets is None:
183                 cnt = 0
184         else:
185                 cnt = len(bouquets)
186                 IBservices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
187         if cnt > 1:
188                 if config.plugins.EasyInfo.buttTV.value == "easysel":
189                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, IBservices, EINzapTo, None, EINchangeBouquetCB))
190                 elif config.plugins.EasyInfo.buttTV.value == "easypg":
191                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, IBservices, EINzapTo, None, EINchangeBouquetCB))
192         elif cnt == 1:
193                 if config.plugins.EasyInfo.buttTV.value == "easysel":
194                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, IBservices, EINzapTo, None, None))
195                 if config.plugins.EasyInfo.buttTV.value == "easypg":
196                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, IBservices, EINzapTo, None, EINchangeBouquetCB))
197
198
199
200 def getPluginByName(sstr):
201         sret = " "
202         for xs in CHOICELIST:
203                 if sstr == xs[0]:
204                         sret = xs[1]
205                         break
206         return sret
207
208
209
210 def EINPanelEntryComponent(key, text):
211         res = [ text ]
212         bpng = LoadPixmap(EasyInfo.EINiconspath + "key-" + text[0] + ".png")
213         if bpng is not None:
214                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 5, 5, 50, bpng))
215         png = LoadPixmap(EasyInfo.EINiconspath + key + ".png")
216         if png is not None:
217                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 5, 100, 50, png))
218         if config.plugins.EasyInfo.EvInStart.value == "yes" or SKINTYPE == 1:
219                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 115, 17, 300, 35, 0, RT_HALIGN_LEFT, getPluginByName(text[1])))
220         return res
221
222
223
224 class EINPanelList(MenuList):
225         def __init__(self, list, selection = 0, enableWrapAround=True):
226                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
227                 self.l.setFont(0, gFont("Regular", 20))
228                 self.l.setItemHeight(60)
229                 self.selection = selection
230         def postWidgetCreate(self, instance):
231                 MenuList.postWidgetCreate(self, instance)
232                 self.moveToIndex(self.selection)
233
234
235
236 class ConfigEasyInfo(ConfigListScreen, Screen):
237         skin = """
238                 <screen name="ConfigEasyInfo" position="center,center" size="600,410" title="EasyInfo settings...">
239                         <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="590,375"/>
240                         <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,385" size="140,26" text="Cancel"/>
241                         <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,385" size="140,26" text="Save"/>
242                 </screen>"""
243         def __init__(self, session):
244                 Screen.__init__(self, session)
245                 self.setTitle(_("EasyInfo settings..."))
246                 self.session = session
247                 self.oldsetting = [config.plugins.EasyInfo.EvInStart.value, config.plugins.EasyInfo.buttTV.value]
248                 list = []
249                 list.append(getConfigListEntry(_("Start first EventInfo:"), config.plugins.EasyInfo.EvInStart ))
250                 list.append(getConfigListEntry(_("Replace TV-button function:"), config.plugins.EasyInfo.buttTV ))
251                 list.append(getConfigListEntry(_("EventInfo yellow button:"), config.plugins.EasyInfo.bEvInYellow ))
252                 list.append(getConfigListEntry(_("EventInfo blue button:"), config.plugins.EasyInfo.bEvInBlue ))
253                 list.append(getConfigListEntry(_("OK function in Easy-PG:"), config.plugins.EasyInfo.epgOKFunc))
254                 list.append(getConfigListEntry(_("Easy-PG picons path:"), config.plugins.EasyInfo.myPicons))
255                 list.append(getConfigListEntry(_("Easy-PG Primetime 1:"), config.plugins.EasyInfo.Primetime1))
256                 list.append(getConfigListEntry(_("Easy-PG Primetime 2 (main):"), config.plugins.EasyInfo.Primetime2))
257                 list.append(getConfigListEntry(_("Easy-PG Primetime 3:"), config.plugins.EasyInfo.Primetime3))
258                 list.append(getConfigListEntry(_("Position 1 (info button):"), config.plugins.EasyInfo.pos1))
259                 list.append(getConfigListEntry(_("Position 2 (red button):"), config.plugins.EasyInfo.pos2))
260                 list.append(getConfigListEntry(_("Position 3 (green button):"), config.plugins.EasyInfo.pos3))
261                 list.append(getConfigListEntry(_("Position 4 (yellow button):"), config.plugins.EasyInfo.pos4))
262                 list.append(getConfigListEntry(_("Position 5 (blue button):"), config.plugins.EasyInfo.pos5))
263                 list.append(getConfigListEntry(_("Position 6:"), config.plugins.EasyInfo.pos6))
264                 list.append(getConfigListEntry(_("Position 7:"), config.plugins.EasyInfo.pos7))
265                 list.append(getConfigListEntry(_("Position 8:"), config.plugins.EasyInfo.pos8))
266                 list.append(getConfigListEntry(_("Position 9:"), config.plugins.EasyInfo.pos9))
267                 list.append(getConfigListEntry(_("Position 10:"), config.plugins.EasyInfo.pos10))
268                 list.append(getConfigListEntry(_("Position 11:"), config.plugins.EasyInfo.pos11))
269                 ConfigListScreen.__init__(self, list)
270                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "red": self.exit, "cancel": self.exit, "yellow": self.exit}, -1)
271
272         def save(self):
273                 for x in self["config"].list:
274                         x[1].save()
275                 if self.oldsetting != [config.plugins.EasyInfo.EvInStart.value, config.plugins.EasyInfo.buttTV.value]:
276                         self.session.open(MessageBox, text = _('You need GUI-restart to load the new settings!'), type = MessageBox.TYPE_INFO)
277                 self.close()
278
279         def exit(self):
280                 for x in self["config"].list:
281                         x[1].cancel()
282                 self.close()
283
284
285
286 class EasyInfo(Screen):
287         if SKINTYPE == 3:
288                 if config.plugins.EasyInfo.EvInStart.value == "yes":
289                         skin = """
290                         <screen flags="wfNoBorder" position="0,0" size="450,720" title="Easy Info">
291                                 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/bg.png" position="0,0" size="450,576"/>
292                                 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/bg.png" position="0,576" size="450,145"/>
293                                 <widget name="list" position="60,30" size="350,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
294                         </screen>"""
295                 else:
296                         skin = """
297                         <screen backgroundColor="background" flags="wfNoBorder" position="0,0" size="1280,720" title="Easy Info">
298                                 <widget name="list" position="55,30" size="110,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
299                                 <eLabel backgroundColor="#666666" position="250,359" size="1280,2"/>
300                                 <widget font="Regular;24" foregroundColor="#fcc000" position="630,50" render="Label" size="600,30" source="session.CurrentService" transparent="1" zPosition="1">
301                                         <convert type="ServiceName">Name</convert>
302                                 </widget>
303                                 <widget font="Regular;24" position="250,50" render="Label" size="100,30" source="session.Event_Now" transparent="1" zPosition="1">
304                                         <convert type="EventTime">StartTime</convert>
305                                         <convert type="ClockToText">Default</convert>
306                                 </widget>
307                                 <widget font="Regular;24" noWrap="1" position="250,90" render="Label" size="900,30" source="session.Event_Now" transparent="1" zPosition="1">
308                                         <convert type="EventName">Name</convert>
309                                 </widget>
310                                 <widget font="Regular;22" foregroundColor="#fcc000" position="350,50" halign="right" render="Label" size="130,30" source="session.Event_Now" transparent="1" zPosition="1">
311                                         <convert type="EventTime">Remaining</convert>
312                                         <convert type="RemainingToText">InMinutes</convert>
313                                 </widget>
314                                 <widget font="Regular;24" position="250,400" render="Label" size="100,30" source="session.Event_Next" transparent="1" zPosition="1">
315                                         <convert type="EventTime">StartTime</convert>
316                                         <convert type="ClockToText">Default</convert>
317                                 </widget>
318                                 <widget font="Regular;24" foregroundColor="#aaaaaa" noWrap="1" position="250,370" render="Label" size="900,30" source="session.Event_Next" transparent="1" zPosition="1">
319                                         <convert type="EventName">Name</convert>
320                                 </widget>
321                                 <widget font="Regular;24" foregroundColor="#aaaaaa" position="350,400" render="Label" size="130,30" source="session.Event_Next" transparent="1" zPosition="1">
322                                         <convert type="EventTime">Duration</convert>
323                                         <convert type="ClockToText">InMinutes</convert>
324                                 </widget>
325                                 <widget backgroundColor="#555555" borderColor="#555555" borderWidth="4" position="490,57" render="Progress" size="120,14" source="session.Event_Now" zPosition="2">
326                                         <convert type="EventTime">Progress</convert>
327                                 </widget>
328                                 <widget font="Regular;22" position="250,127" render="Label" size="950,225" source="session.Event_Now" transparent="1" valign="top" zPosition="5">
329                                         <convert type="EventName">ExtendedDescription</convert>
330                                 </widget>
331                                 <widget font="Regular;22" foregroundColor="#aaaaaa" position="250,437" render="Label" size="950,225" source="session.Event_Next" transparent="1" valign="top" zPosition="5">
332                                         <convert type="EventName">ExtendedDescription</convert>
333                                 </widget>
334                         </screen>"""
335         elif SKINTYPE == 2:
336                 if config.plugins.EasyInfo.EvInStart.value == "yes":
337                         skin = """
338                         <screen flags="wfNoBorder" position="-20,0" size="450,576" title="Easy Info">
339                                 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/bg.png" position="0,0" size="450,576"/>
340                                 <widget name="list" position="70,48" size="320,480" scrollbarMode="showNever" transparent="1" zPosition="2"/>
341                         </screen>"""
342                 else:
343                         skin = """
344                         <screen backgroundColor="background" flags="wfNoBorder" position="0,0" size="1024,720" title="Easy Info">
345                                 <widget name="list" position="40,48" scrollbarMode="showNever" size="110,480" transparent="1" zPosition="2"/>
346                                 <eLabel backgroundColor="#666666" position="210,289" size="1000,2"/>
347                                 <widget font="Regular;20" foregroundColor="#fcc000" position="570,50" render="Label" size="377,30" source="session.CurrentService" transparent="1" zPosition="1">
348                                         <convert type="ServiceName">Name</convert>
349                                 </widget>
350                                 <widget font="Regular;20" position="210,50" render="Label" size="70,30" source="session.Event_Now" transparent="1" zPosition="1">
351                                         <convert type="EventTime">StartTime</convert>
352                                         <convert type="ClockToText">Default</convert>
353                                 </widget>
354                                 <widget font="Regular;20" noWrap="1" position="210,85" render="Label" size="736,30" source="session.Event_Now" transparent="1" zPosition="1">
355                                         <convert type="EventName">Name</convert>
356                                 </widget>
357                                 <widget font="Regular;20" foregroundColor="#fcc000" halign="right" position="290,50" render="Label" size="130,30" source="session.Event_Now" transparent="1" zPosition="1">
358                                         <convert type="EventTime">Remaining</convert>
359                                         <convert type="RemainingToText">InMinutes</convert>
360                                 </widget>
361                                 <widget font="Regular;20" position="210,333" render="Label" size="82,30" source="session.Event_Next" transparent="1" zPosition="1">
362                                         <convert type="EventTime">StartTime</convert>
363                                         <convert type="ClockToText">Default</convert>
364                                 </widget>
365                                 <widget font="Regular;20" foregroundColor="#aaaaaa" noWrap="1" position="210,300" render="Label" size="900,30" source="session.Event_Next" transparent="1" zPosition="1">
366                                         <convert type="EventName">Name</convert>
367                                 </widget>
368                                 <widget font="Regular;20" foregroundColor="#aaaaaa" position="295,333" render="Label" size="130,30" source="session.Event_Next" transparent="1" zPosition="1">
369                                         <convert type="EventTime">Duration</convert>
370                                         <convert type="ClockToText">InMinutes</convert>
371                                 </widget>
372                                 <widget backgroundColor="#555555" borderColor="#555555" borderWidth="4" position="425,55" render="Progress" size="120,14" source="session.Event_Now" zPosition="2">
373                                         <convert type="EventTime">Progress</convert>
374                                 </widget>
375                                 <widget font="Regular;18" position="210,115" render="Label" size="736,170" source="session.Event_Now" transparent="1" valign="top" zPosition="5">
376                                         <convert type="EventName">ExtendedDescription</convert>
377                                 </widget>
378                                 <widget font="Regular;18" foregroundColor="#aaaaaa" position="210,362" render="Label" size="736,170" source="session.Event_Next" transparent="1" valign="top" zPosition="5">
379                                         <convert type="EventName">ExtendedDescription</convert>
380                                 </widget>
381                         </screen>"""
382         else:
383                 skin = """
384                 <screen position="center,center" size="320,440" title="Easy Info">
385                         <widget name="list" position="10,10" size="300,420" scrollbarMode="showOnDemand" />
386                 </screen>"""
387         if pathExists('/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/icons/'):
388                 EINiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/icons/'
389         else:
390                 EINiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/'
391         def __init__(self, session):
392                 Screen.__init__(self, session)
393                 self.session = session
394                 self.list = []
395                 self.__keys = []
396                 MPaskList = []
397                 fertig = False
398                 if True:
399                         if config.plugins.EasyInfo.pos1.value != "no":
400                                 self.__keys.append(config.plugins.EasyInfo.pos1.value)
401                                 MPaskList.append(("info", config.plugins.EasyInfo.pos1.value))
402                                 self["key_info"] = StaticText(_(getPluginByName(config.plugins.EasyInfo.pos1.value)))
403                         else: fertig = True
404                         if config.plugins.EasyInfo.pos2.value != "no" and not fertig:
405                                 self.__keys.append(config.plugins.EasyInfo.pos2.value)
406                                 MPaskList.append(("red", config.plugins.EasyInfo.pos2.value))
407                                 self["key_red"] = StaticText(_(getPluginByName(config.plugins.EasyInfo.pos2.value)))
408                         else: fertig = True
409                         if config.plugins.EasyInfo.pos3.value != "no" and not fertig:
410                                 self.__keys.append(config.plugins.EasyInfo.pos3.value)
411                                 MPaskList.append(("green", config.plugins.EasyInfo.pos3.value))
412                                 self["key_green"] = StaticText(_(getPluginByName(config.plugins.EasyInfo.pos3.value)))
413                         else: fertig = True
414                         if config.plugins.EasyInfo.pos4.value != "no" and not fertig:
415                                 self.__keys.append(config.plugins.EasyInfo.pos4.value)
416                                 MPaskList.append(("yellow", config.plugins.EasyInfo.pos4.value))
417                                 self["key_yellow"] = StaticText(_(getPluginByName(config.plugins.EasyInfo.pos4.value)))
418                         else: fertig = True
419                         if config.plugins.EasyInfo.pos5.value != "no" and not fertig:
420                                 self.__keys.append(config.plugins.EasyInfo.pos5.value)
421                                 MPaskList.append(("blue", config.plugins.EasyInfo.pos5.value))
422                                 self["key_blue"] = StaticText(_(getPluginByName(config.plugins.EasyInfo.pos5.value)))
423                         else: fertig = True
424                         if config.plugins.EasyInfo.pos6.value != "no" and not fertig:
425                                 self.__keys.append(config.plugins.EasyInfo.pos6.value)
426                                 MPaskList.append(("x", config.plugins.EasyInfo.pos6.value))
427                         else: fertig = True
428                         if config.plugins.EasyInfo.pos7.value != "no" and not fertig:
429                                 self.__keys.append(config.plugins.EasyInfo.pos7.value)
430                                 MPaskList.append(("x", config.plugins.EasyInfo.pos7.value))
431                         else: fertig = True
432                         if config.plugins.EasyInfo.pos8.value != "no" and not fertig:
433                                 self.__keys.append(config.plugins.EasyInfo.pos8.value)
434                                 MPaskList.append(("x", config.plugins.EasyInfo.pos8.value))
435                         else: fertig = True
436                         if config.plugins.EasyInfo.pos9.value != "no" and not fertig:
437                                 self.__keys.append(config.plugins.EasyInfo.pos9.value)
438                                 MPaskList.append(("x", config.plugins.EasyInfo.pos9.value))
439                         else: fertig = True
440                         if config.plugins.EasyInfo.pos10.value != "no" and not fertig:
441                                 self.__keys.append(config.plugins.EasyInfo.pos10.value)
442                                 MPaskList.append(("x", config.plugins.EasyInfo.pos10.value))
443                         else: fertig = True
444                         if config.plugins.EasyInfo.pos11.value != "no" and not fertig:
445                                 self.__keys.append(config.plugins.EasyInfo.pos11.value)
446                                 MPaskList.append(("x", config.plugins.EasyInfo.pos11.value))
447                 self.keymap = {}
448                 pos = 0
449                 for x in MPaskList:
450                         strpos = str(self.__keys[pos])
451                         self.list.append(EINPanelEntryComponent(key = strpos, text = x))
452                         if self.__keys[pos] != "":
453                                 self.keymap[self.__keys[pos]] = MPaskList[pos]
454                         pos += 1
455                 self["list"] = EINPanelList(list = self.list, selection = 0)
456                 self["actions"] = ActionMap(["WizardActions", "MenuActions", "ColorActions", "EPGSelectActions"],
457                 {
458                         "ok": self.go,
459                         "back": self.cancel,
460                         "menu": self.emContextMenu,
461                         "green": self.shotgreen,
462                         "red": self.shotred,
463                         "blue": self.shotblue,
464                         "yellow": self.shotyellow,
465                         "info": self.shotinfo
466                 }, -1)
467
468         def cancel(self):
469                 self.close(None)
470
471         def go(self):
472                 cursel = self["list"].l.getCurrentSelection()
473                 if cursel:
474                         antw = cursel[0]
475                         antw = antw and antw[1]
476                         EINcallbackFunc(antw)
477
478         def emContextMenu(self):
479                 self.session.open(ConfigEasyInfo)
480
481         def shotinfo(self):
482                 self["list"].moveToIndex(0)
483                 self.go()
484
485         def shotred(self):
486                 self["list"].moveToIndex(1)
487                 self.go()
488
489         def shotgreen(self):
490                 self["list"].moveToIndex(2)
491                 self.go()
492
493         def shotyellow(self):
494                 self["list"].moveToIndex(3)
495                 self.go()
496
497         def shotblue(self):
498                 self["list"].moveToIndex(4)
499                 self.go()
500
501
502
503 def EINchangeBouquetCB(direction, epg):
504         global EINposition
505         IBbouquets = InfoBar_instance.servicelist.getBouquetList()
506         if EINposition>0 and direction<0:
507                 EINposition = EINposition - 1
508         elif EINposition==0 and direction<0:
509                 EINposition = len(IBbouquets) - 1
510         elif EINposition<(len(IBbouquets)-1) and direction>0:
511                 EINposition = EINposition + 1
512         elif EINposition==(len(IBbouquets)-1) and direction>0:
513                 EINposition = 0
514         IBservices = InfoBar_instance.getBouquetServices(IBbouquets[EINposition][1])
515         if IBservices:
516                 epg.setServices(IBservices)
517
518
519
520 def EINzapTo(NewService):
521         IBbouquets = InfoBar_instance.servicelist.getBouquetList()
522         NewBbouquet = IBbouquets[EINposition][1]
523         InfoBar_instance.servicelist.clearPath()
524         if InfoBar_instance.servicelist.bouquet_root != NewBbouquet:
525                 InfoBar_instance.servicelist.enterPath(InfoBar_instance.servicelist.bouquet_root)
526         InfoBar_instance.servicelist.enterPath(NewBbouquet)
527         InfoBar_instance.servicelist.setCurrentSelection(NewService)
528         InfoBar_instance.servicelist.zap()
529
530
531
532 def EINcallbackFunc(answer):
533         if answer is None: return
534         if EINsession is None: return
535         if not InfoBar_instance: return
536         if answer == "singleepg":
537                 ref=InfoBar_instance.servicelist.getCurrentSelection()
538                 if ref:
539                         InfoBar_instance.servicelist.savedService = ref
540                         EINsession.openWithCallback(InfoBar_instance.servicelist.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = InfoBar_instance.servicelist.changeServiceCB)
541         elif answer == "easypg":
542                 bouquets = InfoBar_instance.servicelist.getBouquetList()
543                 if bouquets is None:
544                         cnt = 0
545                 else:
546                         cnt = len(bouquets)
547                         IBservices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
548                 if cnt > 1:
549                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, IBservices, EINzapTo, None, EINchangeBouquetCB))
550                 elif cnt == 1:
551                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, IBservices, EINzapTo, None, None))
552         elif answer == "easysel":
553                 bouquets = InfoBar_instance.servicelist.getBouquetList()
554                 if bouquets is None:
555                         cnt = 0
556                 else:
557                         cnt = len(bouquets)
558                         IBservices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
559                 if cnt > 1:
560                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, IBservices, EINzapTo, None, EINchangeBouquetCB))
561                 elif cnt == 1:
562                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, IBservices, EINzapTo, None, None))
563         elif answer == "timers":
564                 EINsession.open(TimerEditList)
565         elif answer == "multiepg":
566                 bouquets = InfoBar_instance.servicelist.getBouquetList()
567                 if bouquets is None:
568                         cnt = 0
569                 else:
570                         cnt = len(bouquets)
571                 if cnt > 1:
572                         InfoBar_instance.bouquetSel = EINsession.openWithCallback(InfoBar_instance.closed, BouquetSelector, bouquets, InfoBar_instance.openBouquetEPG, enableWrapAround=True)
573                         InfoBar_instance.dlg_stack.append(InfoBar_instance.bouquetSel)
574                 elif cnt == 1:
575                         InfoBar_instance.openBouquetEPG(bouquets[0][1], True)
576         elif answer == "eventinfo":
577                 epglist = [ ]
578                 InfoBar_instance.epglist = epglist
579                 service = EINsession.nav.getCurrentService()
580                 ref = EINsession.nav.getCurrentlyPlayingServiceReference()
581                 info = service.info()
582                 ptr=info.getEvent(0)
583                 if ptr:
584                         epglist.append(ptr)
585                 ptr=info.getEvent(1)
586                 if ptr:
587                         epglist.append(ptr)
588                 if epglist:
589                         EINsession.open(EventViewSimple, epglist[0], ServiceReference(ref), InfoBar_instance.eventViewCallback)
590         elif answer == "merlinepg":
591                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/plugin.pyo"):
592                         from Plugins.Extensions.MerlinEPG.plugin import Merlin_PGII, Merlin_PGd
593                         if config.plugins.MerlinEPG.Columns.value:
594                                 EINsession.open(Merlin_PGII, InfoBar_instance.servicelist)
595                         else:
596                                 EINsession.open(Merlin_PGd, InfoBar_instance.servicelist)
597                 else:
598                         EINsession.open(MessageBox, text = _('MerlinEPG is not installed!'), type = MessageBox.TYPE_INFO)
599         elif answer == "autotimer":
600                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/AutoTimerEditor.pyo"):
601                         from Plugins.Extensions.AutoTimer.plugin import main as AutoTimerView
602                         AutoTimerView(EINsession)
603                 else:
604                         EINsession.open(MessageBox, text = _('Autotimer is not installed!'), type = MessageBox.TYPE_INFO)
605         elif answer == "epgsearch":
606                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGSearch/plugin.pyo"):
607                         from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
608                         service = EINsession.nav.getCurrentService()
609                         info = service.info()
610                         epg_event=info.getEvent(0)
611                         if epg_event:
612                                 epg_name = epg_event and epg_event.getEventName() or ''
613                                 EINsession.open(EPGSearch, epg_name, False)
614                 else:
615                         EINsession.open(MessageBox, text = _('EPGsearch is not installed!'), type = MessageBox.TYPE_INFO)
616         elif answer == "channelinfo":
617                 EINsession.open(ServiceInfo, InfoBar_instance.servicelist.getCurrentSelection())
618         elif answer == "imdbinfo":
619                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IMDb/plugin.pyo"):
620                         from Plugins.Extensions.IMDb.plugin import IMDB
621                         service = EINsession.nav.getCurrentService()
622                         info = service.info()
623                         epg_event=info.getEvent(0)
624                         if epg_event:
625                                 IeventName = epg_event.getEventName()
626                                 EINsession.open(IMDB, IeventName)
627                 else:
628                         EINsession.open(MessageBox, text = _('IMDB is not installed!'), type = MessageBox.TYPE_INFO)
629         elif answer == "graphepg":
630                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/GraphMultiEPG/plugin.pyo"):
631                         from Plugins.Extensions.GraphMultiEPG.plugin import main as gmepgmain
632                         gmepgmain(EINsession, InfoBar_instance.servicelist)
633                 else:
634                         EINsession.open(MessageBox, text = _('GraphMultiEPG is not installed!'), type = MessageBox.TYPE_INFO)
635         elif answer == "primetime":
636                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/PrimeTimeManager/plugin.pyo"):
637                         from Plugins.Extensions.PrimeTimeManager.plugin import main as ptmanmain
638                         ptmanmain(EINsession)
639                 else:
640                         EINsession.open(MessageBox, text = _('Prime Time Manager is not installed!'), type = MessageBox.TYPE_INFO)
641         elif answer == "epgrefresh":
642                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGRefresh/plugin.pyo"):
643                         from Plugins.Extensions.EPGRefresh.plugin import main as epgrefmain
644                         epgrefmain(EINsession)
645                 else:
646                         EINsession.open(MessageBox, text = _('EPGRefresh is not installed!'), type = MessageBox.TYPE_INFO)
647         elif answer == "cooltv":
648                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/CoolTVGuide/plugin.pyo"):
649                         from Plugins.Extensions.CoolTVGuide.plugin import main as ctvmain
650                         ctvmain(EINsession, InfoBar_instance.servicelist)
651                 else:
652                         EINsession.open(MessageBox, text = _('CoolTVGuide is not installed!'), type = MessageBox.TYPE_INFO)
653         elif answer == "sysinfo":
654                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Sherlock/plugin.pyo"):
655                         from Plugins.Extensions.Sherlock.plugin import SherlockII
656                         EINsession.open(SherlockII)
657                 else:
658                         EINsession.open(MessageBox, text = _('Sherlock is not installed!'), type = MessageBox.TYPE_INFO)
659         elif answer == "sleep":
660                 from Screens.SleepTimerEdit import SleepTimerEdit
661                 EINsession.open(SleepTimerEdit)
662         else:
663                 EINsession.open(MessageBox, text = _('This function is yet not available!'), type = MessageBox.TYPE_INFO)
664
665
666
667 class EasyEvent(Screen, EventViewBase):
668         def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
669                 Screen.__init__(self, session)
670                 self.session = session
671                 self.skinName = "EventView"
672                 EventViewBase.__init__(self, Event, Ref, callback=InfoBar_instance.eventViewCallback)
673                 self["key_yellow"].setText(_(getPluginByName(config.plugins.EasyInfo.bEvInYellow.value)))
674                 self["key_blue"].setText(_(getPluginByName(config.plugins.EasyInfo.bEvInBlue.value)))
675                 self["key_red"].setText(_("Similar"))
676                 self["epgactions"] = ActionMap(["EventViewEPGActions", "EPGSelectActions",  "EventViewActions"],
677                         {
678                                 "openSingleServiceEPG": self.singleEPGCB,
679                                 "openMultiServiceEPG": self.multiEPGCB,
680                                 "openSimilarList": self.openSimilarList,
681                                 "info": self.newExit,
682                                 "pageUp": self.pageUp,
683                                 "pageDown": self.pageDown,
684                                 "prevEvent": self.prevEvent,
685                                 "nextEvent": self.nextEvent
686                         },-1)
687
688         def openSimilarList(self):
689                 self.hide()
690                 EINcallbackFunc("epgsearch")
691                 self.close()
692
693         def singleEPGCB(self):
694                 self.hide()
695                 EINcallbackFunc(config.plugins.EasyInfo.bEvInYellow.value)
696                 self.close()
697
698         def multiEPGCB(self):
699                 self.hide()
700                 EINcallbackFunc(config.plugins.EasyInfo.bEvInBlue.value)
701                 self.close()
702
703         def setEvent(self, event):
704                 self.event = event
705                 if event is None:
706                         return
707                 text = event.getEventName()
708                 short = event.getShortDescription()
709                 ext = event.getExtendedDescription()
710                 if short and short != text:
711                         text += '\n\n' + short
712                 if ext:
713                         if text:
714                                 text += '\n\n'
715                         text += ext
716                 self.setTitle(event.getEventName())
717                 self["epg_description"].setText(text)
718                 self["datetime"].setText(event.getBeginTimeString())
719                 self["duration"].setText(_("%d min")%(event.getDuration()/60))
720                 self["key_red"].setText(_("Similar"))
721                 serviceref = self.currentService
722                 eventid = self.event.getEventId()
723                 refstr = serviceref.ref.toString()
724                 isRecordEvent = False
725                 for timer in self.session.nav.RecordTimer.timer_list:
726                         if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
727                                 isRecordEvent = True
728                                 break
729                 if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
730                         self["key_green"].setText(_("Remove timer"))
731                         self.key_green_choice = self.REMOVE_TIMER
732                 elif not isRecordEvent and self.key_green_choice != self.ADD_TIMER:
733                         self["key_green"].setText(_("Add timer"))
734                         self.key_green_choice = self.ADD_TIMER
735
736         def newExit(self):
737                 self.hide()
738                 self.session.open(EasyInfo)
739                 self.close()
740
741
742
743 class EvNewList(EPGList):
744         def __init__(self, type=EPG_TYPE_MULTI, selChangedCB=None, timer = None):
745                 EPGList.__init__(self, type, selChangedCB, timer)
746                 self.l.setFont(0, gFont("Regular", 20))
747                 self.l.setFont(1, gFont("Regular", 18))
748                 self.l.setItemHeight(50)
749                 self.l.setBuildFunc(self.buildMultiEntry)
750                 self.breite = 200
751                 MyPiconPath = "/"
752
753         def recalcEntrySize(self):
754                 esize = self.l.getItemSize()
755                 self.breite = esize.width() - 200
756
757         def buildMultiEntry(self, changecount, service, eventId, beginTime, duration, EventName, nowTime, service_name):
758                 (clock_pic, rec) = self.getPixmapForEntry(service, eventId, beginTime, duration)
759                 res = [ None ]
760                 sref = str(service)[:-1].replace(':','_')
761                 Spixmap = LoadPixmap(path=(config.plugins.EasyInfo.myPicons.value + sref + '.png'))
762                 if Spixmap is not None:
763                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, 5, 4, 70, 42, Spixmap))
764                 else:
765                         res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 77, 50, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, service_name))
766                 if rec:
767                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 80, 16, 21, 21, clock_pic))
768                 if beginTime is not None and len(EventName) > 60:
769                         if nowTime < beginTime:
770                                 begin = localtime(beginTime)
771                                 end = localtime(beginTime+duration)
772                                 res.extend((
773                                         (eListboxPythonMultiContent.TYPE_TEXT, 100, 4, 10, 20, 1, RT_HALIGN_RIGHT, '>'),
774                                         (eListboxPythonMultiContent.TYPE_TEXT, 110, 4, 70, 44, 1, RT_HALIGN_LEFT, "%02d.%02d\n%02d.%02d"%(begin[3],begin[4],end[3],end[4])),
775                                         (eListboxPythonMultiContent.TYPE_TEXT, 180, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, EventName)
776                                 ))
777                         else:
778                                 percent = (nowTime - beginTime)*100/duration
779                                 restzeit = ((beginTime+duration)-nowTime)
780                                 res.extend((
781                                         (eListboxPythonMultiContent.TYPE_PROGRESS, 110, 11, 40, 8, percent),
782                                         (eListboxPythonMultiContent.TYPE_TEXT, 110, 25, 60, 22, 1, RT_HALIGN_LEFT, "+%d:%02d" % (restzeit/3600, (restzeit/60)-((restzeit /3600)*60))),
783                                         (eListboxPythonMultiContent.TYPE_TEXT, 180, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, EventName)
784                                 ))
785                 elif beginTime is not None:
786                         if nowTime < beginTime:
787                                 begin = localtime(beginTime)
788                                 end = localtime(beginTime+duration)
789                                 res.extend((
790                                         (eListboxPythonMultiContent.TYPE_TEXT, 100, 4, 10, 20, 1, RT_HALIGN_RIGHT, '>'),
791                                         (eListboxPythonMultiContent.TYPE_TEXT, 110, 4, 70, 44, 1, RT_HALIGN_LEFT, "%02d.%02d\n%02d.%02d"%(begin[3],begin[4],end[3],end[4])),
792                                         (eListboxPythonMultiContent.TYPE_TEXT, 180, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, EventName)
793                                 ))
794                         else:
795                                 percent = (nowTime - beginTime)*100/duration
796                                 restzeit = ((beginTime+duration)-nowTime)
797                                 res.extend((
798                                         (eListboxPythonMultiContent.TYPE_PROGRESS, 110, 11, 40, 8, percent),
799                                         (eListboxPythonMultiContent.TYPE_TEXT, 110, 25, 60, 22, 1, RT_HALIGN_LEFT, "+%d:%02d" % (restzeit/3600, (restzeit/60)-((restzeit /3600)*60))),
800                                         (eListboxPythonMultiContent.TYPE_TEXT, 180, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, EventName)
801                                 ))
802                 return res
803
804         def moveToService(self,serviceref):
805                 if not serviceref:
806                         return
807                 index = 0
808                 refstr = serviceref.toString()
809                 for x in self.list:
810                         if x[1] == refstr:
811                                 self.instance.moveSelectionTo(index)
812                                 break
813                         index += 1
814                 if x[1] != refstr:
815                         self.instance.moveSelectionTo(0)
816
817
818
819 class EasyPG(EPGSelection, Screen):
820         if SKINTYPE == 3:
821                 skin = """
822                 <screen name="EasyPG" backgroundColor="#101220" flags="wfNoBorder" position="0,0" size="1280,720" title="Easy PG">
823                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="60,35" size="660,650" zPosition="-1"/>
824                         <widget font="Regular;20" position="785,30" render="Label" size="202,25" source="global.CurrentTime" transparent="1" zPosition="1">
825                                 <convert type="ClockToText">Format:%a %d. %b   %H:%M</convert>
826                         </widget>
827                         <widget backgroundColor="#ff000000" position="755,125" render="Pig" size="497,280" source="session.VideoPicture" zPosition="1"/>
828                         <widget foregroundColor="#fcc000" font="Regular;20" name="date" position="755,415" size="100,25" transparent="1"/>
829                         <widget name="list" position="60,35" scrollbarMode="showNever" size="660,650" transparent="1"/>
830                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-red.png" position="785,65" size="5,20"/>
831                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-green.png" position="785,90" size="5,20"/>
832                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-yellow.png" position="1005,65" size="5,20"/>
833                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-blue.png" position="1005,90" size="5,20"/>
834                         <eLabel font="Regular;18" position="800,63" size="150,25" text="Similar" transparent="1"/>
835                         <eLabel font="Regular;18" position="800,90" size="150,25" text="Timer" transparent="1"/>
836                         <eLabel font="Regular;18" position="1015,63" size="150,25" text="Back" transparent="1"/>
837                         <eLabel font="Regular;18" position="1015,90" size="150,25" text="Next" transparent="1"/>
838                         <widget font="Regular;20" halign="right" position="870,415" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
839                                 <convert type="EventTime">StartTime</convert>
840                                 <convert type="ClockToText">Default</convert>
841                         </widget>
842                         <eLabel font="Regular;18" position="945,415" size="10,25" text="-" transparent="1"/>
843                         <widget font="Regular;20" position="955,415" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
844                                 <convert type="EventTime">EndTime</convert>
845                                 <convert type="ClockToText">Default</convert>
846                         </widget>
847                         <widget font="Regular;20" position="1050,415" render="Label" size="171,25" source="Event" transparent="1" zPosition="1">
848                         <convert type="EventTime">Duration</convert>
849                                 <convert type="ClockToText">InMinutes</convert>
850                         </widget>
851                         <widget font="Regular;20" position="755,445" render="Label" size="480,25" source="Event" transparent="1" zPosition="2" noWrap="1">
852                                 <convert type="EventName">ShortDescription</convert>
853                         </widget>
854                         <widget font="Regular;18" position="755,475" render="Label" size="480,210" source="Event" transparent="1" zPosition="3">
855                                 <convert type="EventName">ExtendedDescription</convert>
856                         </widget>
857                 </screen>"""
858         elif SKINTYPE == 2:
859                 skin = """
860                 <screen name="EasyPG" backgroundColor="#0e1018" flags="wfNoBorder" position="0,0" size="1024,576" title="Easy PG">
861                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="50,50" size="520,450" zPosition="-1"/>
862                         <eLabel backgroundColor="#666666" position="0,518" size="1024,1"/>
863                         <widget font="Regular;20" position="50,525" render="Label" size="186,25" source="global.CurrentTime" transparent="1" zPosition="1">
864                                 <convert type="ClockToText">Format:%a %d. %b   %H:%M</convert>
865                         </widget>
866                         <widget backgroundColor="#ff000000" position="590,30" render="Pig" size="384,216" source="session.VideoPicture" zPosition="-1"/>
867                         <widget foregroundColor="#fcc000" font="Regular;20" name="date" position="590,255" size="100,25" transparent="1"/>
868                         <widget name="list" position="50,48" scrollbarMode="showNever" size="520,450" transparent="1"/>
869                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-red.png" position="275,525" size="5,20"/>
870                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-green.png" position="450,525" size="5,20"/>
871                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-yellow.png" position="625,525" size="5,20"/>
872                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-blue.png" position="800,525" size="5,20"/>
873                         <eLabel font="Regular;18" position="290,526" size="150,25" text="Similar" transparent="1"/>
874                         <eLabel font="Regular;18" position="465,526" size="150,25" text="Timer" transparent="1"/>
875                         <eLabel font="Regular;18" position="640,526" size="150,25" text="Back" transparent="1"/>
876                         <eLabel font="Regular;18" position="815,526" size="150,25" text="Next" transparent="1"/>
877                         <widget font="Regular;20" halign="right" position="695,255" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
878                                 <convert type="EventTime">StartTime</convert>
879                                 <convert type="ClockToText">Default</convert>
880                         </widget>
881                         <eLabel font="Regular;18" position="770,255" size="10,25" text="-" transparent="1"/>
882                         <widget font="Regular;20" position="780,255" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
883                                 <convert type="EventTime">EndTime</convert>
884                                 <convert type="ClockToText">Default</convert>
885                         </widget>
886                         <widget font="Regular;20" position="855,255" render="Label" size="130,25" source="Event" transparent="1" zPosition="1">
887                         <convert type="EventTime">Duration</convert>
888                                 <convert type="ClockToText">InMinutes</convert>
889                         </widget>
890                         <widget font="Regular;20" noWrap="1" position="590,285" render="Label" size="390,25" source="Event" transparent="1" zPosition="2">
891                                 <convert type="EventName">ShortDescription</convert>
892                         </widget>
893                         <widget font="Regular;18" position="590,315" render="Label" size="390,190" source="Event" transparent="1" zPosition="3">
894                                 <convert type="EventName">ExtendedDescription</convert>
895                         </widget>
896                 </screen>
897                 """
898         else:
899                 skin = """
900                 <screen name="EasyPG" backgroundColor="background" flags="wfNoBorder" position="0,0" size="720,576" title="Easy PG">
901                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="50,48" size="620,450" zPosition="-1"/>
902                         <eLabel backgroundColor="#666666" position="0,522" size="756,1"/>
903                         <widget foregroundColor="#fcc000" font="Regular;20" name="date" position="50,525" size="100,25" transparent="1"/>
904                         <widget name="list" position="50,48" scrollbarMode="showOnDemand" size="620,450" transparent="1"/>
905                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-red.png" position="175,525" size="5,20"/>
906                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-yellow.png" position="350,525" size="5,20"/>
907                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-blue.png" position="525,525" size="5,20"/>
908                         <eLabel font="Regular;18" position="190,526" size="150,25" text="Similar" transparent="1"/>
909                         <eLabel font="Regular;18" position="365,526" size="150,25" text="Back" transparent="1"/>
910                         <eLabel font="Regular;18" position="540,526" size="150,25" text="Next" transparent="1"/>
911                 </screen>
912                 """
913         def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None, serviceChangeCB=None):
914                 Screen.__init__(self, session)
915                 EPGSelection.__init__(self, session, service, zapFunc, eventid, bouquetChangeCB, serviceChangeCB)
916                 global EINposition
917                 EINposition = 0
918                 allbouq = InfoBar_instance.servicelist.getBouquetList()
919                 for newpos in range(0, len(allbouq)):
920                         if InfoBar_instance.servicelist.getRoot() == allbouq[newpos][1]:
921                                 EINposition = newpos
922                                 break
923                 self.PTinit = False
924                 self.session = session
925                 EPGSelection.skinName = "EasyPG"
926                 self.PThour = config.plugins.EasyInfo.Primetime2.value[0]
927                 self.PTmin = config.plugins.EasyInfo.Primetime2.value[1]
928                 self["list"] = EvNewList(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
929                 self.skinName = "EasyPG"
930                 self.RefrTimer = eTimer()
931                 self.RefrTimer.callback.append(self.RefreshEPG)
932                 self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions", "NumberActions", "InfobarActions"],
933                         {
934                                 "cancel": self.closeScreen,
935                                 "ok": self.newOKFunc,
936                                 "timerAdd": self.timerAdd,
937                                 "yellow": self.yellowButtonPressed,
938                                 "blue": self.blueButtonPressed,
939                                 "info": self.infoKeyPressed,
940                                 "red": self.newRedFunc,
941                                 "input_date_time": self.einContextMenu,
942                                 "nextBouquet": self.nextBouquet,
943                                 "prevBouquet": self.prevBouquet,
944                                 "nextService": self.PTfor,
945                                 "prevService": self.PTback,
946                                 "showMovies": self.enterDateTime,
947                                 "showTv": self.zapTo,
948                                 "showRadio": self.zapForRefr,
949                                 "0": self.GoFirst,
950                                 "1": self.SetPT1,
951                                 "2": self.SetPT2,
952                                 "3": self.SetPT3
953                         },-1)
954
955         def closeScreen(self):
956                 self.close(True)
957
958         def GoFirst(self):
959                 self["list"].fillMultiEPG(self.services, -1)
960                 self.PTinit = False
961
962         def GoPrimetime(self):
963                 heute = localtime()
964                 pt = (heute[0],heute[1],heute[2],self.PThour,self.PTmin,0,heute[6],heute[7],0)
965                 self.ask_time = int(mktime(pt))
966                 self.PTinit = True
967                 if self.ask_time > int(mktime(heute)):
968                         self["list"].fillMultiEPG(self.services, self.ask_time)
969
970         def newOKFunc(self):
971                 if  config.plugins.EasyInfo.epgOKFunc.value == "exitzap":
972                         self.zapTo()
973                         self.close(True)
974                 elif config.plugins.EasyInfo.epgOKFunc.value == "zap":
975                         self.zapTo()
976                 else:
977                         self.infoKeyPressed()
978
979         def newRedFunc(self):
980                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGSearch/plugin.pyo"):
981                         from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
982                         epg_event = self["list"].getCurrent()[0]
983                         if epg_event:
984                                 epg_name = epg_event and epg_event.getEventName() or ''
985                                 self.session.open(EPGSearch, epg_name, False)
986                 else:
987                         self.session.open(MessageBox, text = _('EPGsearch is not installed!'), type = MessageBox.TYPE_INFO)
988
989         def PTfor(self):
990                 if not self["list"].getCurrent()[0]:
991                         return
992                 heute = localtime()
993                 if not self.PTinit:
994                         pt = (heute[0],heute[1],heute[2],self.PThour,self.PTmin,0,heute[6],heute[7],0)
995                         self.ask_time = int(mktime(pt))
996                         self.PTinit = True
997                         if self.ask_time < int(mktime(heute)):
998                                 self.ask_time = self.ask_time + 86400
999                 else:
1000                         self.ask_time = self.ask_time + 86400
1001                 self["list"].fillMultiEPG(self.services, self.ask_time)
1002
1003         def PTback(self):
1004                 heute = localtime()
1005                 if not self.PTinit:
1006                         pt = (heute[0],heute[1],heute[2],self.PThour,self.PTmin,0,heute[6],heute[7],0)
1007                         self.ask_time = int(mktime(pt))
1008                         self.PTinit = True
1009                 else:
1010                         self.ask_time = self.ask_time - 86400
1011                 if self.ask_time > int(mktime(heute)):
1012                         self["list"].fillMultiEPG(self.services, self.ask_time)
1013                 else:
1014                         self["list"].fillMultiEPG(self.services, -1)
1015                         self.PTinit = False
1016
1017         def SetPT1(self):
1018                 self.PThour = config.plugins.EasyInfo.Primetime1.value[0]
1019                 self.PTmin = config.plugins.EasyInfo.Primetime1.value[1]
1020                 self.GoPrimetime()
1021
1022         def SetPT2(self):
1023                 self.PThour = config.plugins.EasyInfo.Primetime2.value[0]
1024                 self.PTmin = config.plugins.EasyInfo.Primetime2.value[1]
1025                 self.GoPrimetime()
1026
1027         def SetPT3(self):
1028                 self.PThour = config.plugins.EasyInfo.Primetime3.value[0]
1029                 self.PTmin = config.plugins.EasyInfo.Primetime3.value[1]
1030                 self.GoPrimetime()
1031
1032         def einContextMenu(self):
1033                 self.session.open(ConfigEasyInfo)
1034
1035         def zapForRefr(self):
1036                 self.zapTo()
1037                 self.RefrTimer.start(4000, True)
1038
1039         def RefreshEPG(self):
1040                 self.RefrTimer.stop()
1041                 self.GoFirst()
1042
1043
1044
1045 class ESListNext(EPGList):
1046         def __init__(self, type=EPG_TYPE_MULTI, selChangedCB=None, timer = None):
1047                 EPGList.__init__(self, type, selChangedCB, timer)
1048                 self.l.setFont(0, gFont("Regular", 20))
1049                 self.l.setFont(1, gFont("Regular", 18))
1050                 self.l.setItemHeight(50)
1051                 self.l.setBuildFunc(self.buildMultiEntry)
1052                 self.breite = 200
1053                 MyPiconPath = "/"
1054
1055         def recalcEntrySize(self):
1056                 esize = self.l.getItemSize()
1057                 self.breite = esize.width() - 100
1058
1059         def buildMultiEntry(self, changecount, service, eventId, beginTime, duration, EventName, nowTime, service_name):
1060                 (clock_pic, rec) = self.getPixmapForEntry(service, eventId, beginTime, duration)
1061                 res = [ None ]
1062                 if rec:
1063                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 58, 16, 21, 21, clock_pic))
1064                 if beginTime is not None and len(EventName) > 60:
1065                         if nowTime < beginTime:
1066                                 begin = localtime(beginTime)
1067                                 end = localtime(beginTime+duration)
1068                                 res.extend((
1069                                         (eListboxPythonMultiContent.TYPE_TEXT, 0, 4, 10, 20, 1, RT_HALIGN_RIGHT, '>'),
1070                                         (eListboxPythonMultiContent.TYPE_TEXT, 10, 4, 70, 44, 1, RT_HALIGN_LEFT, "%02d.%02d\n%02d.%02d"%(begin[3],begin[4],end[3],end[4])),
1071                                         (eListboxPythonMultiContent.TYPE_TEXT, 80, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, EventName)
1072                                 ))
1073                         else:
1074                                 percent = (nowTime - beginTime)*100/duration
1075                                 restzeit = ((beginTime+duration)-nowTime)
1076                                 res.extend((
1077                                         (eListboxPythonMultiContent.TYPE_PROGRESS, 10, 11, 40, 8, percent),
1078                                         (eListboxPythonMultiContent.TYPE_TEXT, 10, 25, 60, 22, 1, RT_HALIGN_LEFT, "+%d:%02d" % (restzeit/3600, (restzeit/60)-((restzeit /3600)*60))),
1079                                         (eListboxPythonMultiContent.TYPE_TEXT, 80, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP, EventName)
1080                                 ))
1081                 elif beginTime is not None:
1082                         if nowTime < beginTime:
1083                                 begin = localtime(beginTime)
1084                                 end = localtime(beginTime+duration)
1085                                 res.extend((
1086                                         (eListboxPythonMultiContent.TYPE_TEXT, 0, 4, 10, 20, 1, RT_HALIGN_RIGHT, '>'),
1087                                         (eListboxPythonMultiContent.TYPE_TEXT, 10, 4, 70, 44, 1, RT_HALIGN_LEFT, "%02d.%02d\n%02d.%02d"%(begin[3],begin[4],end[3],end[4])),
1088                                         (eListboxPythonMultiContent.TYPE_TEXT, 80, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, EventName)
1089                                 ))
1090                         else:
1091                                 percent = (nowTime - beginTime)*100/duration
1092                                 restzeit = ((beginTime+duration)-nowTime)
1093                                 res.extend((
1094                                         (eListboxPythonMultiContent.TYPE_PROGRESS, 10, 11, 40, 8, percent),
1095                                         (eListboxPythonMultiContent.TYPE_TEXT, 10, 25, 60, 22, 1, RT_HALIGN_LEFT, "+%d:%02d" % (restzeit/3600, (restzeit/60)-((restzeit /3600)*60))),
1096                                         (eListboxPythonMultiContent.TYPE_TEXT, 80, 1, self.breite, 48, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, EventName)
1097                                 ))
1098                 return res
1099
1100         def moveToService(self,serviceref):
1101                 if not serviceref:
1102                         return
1103                 index = 0
1104                 refstr = serviceref.toString()
1105                 for x in self.list:
1106                         if x[1] == refstr:
1107                                 self.instance.moveSelectionTo(index)
1108                                 break
1109                         index += 1
1110                 if x[1] != refstr:
1111                         self.instance.moveSelectionTo(0)
1112
1113
1114
1115 class EasySelection(EPGSelection, Screen):
1116         if SKINTYPE == 3:
1117                 skin = """
1118                 <screen name="EasySelection" backgroundColor="background" flags="wfNoBorder" position="0,0" size="1280,720" title="Easy Selection">
1119                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="60,35" size="660,650" zPosition="-1"/>
1120                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="720,35" size="500,650" zPosition="-1"/>
1121                         <widget name="list" position="60,35" scrollbarMode="showNever" size="660,650" transparent="1"/>
1122                         <widget name="listN" position="720,35" scrollbarMode="showNever" size="500,650" transparent="1"/>
1123                 </screen>"""
1124         elif SKINTYPE == 2:
1125                 skin = """
1126                 <screen name="EasySelection" backgroundColor="background" flags="wfNoBorder" position="0,0" size="1024,576" title="Easy Selection">
1127                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="40,38" size="660,500" zPosition="-1"/>
1128                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="700,38" size="284,500" zPosition="-1"/>
1129                         <widget name="list" position="40,38" scrollbarMode="showNever" size="520,500" transparent="1"/>
1130                         <widget name="listN" position="560,38" scrollbarMode="showNever" size="444,500" transparent="1"/>
1131                 </screen>
1132                 """
1133         else:
1134                 skin = """
1135                 <screen name="EasySelection" backgroundColor="background" flags="wfNoBorder" position="0,0" size="720,576" title="Easy Selection">
1136                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="50,38" size="620,500" zPosition="-1"/>
1137                         <widget name="list" position="50,38" scrollbarMode="showOnDemand" size="620,500" transparent="1"/>
1138                 </screen>
1139                 """
1140         def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None, serviceChangeCB=None):
1141                 Screen.__init__(self, session)
1142                 EPGSelection.__init__(self, session, service, zapFunc, eventid, bouquetChangeCB, serviceChangeCB)
1143                 global EINposition
1144                 EINposition = 0
1145                 allbouq = InfoBar_instance.servicelist.getBouquetList()
1146                 for newpos in range(0, len(allbouq)):
1147                         if InfoBar_instance.servicelist.getRoot() == allbouq[newpos][1]:
1148                                 EINposition = newpos
1149                                 break
1150                 self.session = session
1151                 EPGSelection.skinName = "EasySelection"
1152                 self["list"] = EvNewList(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
1153                 self["listN"] = ESListNext(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
1154                 self.skinName = "EasySelection"
1155                 self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions", "DirectionActions"],
1156                         {
1157                                 "cancel": self.closeScreen,
1158                                 "ok": self.newOKFunc,
1159                                 "info": self.infoKeyPressed,
1160                                 "nextBouquet": self.nextBouquet,
1161                                 "prevBouquet": self.prevBouquet,
1162                                 "right": self.right,
1163                                 "rightRepeated": self.right,
1164                                 "left": self.left,
1165                                 "leftRepeated": self.left,
1166                                 "up": self.up,
1167                                 "upRepeated": self.up,
1168                                 "down": self.down,
1169                                 "downRepeated": self.down,
1170                                 "nextService": self.PrimeTimeLook,
1171                                 "prevService": self.NowNextLook
1172                         },-1)
1173                 self.onLayoutFinish.append(self.byLayoutEnd)
1174
1175         def byLayoutEnd(self):
1176                 self["listN"].recalcEntrySize()
1177                 self["listN"].fillMultiEPG(self.services, -1)
1178                 self["listN"].moveToService(self.session.nav.getCurrentlyPlayingServiceReference())
1179                 self["listN"].updateMultiEPG(1)
1180
1181         def closeScreen(self):
1182                 self.close(True)
1183
1184         def newOKFunc(self):
1185                 self.zapTo()
1186                 self.close(True)
1187
1188         def left(self):
1189                 self["list"].instance.moveSelection(self["list"].instance.pageUp)
1190                 self["listN"].instance.moveSelection(self["list"].instance.pageUp)
1191
1192         def right(self):
1193                 self["list"].instance.moveSelection(self["list"].instance.pageDown)
1194                 self["listN"].instance.moveSelection(self["list"].instance.pageDown)
1195
1196         def up(self):
1197                 self["list"].moveUp()
1198                 self["listN"].moveUp()
1199
1200         def down(self):
1201                 self["list"].moveDown()
1202                 self["listN"].moveDown()
1203
1204         def nextBouquet(self):
1205                 if self.bouquetChangeCB:
1206                         self.bouquetChangeCB(1, self)
1207                         self.byLayoutEnd()
1208
1209         def prevBouquet(self):
1210                 if self.bouquetChangeCB:
1211                         self.bouquetChangeCB(-1, self)
1212                         self.byLayoutEnd()
1213
1214         def PrimeTimeLook(self):
1215                 heute = localtime()
1216                 pt = (heute[0],heute[1],heute[2],config.plugins.EasyInfo.Primetime2.value[0],config.plugins.EasyInfo.Primetime2.value[1],0,heute[6],heute[7],0)
1217                 ask_time = int(mktime(pt))
1218                 if ask_time > int(mktime(heute)):
1219                         self["list"].fillMultiEPG(self.services, ask_time)
1220                         pt = (heute[0],heute[1],heute[2],config.plugins.EasyInfo.Primetime3.value[0],config.plugins.EasyInfo.Primetime3.value[1],0,heute[6],heute[7],0)
1221                         ask_time = int(mktime(pt))
1222                         self["listN"].fillMultiEPG(self.services, ask_time)
1223
1224         def NowNextLook(self):
1225                 self["list"].fillMultiEPG(self.services, -1)
1226                 self["listN"].fillMultiEPG(self.services, -1)
1227                 self["listN"].updateMultiEPG(1)
1228
1229         def infoKeyPressed(self):
1230                 cur = self["list"].getCurrent()
1231                 service = cur[1].ref.toString()
1232                 ref = eServiceReference(service)
1233                 if ref:
1234                         InfoBar_instance.servicelist.savedService = ref
1235                         self.session.openWithCallback(InfoBar_instance.servicelist.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = InfoBar_instance.servicelist.changeServiceCB)
1236
1237
1238
1239
1240
1241
1242
1243         
1244
1245
1246
1247