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