do not let the user leave the parental control setup when setup protection
[enigma2.git] / lib / python / Screens / ParentalControlSetup.py
index 7c4c3ecff781ef3520b1b2bdaf5cd519ca3094c8..cde1f7c264d45d5d79cf743e2658ca465f5848aa 100644 (file)
@@ -9,12 +9,10 @@ from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
 from Screens.InputBox import InputBox, Input, PinInput
 from Screens.ChannelSelection import service_types_tv
 from Screens.MessageBox import MessageBox
 from Screens.InputBox import InputBox, Input, PinInput
 from Screens.ChannelSelection import service_types_tv
-from Tools.Directories import resolveFilename, SCOPE_CONFIG
 from Tools.BoundFunction import boundFunction
 from ServiceReference import ServiceReference
 from enigma import eServiceCenter, eServiceReference, eTimer
 from Tools.BoundFunction import boundFunction
 from ServiceReference import ServiceReference
 from enigma import eServiceCenter, eServiceReference, eTimer
-import os
-import operator
+from operator import itemgetter
 
 class ProtectedScreen:
        def __init__(self):
 
 class ProtectedScreen:
        def __init__(self):
@@ -111,10 +109,32 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
                print "current selection:", self["config"].l.getCurrentSelection()
                self.createSetup()
 
                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):
        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
 
        def keyNumberGlobal(self, number):
                pass
@@ -192,7 +212,7 @@ class ParentalControlEditor(Screen):
                        else:
                                x = (x, x)
                        mylist.append(x)
                        else:
                                x = (x, x)
                        mylist.append(x)
-               mylist.sort(key=operator.itemgetter(1))
+               mylist.sort(key=itemgetter(1))
                sel = ord(self.currentLetter) - SPECIAL_CHAR
                self.session.openWithCallback(self.letterChosen, ChoiceBox, title=_("Show services beginning with"), list=mylist, keys = [], selection = sel)
 
                sel = ord(self.currentLetter) - SPECIAL_CHAR
                self.session.openWithCallback(self.letterChosen, ChoiceBox, title=_("Show services beginning with"), list=mylist, keys = [], selection = sel)