drop plugin-local translations (in favor of the global ones in /po)
[enigma2-plugins.git] / easymedia / src / plugin.py
1 #######################################################################
2 #
3 #    EasyMedia for Dreambox-Enigma2
4 #    Coded by Vali (c)2010-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 from Screens.Screen import Screen
21 from Screens.MessageBox import MessageBox
22 from Screens.InfoBarGenerics import InfoBarPlugins
23 from Screens.InfoBar import InfoBar
24 from Screens.ChoiceBox import ChoiceBox
25 from Plugins.Plugin import PluginDescriptor
26 from Components.ActionMap import ActionMap
27 from Components.MenuList import MenuList
28 from Components.Label import Label
29 from Components.ConfigList import ConfigListScreen
30 from Components.PluginComponent import plugins
31 from Components.PluginList import *
32 from Components.Sources.StaticText import StaticText
33 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
34 from Tools.Directories import fileExists, pathExists, resolveFilename, SCOPE_PLUGINS
35 from Tools.LoadPixmap import LoadPixmap
36 from Tools.HardwareInfo import HardwareInfo
37 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont, getDesktop
38 import pickle
39 from os import system as os_system
40 from os import listdir as os_listdir
41
42
43
44 EMbaseInfoBarPlugins__init__ = None
45 EMStartOnlyOneTime = False
46 EMsession = None
47 InfoBar_instance = None
48
49
50
51 config.plugins.easyMedia  = ConfigSubsection()
52 config.plugins.easyMedia.music = ConfigSelection(default="mediaplayer", choices = [("no", _("Disabled")), ("mediaplayer", _("MediaPlayer")), ("merlinmp", _("MerlinMusicPlayer"))])
53 config.plugins.easyMedia.files = ConfigSelection(default="dreamexplorer", choices = [("no", _("Disabled")), ("filebrowser", _("Filebrowser")), ("dreamexplorer", _("DreamExplorer")), ("tuxcom", _("TuxCom"))])
54 config.plugins.easyMedia.videodb = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
55 config.plugins.easyMedia.bookmarks = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
56 config.plugins.easyMedia.pictures = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
57 config.plugins.easyMedia.mytube = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
58 config.plugins.easyMedia.vlc = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
59 config.plugins.easyMedia.dvd = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
60 config.plugins.easyMedia.weather = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
61 config.plugins.easyMedia.iradio = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
62 config.plugins.easyMedia.idream = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
63 config.plugins.easyMedia.zdfmedia = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
64 config.plugins.easyMedia.radio = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
65 config.plugins.easyMedia.myvideo = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
66 config.plugins.easyMedia.timers = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
67
68
69
70 def Plugins(**kwargs):
71         return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = EasyMediaAutostart),
72                         PluginDescriptor(name="EasyMedia", description=_("Not easy way to start EasyMedia"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=notEasy),]
73
74
75
76 def EasyMediaAutostart(reason, **kwargs):
77         global EMbaseInfoBarPlugins__init__
78         if "session" in kwargs:
79                 global EMsession
80                 EMsession = kwargs["session"]
81                 if EMbaseInfoBarPlugins__init__ is None:
82                         EMbaseInfoBarPlugins__init__ = InfoBarPlugins.__init__
83                 InfoBarPlugins.__init__ = InfoBarPlugins__init__
84                 InfoBarPlugins.pvr = pvr
85
86
87
88 def InfoBarPlugins__init__(self):
89         global EMStartOnlyOneTime
90         if not EMStartOnlyOneTime: 
91                 EMStartOnlyOneTime = True
92                 global InfoBar_instance
93                 InfoBar_instance = self
94                 self["EasyMediaActions"] = ActionMap(["EasyMediaActions"],
95                         {"video_but": self.pvr}, -1)
96         else:
97                 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
98                 InfoBarPlugins.pvr = None
99         EMbaseInfoBarPlugins__init__(self)
100
101
102
103 def pvr(self):
104         self.session.openWithCallback(MPcallbackFunc, EasyMedia)
105
106
107
108 def notEasy(session, **kwargs):
109         session.openWithCallback(MPcallbackFunc, EasyMedia)
110
111
112
113 def MPanelEntryComponent(key, text, cell):
114         sz_w = getDesktop(0).size().width()
115         if sz_w > 1400:
116                 ih=90
117                 wx=200
118                 wy=20
119                 psx=135
120                 psy=85
121         else:
122                 ih=60
123                 wx=150
124                 wy=17
125                 psx=100
126                 psy=50
127
128         res = [ text ]
129         res.append((eListboxPythonMultiContent.TYPE_TEXT, wx, wy, 300, ih, 0, RT_HALIGN_LEFT, text[0]))
130         if cell<5:
131                 bpng = LoadPixmap('/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/key-' + str(cell) + ".png")
132                 if bpng is not None:
133                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 5, 5, psy, bpng))
134         png = LoadPixmap(EasyMedia.EMiconspath + key + '.png')
135         if png is not None:
136                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 25, 5, psx, psy, png))
137         else:
138                 png = LoadPixmap(EasyMedia.EMiconspath + 'default.png')
139                 if png is not None:
140                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 25, 5, psx, psy, png))
141         return res
142
143
144
145 class MPanelList(MenuList):
146         def __init__(self, list, selection = 0, enableWrapAround=True):
147                 sz_w = getDesktop(0).size().width()
148                 if sz_w > 1400:
149                         fs=30
150                         ih=90
151                 else:
152                         fs=20
153                         ih=60 
154
155                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
156                 self.l.setFont(0, gFont("Regular", fs))
157                 self.l.setItemHeight(ih)
158                 self.selection = selection
159         def postWidgetCreate(self, instance):
160                 MenuList.postWidgetCreate(self, instance)
161                 self.moveToIndex(self.selection)
162
163
164
165 def BookmarksCallback(choice):
166         choice = choice and choice[1]
167         if choice:
168                 config.movielist.last_videodir.value = choice
169                 config.movielist.last_videodir.save()
170                 if InfoBar_instance:
171                         InfoBar_instance.showMovies()
172
173
174
175 def TvRadioCallback(choice):
176         choice = choice and choice[1]
177         if choice == "TM":
178                 if InfoBar_instance:
179                         InfoBar_instance.showTv()
180         elif choice == "RM":
181                 if InfoBar_instance:
182                         InfoBar_instance.showRadio()
183
184
185
186 class ConfigEasyMedia(ConfigListScreen, Screen):
187         skin = """
188                 <screen name="ConfigEasyMedia" position="center,center" size="600,410" title="EasyMedia settings...">
189                         <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="590,380"/>
190                         <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,388" size="140,26" text="Cancel"/>
191                         <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,388" size="140,26" text="Save"/>
192                         <eLabel font="Regular;20" foregroundColor="#00f3ca09" halign="center" position="310,388" size="140,26" text="Plugins"/>
193                 </screen>"""
194         def __init__(self, session):
195                 Screen.__init__(self, session)
196                 self.setTitle(_("EasyMedia settings..."))
197                 self.session = session
198                 list = []
199                 list.append(getConfigListEntry(_("Video database:"), config.plugins.easyMedia.videodb))
200                 list.append(getConfigListEntry(_("Music player:"), config.plugins.easyMedia.music))
201                 list.append(getConfigListEntry(_("Files browser:"), config.plugins.easyMedia.files))
202                 list.append(getConfigListEntry(_("Show bookmarks:"), config.plugins.easyMedia.bookmarks))
203                 list.append(getConfigListEntry(_("Timer:"), config.plugins.easyMedia.timers))
204                 list.append(getConfigListEntry(_("PicturePlayer:"), config.plugins.easyMedia.pictures))
205                 list.append(getConfigListEntry(_("Show tv/radio switch:"), config.plugins.easyMedia.radio))
206                 list.append(getConfigListEntry(_("YouTube player:"), config.plugins.easyMedia.mytube))
207                 list.append(getConfigListEntry(_("VLC player:"), config.plugins.easyMedia.vlc))
208                 list.append(getConfigListEntry(_("DVD player:"), config.plugins.easyMedia.dvd))
209                 list.append(getConfigListEntry(_("Weather plugin:"), config.plugins.easyMedia.weather))
210                 list.append(getConfigListEntry(_("InternetRadio player:"), config.plugins.easyMedia.iradio))
211                 list.append(getConfigListEntry(_("Show Merlin-iDream:"), config.plugins.easyMedia.idream))
212                 list.append(getConfigListEntry(_("ZDFmediathek player:"), config.plugins.easyMedia.zdfmedia))
213                 list.append(getConfigListEntry(_("MyVideo player:"), config.plugins.easyMedia.myvideo))
214                 ConfigListScreen.__init__(self, list)
215                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "red": self.exit, "cancel": self.exit, "yellow": self.plug}, -1)
216
217         def save(self):
218                 for x in self["config"].list:
219                         x[1].save()
220                 self.close()
221
222         def exit(self):
223                 for x in self["config"].list:
224                         x[1].cancel()
225                 self.close()
226
227         def plug(self):
228                 self.session.open(AddPlug)
229
230
231
232 class AddPlug(Screen):
233         skin = """
234                 <screen name="AddPlug" position="center,center" size="440,420" title="EasyMedia...">
235                 <widget source="pluginlist" render="Listbox" position="10,10" size="420,400" scrollbarMode="showOnDemand">
236                         <convert type="TemplatedMultiContent">
237                         {"templates":
238                                 {"default": (50,[
239                                                 MultiContentEntryText(pos = (120, 5), size = (320, 25), font = 0, text = 1), # index 1 is the plugin.name
240                                                 MultiContentEntryText(pos = (120, 26), size = (320, 17), font = 1, text = 2), # index 2 is the plugin.description
241                                                 MultiContentEntryPixmapAlphaTest(pos = (10, 5), size = (100, 40), png = 3), # index 3 is the icon
242                                                 
243                                         ]),
244                                 },
245                                 "fonts": [gFont("Regular", 20), gFont("Regular", 14)],
246                                 "itemHeight": 50
247                         }
248                         </convert>
249                 </widget>
250                 </screen>"""
251         def __init__(self, session):
252                 Screen.__init__(self, session)
253                 self.setTitle(_("Add/remove plugin"))
254                 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
255                 self.session = session
256                 self.list = []
257                 self["pluginlist"] = PluginList(self.list)
258                 #self.updateList()
259                 self.pluginlist = []
260                 self["actions"] = ActionMap(["WizardActions"],
261                 {
262                         "ok": self.save,
263                         "back": self.close
264                 }, -1)
265                 self.onExecBegin.append(self.checkWarnings)
266                 self.onShown.append(self.updateList)
267
268         def checkWarnings(self):
269                 if len(plugins.warnings):
270                         text = _("Some plugins are not available:\n")
271                         for (pluginname, error) in plugins.warnings:
272                                 text += _("%s (%s)\n") % (pluginname, error)
273                         plugins.resetWarnings()
274                         self.session.open(MessageBox, text = text, type = MessageBox.TYPE_WARNING)
275
276         def updateList(self):
277                 self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
278                 self.list = [PluginEntryComponent(plugin) for plugin in self.pluginlist]
279                 self["pluginlist"].setList(self.list)
280
281         def save(self):
282                 plugin = self["pluginlist"].getCurrent()[0]
283                 print plugin
284                 plugin.icon = None
285                 if not fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugin.name + ".plug"):
286                         try:
287                                 outf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugin.name + ".plug"), 'wb')
288                                 pickle.dump(plugin, outf)
289                                 outf.close()
290                                 self.session.open(MessageBox, text = (plugin.name + _(" added to EasyMedia")), type = MessageBox.TYPE_INFO)
291                         except: self.session.open(MessageBox, text = "Write Error!", type = MessageBox.TYPE_WARNING)
292                 else:
293                         order = 'rm -f \"' + '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/' + plugin.name + '.plug' + '\"'
294                         try:
295                                 os_system(order)
296                                 self.session.open(MessageBox, text = (plugin.name + _(" removed from EasyMedia")), type = MessageBox.TYPE_INFO)
297                         except: self.session.open(MessageBox, text = "Write Error!", type = MessageBox.TYPE_WARNING)
298
299
300
301 class EasyMediaSummary(Screen):
302         if "800se" in HardwareInfo().get_device_name():
303                 skin = """
304                         <screen position="0,0" size="96,64" id="2">
305                                 <eLabel text="EasyMedia:" foregroundColor="#fcc000" position="0,0" size="96,24" font="Regular;16"/>
306                                 <widget name="text1" position="0,24" size="96,40" font="Regular;18"/>
307                         </screen>"""
308         else:
309                 skin = """
310                         <screen position="0,0" size="132,64">
311                                 <eLabel text="EasyMedia:" position="0,0" size="132,24" font="Regular;14"/>
312                                 <widget name="text1" position="0,24" size="132,40" font="Regular;16"/>
313                         </screen>"""
314         def __init__(self, session, parent):
315                 Screen.__init__(self, session)
316                 self["text1"] = Label()
317                 self.onLayoutFinish.append(self.layoutEnd)
318
319         def layoutEnd(self):
320                 self["text1"].setText(_("Movies"))
321
322         def setText(self, text, line):
323                 self["text1"].setText(text)
324
325
326
327 class EasyMedia(Screen):
328         sz_w = getDesktop(0).size().width()
329         if sz_w > 1800:
330                 skin = """
331                 <screen flags="wfNoBorder" position="0,0" size="550,1080" title="Easy Media">
332                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg2.png" position="0,0" size="750,576"/>
333                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg2.png" position="0,576" size="750,503"/>
334                         <widget name="list" position="60,30" size="450,1080" scrollbarMode="showNever" transparent="1" zPosition="2"/>
335                 </screen>"""
336         elif sz_w > 1100:
337                 skin = """
338                 <screen flags="wfNoBorder" position="0,0" size="450,720" title="Easy Media">
339                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
340                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,576" size="450,145"/>
341                         <widget name="list" position="60,30" size="350,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
342                 </screen>"""
343         elif sz_w > 1000:
344                 skin = """
345                 <screen flags="wfNoBorder" position="-20,0" size="450,576" title="Easy Media">
346                         #<ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
347                         <widget name="list" position="70,48" size="320,480" scrollbarMode="showNever" transparent="1" zPosition="2"/>
348                 </screen>"""
349         else:
350                 skin = """
351                 <screen position="center,center" size="320,440" title="Easy Media">
352                         <widget name="list" position="10,10" size="300,420" scrollbarMode="showOnDemand" />
353                 </screen>"""
354         if pathExists('/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/icons/'):
355                 EMiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/icons/'
356         else:
357                 EMiconspath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/'
358         def __init__(self, session):
359                 Screen.__init__(self, session)
360                 self.session = session
361                 self.list = []
362                 self.__keys = []
363                 MPaskList = []
364                 self["key_pvr"] = StaticText(" ")
365                 self["key_yellow"] = StaticText(" ")
366                 self["key_green"] = StaticText(" ")
367                 self["key_red"] = StaticText(" ")
368                 self["key_blue"] = StaticText(" ")
369                 if True:
370                         self.__keys.append("movies")
371                         MPaskList.append((_("Movies"), "PLAYMOVIES"))
372                 if config.plugins.easyMedia.bookmarks.value != "no":
373                         self.__keys.append("bookmarks")
374                         MPaskList.append((_("Bookmarks"), "BOOKMARKS"))
375                 if config.plugins.easyMedia.timers.value != "no":
376                         self.__keys.append("timers")
377                         MPaskList.append((_("Timer"), "TIMERS"))
378                 if config.plugins.easyMedia.videodb.value != "no":
379                         self.__keys.append("videodb")
380                         MPaskList.append((_("VideoDB"), "VIDEODB"))
381                 if config.plugins.easyMedia.pictures.value != "no":
382                         self.__keys.append("pictures")
383                         MPaskList.append((_("Pictures"), "PICTURES"))
384                 if config.plugins.easyMedia.music.value != "no":
385                         self.__keys.append("music")
386                         MPaskList.append((_("Music"), "MUSIC"))
387                 if config.plugins.easyMedia.radio.value != "no":
388                         self.__keys.append("radio")
389                         if config.usage.e1like_radio_mode.value:
390                                 MPaskList.append((_("Tv/Radio"), "RADIO"))
391                         else:
392                                 MPaskList.append((_("Radio"), "RADIO"))
393                 if config.plugins.easyMedia.dvd.value != "no":
394                         self.__keys.append("dvd")
395                         MPaskList.append((_("DVD Player"), "DVD"))
396                 if config.plugins.easyMedia.weather.value != "no":
397                         self.__keys.append("weather")
398                         MPaskList.append((_("Weather"), "WEATHER"))
399                 if config.plugins.easyMedia.files.value != "no":
400                         self.__keys.append("files")
401                         MPaskList.append((_("Files"), "FILES"))
402                 if config.plugins.easyMedia.iradio.value != "no":
403                         self.__keys.append("internetradio")
404                         MPaskList.append((_("InternetRadio"), "INTERNETRADIO"))
405                 if config.plugins.easyMedia.idream.value != "no":
406                         self.__keys.append("idream")
407                         MPaskList.append((_("iDream"), "IDREAM"))
408                 if config.plugins.easyMedia.mytube.value != "no":
409                         self.__keys.append("mytube")
410                         MPaskList.append((_("MyTube Player"), "MYTUBE"))
411                 if config.plugins.easyMedia.vlc.value != "no":
412                         self.__keys.append("vlc")
413                         MPaskList.append((_("VLC Player"), "VLC"))
414                 if config.plugins.easyMedia.zdfmedia.value != "no":
415                         self.__keys.append("zdf")
416                         MPaskList.append((_("ZDFmediathek"), "ZDF"))
417                 if config.plugins.easyMedia.myvideo.value != "no":
418                         self.__keys.append("myvideo")
419                         MPaskList.append((_("MyVideo"), "MYVIDEO"))
420                 plist = os_listdir("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia")
421                 plist = [x[:-5] for x in plist if x.endswith('.plug')]
422                 plist.sort()
423                 for onePlug in plist:
424                         try:
425                                 inpf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + onePlug + ".plug"), 'rb')
426                                 binPlug = pickle.load(inpf)
427                                 inpf.close()    
428                                 self.__keys.append(binPlug.name)
429                                 MPaskList.append((binPlug.name, ("++++" + binPlug.name)))
430                         except: pass
431                 pos = 0
432                 for x in MPaskList:
433                         strpos = str(self.__keys[pos])
434                         self.list.append(MPanelEntryComponent(key = strpos, text = x, cell = pos))
435                         if pos==0: self["key_pvr"].setText(MPaskList[0][0])
436                         elif pos==1: self["key_red"].setText(MPaskList[1][0])
437                         elif pos==2: self["key_green"].setText(MPaskList[2][0])
438                         elif pos==3: self["key_yellow"].setText(MPaskList[3][0])
439                         elif pos==4: self["key_blue"].setText(MPaskList[4][0])
440                         pos += 1
441                 self["list"] = MPanelList(list = self.list, selection = 0)
442                 self["list"].onSelectionChanged.append(self.updateOLED)
443                 self["actions"] = ActionMap(["WizardActions", "MenuActions", "InfobarActions", "ColorActions"],
444                 {
445                         "ok": self.go,
446                         "back": self.cancel,
447                         "menu": self.emContextMenu,
448                         "showMovies": lambda: self.go2(MPaskList,0),
449                         "green": lambda: self.go2(MPaskList,2),
450                         "red": lambda: self.go2(MPaskList,1),
451                         "blue": lambda: self.go2(MPaskList,4),
452                         "yellow": lambda: self.go2(MPaskList,3)
453                 }, -1)
454
455         def cancel(self):
456                 self.close(None)
457
458         def go(self):
459                 cursel = self["list"].l.getCurrentSelection()
460                 if cursel:
461                         self.goEntry(cursel[0])
462                 else:
463                         self.cancel()
464
465         def go2(self, was, wohin):
466                 if wohin == 0:
467                         self.close(was[wohin])
468                 elif wohin == 1:
469                         if len(was)>1: 
470                                 self.close(was[wohin])
471                 elif wohin == 2:
472                         if len(was)>2: 
473                                 self.close(was[wohin])
474                 elif wohin == 3:
475                         if len(was)>3: 
476                                 self.close(was[wohin])
477                 elif wohin == 4:
478                         if len(was)>4: 
479                                 self.close(was[wohin])
480
481         def goEntry(self, entry):
482                 if len(entry) > 2 and isinstance(entry[1], str) and entry[1] == "CALLFUNC":
483                         arg = self["list"].l.getCurrentSelection()[0]
484                         entry[2](arg)
485                 else:
486                         self.close(entry)
487
488         def emContextMenu(self):
489                 self.session.open(ConfigEasyMedia)
490
491         def createSummary(self):
492                 return EasyMediaSummary
493
494         def updateOLED(self):
495                 text = str(self["list"].l.getCurrentSelection()[0][0])
496                 self.summaries.setText(text, 1)
497
498
499
500 def MPcallbackFunc(answer):
501         if EMsession is None:
502                 return
503         answer = answer and answer[1]
504         if answer == "PLAYMOVIES":
505                 if InfoBar_instance:
506                         InfoBar_instance.showMovies()
507         elif answer == "RADIO":
508                 if config.usage.e1like_radio_mode.value:
509                         askBM = []
510                         askBM.append((_("TV-mode"), "TM"))
511                         askBM.append((_("Radio-mode"), "RM"))
512                         askBM.append((_("Nothing"), "NO"))
513                         EMsession.openWithCallback(TvRadioCallback, ChoiceBox, title="EasyMedia...", list = askBM)
514                 else:
515                         if InfoBar_instance:
516                                 InfoBar_instance.showRadio()
517         elif answer == "BOOKMARKS":
518                 tmpBookmarks = config.movielist.videodirs
519                 myBookmarks = tmpBookmarks and tmpBookmarks.value[:] or []
520                 if len(myBookmarks)>0:
521                         askBM = []
522                         for s in myBookmarks:
523                                 askBM.append((s, s))
524                         EMsession.openWithCallback(BookmarksCallback, ChoiceBox, title=_("Select bookmark..."), list = askBM)
525         elif answer == "PICTURES":
526                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/PicturePlayer/plugin.pyo"):
527                         from Plugins.Extensions.PicturePlayer.plugin import picshow
528                         EMsession.open(picshow)
529                 else:
530                         EMsession.open(MessageBox, text = _('Picture-player is not installed!'), type = MessageBox.TYPE_ERROR)
531         elif answer == "MUSIC":
532                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "merlinmp"):
533                         from Plugins.Extensions.MerlinMusicPlayer.plugin import MerlinMusicPlayerFileList
534                         servicelist = None
535                         EMsession.open(MerlinMusicPlayerFileList, servicelist)
536                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MediaPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "mediaplayer"):
537                         from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
538                         EMsession.open(MediaPlayer)
539                 else:
540                         EMsession.open(MessageBox, text = _('No Music-Player installed!'), type = MessageBox.TYPE_ERROR)
541         elif answer == "FILES":
542                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Tuxcom/plugin.pyo") and (config.plugins.easyMedia.files.value == "tuxcom"):
543                         from Plugins.Extensions.Tuxcom.plugin import TuxComStarter
544                         EMsession.open(TuxComStarter)
545                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/plugin.pyo") and (config.plugins.easyMedia.files.value == "dreamexplorer"):
546                         from Plugins.Extensions.DreamExplorer.plugin import DreamExplorerII
547                         EMsession.open(DreamExplorerII)
548                 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Filebrowser/plugin.pyo") and (config.plugins.easyMedia.files.value == "filebrowser"):
549                         from Plugins.Extensions.Filebrowser.plugin import FilebrowserScreen
550                         EMsession.open(FilebrowserScreen)
551                 else:
552                         EMsession.open(MessageBox, text = _('No File-Manager installed!'), type = MessageBox.TYPE_ERROR)
553         elif answer == "WEATHER":
554                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/WeatherPlugin/plugin.pyo"):
555                         from Plugins.Extensions.WeatherPlugin.plugin import MSNWeatherPlugin
556                         EMsession.open(MSNWeatherPlugin)
557                 else:
558                         EMsession.open(MessageBox, text = _('Weather Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
559         elif answer == "DVD":
560                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DVDPlayer/plugin.pyo"):
561                         from Plugins.Extensions.DVDPlayer.plugin import DVDPlayer
562                         EMsession.open(DVDPlayer)
563                 else:
564                         EMsession.open(MessageBox, text = _('DVDPlayer Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
565         elif answer == "MYTUBE":
566                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MyTube/plugin.pyo"):
567                         from Plugins.Extensions.MyTube.plugin import *
568                         MyTubeMain(EMsession)
569                 else:
570                         EMsession.open(MessageBox, text = _('MyTube Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
571         elif answer == "INTERNETRADIO":
572                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/plugin.pyo"):
573                         from Plugins.Extensions.InternetRadio.InternetRadioScreen import InternetRadioScreen
574                         EMsession.open(InternetRadioScreen)
575                 else:
576                         EMsession.open(MessageBox, text = _('SHOUTcast Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
577         elif answer == "ZDF":
578                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/ZDFMediathek/plugin.pyo"):
579                         from Plugins.Extensions.ZDFMediathek.plugin import ZDFMediathek
580                         EMsession.open(ZDFMediathek)
581                 else:
582                         EMsession.open(MessageBox, text = _('ZDFmediathek Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
583         elif answer == "VLC":
584                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VlcPlayer/plugin.pyo"):
585                         from Plugins.Extensions.VlcPlayer.plugin import *
586                         main(EMsession)
587                 else:
588                         EMsession.open(MessageBox, text = _('VLC Player is not installed!'), type = MessageBox.TYPE_ERROR)
589         elif answer == "IDREAM":
590                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo"):
591                         from Plugins.Extensions.MerlinMusicPlayer.plugin import iDreamMerlin
592                         servicelist = None
593                         EMsession.open(iDreamMerlin, servicelist)
594                 else:
595                         EMsession.open(MessageBox, text = _('Merlin iDream is not installed!'), type = MessageBox.TYPE_ERROR)
596         elif answer == "MYVIDEO":
597                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MyVideoPlayer/plugin.pyo"):
598                         from Plugins.Extensions.MyVideoPlayer.plugin import Vidtype
599                         EMsession.open(Vidtype)
600                 else:
601                         EMsession.open(MessageBox, text = _('MyVideo Player is not installed!'), type = MessageBox.TYPE_ERROR)
602         elif answer == "VIDEODB":
603                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VideoDB/plugin.pyo"):
604                         from Plugins.Extensions.VideoDB.plugin import main as vdbmain
605                         vdbmain(EMsession)
606                 else:
607                         EMsession.open(MessageBox, text = _('VideoDB is not installed!'), type = MessageBox.TYPE_ERROR)
608         elif answer == "TIMERS":
609                 from Screens.TimerEdit import TimerEditList
610                 EMsession.open(TimerEditList)
611         elif answer is not None and "++++" in answer:
612                 plugToRun = answer[4:]
613                 try:
614                         inpf = open(("/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/" + plugToRun + ".plug"), 'rb')
615                         runPlug = pickle.load(inpf)
616                         inpf.close()    
617                         runPlug(session = EMsession)
618                 except: EMsession.open(MessageBox, text = (plugToRun + " not found!"), type = MessageBox.TYPE_WARNING)
619
620
621