added ci-selection / setup-menu screen
[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                         x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("INTEGER", (0, ((10**entry[1])-1))))
61                         list.append( getConfigListEntry(entry[2],x) )
62
63         def okbuttonClick(self):
64                 print "actual:" + str(self["entries"].getCurrentIndex())
65
66         def keyNumberGlobal(self, number):
67                 self["entries"].handleKey(config.key[str(number)])
68
69         def keyLeft(self):
70                 self["entries"].handleKey(config.key["prevElement"])
71
72         def keyRight(self):
73                 self["entries"].handleKey(config.key["nextElement"])
74
75         def keyCancel(self):
76                 print "keyCancel"
77                 self.close()
78                 
79         def __init__(self, session, slotid, title, subtitle, bottom, entries):
80                 Screen.__init__(self, session)
81
82                 self.slotid = slotid
83                 self["title"] = Label(title)
84                 self["subtitle"] = Label(subtitle)
85                 self["bottom"] = Label(bottom)
86                                 
87                 list = [ ]
88                 cnt = 0
89                 for entry in entries:
90                         self.addEntry(list, entry, cnt)
91                         cnt = cnt + 1
92                 self["entries"] = CiEntryList(list)
93
94                 self["actions"] = NumberActionMap(["SetupActions"],
95                         {
96                                 "ok": self.okbuttonClick,
97                                 "cancel": self.keyCancel,
98                                 #for PIN
99                                 "left": self.keyLeft,
100                                 "right": self.keyRight,
101                                 "1": self.keyNumberGlobal,
102                                 "2": self.keyNumberGlobal,
103                                 "3": self.keyNumberGlobal,
104                                 "4": self.keyNumberGlobal,
105                                 "5": self.keyNumberGlobal,
106                                 "6": self.keyNumberGlobal,
107                                 "7": self.keyNumberGlobal,
108                                 "8": self.keyNumberGlobal,
109                                 "9": self.keyNumberGlobal,
110                                 "0": self.keyNumberGlobal
111                         }, -1)
112
113 class CiSelection(Screen):
114         def okbuttonClick(self):
115         
116                 if self["entries"].getCurrent()[1] == 0:                #reset
117                         print "ci reset requested"
118                         pass
119                 if self["entries"].getCurrent()[1] == 1:                #init
120                         print "ci init requested"
121                         pass
122                 if self["entries"].getCurrent()[1] == 2:                #mmi open
123                         #ci->getInstance().mmiOpen() and wait for list of elments ???
124                         #generate menu / list
125                         list = [ ]
126                         list.append( ("TEXT", "CA-Info") )
127                         list.append( ("TEXT", "Card Status") )
128                         list.append( ("PIN", 6, "Card Pin") )
129                         self.session.open(CiMmi, 0, "Wichtiges CI", "Mainmenu", "Footer", list)
130                 
131         def __init__(self, session):
132                 #FIXME support for one ci only
133                 Screen.__init__(self, session)
134                 
135                 self["actions"] = ActionMap(["OkCancelActions"], 
136                         {
137                                 "ok": self.okbuttonClick,
138                                 "cancel": self.close
139                         })
140                         
141                 list = [ ]
142                 list.append( ("Reset", 0) )     
143                 list.append( ("Init", 1) )      
144                 #add timer for "app-manager name" ?
145                 list.append( ("Irdeto Blasel SE", 2) )  
146                 self["entries"] = CiEntryList(list)