From 1743f5e172cd8815a5a9d687ead3cd051e681ea3 Mon Sep 17 00:00:00 2001 From: "Chang.H.S" Date: Fri, 29 Jun 2012 14:51:31 +0900 Subject: [PATCH] Zapping Mode Selection : add new Plugin --- configure.ac | 2 + lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- .../SystemPlugins/ZappingModeSelection/Makefile.am | 7 ++ .../SystemPlugins/ZappingModeSelection/__init__.py | 1 + .../ZappingModeSelection/meta/Makefile.am | 3 + .../meta/plugin_zappingmodeselection.xml | 16 +++++ .../SystemPlugins/ZappingModeSelection/plugin.py | 80 ++++++++++++++++++++++ 7 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 lib/python/Plugins/SystemPlugins/ZappingModeSelection/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/ZappingModeSelection/__init__.py create mode 100644 lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/plugin_zappingmodeselection.xml create mode 100644 lib/python/Plugins/SystemPlugins/ZappingModeSelection/plugin.py diff --git a/configure.ac b/configure.ac index 76585fa..ab3b786 100644 --- a/configure.ac +++ b/configure.ac @@ -263,6 +263,8 @@ lib/python/Plugins/SystemPlugins/3GModemManager/meta/Makefile lib/python/Plugins/SystemPlugins/3GModemManager/script/Makefile lib/python/Plugins/SystemPlugins/WirelessAccessPoint/Makefile lib/python/Plugins/SystemPlugins/WirelessAccessPoint/meta/Makefile +lib/python/Plugins/SystemPlugins/ZappingModeSelection/Makefile +lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index 7e31a15..428783b 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \ TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \ Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC LEDBrightnessSetup \ - FirmwareUpgrade CrashReport 3GModemManager WirelessAccessPoint + FirmwareUpgrade CrashReport 3GModemManager WirelessAccessPoint ZappingModeSelection install_PYTHON = \ __init__.py diff --git a/lib/python/Plugins/SystemPlugins/ZappingModeSelection/Makefile.am b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/Makefile.am new file mode 100644 index 0000000..f4c9603 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/Makefile.am @@ -0,0 +1,7 @@ +installdir = $(pkglibdir)/python/Plugins/SystemPlugins/ZappingModeSelection + +SUBDIRS = meta + +install_PYTHON = \ + __init__.py \ + plugin.py diff --git a/lib/python/Plugins/SystemPlugins/ZappingModeSelection/__init__.py b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/__init__.py new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/__init__.py @@ -0,0 +1 @@ + diff --git a/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/Makefile.am new file mode 100644 index 0000000..623d015 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(datadir)/meta + +dist_install_DATA = plugin_zappingmodeselection.xml diff --git a/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/plugin_zappingmodeselection.xml b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/plugin_zappingmodeselection.xml new file mode 100644 index 0000000..74bf487 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/meta/plugin_zappingmodeselection.xml @@ -0,0 +1,16 @@ + + + + + + hschang + ZappingModeSelection + enigma2-plugin-systemplugins-zappingmodeselection + Select Zapping Mode + Select Zapping Mode, HOLD or MUTE + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/ZappingModeSelection/plugin.py b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/plugin.py new file mode 100644 index 0000000..b0fee9b --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/ZappingModeSelection/plugin.py @@ -0,0 +1,80 @@ +from Screens.Screen import Screen +from Components.ConfigList import ConfigListScreen +from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection +from Components.ActionMap import ActionMap +from Screens.MessageBox import MessageBox +from Components.Sources.StaticText import StaticText +from Plugins.Plugin import PluginDescriptor +from Tools.Directories import fileExists + +config.plugins.zappingModeSelection = ConfigSubsection() +config.plugins.zappingModeSelection.zappingMode = ConfigSelection(default = "mute", choices = [ ("mute", _("MUTE")), ("hold", _("HOLD"))] ) + +class ZappingModeSelectionInit: + def __init__(self): + self.setZappingMode(config.plugins.zappingModeSelection.zappingMode.value) + + def setZappingMode(self, mode = "mute"): + if not fileExists("/proc/stb/video/zapping_mode"): + return -1 + print " set zapping mode : %s" % mode + f = open("/proc/stb/video/zapping_mode", "w") + f.write("%s" % mode) + f.close() + return 0 + +class ZappingModeSelection(Screen,ConfigListScreen,ZappingModeSelectionInit): + skin = """ + + + + + + + + """ + + def __init__(self,session): + Screen.__init__(self,session) + self.session = session + self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ], + { + "ok": self.keySave, + "cancel": self.keyCancel, + "red": self.keyCancel, + "green": self.keySave, + }, -2) + self.list = [] + ConfigListScreen.__init__(self, self.list,session = self.session) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Ok")) + self.createSetup() + + def createSetup(self): + self.list = [] + self.rcsctype = getConfigListEntry(_("Zapping Mode"), config.plugins.zappingModeSelection.zappingMode) + self.list.append( self.rcsctype ) + self["config"].list = self.list + self["config"].l.setList(self.list) + + def keySave(self): + print " Zapping Code : ",config.plugins.zappingModeSelection.zappingMode.value + ret = self.setZappingMode(config.plugins.zappingModeSelection.zappingMode.value) + if ret == -1: + self.resetConfig() + self.session.openWithCallback(self.close, MessageBox, _("SET FAILED!\nPlease update to the latest driver"), MessageBox.TYPE_ERROR) + else: + self.saveAll() + self.close() + + def resetConfig(self): + for x in self["config"].list: + x[1].cancel() + +def main(session, **kwargs): + session.open(ZappingModeSelection) + +def Plugins(**kwargs): + return [PluginDescriptor(name=_("ZappingModeSelection"), description="Zapping Mode Selection", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)] + +zappingmodeselectioninit = ZappingModeSelectionInit() -- 2.7.4