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 *
15 #use this class to synchronize all ci to/from user communications
18 #stop pending requests
23 if self.lastQuery >= 2:
24 eDVBCI_UI.getInstance().stopMMI(self.slot)
25 self.parent.mmistate = 0
29 #special cases to prevent to fast resets/inits
30 if self.lastQuery == 0: #reset requested
32 elif self.lastQuery == 1: #init requested
34 elif self.lastQuery == 4: #close requested
37 if eDVBCI_UI.getInstance().getState(self.slot) != 2: #module removed
40 if eDVBCI_UI.getInstance().availableMMI(self.slot) == 1: #data?
41 self.parent.mmistate = 2 #request screen
44 def __init__(self, session, parent, slot, query):
45 Screen.__init__(self, session)
47 self["message"] = Label(_("waiting for CI..."))
49 self["actions"] = ActionMap(["OkCancelActions"],
51 "cancel": self.Keycancel
55 self.lastQuery = query
59 self.Timer.timeout.get().append(self.TimerCheck)
60 self.Timer.start(1000) #check and block 1 second
64 eDVBCI_UI.getInstance().setReset(slot)
67 eDVBCI_UI.getInstance().initialize(slot)
68 if query == 2: #mmi-open
70 eDVBCI_UI.getInstance().startMMI(slot)
71 if query == 3: #mmi-answer
73 if self.parent.answertype == 0: #ENQ
74 eDVBCI_UI.getInstance().answerEnq(slot, self.parent.answertype, self.parent.answer)
75 elif self.parent.answertype == 1: #ENQ cancel
76 eDVBCI_UI.getInstance().answerEnq(slot, self.parent.answertype, "")
77 elif self.parent.answertype == 2: #Menu
78 eDVBCI_UI.getInstance().answerMenu(slot, self.parent.answer)
79 elif self.parent.answertype == 3: #List
80 eDVBCI_UI.getInstance().answerMenu(slot, self.parent.answer)
81 if query == 4: #mmi-close
86 class CiEntryList(HTMLComponent, GUIComponent):
87 def __init__(self, list):
88 GUIComponent.__init__(self)
89 self.l = eListboxPythonConfigContent()
91 self.l.setSeperation(100)
95 selection = self.getCurrent()
97 self.invalidateCurrent()
99 def handleKey(self, key):
100 #not every element got an .handleKey
102 selection = self.getCurrent()
103 selection[1].handleKey(key)
104 self.invalidateCurrent()
108 def getCurrent(self):
109 return self.l.getCurrentSelection()
111 def getCurrentIndex(self):
112 return self.l.getCurrentSelectionIndex()
114 def invalidateCurrent(self):
115 self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
117 def GUIcreate(self, parent):
118 self.instance = eListbox(parent)
119 self.instance.setContent(self.l)
122 self.instance.setContent(None)
126 def addEntry(self, list, entry):
127 if entry[0] == "TEXT": #handle every item (text / pin only?)
128 list.append( (entry[1], entry[2]) )
129 if entry[0] == "PIN":
132 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "-")))
135 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "")))
137 self.pin = getConfigListEntry(entry[2],x)
138 list.append( self.pin )
140 def closeMMI(self, cancel):
141 if self.tag == "ENQ":
142 #print "enq- answer pin:" + str(self.pin[1].parent.value[0])
144 self.parent.answertype = 0
145 self.parent.answer = str(self.pin[1].parent.value[0])
147 self.parent.answertype = 1
148 self.parent.answer = 0
149 elif self.tag == "MENU":
150 #print "answer - actual:" + str(self["entries"].getCurrent()[1])
151 self.parent.answertype = 2
153 self.parent.answer = self["entries"].getCurrent()[1]
155 self.parent.answer = 0
156 elif self.tag == "LIST":
157 #print "answer on List"
158 self.parent.answertype = 3
160 self.parent.answer = self["entries"].getCurrent()[1]
162 self.parent.answer = 0
164 self.parent.mmistate = 4 #request wait
167 def okbuttonClick(self):
174 def keyNumberGlobal(self, number):
175 self["entries"].handleKey(config.key[str(number)])
178 self["entries"].handleKey(config.key["prevElement"])
181 self["entries"].handleKey(config.key["nextElement"])
183 def __init__(self, session, parent, slotid, appname, entries):
184 Screen.__init__(self, session)
188 self.tag = entries[0][0]
190 #else the skins fails
191 self["title"] = Label("")
192 self["subtitle"] = Label("")
193 self["bottom"] = Label("")
197 for entry in entries:
198 if entry[0] == "TITLE":
199 self["title"] = Label(entry[1])
200 elif entry[0] == "SUBTITLE":
201 self["subtitle"] = Label(entry[1])
202 elif entry[0] == "BOTTOM":
203 self["bottom"] = Label(entry[1])
204 elif entry[0] == "TEXT":
205 self.addEntry(list, entry)
206 elif entry[0] == "PIN":
207 self.addEntry(list, entry)
209 self["entries"] = CiEntryList(list)
211 self["actions"] = NumberActionMap(["SetupActions"],
213 "ok": self.okbuttonClick,
214 "cancel": self.keyCancel,
216 "left": self.keyLeft,
217 "right": self.keyRight,
218 "1": self.keyNumberGlobal,
219 "2": self.keyNumberGlobal,
220 "3": self.keyNumberGlobal,
221 "4": self.keyNumberGlobal,
222 "5": self.keyNumberGlobal,
223 "6": self.keyNumberGlobal,
224 "7": self.keyNumberGlobal,
225 "8": self.keyNumberGlobal,
226 "9": self.keyNumberGlobal,
227 "0": self.keyNumberGlobal
231 class CiSelection(Screen):
232 def createMenu(self):
234 self.list.append( ("Reset", 0) )
235 self.list.append( ("Init", 1) )
237 self.state = eDVBCI_UI.getInstance().getState(0)
238 if self.state == 0: #no module
239 self.list.append( ("no module found", 2) )
240 elif self.state == 1: #module in init
241 self.list.append( ("init module", 2) )
242 elif self.state == 2: #module ready
244 appname = eDVBCI_UI.getInstance().getAppName(0)
245 self.list.append( (appname, 2) )
247 self["entries"] .list = self.list
248 self["entries"] .l.setList(self.list)
250 def TimerCheck(self):
251 state = eDVBCI_UI.getInstance().getState(0)
252 if self.state != state:
253 #print "something happens"
257 def ciWaitAnswer(self):
258 #FIXME: handling for correct slot
259 #print "ciWaitAnswer with self.mmistate = " + str(self.mmistate)
261 if self.mmistate == 0:
264 elif self.mmistate == 1: #wait requested
265 #print "wait requested"
266 self.session.openWithCallback(self.ciWaitAnswer, CiWait, self, 0, self["entries"].getCurrent()[1])
267 elif self.mmistate == 2: #open screen requested
268 #print "open screen requested"
271 appname = eDVBCI_UI.getInstance().getAppName(0)
272 list = eDVBCI_UI.getInstance().getMMIScreen(self.slot)
273 self.session.openWithCallback(self.ciWaitAnswer, CiMmi, self, self.slot, appname, list)
274 elif self.mmistate == 3: #close mmi requested
275 #print "close mmi requested"
276 self.session.openWithCallback(self.ciWaitAnswer, CiWait, self, 0, 4)
277 elif self.mmistate == 4: #mmi answer requested
278 #print "mmi answer requested"
279 self.session.openWithCallback(self.ciWaitAnswer, CiWait, self, 0, 3)
281 def okbuttonClick(self):
288 #generate menu / list
290 #list.append( ("TEXT", "CA-Info") )
291 #list.append( ("TEXT", "Card Status") )
292 #list.append( ("PIN", 6, "Card Pin", 1) )
293 #self.session.open(CiMmi, 0, 0, "Wichtiges CI", "Mainmenu", "Footer", list)
299 def __init__(self, session):
300 #FIXME support for one ci only
301 Screen.__init__(self, session)
303 self["actions"] = ActionMap(["OkCancelActions"],
305 "ok": self.okbuttonClick,
306 "cancel": self.cancel
310 self["entries"] = CiEntryList(list)
313 self.Timer = eTimer()
314 self.Timer.timeout.get().append(self.TimerCheck)
315 self.Timer.start(1000)