From 88a6749020acfb921ae70f714e995af74e72c47c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 3 Mar 2006 12:05:50 +0000 Subject: [PATCH] add a proof-of-concept plugin to define alternative services example: NIM A: DVB-C NIM B: DVB-S (Astra) NIM B records "Sat 1" (vertical) and cannot play or record "Das Erste". Zapping to "Das Erste" now looks up an alternative-table (defined by the user) and plays the service "Das Erste" (cable service) on NIM A, which is assossiated to "Das Erste" (sat service). --- configure.ac | 1 + lib/python/Plugins/Extensions/Makefile.am | 3 +- .../Extensions/ZappingAlternatives/Makefile.am | 0 .../Extensions/ZappingAlternatives/__init__.py | 0 .../Extensions/ZappingAlternatives/plugin.py | 166 +++++++++++++++++++++ mytest.py | 3 +- 6 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 lib/python/Plugins/Extensions/ZappingAlternatives/Makefile.am create mode 100644 lib/python/Plugins/Extensions/ZappingAlternatives/__init__.py create mode 100644 lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py diff --git a/configure.ac b/configure.ac index 66c3a1c..6d4ea16 100644 --- a/configure.ac +++ b/configure.ac @@ -72,6 +72,7 @@ lib/python/Plugins/Extensions/TuxboxPlugins/Makefile lib/python/Plugins/Extensions/WebInterface/Makefile lib/python/Plugins/Extensions/FileManager/Makefile lib/python/Plugins/Extensions/CutListEditor/Makefile +lib/python/Plugins/Extensions/ZappingAlternatives/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Plugins/Extensions/Makefile.am b/lib/python/Plugins/Extensions/Makefile.am index c20a1d8..c5e92f6 100644 --- a/lib/python/Plugins/Extensions/Makefile.am +++ b/lib/python/Plugins/Extensions/Makefile.am @@ -1 +1,2 @@ -SUBDIRS = TuxboxPlugins WebInterface FileManager CutListEditor +SUBDIRS = TuxboxPlugins WebInterface FileManager CutListEditor ZappingAlternatives + diff --git a/lib/python/Plugins/Extensions/ZappingAlternatives/Makefile.am b/lib/python/Plugins/Extensions/ZappingAlternatives/Makefile.am new file mode 100644 index 0000000..e69de29 diff --git a/lib/python/Plugins/Extensions/ZappingAlternatives/__init__.py b/lib/python/Plugins/Extensions/ZappingAlternatives/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py b/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py new file mode 100644 index 0000000..b018c25 --- /dev/null +++ b/lib/python/Plugins/Extensions/ZappingAlternatives/plugin.py @@ -0,0 +1,166 @@ +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import ActionMap +from Components.Label import Label +from Components.Input import Input +from Components.GUIComponent import * +from Components.Pixmap import Pixmap +from Components.MenuList import MenuList +from Components.FileList import FileEntryComponent, FileList +from Navigation import Navigation +import NavigationInstance +from Screens.ChannelSelection import SimpleChannelSelection +from ServiceReference import ServiceReference +from Plugins.Plugin import PluginDescriptor + +import os + +alternatives = {} + +class AlternativeZapping(Screen): + skin = """ + + + + + + + + """ + def __init__(self, session): + self.skin = AlternativeZapping.skin + Screen.__init__(self, session) + + self.red = Label("") + self["red"] = self.red + self.green = Label(_("Add service")) + self["green"] = self.green + self.yellow = Label("") + self["yellow"] = self.yellow + self.blue = Label("") + self["blue"] = self.blue + + self.serviceslist = [] + self["serviceslist"] = MenuList(self.serviceslist) + + self.alternativeslist = [] + self["alternativeslist"] = MenuList(self.alternativeslist) + + self.onShown.append(self.updateServices) + self.onShown.append(self.updateAlternatives) + + self["actions"] = ActionMap(["DirectionActions", "OkCancelActions", "ColorActions"], + { + "ok": self.go, + "cancel": self.close, + "up": self.up, + "down": self.down, + "left": self.left, + "right": self.right, + "red": self.redKey, + "green": self.greenKey, + "yellow": self.yellowKey, + "blue": self.blueKey, + }, -1) + + def go(self): + pass + + def up(self): + self["serviceslist"].instance.moveSelection(self["serviceslist"].instance.moveUp) + self.updateAlternatives() + + def down(self): + self["serviceslist"].instance.moveSelection(self["serviceslist"].instance.moveDown) + self.updateAlternatives() + + def left(self): + pass + + def right(self): + pass + + def redKey(self): + if len(self.serviceslist) > 0: + del alternatives[self["serviceslist"].getCurrent()[1]] + self.updateServices() + self.updateAlternatives() + + def finishedAlternativeSelection(self, args): + alternatives[self["serviceslist"].getCurrent()[1]].append(str(ServiceReference(args))) + self.updateAlternatives() + + def updateServices(self): + self.serviceslist = [] + + for x in alternatives.keys(): + self.serviceslist.append((ServiceReference(x).getServiceName(), x)) + + self["serviceslist"].l.setList(self.serviceslist) + if len(self.serviceslist) > 0: + self.yellow.setText(_("Add alternative")) + self.red.setText(_("Remove service")) + else: + self.yellow.setText("") + self.red.setText("") + + def updateAlternatives(self): + self.alternativeslist = [] + + if len(self.serviceslist) > 0: + alternativelist = alternatives[self["serviceslist"].getCurrent()[1]] + + for x in alternativelist: + self.alternativeslist.append((ServiceReference(x).getServiceName(), x)) + + self["alternativeslist"].l.setList(self.alternativeslist) + + def greenKey(self): + self.session.openWithCallback(self.finishedChannelSelection, SimpleChannelSelection, _("Select reference service")) + + def finishedChannelSelection(self, args): + if alternatives.has_key(str(ServiceReference(args))): + pass + else: + alternatives[str(ServiceReference(args))] = [] + print alternatives + self.updateServices() + #oldref = self.timer.service_ref + #try: + #self.timer.service_ref = ServiceReference(args) + #config.timerentry.service.vals = (str(self.timer.service_ref.getServiceName()),) + #self["config"].invalidate(config.timerentry.service) + #except: + # print "you pressed cancel" + #self.timer.service_ref = oldref + + def yellowKey(self): + if len(self.serviceslist) > 0: + self.session.openWithCallback(self.finishedAlternativeSelection, SimpleChannelSelection, _("Select alternative service")) + + def blueKey(self): + pass + + +oldPlayService = NavigationInstance.instance.playService + +def playService(self, ref): + if not oldPlayService(ref): + if alternatives.has_key(str(ServiceReference(ref))): + for x in alternatives[str(ServiceReference(ref))]: + if oldPlayService(ServiceReference(x).ref): + return 1 + return 0 + return 1 + +def autostart(reason): + if reason == 0: + NavigationInstance.instance.playService = type(NavigationInstance.instance.playService)(playService, NavigationInstance, Navigation) + +def AlternativeZappingSetup(session): + session.open(AlternativeZapping) + +def Plugins(): + return [PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart), + PluginDescriptor(name="Alternative services setup" , description="Defines alternatives for services.", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=AlternativeZappingSetup)] diff --git a/mytest.py b/mytest.py index 4ac9ed6..77e925b 100644 --- a/mytest.py +++ b/mytest.py @@ -37,7 +37,6 @@ except ImportError: # initialize autorun plugins and plugin menu entries from Components.PluginComponent import plugins -plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) from Screens.Wizard import wizardManager from Screens.StartWizard import * @@ -304,6 +303,8 @@ class VolumeControl: def runScreenTest(): session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = Navigation()) + + plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) screensToRun = [ ] -- 2.7.4