From b9d9e49b2d990fbd32f647c20ad3f7ddcaf17d02 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Fri, 23 Nov 2007 18:03:59 +0000 Subject: [PATCH] add python files for socket mmi plugin --- .../Plugins/Extensions/SocketMMI/Makefile.am | 7 ++++ .../Plugins/Extensions/SocketMMI/SocketMMI.py | 34 +++++++++++++++++++ .../Plugins/Extensions/SocketMMI/__init__.py | 1 + .../Plugins/Extensions/SocketMMI/plugin.py | 27 +++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 lib/python/Plugins/Extensions/SocketMMI/Makefile.am create mode 100644 lib/python/Plugins/Extensions/SocketMMI/SocketMMI.py create mode 100644 lib/python/Plugins/Extensions/SocketMMI/__init__.py create mode 100644 lib/python/Plugins/Extensions/SocketMMI/plugin.py diff --git a/lib/python/Plugins/Extensions/SocketMMI/Makefile.am b/lib/python/Plugins/Extensions/SocketMMI/Makefile.am new file mode 100644 index 00000000..209ab8aa --- /dev/null +++ b/lib/python/Plugins/Extensions/SocketMMI/Makefile.am @@ -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 index 00000000..e44c71f0 --- /dev/null +++ b/lib/python/Plugins/Extensions/SocketMMI/SocketMMI.py @@ -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 index 00000000..8d1c8b69 --- /dev/null +++ b/lib/python/Plugins/Extensions/SocketMMI/__init__.py @@ -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 index 00000000..4eadf2ea --- /dev/null +++ b/lib/python/Plugins/Extensions/SocketMMI/plugin.py @@ -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) ] -- 2.30.2