[Solo4kMiscControl] add new plugin.
authorhschang <chang@dev3>
Mon, 11 Apr 2016 08:15:38 +0000 (17:15 +0900)
committerhschang <chang@dev3>
Tue, 12 Apr 2016 07:35:53 +0000 (16:35 +0900)
configure.ac
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/Solo4kMiscControl/Makefile.am [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/Solo4kMiscControl/__init__.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/Makefile.am [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/plugin_solo4kmisccontrol.xml [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/Solo4kMiscControl/plugin.py [new file with mode: 0644]

index ba807c9..134dc50 100644 (file)
@@ -304,6 +304,8 @@ lib/python/Plugins/SystemPlugins/AnimationSetup/Makefile
 lib/python/Plugins/SystemPlugins/AnimationSetup/meta/Makefile
 lib/python/Plugins/SystemPlugins/BoxModeConfig/Makefile
 lib/python/Plugins/SystemPlugins/BoxModeConfig/meta/Makefile
+lib/python/Plugins/SystemPlugins/Solo4kMiscControl/Makefile
+lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
index 7f546fe..3a16f5f 100755 (executable)
@@ -8,7 +8,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC LEDBrightnessSetup \
        FirmwareUpgrade CrashReport 3GModemManager WirelessAccessPoint ZappingModeSelection \
        DeviceManager TransCodingSetup WOLSetup NetDrive AudioEffect AnimationSetup \
-       BoxModeConfig
+       BoxModeConfig Solo4kMiscControl
 
 install_PYTHON =       \
        __init__.py
diff --git a/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/Makefile.am b/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/Makefile.am
new file mode 100644 (file)
index 0000000..1d7f276
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/Solo4kMiscControl
+
+SUBDIRS = meta
+
+install_PYTHON =  \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/__init__.py b/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/__init__.py
new file mode 100644 (file)
index 0000000..8d1c8b6
--- /dev/null
@@ -0,0 +1 @@
diff --git a/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/Makefile.am
new file mode 100644 (file)
index 0000000..990f998
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_solo4kmisccontrol.xml
diff --git a/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/plugin_solo4kmisccontrol.xml b/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/meta/plugin_solo4kmisccontrol.xml
new file mode 100644 (file)
index 0000000..d4bd7e2
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>Solo4kMiscControl</name>
+                    <packagename>enigma2-plugin-systemplugins-solo4kmisccontrol</packagename>
+                    <shortdescription>set Solo4K LNB Power and etc..</shortdescription>
+                    <description>Control LNB Power and ToneBurst,CI delay for Solo4K.</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-solo4kmisccontrol" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/plugin.py b/lib/python/Plugins/SystemPlugins/Solo4kMiscControl/plugin.py
new file mode 100644 (file)
index 0000000..26c3aa0
--- /dev/null
@@ -0,0 +1,116 @@
+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.solo4kMiscControl = ConfigSubsection()
+config.plugins.solo4kMiscControl.forceLnbPower = ConfigSelection(default = "off", choices = [ ("on", _("Yes")), ("off", _("No"))] )
+config.plugins.solo4kMiscControl.forceToneBurst = ConfigSelection(default = "disable", choices = [ ("enable", _("Yes")), ("disable", _("No"))] )
+config.plugins.solo4kMiscControl.dvbCiDelay = ConfigSelection(default = "256", choices = [ ("16", _("16")), ("32", _("32")), ("64", _("64")), ("128", _("128")), ("256", _("256"))] )
+
+PROC_FORCE_LNBPOWER = "/proc/stb/frontend/fbc/force_lnbon"
+PROC_FORCE_TONEBURST = "/proc/stb/frontend/fbc/force_toneburst"
+PROC_DVB_CI_DELAY = "/proc/stb/tsmux/rmx_delay"
+
+def setProcValueOnOff(value, procPath):
+       try:
+               print "[Solo4kMiscControl] set %s : %s" % (procPath, value)
+               fd = open(procPath,'w')
+               fd.write(value)
+               fd.close()
+               return 0
+       except Exception, e:
+               print "[Solo4kMiscControl] proc write Error", e
+               return -1
+
+
+from enigma import eTimer
+class checkDriverSupport:
+       def __init__(self):
+               self.onLayoutFinish.append(self.procCheck)
+               self.dispErrorTimer = eTimer()
+               self.dispErrorTimer.callback.append(self.dispErrorMsg)
+
+       def procCheck(self):
+               if not (fileExists(PROC_FORCE_LNBPOWER) and fileExists(PROC_FORCE_TONEBURST) and fileExists(PROC_DVB_CI_DELAY)):
+                       self.dispErrorTimer.start(0, True)
+
+       def dispErrorMsg(self):
+               self.session.openWithCallback(self.close ,MessageBox, _("Driver is not supported."), MessageBox.TYPE_ERROR)
+
+class Solo4kMiscControl(Screen, ConfigListScreen, checkDriverSupport):
+       skin =  """
+               <screen position="center,center" size="400,250" title="Solo4K Misc. Control" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="30,10" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="230,10" size="140,40" alphatest="on" />
+                       <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
+                       <widget source="key_green" render="Label" position="230,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
+                       <widget name="config" zPosition="2" position="5,70" size="380,180" scrollbarMode="showOnDemand" transparent="1" />
+               </screen>
+               """
+
+       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()
+
+               checkDriverSupport.__init__(self)
+
+       def createSetup(self):
+               self.list = []
+               self.lnbPowerEntry = getConfigListEntry(_("Force LNB Power"), config.plugins.solo4kMiscControl.forceLnbPower)
+               self.toneBurstEntry = getConfigListEntry(_("Force ToneBurst"), config.plugins.solo4kMiscControl.forceToneBurst)
+               self.ciDelayEntry = getConfigListEntry(_("DVB CI Delay"), config.plugins.solo4kMiscControl.dvbCiDelay)
+               self.list.append( self.lnbPowerEntry )
+               self.list.append( self.toneBurstEntry )
+               self.list.append( self.ciDelayEntry )
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keySave(self):
+               res = setProcValueOnOff(config.plugins.solo4kMiscControl.forceLnbPower.value, PROC_FORCE_LNBPOWER)
+               if res == 0:
+                       res = setProcValueOnOff(config.plugins.solo4kMiscControl.forceToneBurst.value, PROC_FORCE_TONEBURST)
+               if res == 0:
+                       res = setProcValueOnOff(config.plugins.solo4kMiscControl.dvbCiDelay.value, PROC_DVB_CI_DELAY)
+
+               if res == -1:
+                       self.resetConfig()
+                       self.session.openWithCallback(self.close, MessageBox, _("SET FAILED!\n"), 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(Solo4kMiscControl)
+
+def OnSessionStart(session, **kwargs):
+       setProcValueOnOff(config.plugins.solo4kMiscControl.forceLnbPower.value, PROC_FORCE_LNBPOWER)
+       setProcValueOnOff(config.plugins.solo4kMiscControl.forceToneBurst.value, PROC_FORCE_TONEBURST)
+       setProcValueOnOff(config.plugins.solo4kMiscControl.dvbCiDelay.value, PROC_DVB_CI_DELAY)
+
+def Plugins(**kwargs):
+       pList = []
+       pList.append( PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=OnSessionStart) )
+       pList.append( PluginDescriptor(name=_("Solo4K Misc. Control"), description="set Solo4K LNB Power and etc..", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main) )
+       return pList
+