fix bluescreen in ci menu when no entries in a menulist an ok is pressed
[enigma2.git] / lib / python / Screens / Ci.py
index f659355..ecc5604 100644 (file)
@@ -71,13 +71,13 @@ class CiMmi(Screen):
                if entry[0] == "TEXT":          #handle every item (text / pin only?)
                        list.append( (entry[1], entry[2]) )
                if entry[0] == "PIN":
+                       self.pinlength = entry[1]
                        if entry[3] == 1:
                                # masked pins:
-                               x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "*")))
+                               x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (self.pinlength, "*")))
                        else:                           
                                # unmasked pins:
-                               x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (entry[1], "")))
-                       
+                               x = configElement_nonSave("", configSequence, [1234], configsequencearg.get("PINCODE", (self.pinlength, "")))
                        self["subtitle"].setText(entry[2])
                        self.pin = getConfigListEntry("",x)
                        list.append( self.pin )
@@ -89,7 +89,11 @@ class CiMmi(Screen):
                        print "do nothing - wait"
                elif self.tag == "MENU":
                        print "answer MENU"
-                       eDVBCI_UI.getInstance().answerMenu(self.slotid, self["entries"].getCurrent()[1])
+                       cur = self["entries"].getCurrent()
+                       if cur:
+                               eDVBCI_UI.getInstance().answerMenu(self.slotid, cur[1])
+                       else:
+                               eDVBCI_UI.getInstance().answerMenu(self.slotid, 0)
                        self.showWait() 
                elif self.tag == "LIST":
                        print "answer LIST"
@@ -97,7 +101,10 @@ class CiMmi(Screen):
                        self.showWait() 
                elif self.tag == "ENQ":
                        answer = str(self.pin[1].parent.value[0])
-                       print "answer ENQ", answer
+                       length = len(answer)
+                       while length < self.pinlength:
+                               answer = '0'+answer
+                               length+=1
                        eDVBCI_UI.getInstance().answerEnq(self.slotid, answer)
                        self.showWait()
 
@@ -121,14 +128,20 @@ class CiMmi(Screen):
                else:
                        print "give cancel action to ci"        
 
+       def keyConfigEntry(self, key):
+               try:
+                       self["entries"].handleKey(key)
+               except AttributeError:
+                       pass
+
        def keyNumberGlobal(self, number):
-               self["entries"].handleKey(config.key[str(number)])
+               self.keyConfigEntry(config.key[str(number)])
 
        def keyLeft(self):
-               self["entries"].handleKey(config.key["prevElement"])
+               self.keyConfigEntry(config.key["prevElement"])
 
        def keyRight(self):
-               self["entries"].handleKey(config.key["nextElement"])
+               self.keyConfigEntry(config.key["nextElement"])
 
        def updateList(self, list):
                List = self["entries"]
@@ -153,7 +166,6 @@ class CiMmi(Screen):
 
                List.l.setList(list)
 
-
        def showWait(self):
                self.tag = "WAIT"
                self["title"].setText("")