2 from Components.MenuList import MenuList
3 from Components.ActionMap import ActionMap
4 from Components.ActionMap import NumberActionMap
5 from Components.Header import Header
6 from Components.Button import Button
7 from Components.Label import Label
9 from Components.HTMLComponent import *
10 from Components.GUIComponent import *
11 from Components.config import *
12 from Components.ConfigList import ConfigList
14 from enigma import eTimer, eDVBCI_UI, eListboxPythonStringContent, eListboxPythonConfigContent
20 def __init__(self, session, slotid, action):
21 Screen.__init__(self, session)
23 print "ciMMI with action" + str(action)
28 self.Timer.timeout.get().append(self.TimerCheck)
29 self.Timer.start(1000)
32 self["title"] = Label("")
33 self["subtitle"] = Label("")
34 self["bottom"] = Label("")
35 self["entries"] = ConfigList([ ])
36 self.listtype = TYPE_CONFIG
38 self["actions"] = NumberActionMap(["SetupActions"],
40 "ok": self.okbuttonClick,
41 "cancel": self.keyCancel,
44 "right": self.keyRight,
45 "1": self.keyNumberGlobal,
46 "2": self.keyNumberGlobal,
47 "3": self.keyNumberGlobal,
48 "4": self.keyNumberGlobal,
49 "5": self.keyNumberGlobal,
50 "6": self.keyNumberGlobal,
51 "7": self.keyNumberGlobal,
52 "8": self.keyNumberGlobal,
53 "9": self.keyNumberGlobal,
54 "0": self.keyNumberGlobal
59 if action == 0: #reset
60 eDVBCI_UI.getInstance().setReset(self.slotid)
62 elif action == 1: #init
63 eDVBCI_UI.getInstance().setInit(self.slotid)
64 elif action == 2: #start MMI
65 eDVBCI_UI.getInstance().startMMI(self.slotid)
67 elif action == 3: #mmi already there (called from infobar)
70 def addEntry(self, list, entry):
71 if entry[0] == "TEXT": #handle every item (text / pin only?)
72 list.append( (entry[1], entry[2]) )
74 self.pinlength = entry[1]
77 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (self.pinlength, "*")))
80 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (self.pinlength, "")))
81 self["subtitle"].setText(entry[2])
82 self.pin = getConfigListEntry("",x)
83 list.append( self.pin )
84 self["bottom"].setText(_("please press OK when ready"))
86 def okbuttonClick(self):
88 if self.tag == "WAIT":
89 print "do nothing - wait"
90 elif self.tag == "MENU":
92 eDVBCI_UI.getInstance().answerMenu(self.slotid, self["entries"].getCurrent()[1])
94 elif self.tag == "LIST":
96 eDVBCI_UI.getInstance().answerMenu(self.slotid, 0)
98 elif self.tag == "ENQ":
99 answer = str(self.pin[1].parent.value[0])
101 while length < self.pinlength:
104 eDVBCI_UI.getInstance().answerEnq(self.slotid, answer)
113 if self.tag == "WAIT":
114 eDVBCI_UI.getInstance().stopMMI(self.slotid)
116 elif self.tag in [ "MENU", "LIST" ]:
118 eDVBCI_UI.getInstance().answerMenu(self.slotid, 0)
120 elif self.tag == "ENQ":
122 eDVBCI_UI.getInstance().cancelEnq(self.slotid)
125 print "give cancel action to ci"
127 def keyNumberGlobal(self, number):
128 self["entries"].handleKey(config.key[str(number)])
131 self["entries"].handleKey(config.key["prevElement"])
134 self["entries"].handleKey(config.key["nextElement"])
136 def updateList(self, list):
137 List = self["entries"]
139 List.instance.moveSelectionTo(0)
144 if self.tag == "ENQ":
149 if type != self.listtype:
150 if type == TYPE_CONFIG:
151 List.l = eListboxPythonConfigContent()
153 List.l = eListboxPythonStringContent()
154 List.instance.setContent(List.l)
162 self["title"].setText("")
163 self["subtitle"].setText("")
164 self["bottom"].setText("")
166 list.append( ("wait for ci...", 0) )
167 self.updateList(list)
169 def showScreen(self):
170 screen = eDVBCI_UI.getInstance().getMMIScreen(self.slotid)
174 self.tag = screen[0][0]
177 if entry[0] == "PIN":
178 self.addEntry(list, entry)
180 if entry[0] == "TITLE":
181 self["title"].setText(entry[1])
182 elif entry[0] == "SUBTITLE":
183 self["subtitle"].setText(entry[1])
184 elif entry[0] == "BOTTOM":
185 self["bottom"].setText(entry[1])
186 elif entry[0] == "TEXT":
187 self.addEntry(list, entry)
188 self.updateList(list)
190 def TimerCheck(self):
191 if self.action == 0: #reset
193 if self.action == 1: #init
196 #module still there ?
197 if eDVBCI_UI.getInstance().getState(self.slotid) != 2:
200 #mmi session still active ?
201 if eDVBCI_UI.getInstance().getMMIState(self.slotid) != 1:
204 #new screen available?
205 if eDVBCI_UI.getInstance().availableMMI(self.slotid) == 1:
208 #FIXME: check for mmi-session closed
210 class CiSelection(Screen):
211 def createMenu(self):
213 self.list.append( (_("Reset"), 0) )
214 self.list.append( (_("Init"), 1) )
216 self.state = eDVBCI_UI.getInstance().getState(0)
217 if self.state == 0: #no module
218 self.list.append( (_("no module found"), 2) )
219 elif self.state == 1: #module in init
220 self.list.append( (_("init module"), 2) )
221 elif self.state == 2: #module ready
223 appname = eDVBCI_UI.getInstance().getAppName(0)
224 self.list.append( (appname, 2) )
226 self["entries"].list = self.list
227 self["entries"].l.setList(self.list)
229 def TimerCheck(self):
230 state = eDVBCI_UI.getInstance().getState(0)
231 if self.state != state:
232 #print "something happens"
236 def okbuttonClick(self):
240 self.session.open(CiMmi, 0, self["entries"].getCurrent()[1])
242 #generate menu / list
244 #list.append( ("TEXT", "CA-Info") )
245 #list.append( ("TEXT", "Card Status") )
246 #list.append( ("PIN", 6, "Card Pin", 1) )
247 #self.session.open(CiMmi, 0, 0, "Wichtiges CI", "Mainmenu", "Footer", list)
253 def __init__(self, session):
254 #FIXME support for one ci only
255 Screen.__init__(self, session)
257 self["actions"] = ActionMap(["OkCancelActions"],
259 "ok": self.okbuttonClick,
260 "cancel": self.cancel
264 self["entries"] = MenuList(list)
267 self.Timer = eTimer()
268 self.Timer.timeout.get().append(self.TimerCheck)
269 self.Timer.start(1000)