add babelzapper plugin by gutemine
authorNabil Hanna <ali@users.schwerkraft.elitedvb.net>
Sat, 1 May 2010 10:25:46 +0000 (10:25 +0000)
committerNabil Hanna <ali@users.schwerkraft.elitedvb.net>
Sat, 1 May 2010 10:25:46 +0000 (10:25 +0000)
28 files changed:
Makefile.am
babelzapper/CONTROL/control [new file with mode: 0644]
babelzapper/CONTROL/postrm [new file with mode: 0755]
babelzapper/Makefile.am [new file with mode: 0644]
babelzapper/etc/Makefile.am [new file with mode: 0644]
babelzapper/etc/babelzapper.zbb [new file with mode: 0644]
babelzapper/etc/colormenu.zbb [new file with mode: 0644]
babelzapper/etc/colorzapp.zbb [new file with mode: 0644]
babelzapper/etc/epg.zbb [new file with mode: 0644]
babelzapper/etc/macros.zbb [new file with mode: 0644]
babelzapper/etc/manynum.zbb [new file with mode: 0644]
babelzapper/etc/menu.zbb [new file with mode: 0644]
babelzapper/etc/numbermenu.zbb [new file with mode: 0644]
babelzapper/etc/pip.zbb [new file with mode: 0644]
babelzapper/etc/pvr.zbb [new file with mode: 0644]
babelzapper/etc/quickjump.zbb [new file with mode: 0644]
babelzapper/etc/recplay.zbb [new file with mode: 0644]
babelzapper/etc/zapp.zbb [new file with mode: 0644]
babelzapper/meta/Makefile.am [new file with mode: 0644]
babelzapper/meta/plugin_babelzapper.xml [new file with mode: 0644]
babelzapper/src/Makefile.am [new file with mode: 0644]
babelzapper/src/__init__.py [new file with mode: 0755]
babelzapper/src/babel.png [new file with mode: 0644]
babelzapper/src/babelzapper.png [new file with mode: 0644]
babelzapper/src/maintainer.info [new file with mode: 0644]
babelzapper/src/plugin.py [new file with mode: 0755]
babelzapper/src/readme.txt [new file with mode: 0644]
configure.ac

index befdc0f..429640c 100644 (file)
@@ -6,6 +6,7 @@ SUBDIRS = \
        automatictimerlistcleanup \
        autoresolution \
        autotimer \
+       babelzapper \
        cdinfo \
        dreamirc \
        dvdbackup \
