From 5a1048279484f56b1db86908e8260b70dfc7bdfb Mon Sep 17 00:00:00 2001 From: "Chang.H.S" Date: Tue, 27 Sep 2011 21:32:10 +0900 Subject: [PATCH] Remote Control Code : Add new plugin --- configure.ac | 2 + lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- .../SystemPlugins/RemoteControlCode/Makefile.am | 7 + .../SystemPlugins/RemoteControlCode/__init__.py | 0 .../RemoteControlCode/meta/Makefile.am | 3 + .../meta/plugin_remotecontrolcode.xml | 16 ++ .../SystemPlugins/RemoteControlCode/plugin.py | 176 +++++++++++++++++++++ 7 files changed, 205 insertions(+), 1 deletion(-) create mode 100755 lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py create mode 100755 lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml create mode 100755 lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py diff --git a/configure.ac b/configure.ac index 27beb1e..de3fa09 100644 --- a/configure.ac +++ b/configure.ac @@ -211,6 +211,8 @@ lib/python/Plugins/SystemPlugins/ManualFancontrol/Makefile lib/python/Plugins/SystemPlugins/ManualFancontrol/meta/Makefile lib/python/Plugins/SystemPlugins/Blindscan/Makefile lib/python/Plugins/SystemPlugins/Blindscan/meta/Makefile +lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile +lib/python/Plugins/SystemPlugins/RemoteControlCode/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 ab4883e..feadb2d 100755 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \ DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \ CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \ TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \ - Blindscan + Blindscan RemoteControlCode install_PYTHON = \ __init__.py diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am b/lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am new file mode 100755 index 0000000..384f3e5 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am @@ -0,0 +1,7 @@ +installdir = $(pkglibdir)/python/Plugins/SystemPlugins/RemoteControlCode + +SUBDIRS = meta + +install_PYTHON = \ + __init__.py \ + plugin.py diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py b/lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py new file mode 100755 index 0000000..e69de29 diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am new file mode 100755 index 0000000..5f2b922 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(datadir)/meta + +dist_install_DATA = plugin_remotecontrolcode.xml diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml new file mode 100755 index 0000000..8301530 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml @@ -0,0 +1,16 @@ + + + + + + hschang + RemoteControlCode + enigma2-plugin-systemplugins-remotecontrolcode + Change Remote Control Code + Change Remote Control Code + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py b/lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py new file mode 100755 index 0000000..cb197e8 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py @@ -0,0 +1,176 @@ +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 +from enigma import eTimer + +config.plugins.remotecontrolcode = ConfigSubsection() +config.plugins.remotecontrolcode.systemcode = ConfigSelection(default = "2", choices = + [ ("1", "1 "), ("2", "2 "), ("3", "3 "), ("4", "4 ") ] ) + +class RemoteControlCodeInit: + def __init__(self): + self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value)) + + def setSystemCode(self, type = 2): + if not fileExists("/proc/stb/fp/remote_code"): + return -1 + print " Write Remote Control Code : %d" % type + f = open("/proc/stb/fp/remote_code", "w") + f.write("%d" % type) + f.close() + return 0 + + def getModel(self): + if fileExists("/proc/stb/info/vumodel"): + vumodel = open("/proc/stb/info/vumodel") + info=vumodel.read().strip() + vumodel.close() + if info in ["uno", "ultimo"]: + return True + else: + return False + else: + return False + +class RemoteControlCode(Screen,ConfigListScreen,RemoteControlCodeInit): + 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(_("Save")) + self.createSetup() + self.onLayoutFinish.append(self.checkModel) + self.checkModelTimer = eTimer() + self.checkModelTimer.callback.append(self.invalidmodel) + + def checkModel(self): + if not self.getModel(): + self.checkModelTimer.start(1000,True) + + def invalidmodel(self): + self.session.openWithCallback(self.close, MessageBox, _("This Plugin only support for UNO/ULTIMO"), MessageBox.TYPE_ERROR) + + def createSetup(self): + self.list = [] + self.rcsctype = getConfigListEntry(_("Remote Control System Code"), config.plugins.remotecontrolcode.systemcode) + self.list.append( self.rcsctype ) + self["config"].list = self.list + self["config"].l.setList(self.list) + + def keySave(self): + print " Selected System Code : ",config.plugins.remotecontrolcode.systemcode.value + ret = self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value)) + if ret == -1: + self.restoreCode() + self.session.openWithCallback(self.close, MessageBox, _("FILE NOT EXIST : /proc/stb/fp/remote_code"), MessageBox.TYPE_ERROR) + else: + self.session.openWithCallback(self.MessageBoxConfirmCodeCallback, MessageBoxConfirmCode, _("If new remote control code correct, select 'yes'."), MessageBox.TYPE_YESNO, timeout = 10, default = False) + + def restoreCode(self): + for x in self["config"].list: + x[1].cancel() + + def MessageBoxConfirmCodeCallback(self,ret): + if ret: + ConfigListScreen.keySave(self) + else: + self.restoreCode() + self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value)) + +class MessageBoxConfirmCode(MessageBox): + skin = """ + + + + + + + +# this should be factored out into some helper code, but currently demonstrates applets. +from enigma import eSize, ePoint + +orgwidth = self.instance.size().width() +orgpos = self.instance.position() +textsize = self["text"].getSize() + +# y size still must be fixed in font stuff... +textsize = (textsize[0] + 50, textsize[1] + 50) +offset = 0 +if self.type == self.TYPE_YESNO: + offset = 60 +wsizex = textsize[0] + 60 +wsizey = textsize[1] + offset +if (280 > wsizex): + wsizex = 280 +wsize = (wsizex, wsizey) + + +# resize +self.instance.resize(eSize(*wsize)) + +# resize label +self["text"].instance.resize(eSize(*textsize)) + +# move list +listsize = (wsizex, 50) +self["list"].instance.move(ePoint(0, textsize[1])) +self["list"].instance.resize(eSize(*listsize)) + +# center window +newwidth = wsize[0] +self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) + + """ + def timerTick(self): + if self.execing: + self.timeout -= 1 +# if self.origTitle is None: +# self.origTitle = self.instance.getTitle() +# self.setTitle(self.origTitle + " ( after %d second, return to previous code)" %self.timeout) + self["text"].setText(self.text + " (after %d second, return to previous code)" %self.timeout) + if self.timeout == 0: + self.timer.stop() + self.timerRunning = False + self.timeoutCallback() + + def move(self, direction): + if self.close_on_any_key: + self.close(True) + self["list"].instance.moveSelection(direction) + if self.list: + self["selectedChoice"].setText(self["list"].getCurrent()[0]) +# self.stopTimer() + + def timeoutCallback(self): + self.close(False) + +def main(session, **kwargs): + session.open(RemoteControlCode) + +def Plugins(**kwargs): + return [PluginDescriptor(name=_("RemoteControlCode"), description="setup Remote Control System Code Type", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)] + +remotecontrolcodeinit = RemoteControlCodeInit() -- 2.7.4