- add pissibility to mask pins
[enigma2.git] / lib / python / Screens / Ci.py
1 from Screen import *
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
8
9 from Components.HTMLComponent import *
10 from Components.GUIComponent import *
11 from Components.config import *
12
13 from enigma import eListbox, eListboxPythonConfigContent
14
15 class CiEntryList(HTMLComponent, GUIComponent):
16         def __init__(self, list):
17                 GUIComponent.__init__(self)
18                 self.l = eListboxPythonConfigContent()
19                 self.l.setList(list)
20                 self.l.setSeperation(100)
21                 self.list = list
22
23         def toggle(self):
24                 selection = self.getCurrent()
25                 selection[1].toggle()
26                 self.invalidateCurrent()
27
28         def handleKey(self, key):
29                 #not every element got an .handleKey
30                 try:
31                         selection = self.getCurrent()
32                         selection[1].handleKey(key)
33                         self.invalidateCurrent()
34                 except: 
35                         pass    
36                         
37
38         def getCurrent(self):
39                 return self.l.getCurrentSelection()
40
41         def getCurrentIndex(self):
42                 return self.l.getCurrentSelectionIndex()
43
44         def invalidateCurrent(self):
45                 self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
46
47         def GUIcreate(self, parent):
48                 self.instance = eListbox(parent)
49                 self.instance.setContent(self.l)
50
51         def GUIdelete(self):
52                 self.instance.setContent(None)
53                 self.instance = None
54
55 class CiMmi(Screen):
56         def addEntry(self, list, entry, index):
57                 if entry[0] == "TEXT":          #handle every item (text / pin only?)
58                         list.append( (entry[1], index) )
59                 if entry[0] == "PIN":
60                         # masked pins:
61                         x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "-")))
62                         # unmasked pins:
63                         # x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "")))                       
64                         list.append( getConfigListEntry(entry[2],x) )
65
66         def okbuttonClick(self):
67                 print "actual:" + str(self["entries"].getCurrentIndex())
68
69         def keyNumberGlobal(self, number):
70                 self["entries"].handleKey(config.key[str(number)])
71
72         def keyLeft(self):
73                 self["entries"].handleKey(config.key["prevElement"])
74
75         def keyRight(self):
76                 self["entries"].handleKey(config.key["nextElement"])
77
78         def keyCancel(self):
79                 print "keyCancel"
80                 self.close()
81                 
82         def __init__(self, session, slotid, title, subtitle, bottom, entries):
83                 Screen.__init__(self, session)
84
85                 self.slotid = slotid
86                 self["title"] = Label(title)
87                 self["subtitle"] = Label(subtitle)
88                 self["bottom"] = Label(bottom)
89                                 
90                 list = [ ]
91                 cnt = 0
92                 for entry in entries:
93                         self.addEntry(list, entry, cnt)
94                         cnt = cnt + 1
95                 self["entries"] = CiEntryList(list)
96
97                 self["actions"] = NumberActionMap(["SetupActions"],
98                         {
99                                 "ok": self.okbuttonClick,
100                                 "cancel": self.keyCancel,
101                                 #for PIN
102                                 "left": self.keyLeft,
103                                 "right": self.keyRight,
104                                 "1": self.keyNumberGlobal,
105                                 "2": self.keyNumberGlobal,
106                                 "3": self.keyNumberGlobal,
107                                 "4": self.keyNumberGlobal,
108                                 "5": self.keyNumberGlobal,
109                                 "6": self.keyNumberGlobal,
110                                 "7": self.keyNumberGlobal,
111                                 "8": self.keyNumberGlobal,
112                                 "9": self.keyNumberGlobal,
113                                 "0": self.keyNumberGlobal
114                         }, -1)
115
116 class CiSelection(Screen):
117         def okbuttonClick(self):
118         
119                 if self["entries"].getCurrent()[1] == 0:                #reset
120                         print "ci reset requested"
121                         pass
122                 if self["entries"].getCurrent()[1] == 1:                #init
123                         print "ci init requested"
124                         pass
125                 if self["entries"].getCurrent()[1] == 2:                #mmi open
126                         #ci->getInstance().mmiOpen() and wait for list of elments ???
127                         #generate menu / list
128                         list = [ ]
129                         list.append( ("TEXT", "CA-Info") )
130                         list.append( ("TEXT", "Card Status") )
131                         list.append( ("PIN", 6, "Card Pin") )
132                         self.session.open(CiMmi, 0, "Wichtiges CI", "Mainmenu", "Footer", list)
133                 
134         def __init__(self, session):
135                 #FIXME support for one ci only
136                 Screen.__init__(self, session)
137                 
138                 self["actions"] = ActionMap(["OkCancelActions"], 
139                         {
140                                 "ok": self.okbuttonClick,
141                                 "cancel": self.close
142                         })
143                         
144                 list = [ ]
145                 list.append( ("Reset", 0) )     
146                 list.append( ("Init", 1) )      
147                 #add timer for "app-manager name" ?
148                 list.append( ("Irdeto Blasel SE", 2) )  
149                 self["entries"] = CiEntryList(list)