diff --git a/babelzapper/CONTROL/control b/babelzapper/CONTROL/control
new file mode 100644 (file)
index 0000000..308ef09
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-extensions-babelzapper
+Version: 1.0
+Description: Control your dreambox with only the MUTE button
+Architecture: all
+Section: extra
+Priority: optional
+Maintainer: gutemine
+Homepage: http://www.i-have-a-dreambox.com
+Depends: enigma2(>=2.6git20090615)
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/babelzapper/CONTROL/postrm b/babelzapper/CONTROL/postrm
new file mode 100755 (executable)
index 0000000..3e3fcb5
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+sed -ie s!'id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"b\"'!'id=\"KEY_MUTE\" mapto=\"delete\" flags=\"mr\"'!g /usr/share/enigma2/keymap.xml
+sed -ie s!'id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"m\"'!'id=\"KEY_MUTE\" mapto=\"deleteForward\" flags=\"mr\"'!g /usr/share/enigma2/keymap.xml
+sed -ie s!"babelzapperMute"!"volumeMute"!g /usr/share/enigma2/keymap.xml
+rm -r /usr/lib/enigma2/python/Plugins/Extensions/BabelZapper > /dev/null 2>&1
+exit 0
diff --git a/babelzapper/Makefile.am b/babelzapper/Makefile.am
new file mode 100644 (file)
index 0000000..f0b8b73
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = etc meta src
diff --git a/babelzapper/etc/Makefile.am b/babelzapper/etc/Makefile.am
new file mode 100644 (file)
index 0000000..48331dc
--- /dev/null
@@ -0,0 +1,15 @@
+installdir = /etc/babelzapper\r
+install_DATA = \
+       babelzapper.zbb \
+       colormenu.zbb \
+       colorzapp.zbb \
+       epg.zbb \
+       macros.zbb \
+       manynum.zbb \
+       menu.zbb \
+       numbermenu.zbb \
+       pip.zbb \
+       pvr.zbb \
+       quickjump.zbb \
+       recplay.zbb \
+       zapp.zbb
diff --git a/babelzapper/etc/babelzapper.zbb b/babelzapper/etc/babelzapper.zbb
new file mode 100644 (file)
index 0000000..aa5a54b
--- /dev/null
@@ -0,0 +1,6 @@
+zapp; LOAD zapp
+epg; $KEY_RED; LOAD epg
+menu; $KEY_MENU; LOAD menu
+pvr; $KEY_VIDEO; LOAD pvr
+macros; LOAD macros
+STANDBY; $KEY_POWER
diff --git a/babelzapper/etc/colormenu.zbb b/babelzapper/etc/colormenu.zbb
new file mode 100644 (file)
index 0000000..de21855
--- /dev/null
@@ -0,0 +1,5 @@
+RED; $KEY_RED; GOTO 5
+GREEN; $KEY_GREEN; GOTO 5
+YELLOW; $KEY_YELLOW; GOTO 5
+BLUE; $KEY_BLUE; GOTO 5
+---; RUN menu
\ No newline at end of file
diff --git a/babelzapper/etc/colorzapp.zbb b/babelzapper/etc/colorzapp.zbb
new file mode 100644 (file)
index 0000000..291aeac
--- /dev/null
@@ -0,0 +1,5 @@
+RED; $KEY_RED; GOTO 5
+GREEN; $KEY_GREEN; GOTO 5
+YELLOW; $KEY_YELLOW; GOTO 5
+BLUE; $KEY_BLUE; GOTO 5
+---; RUN zapp
\ No newline at end of file
diff --git a/babelzapper/etc/epg.zbb b/babelzapper/etc/epg.zbb
new file mode 100644 (file)
index 0000000..155e037
--- /dev/null
@@ -0,0 +1,9 @@
+DOWN; $KEY_DOWN
+RIGHT; $KEY_RIGHT
+UP; $KEY_UP
+LEFT; $KEY_LEFT
+OK; $KEY_OK
+EXIT; $KEY_EXIT
+TIMER; $KEY_GREEN; $KEY_GREEN
+zapp; $KEY_EXIT; LOAD zapp
+<==; LOAD
\ No newline at end of file
diff --git a/babelzapper/etc/macros.zbb b/babelzapper/etc/macros.zbb
new file mode 100644 (file)
index 0000000..0a7b881
--- /dev/null
@@ -0,0 +1,4 @@
+CAM1; $KEY_MENU; $KEY_UP; $KEY_UP; $KEY_UP; $KEY_OK; $KEY_DOWN; $KEY_DOWN; $KEY_OK; STOP 2000; $KEY_OK; STOP 7000; $KEY_EXIT; STOP 1000; $KEY_MENU; LOAD
+OK; $KEY_OK
+EXIT; $KEY_EXIT
+---; RUN
\ No newline at end of file
diff --git a/babelzapper/etc/manynum.zbb b/babelzapper/etc/manynum.zbb
new file mode 100644 (file)
index 0000000..7912f08
--- /dev/null
@@ -0,0 +1,11 @@
+0; $KEY_0
+1; $KEY_1
+2; $KEY_2
+3; $KEY_3
+4; $KEY_4
+5; $KEY_5
+6; $KEY_6
+7; $KEY_7
+8; $KEY_8
+9; $KEY_9
+menu; LOAD menu
\ No newline at end of file
diff --git a/babelzapper/etc/menu.zbb b/babelzapper/etc/menu.zbb
new file mode 100644 (file)
index 0000000..d1e416e
--- /dev/null
@@ -0,0 +1,9 @@
+DOWN; $KEY_DOWN
+RIGHT; $KEY_RIGHT
+UP; $KEY_UP
+LEFT; $KEY_LEFT
+OK; $KEY_OK; GOTO 1
+EXIT; $KEY_EXIT; GOTO 0
+colors; LOAD colormenu
+numbers; LOAD numbermenu
+<==; $KEY_MENU; LOAD
\ No newline at end of file
diff --git a/babelzapper/etc/numbermenu.zbb b/babelzapper/etc/numbermenu.zbb
new file mode 100644 (file)
index 0000000..d858ac2
--- /dev/null
@@ -0,0 +1,12 @@
+manynum; LOAD manynum
+0; $KEY_0; GOTO 12
+1; $KEY_1; GOTO 12
+2; $KEY_2; GOTO 12
+3; $KEY_3; GOTO 12
+4; $KEY_4; GOTO 12
+5; $KEY_5; GOTO 12
+6; $KEY_6; GOTO 12
+7; $KEY_7; GOTO 12
+8; $KEY_8; GOTO 12
+9; $KEY_9; GOTO 12
+---; RUN menu
\ No newline at end of file
diff --git a/babelzapper/etc/pip.zbb b/babelzapper/etc/pip.zbb
new file mode 100644 (file)
index 0000000..51ec479
--- /dev/null
@@ -0,0 +1,10 @@
+RIGHT; $KEY_RIGHT
+LEFT; $KEY_LEFT
+SWITCH; $KEY_0
+OK; $KEY_OK; GOTO 1
+zapp; GOTO 9
+UP; $KEY_UP
+DOWN; $KEY_DOWN
+---; RUN pip
+ENDPIP; $KEY_BLUE_LONG; $KEY_BLUE
+---; RUN zapp 
\ No newline at end of file
diff --git a/babelzapper/etc/pvr.zbb b/babelzapper/etc/pvr.zbb
new file mode 100644 (file)
index 0000000..211d06e
--- /dev/null
@@ -0,0 +1,9 @@
+DOWN; $KEY_DOWN
+RIGHT; $KEY_RIGHT
+UP; $KEY_UP
+LEFT; $KEY_LEFT
+OK; $KEY_OK; LOAD recplay
+EXIT; $KEY_EXIT; GOTO 0
+MENU; $KEY_MENU
+recplay; LOAD recplay
+<==; LOAD
\ No newline at end of file
diff --git a/babelzapper/etc/quickjump.zbb b/babelzapper/etc/quickjump.zbb
new file mode 100644 (file)
index 0000000..f22b28c
--- /dev/null
@@ -0,0 +1,7 @@
+5min >; $KEY_3
+7min >; $KEY_6
+5min <; $KEY_1
+7min <; $KEY_4
+30min >; $KEY_9
+30min <; $KEY_7
+---; RUN recplay
\ No newline at end of file
diff --git a/babelzapper/etc/recplay.zbb b/babelzapper/etc/recplay.zbb
new file mode 100644 (file)
index 0000000..cc5db30
--- /dev/null
@@ -0,0 +1,8 @@
+PlayPause; $KEY_PLAYPAUSE
+TV; $KEY_TV; LOAD zapp
+RIGHT; $KEY_RIGHT
+LEFT; $KEY_LEFT
+OK; $KEY_OK; GOTO 0
+quickjump; LOAD quickjump
+pvr; LOAD pvr
+<==; LOAD
\ No newline at end of file
diff --git a/babelzapper/etc/zapp.zbb b/babelzapper/etc/zapp.zbb
new file mode 100644 (file)
index 0000000..8565c51
--- /dev/null
@@ -0,0 +1,12 @@
+RIGHT; $KEY_RIGHT
+LEFT; $KEY_LEFT
+UP; $KEY_UP
+DOWN; $KEY_DOWN
+OK; $KEY_OK; GOTO 1
+EXIT; $KEY_EXIT; GOTO 0
+colors; LOAD colorzapp
+pip; $KEY_BLUE_LONG; $KEY_BLUE; LOAD pip
+epg; $KEY_RED; LOAD epg
+<==; LOAD
+VOLUP; $KEY_VOLUMEUP
+VOLDOWN; $KEY_VOLUMEDOWN
\ No newline at end of file
diff --git a/babelzapper/meta/Makefile.am b/babelzapper/meta/Makefile.am
new file mode 100644 (file)
index 0000000..1d23817
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta/
+
+dist_install_DATA = plugin_babelzapper.xml
diff --git a/babelzapper/meta/plugin_babelzapper.xml b/babelzapper/meta/plugin_babelzapper.xml
new file mode 100644 (file)
index 0000000..7139388
--- /dev/null
@@ -0,0 +1,22 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info language="en">
+                    <author>gutemine</author>
+                    <name>BabelZapper</name>
+                    <packagename>enigma2-plugin-extensions-babelzapper</packagename>
+                    <shortdescription>Control your dreambox with only the MUTE button</shortdescription>
+                    <description>Control your dreambox with only the MUTE button</description>
+          </info>
+          <info language="de">
+                    <author>gutemine</author>
+                    <name>BabelZapper</name>
+                    <packagename>enigma2-plugin-extensions-babelzapper</packagename>
+                    <shortdescription>Bediene deine dreambox mit nur der MUTE Taste</shortdescription>
+                    <description>Bediene deine dreambox mit nur der MUTE Taste</description>
+          </info>
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-extensions-babelzapper" />
+         </files>
+</default>
diff --git a/babelzapper/src/Makefile.am b/babelzapper/src/Makefile.am
new file mode 100644 (file)
index 0000000..5548d96
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/BabelZapper
+install_PYTHON = __init__.py plugin.py
+install_DATA = babel.png babelzapper.png maintainer.info readme.txt
diff --git a/babelzapper/src/__init__.py b/babelzapper/src/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/babelzapper/src/babel.png b/babelzapper/src/babel.png
new file mode 100644 (file)
index 0000000..a063f2f
Binary files /dev/null and b/babelzapper/src/babel.png differ
diff --git a/babelzapper/src/babelzapper.png b/babelzapper/src/babelzapper.png
new file mode 100644 (file)
index 0000000..2236f87
Binary files /dev/null and b/babelzapper/src/babelzapper.png differ
diff --git a/babelzapper/src/maintainer.info b/babelzapper/src/maintainer.info
new file mode 100644 (file)
index 0000000..7ac0c7d
--- /dev/null
@@ -0,0 +1,2 @@
+nabil1978@web.de
+BabelZapper
diff --git a/babelzapper/src/plugin.py b/babelzapper/src/plugin.py
new file mode 100755 (executable)
index 0000000..e44c0e0
--- /dev/null
@@ -0,0 +1,470 @@
+# -*- coding: iso-8859-1 -*-
+#
+# Babelzapper Plugin by gutemine
+#
+babelzapper_version = "0.9.6"
+babelzapper_plugindir="/usr/lib/enigma2/python/Plugins/Extensions/BabelZapper" 
+babelzapper_readme = "%s/readme.txt" % babelzapper_plugindir
+babelzapper_menus = "/etc/babelzapper"
+#
+from RecordTimer import parseEvent
+from Plugins.Plugin import PluginDescriptor
+from enigma import eTimer,  eServiceReference, eServiceCenter, iServiceInformation, eEPGCache, iTimeshiftServicePtr
+from Screens.Screen import Screen
+from Screens.Setup import SetupSummary
+from Screens.Console import Console
+from Screens.MessageBox import MessageBox
+from Components.config import config, ConfigSubsection, ConfigEnableDisable, ConfigInteger, getConfigListEntry
+from Components.ConfigList import ConfigListScreen
+from Components.ActionMap import ActionMap
+from Components.Label import Label, MultiColorLabel
+from Tools.Directories import *
+from Tools.HardwareInfo import HardwareInfo
+from GlobalActions import globalActionMap
+from Components.config import config, ConfigSubsection, ConfigInteger
+import os
+import keymapparser
+from struct import pack
+from keyids import KEYIDS
+
+global babelkey
+global babeldone
+global babelon
+babelkey=-1
+babeldone=0
+babelon=0
+
+config.plugins.babelzapper = ConfigSubsection()
+config.plugins.babelzapper.enabled = ConfigEnableDisable(default = False)
+config.plugins.babelzapper.changetime = ConfigInteger(default = 1000, limits = (200, 10000))
+config.plugins.babelzapper.exit2escape = ConfigEnableDisable(default = False)
+
+def main(session,**kwargs):
+       session.open(BabelzapperConfiguration)
+
+def autostart(reason, **kwargs):
+#      global session
+       if kwargs.has_key("session") and reason == 0:
+               session = kwargs["session"]
+               print "[BABELZAPPER] autostart"
+               session.open(BabelZapperStartup)
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
+               PluginDescriptor(name="Babelzapper", description=_("Mute button remote control"), where = PluginDescriptor.WHERE_PLUGINMENU, icon="babelzapper.png", fnc=main)]
+
+class BabelzapperConfiguration(Screen, ConfigListScreen):
+       skin = """
+               <screen position="center,center" size="450,240" title="Babelzapper Plugin" >
+               <widget name="config" position="0,0" size="450,200" scrollbarMode="showOnDemand" />
+               <widget name="buttonred" position="10,200" size="100,40" backgroundColor="red" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+               <widget name="buttongreen" position="120,200" size="100,40" backgroundColor="green" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+               <widget name="buttonyellow" position="230,200" size="100,40" backgroundColor="yellow" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+               <widget name="buttonblue" position="340,200" size="100,40" backgroundColor="blue" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+               <ePixmap position="175,80" size="100,100" pixmap="%s/babel.png" transparent="1" alphatest="on" />       
+       </screen>""" % babelzapper_plugindir
+       def __init__(self, session, args = 0):
+               Screen.__init__(self, session)
+               self.list = []
+               self.list.append(getConfigListEntry(_("Enable Babelzapper on Mute"), config.plugins.babelzapper.enabled))
+               self.list.append(getConfigListEntry(_("Scroll Time [msec]"), config.plugins.babelzapper.changetime))
+               self.list.append(getConfigListEntry(_("Send ESC for EXIT key"), config.plugins.babelzapper.exit2escape))
+               self.onShown.append(self.setWindowTitle)
+               ConfigListScreen.__init__(self, self.list)
+               self.onChangedEntry = []
+               self["buttonred"] = Label(_("Cancel"))
+               self["buttongreen"] = Label(_("OK"))
+               self["buttonyellow"] = Label(_("Info"))
+               self["buttonblue"] = Label(_("About"))
+               self["setupActions"] = ActionMap([ "ColorActions", "SetupActions" ],
+                       {
+                       "green": self.save,
+                       "red": self.cancel,
+                       "yellow": self.readme,
+                       "blue": self.about,
+                       "save": self.save,
+                       "cancel": self.cancel,
+                       "ok": self.save,
+                       })
+
+       def setWindowTitle(self):
+               self.setTitle(_("Babelzapper Plugin"))
+
+       def save(self):
+               for x in self["config"].list:
+                       x[1].save()
+               keymapfile = open("/usr/share/enigma2/keymap.xml", "r")
+               text=keymapfile.read()
+               keymapfile.close()
+               keymapfile = open("/usr/share/enigma2/keymap.xml", "w")
+               if config.plugins.babelzapper.enabled.value:
+                       text=text.replace("volumeMute","babelzapperMute")
+                       text=text.replace("id=\"KEY_MUTE\" mapto=\"deleteForward\" flags=\"mr\"","id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"m\"")
+                       text=text.replace("id=\"KEY_MUTE\" mapto=\"delete\" flags=\"mr\"","id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"b\"")
+               else:
+                       text=text.replace("id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"b\"","id=\"KEY_MUTE\" mapto=\"delete\" flags=\"mr\"")
+                       text=text.replace("id=\"KEY_MUTE\" mapto=\"babelzapperMute\" flags=\"m\"","id=\"KEY_MUTE\" mapto=\"deleteForward\" flags=\"mr\"")
+                       text=text.replace("babelzapperMute","volumeMute")
+               keymapfile.write(text)
+               keymapfile.close()
+               keymapparser.removeKeymap("/usr/share/enigma2/keymap.xml")
+               keymapparser.readKeymap("/usr/share/enigma2/keymap.xml")
+               self.close(True)
+
+       def cancel(self):
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.close(False)
+
+       def readme(self):
+               self.session.open(Console,_("Babelzapper readme.txt"),["cat %s" % (babelzapper_readme) ])
+       def about(self):
+               self.session.open(MessageBox, _("Babelzapper Version %s\nby gutemine and garbage") % babelzapper_version, MessageBox.TYPE_INFO)
+
+class BabelZapperStartup(Screen):
+       skin = ""
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self.skin = BabelZapperStartup.skin
+               print "[BABELZAPPER] starting"
+               global globalActionMap
+               # overwrite Mute  for the handicaped
+               globalActionMap.actions["babelzapperMute"]=self.setKey
+               self.babelDialog = session.instantiateDialog(BabelZapper)
+                               
+       def setKey(self):
+               global babelmenu
+               global babelkey
+               global babeldone
+               global babelon
+               length=len(babelmenu)-1
+               self.nextKeyTimer = eTimer()
+               self.nextKeyTimer.callback.append(self.nextKey)
+               self.nextKeyTimer.stop()
+               self.resetKeyTimer = eTimer()
+               self.resetKeyTimer.callback.append(self.resetKey)
+               self.resetKeyTimer.stop()
+               self.delayedKeyTimer = eTimer()
+               self.delayedKeyTimer.callback.append(self.setKey)
+               self.delayedKeyTimer.stop()
+               print "[BABELZAPPER] received mute key"
+               if babelkey==-1:
+                       print "[BABELZAPPER] now starts from beginning\n"
+                       self.nextKeyTimer.start(200, True)
+               elif babeldone==-1:
+                       print "[BABELZAPPER] now starts with last key\n"
+                       babeldone=0
+                       babelkey=babelkey-1
+                       self.nextKeyTimer.start(config.plugins.babelzapper.changetime.value, True)
+#                      self.nextKeyTimer.start(200, True)
+               else:
+                       self.babelDialog.hide()
+                       cmdlen=len(babelmenu[babelkey])
+                       print "[BABELZAPPER] %i commands" % cmdlen
+                       i=1+babeldone
+                       babeldone=0
+                       # here comes the command line interpreter
+                       while i < cmdlen: 
+                               cmd=babelmenu[babelkey][i]
+                               cmdname=cmd.lstrip("     ")
+                               print "[BABELZAPPER] command: %s" % cmdname
+                               if cmdname.startswith("$KEY_"):
+                                       self.babelDialog.executeKey(cmdname)
+                               elif cmdname.startswith("END"):
+                                       self.babelDialog.hide()
+                                       print "[BABELZAPPER] ENDs\n" 
+                                       babelkey=-1
+                                       return
+                               elif cmdname.startswith("IFON"):
+                                       if babelon == 0:
+                                               print "[BABELZAPPER] ON is off\n" 
+                                               # skip rest of commandline
+                                               i=cmdlen
+                                       else:
+                                               print "[BABELZAPPER] ON is on executing rest and setting it off\n" 
+                                               babelon=0;
+                               elif cmdname.startswith("ON"):
+                                       print "[BABELZAPPER] ON\n" 
+                                       babelon=1
+                               elif cmdname.startswith("TOGGLE"):
+                                       if babelon == 0:
+                                               print "[BABELZAPPER] TOGGLE on\n" 
+                                               babelon=1
+                                       else:
+                                               print "[BABELZAPPER] TOGGLE off\n" 
+                                               babelon=0
+                               elif cmdname.startswith("OFF"):
+                                       print "[BABELZAPPER] OFF\n" 
+                                       babelon=0
+                               elif cmdname.startswith("GOTO"):
+                                       try:
+                                               babelkey=int(cmdname.replace("GOTO",""))
+                                               print "[BABELZAPPER] GOTO %i \n" % babelkey
+                                       except:
+                                               babelkey=0
+                                       # skip rest of commandline
+                                       i=cmdlen
+                               elif cmdname.startswith("STOP"):
+                                       try:            
+                                               babelstop=int(cmdname.replace("STOP",""))
+                                       except:
+                                               babelstop=1000
+                                       if babelstop < 1000:            
+                                               babelstop=1000
+                                       elif babelstop > 60000:
+                                               babelstop=60000
+                                       print "[BABELZAPPER] STOP %i \n" % babelstop
+                                       self.babelDialog.show()
+                                       babeldone=i
+                                       self.delayedKeyTimer.start(babelstop, True)
+                                       return
+                               elif cmdname.startswith("PRINT"):
+                                       babeltext=cmd.replace("PRINT","")
+                                       print "[BABELZAPPER] PRINTs: %s \n" % babeltext
+                                       self.session.open(MessageBox, babeltext, MessageBox.TYPE_INFO)
+                               elif cmdname.startswith("LOAD") or cmdname.startswith("RUN"):
+                                       babelkey=-1
+                                       babeldone=0
+                                       i=len(babelmenu)
+                                       while i > 1:
+                                               i=i-1
+                                               babelmenu.pop(i)
+                                       babelfile="%s/%s.zbb" % (babelzapper_menus,cmdname.replace("LOAD","").replace("RUN","").replace(" ","").replace("       ",""))
+                                       print "[BABELZAPPER] LOADs: %s\n" % babelfile
+                                       if os.path.exists(babelfile):
+                                               f = open(babelfile, 'r')
+                                       else:
+                                               f = open("%s/babelzapper.zbb" % babelzapper_menus, 'r')
+                                       line=f.readline().replace("\r","").replace("\n","")
+                                       while (line):
+                                               bz=line.split(";")
+                                               if len(bz) < 2:
+                                                       print "[BABELZAPPER] wrong line %s in babelzapper.zbb" % line
+                                                       babelmenu.append(("????", "PRINT ???? %s" % line))
+                                               else:
+                                                       babelmenu.append((bz))
+                                               line=f.readline().replace("\r","").replace("\n","")
+                                       f.close()
+                                       # skip rest of commandline
+                                       i=cmdlen
+                               elif cmdname.startswith("REM"):
+                                       # skip rest of commandline
+                                       i=cmdlen
+                               else:
+                                       if len(cmd) > 0:
+                                               print "[BABELZAPPER] unknown command %s\n" % cmd
+                                               babeltext="???? %s\n" % cmd
+                                       else:
+                                               babeltext="???? empty command found\n"
+                                       self.session.open(MessageBox, babeltext, MessageBox.TYPE_ERROR)
+                                       # skip rest of commandline
+                                       i=cmdlen
+                               # next command  
+                               i=i+1
+                       # continue babelzapping but show last command again to make repeats easier
+                       babelkey=babelkey-1
+                       self.nextKeyTimer.start(config.plugins.babelzapper.changetime.value, True)
+                       
+                               
+       def resetKey(self):
+               print "[BABELZAPPER] resets last key"
+               self.resetKeyTimer.stop()
+               self.babelDialog.hide()
+               global babelkey
+               global babeldone
+               babelkey=-1
+               babeldone=0
+
+       def nextKey(self):
+               global babelmenu
+               global babelkey
+               global babelon
+               if not config.plugins.babelzapper.enabled.value:
+                       self.babelDialog.hide()
+                       return
+               length=len(babelmenu)-1
+               if babelkey<0:
+                       babelkey=0
+               elif babelkey < length:
+                       babelkey=babelkey+1
+               else:
+                       babelkey=0
+               self.nextKeyTimer.stop()
+               cmd=babelmenu[babelkey][1]
+               cmdname=cmd.lstrip("     ")
+               if cmdname.startswith("RETURN"):
+                       try:            
+                               babelkey=int(cmdname.replace("RETURN",""))-1
+                       except:
+                               babelkey=-1
+                       print "[BABELZAPPER] RETURN %i \n" % babelkey
+                       self.nextKeyTimer.start(0, True)
+                       return
+               elif cmdname.startswith("REM"):
+                       # skip this commandline
+                       self.nextKeyTimer.start(0, True)
+                       return
+               elif cmdname.startswith("ON"):
+                       print "[BABELZAPPER] ON\n" 
+                       babelon=1
+                       # skip this commandline
+                       self.nextKeyTimer.start(0, True)
+                       return
+               elif cmdname.startswith("OFF"):
+                       print "[BABELZAPPER] OFF\n" 
+                       babelon=0
+                       # skip this commandline
+                       self.nextKeyTimer.start(0, True)
+                       return
+               elif cmdname.startswith("TOGGLE"):
+                       if babelon == 0:
+                               print "[BABELZAPPER] TOGGLE on\n" 
+                               babelon=0
+                       else:
+                               print "[BABELZAPPER] TOGGLE off\n" 
+                               babelon=1
+                       # skip this commandline
+                       self.nextKeyTimer.start(0, True)
+                       return
+               elif cmdname.startswith("STOP"):
+                       try:            
+                               babelstop=int(cmdname.replace("STOP",""))
+                       except:
+                               babelstop=1000
+                       if babelstop < 1000:            
+                               babelstop=1000
+                       elif babelstop > 60000:
+                               babelstop=60000
+                       print "[BABELZAPPER] STOP %i \n" % babelstop
+                       currentkey=babelmenu[babelkey][0]
+                       split=currentkey.split(":")
+                       currentkey=split[0]
+                       currentbg=0
+                       currentfg=1
+                        if len(split) > 1:
+                               currentbg=int(split[1])
+                        if len(split) > 2:
+                               currentfg=int(split[2])
+                       self.babelDialog.updateKey(currentkey,currentbg,currentfg)
+                       self.babelDialog.show()
+                       self.nextKeyTimer.start(babelstop, True)
+                       return
+               elif cmdname.startswith("RUN"):
+                       i=len(babelmenu)
+                       while i > 1:
+                               i=i-1
+                               babelmenu.pop(i)
+                       babelfile="%s/%s.zbb" % (babelzapper_menus,cmdname.replace("RUN","").replace(" ","").replace("  ",""))
+                       print "[BABELZAPPER] RUNs: %s\n" % babelfile
+                       if os.path.exists(babelfile):
+                               f = open(babelfile, 'r')
+                       else:
+                               f = open("/%s/babelzapper.zbb" % babelzapper_menus, 'r')
+                       line=f.readline().replace("\r","").replace("\n","")
+                       while (line):
+                               bz=line.split(";")
+                               if len(bz) < 2:
+                                       print "[BABELZAPPER] wrong line %s in babelzapper.zbb" % line
+                                       babelmenu.append(("????", "PRINT ???? %s" % line))
+                               else:
+                                       babelmenu.append((bz))
+                               line=f.readline().replace("\r","").replace("\n","")
+                       f.close()
+                       babelkey=-1
+                       self.babelDialog.updateKey(babelmenu[babelkey][0])
+                       self.babelDialog.show()
+                       self.nextKeyTimer.start(0, True)
+                       return
+               else:
+                       pass
+               currentkey=babelmenu[babelkey][0]
+               split=currentkey.split(":")
+               currentkey=split[0]
+               currentbg=0
+               currentfg=1
+                if len(split) > 1:
+                       currentbg=int(split[1])
+                if len(split) > 2:
+                       currentfg=int(split[2])
+               self.babelDialog.updateKey(currentkey,currentbg,currentfg)
+               self.babelDialog.show()
+               self.nextKeyTimer.start(config.plugins.babelzapper.changetime.value, True)
+
+class BabelZapper(Screen):
+       skin = """
+               <screen position="center,60" size="180,30" flags="wfNoBorder">
+               <widget name="babelzapper" position="1,1" size="180,30" font="Regular;26" valign="center" halign="center" backgroundColors="black,white,#00AAAAAA,red,green,yellow,blue" foregroundColors="black,white,#00AAAAAA,red,green,yellow,blue">
+               </widget>
+               </screen>"""
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self.skin = BabelZapper.skin
+               global babelmenu
+               print "[BABELZAPPER] loading %s/babelzapper.zbb" % babelzapper_menus
+               global babelkey
+               babelmenu= []
+               babelmenu.append(("NONE", "END"))
+               if os.path.exists("%s/babelzapper.zbb" % babelzapper_menus):
+                       f = open("%s/babelzapper.zbb" % babelzapper_menus, 'r')
+                       line=f.readline().replace("\r","").replace("\n","")
+                       while (line):
+                               bz=line.split(";")
+                               if len(bz) < 2:
+                                       print "[BABELZAPPER] wrong line %s in babelzapper.zbb" % line
+                                       babelmenu.append(("????", "PRINT ???? %s" % line))
+                                       
+                               else:
+                                       babelmenu.append((bz))
+                               line=f.readline().replace("\r","").replace("\n","")
+                       f.close()
+               babelkey=-1
+               self["babelzapper"] = MultiColorLabel(babelmenu[babelkey][0])
+                self["babelzapper"].setForegroundColorNum(0)
+                self["babelzapper"].setBackgroundColorNum(1)
+               
+       def updateKey(self, keyname,keybg=0,keyfg=1):
+               self["babelzapper"].setText(keyname)
+                self["babelzapper"].setForegroundColorNum(keyfg)
+                self["babelzapper"].setBackgroundColorNum(keybg)
+
+       def executeKey(self, keyname):
+               keyname=keyname.replace("$","").replace(" ","").replace("\n","")
+               long=False
+               if keyname.startswith("KEY_EXIT") and config.plugins.babelzapper.exit2escape.value:
+                       keyname=keyname.replace("KEY_EXIT","KEY_ESC")
+               if keyname.startswith("KEY_"):
+                       if keyname.endswith("_LONG"):
+                               long=True
+                               keyname=keyname.replace("_LONG","")
+                       try:            
+                               keycode=KEYIDS[keyname]
+                               print "[BABELZAPPER] found key %i" % keycode
+                       except:
+                               print "[BABELZAPPER] found unknown key %s" % keyname
+                               return
+               else:
+                       print "[BABELZAPPER] found unknown key %s" % keyname
+                       return
+               if HardwareInfo.device_name == "dm8000":
+                       fp = open("/dev/input/event2", 'wb')
+               else:
+                       fp = open("/dev/input/event1", 'wb')
+               if long:
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 1)
+                       fp.write(dataon)
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 2)
+                       fp.write(dataon)
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 2)
+                       fp.write(dataon)
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 2)
+                       fp.write(dataon)
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 2)
+                       fp.write(dataon)
+               else:
+                       print "[BABELZAPPER] now writes out: %i\n" % (keycode)
+                       dataon = pack('iiHHi', 0, 0, 1, keycode, 1)
+                       fp.write(dataon)
+               dataoff = pack('iiHHi', 0, 0, 1, keycode, 0)
+               fp.write(dataoff)
+               fp.close()
diff --git a/babelzapper/src/readme.txt b/babelzapper/src/readme.txt
new file mode 100644 (file)
index 0000000..161321a
--- /dev/null
@@ -0,0 +1,168 @@
+===========================================
+Babelzapper Version 0.8 
+by gutemine from 15.03.2010
+===========================================
+Release infos 
+===========================================
+0.9.6  IF and TOGGLE
+0.9.5  colors
+0.9.4  new menu and ON/OFF
+0.9.3  EXIT to ESC
+0.9.2  bugfixing
+0.9.1  LOAD command
+0.9    Release Candidate
+0.8    learn the basics
+0.7    Jumpin Jack
+0.6    bugfixing
+0.5    to release or not release ?
+0.4    going python now
+0.3    menu is now sticky
+0.2    speed is now msec
+0.1    First public Beta
+===========================================
+
+Installation:
+-------------
+
+First copy the file enigma2-plugin-extensions-babelzapper*.ipk 
+to /tmp with ftp (TCP/IP must be working already). 
+
+Then install Babelzapping by entering the 
+following commands in a Telnet session:
+
+cd /
+ipkg install /tmp/enigma2-plugin-extensions-babelzapper*.ipk
+
+You can remove Babelzapper with the red button in the Plugin List,
+or the Softwaremanager Plugin of enigma2,
+or with the following command in telnet:
+
+ipkg remove enigma2-plugin-extensions-babelzapper
+
+Usage:
+------
+
+The Babelzapper plugin allows you to control 
+your Dreambox completely with a single RC button,
+the mute button.
+
+If the Plugin is enabled and you press the mute 
+button the Babelzapping Command Button 
+will appear in the upper middle of the TV screen.
+
+It then simply srolls trough the appropiate 
+remote control buttons as defined in the babelzapper.zbb
+file, and if you press the mute button
+again the choosen remote control button
+or other babelzapper commands as defined in the
+babelzapper.zbb file will be executed.
+When you choose NONE (which executes STOP)
+you can exit without executing a command.
+
+The speed of button scrolling is adjustable
+in the Babelzapper Plugin.
+
+The real mute button is disabled 
+when you enable the Babelzapper,
+use volume down to mute instead of this.
+
+For adapting the commands available for execution
+edit the babelzapper.zbb file at /etc/enigma2
+
+zBABEL Language:
+---------------
+
+The first text at the beginning of the line in the
+babelzapper.zbb file is always the label as shown
+on the TV screen when scrolling through the command
+lines of the babelzapper.zbb file.
+
+For the correct key names of your remote control
+have a look at the provided
+examples in the babelzapper.cfg
+file or at /usr/lib/enigma2/python/keyids.py
+for the full list of available keys.
+Keycodes are always writen with $KEY_LABEL
+and will be replaced by the apropiate keycodes
+as found in the keyids.py file.
+
+If you add _LONG to the keyname (for example
+$KEY_BLUE_LONG) the keycode will be executed 
+as long press, and you can spefify
+multiple keycodes to be 
+sequentially executed from left
+to right and other babelzapper commands
+as explained below when they are 
+seperated with the ";" 
+
+The first text at the beginning of the line in the
+babelzapper.zbb file is always the label as shown
+on the TV screen when scrolling through the command
+lines of the babelzapper.zbb file.
+
+Other commands supported are:
+
+GOTO   linenumber
+STOP   miliseconds (from 1000 to 60000)
+REM    remarking text
+RETURN linenumber
+PRINT  text for the TV screen
+END    exit scrollmode
+LOAD   menufile
+RUN    menufile
+ON     on flag enable and continue if enabled
+OFF    on flag disable
+
+A line with a GOTO has to be executed 
+by pressing Mute, but GOTO can also be
+used at the end of a line with other 
+commands. This can be used for
+jumping into all areas of the 
+babelzapper.zbb file.
+
+If you edit the babelzapper.zbb file on a PC 
+it is wise to use an editor which shows 
+you the linenumbers to simplify identifying
+the correct linenumbers. Be aware
+that line 0 is a NONE with the END command
+which is hardcoded and not in the babelzapper.zbb
+file.
+
+RETURN is a jump to the specified
+linenumber which gets executed 
+when reached during the scrolling
+of the commands and doesn't need to be selected 
+(it is not even shown on the TV). 
+Hence RETURN cann be used to jump
+back from submenus entered with GOTO.
+
+If you don't specifiy a linenumber
+for RETURN or GOTO always 0 will be used.
+
+You can now also add colors to the button label
+by using LABEL:x:y
+
+with x the background color and y the foreground color
+with the following values:
+
+black  0
+white  1
+grey   2
+red    3
+green  4
+yellow 5
+blue   6
+
+The zBABEL script language used in 
+the babelzapper.zbb file
+is a little bit like good old BASIC, 
+so keep in mind the typical
+recommandations for it like commenting your code
+with REM lines, using tabs and/or blanks
+to increase readability
+and especially use GOTO and RETURN with care and 
+wisdom.
+
+=======================================================
+Have fun testing and using Babelzapper on your Dreambox
+=======================================================
index 7b175fb..fe6fc73 100644 (file)
@@ -58,6 +58,11 @@ autotimer/po/Makefile
 autotimer/src/Makefile
 autotimer/src/webinterface/Makefile
 
+babelzapper/Makefile
+babelzapper/etc/Makefile
+babelzapper/meta/Makefile
+babelzapper/src/Makefile
+
 cdinfo/Makefile
 cdinfo/meta/Makefile
 cdinfo/src/Makefile