ignore show requests when no instance available yet
[enigma2.git] / lib / python / Screens / ParentalControlSetup.py
index 045e8fb72d0b40dcb326fdfb183150272732ef44..c0561b5deb0acb81d9109c8b02478c397a464091 100644 (file)
@@ -51,7 +51,7 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
                }, -2)
 
        def isProtected(self):
-               return config.ParentalControl.setuppinactive.value
+               return config.ParentalControl.setuppinactive.value and config.ParentalControl.configured.value
        
        def createSetup(self):
                self.editListEntry = None
@@ -109,10 +109,32 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
                print "current selection:", self["config"].l.getCurrentSelection()
                self.createSetup()
 
+       def SetupPinMessageCallback(self, value):
+               if value:
+                       self.session.openWithCallback(self.cancelCB, ParentalControlChangePin, config.ParentalControl.setuppin, _("setup pin"))
+               else:
+                       config.ParentalControl.setuppinactive.value = False
+                       self.keyCancel()
+
+       def ServicePinMessageCallback(self, value):
+               if value:
+                       self.session.openWithCallback(self.cancelCB, ParentalControlChangePin, config.ParentalControl.servicepin[0], _("service pin"))
+               else:
+                       config.ParentalControl.servicepinactive.value = False
+                       self.keyCancel()
+
+       def cancelCB(self,value):
+               self.keyCancel()
+
        def keyCancel(self):
-               for x in self["config"].list:
-                       x[1].save()
-               self.close()
+               if config.ParentalControl.setuppinactive.value and config.ParentalControl.setuppin.value == 'aaaa':
+                       self.session.openWithCallback(self.SetupPinMessageCallback, MessageBox, _("No valid setup PIN found!\nDo you like to change the setup PIN now?\nWhen you say 'No' here the setup protection stay disabled!"), MessageBox.TYPE_YESNO)
+               elif config.ParentalControl.servicepinactive.value and config.ParentalControl.servicepin[0].value == 'aaaa':
+                       self.session.openWithCallback(self.ServicePinMessageCallback, MessageBox, _("No valid service PIN found!\nDo you like to change the service PIN now?\nWhen you say 'No' here the service protection stay disabled!"), MessageBox.TYPE_YESNO)
+               else:
+                       for x in self["config"].list:
+                               x[1].save()
+                       self.close()
 
        def keyNumberGlobal(self, number):
                pass
@@ -170,10 +192,7 @@ class ParentalControlEditor(Screen):
                if list is not None:
                        services = list.getContent("CN", True) #(servicecomparestring, name)
                        for s in services:
-                               if ord(s[1][0])==0xc2 and ord(s[1][1])==0x86: # ignore shortname brackets
-                                       key = s[1].lower()[2]
-                               else:
-                                       key = s[1].lower()[0]
+                               key = s[1].lower()[0]
                                if key < 'a' or key > 'z':
                                        key = chr(SPECIAL_CHAR)
                                #key = str(key)