add python files for socket mmi plugin
[enigma2.git] / lib / python / Plugins / Extensions / SocketMMI / SocketMMI.py
1 from Screens.Ci import MMIDialog
2 from enigma import eTimer, eSocket_UI
3
4 class SocketMMIMessageHandler:
5         def __init__(self):
6                 self.session = None
7                 self.dlgs = { }
8                 self.handler = eSocket_UI.getInstance()
9                 self.handler.socketStateChanged.get().append(self.socketStateChanged)
10
11         def setSession(self, session):
12                 self.session = session
13
14         def connected(self):
15                 return self.handler.getState(0)
16
17         def getName(self):
18                 return self.handler.getName(0)
19
20         def startMMI(self):
21                 slot = 0
22                 self.dlgs[slot] = self.session.openWithCallback(self.dlgClosed, MMIDialog, slot, 2, self.handler, _("wait for mmi..."))
23
24         def socketStateChanged(self, slot):
25                 if slot in self.dlgs:
26                         self.dlgs[slot].ciStateChanged()
27                 elif self.handler.availableMMI(slot) == 1:
28                         if self.session:
29                                 self.dlgs[slot] = self.session.openWithCallback(self.dlgClosed, MMIDialog, slot, 3, self.handler, _("wait for mmi..."))
30
31         def dlgClosed(self, slot):
32                 if slot in self.dlgs:
33                         del self.dlgs[slot]
34