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 #special cases to prevent to fast resets/inits
24 if self.lastQuery == 0:
26 elif self.lastQuery == 1:
29 def __init__(self, session, slot, query):
30 Screen.__init__(self, session)
32 self["message"] = Label("waiting for CI...")
34 self["actions"] = ActionMap(["OkCancelActions"],
39 self.lastQuery = query
42 self.Timer.timeout.get().append(self.TimerCheck)
45 self.Timer.start(1000) #block 1 second
47 eDVBCI_UI.getInstance().setReset(0)
49 self.Timer.start(1000) #block 1 second
51 if query == 2: #mmi-open
53 if query == 3: #mmi-answer
57 class CiEntryList(HTMLComponent, GUIComponent):
58 def __init__(self, list):
59 GUIComponent.__init__(self)
60 self.l = eListboxPythonConfigContent()
62 self.l.setSeperation(100)
66 selection = self.getCurrent()
68 self.invalidateCurrent()
70 def handleKey(self, key):
71 #not every element got an .handleKey
73 selection = self.getCurrent()
74 selection[1].handleKey(key)
75 self.invalidateCurrent()
80 return self.l.getCurrentSelection()
82 def getCurrentIndex(self):
83 return self.l.getCurrentSelectionIndex()
85 def invalidateCurrent(self):
86 self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
88 def GUIcreate(self, parent):
89 self.instance = eListbox(parent)
90 self.instance.setContent(self.l)
93 self.instance.setContent(None)
97 def addEntry(self, list, entry, index):
98 if entry[0] == "TEXT": #handle every item (text / pin only?)
99 list.append( (entry[1], index) )
100 if entry[0] == "PIN":
103 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "-")))
106 x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "")))
108 self.pin = getConfigListEntry(entry[2],x)
109 list.append( self.pin )
111 def okbuttonClick(self):
112 if self.tag == 0: #ENQ
113 print "enq- answer pin:" + str(self.pin[1].parent.value[0])
114 #ci[self.slotid]->getInstance().mmiEnqAnswer(self.pin[1].parent.value[0])
115 elif self.tag == 1: #Menu
116 print "answer - actual:" + str(self["entries"].getCurrentIndex())
117 #ci[self.slotid]->getInstance().mmiAnswer(self["entries"].getCurrentIndex())
118 elif self.tag == 2: #List
119 print "answer on List - send 0"
120 #ci[self.slotid]->getInstance().mmiAnswer(0)
123 def keyNumberGlobal(self, number):
124 self["entries"].handleKey(config.key[str(number)])
127 self["entries"].handleKey(config.key["prevElement"])
130 self["entries"].handleKey(config.key["nextElement"])
136 #tag is 0=ENQ 1=Menu 2=List
137 def __init__(self, session, slotid, tag, title, subtitle, bottom, entries):
138 Screen.__init__(self, session)
142 self["title"] = Label(title)
143 self["subtitle"] = Label(subtitle)
144 self["bottom"] = Label(bottom)
148 for entry in entries:
149 self.addEntry(list, entry, cnt)
151 self["entries"] = CiEntryList(list)
153 self["actions"] = NumberActionMap(["SetupActions"],
155 "ok": self.okbuttonClick,
156 "cancel": self.keyCancel,
158 "left": self.keyLeft,
159 "right": self.keyRight,
160 "1": self.keyNumberGlobal,
161 "2": self.keyNumberGlobal,
162 "3": self.keyNumberGlobal,
163 "4": self.keyNumberGlobal,
164 "5": self.keyNumberGlobal,
165 "6": self.keyNumberGlobal,
166 "7": self.keyNumberGlobal,
167 "8": self.keyNumberGlobal,
168 "9": self.keyNumberGlobal,
169 "0": self.keyNumberGlobal
173 class CiSelection(Screen):
174 def createMenu(self):
176 self.list.append( ("Reset", 0) )
177 self.list.append( ("Init", 1) )
179 self.state = eDVBCI_UI.getInstance().getState(0)
180 if self.state == 0: #no module
181 self.list.append( ("no module found", 2) )
182 elif self.state == 1: #module in init
183 self.list.append( ("init module", 2) )
184 elif self.state == 2: #module ready
186 appname = eDVBCI_UI.getInstance().getAppName(0)
187 self.list.append( (appname, 2) )
189 self["entries"] .list = self.list
190 self["entries"] .l.setList(self.list)
192 def TimerCheck(self):
193 state = eDVBCI_UI.getInstance().getState(0)
194 if self.state != state:
195 print "something happens"
199 def okbuttonClick(self):
201 #FIXME: find out the correct slot
202 self.session.open(CiWait, 0, self["entries"].getCurrent()[1])
204 #generate menu / list
206 #list.append( ("TEXT", "CA-Info") )
207 #list.append( ("TEXT", "Card Status") )
208 #list.append( ("PIN", 6, "Card Pin", 1) )
209 #self.session.open(CiMmi, 0, 0, "Wichtiges CI", "Mainmenu", "Footer", list)
215 def __init__(self, session):
216 #FIXME support for one ci only
217 Screen.__init__(self, session)
219 self["actions"] = ActionMap(["OkCancelActions"],
221 "ok": self.okbuttonClick,
222 "cancel": self.cancel
226 self["entries"] = CiEntryList(list)
229 self.Timer = eTimer()
230 self.Timer.timeout.get().append(self.TimerCheck)
231 self.Timer.start(1000)