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