add python files for socket mmi plugin
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 23 Nov 2007 18:03:59 +0000 (18:03 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 23 Nov 2007 18:03:59 +0000 (18:03 +0000)
lib/python/Plugins/Extensions/SocketMMI/Makefile.am [new file with mode: 0644]
lib/python/Plugins/Extensions/SocketMMI/SocketMMI.py [new file with mode: 0644]
lib/python/Plugins/Extensions/SocketMMI/__init__.py [new file with mode: 0644]
lib/python/Plugins/Extensions/SocketMMI/plugin.py [new file with mode: 0644]

diff --git a/lib/python/Plugins/Extensions/SocketMMI/Makefile.am b/lib/python/Plugins/Extensions/SocketMMI/Makefile.am
new file mode 100644 (file)
index 0000000..209ab8a
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/SocketMMI
+
+install_PYTHON = \
+       __init__.py \
+       plugin.py \
+       SocketMMI.py
+
diff --git a/lib/python/Plugins/Extensions/SocketMMI/SocketMMI.py b/lib/python/Plugins/Extensions/SocketMMI/SocketMMI.py
new file mode 100644 (file)
index 0000000..e44c71f
--- /dev/null
@@ -0,0 +1,34 @@
+from Screens.Ci import MMIDialog
+from enigma import eTimer, eSocket_UI
+
+class SocketMMIMessageHandler:
+       def __init__(self):
+               self.session = None
+               self.dlgs = { }
+               self.handler = eSocket_UI.getInstance()
+               self.handler.socketStateChanged.get().append(self.socketStateChanged)
+
+       def setSession(self, session):
+               self.session = session
+
+       def connected(self):
+               return self.handler.getState(0)
+
+       def getName(self):
+               return self.handler.getName(0)
+
+       def startMMI(self):
+               slot = 0
+               self.dlgs[slot] = self.session.openWithCallback(self.dlgClosed, MMIDialog, slot, 2, self.handler, _("wait for mmi..."))
+
+       def socketStateChanged(self, slot):
+               if slot in self.dlgs:
+                       self.dlgs[slot].ciStateChanged()
+               elif self.handler.availableMMI(slot) == 1:
+                       if self.session:
+                               self.dlgs[slot] = self.session.openWithCallback(self.dlgClosed, MMIDialog, slot, 3, self.handler, _("wait for mmi..."))
+
+       def dlgClosed(self, slot):
+               if slot in self.dlgs:
+                       del self.dlgs[slot]
+
diff --git a/lib/python/Plugins/Extensions/SocketMMI/__init__.py b/lib/python/Plugins/Extensions/SocketMMI/__init__.py
new file mode 100644 (file)
index 0000000..8d1c8b6
--- /dev/null
@@ -0,0 +1 @@
diff --git a/lib/python/Plugins/Extensions/SocketMMI/plugin.py b/lib/python/Plugins/Extensions/SocketMMI/plugin.py
new file mode 100644 (file)
index 0000000..4eadf2e
--- /dev/null
@@ -0,0 +1,27 @@
+from Plugins.Plugin import PluginDescriptor
+from SocketMMI import SocketMMIMessageHandler
+
+socketHandler = None
+
+def main(session, **kwargs):
+       socketHandler.startMMI()
+
+def menu(menuid, **kwargs):
+       if menuid == "setup" and socketHandler and socketHandler.connected():
+               return [(socketHandler.getName(), main, "socket_mmi", 0)]
+       return [ ]
+
+def sessionstart(reason, session):
+       socketHandler.setSession(session)
+
+def autostart(reason, **kwargs):
+       global socketHandler
+       if reason == 1:
+               socketHandler = None
+       else:
+               socketHandler = SocketMMIMessageHandler()
+
+def Plugins(**kwargs):
+       return [ PluginDescriptor(name = "SocketMMI", description = "Python frontend for /tmp/mmi.socket", where = PluginDescriptor.WHERE_MENU, fnc = menu),
+               PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart),
+               PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) ]