Correctly parental protect time edit menu
authorlittlesat <littlesat99@yahoo.com>
Thu, 2 Apr 2015 23:03:00 +0000 (01:03 +0200)
committerlittlesat <littlesat99@yahoo.com>
Thu, 2 Apr 2015 23:03:00 +0000 (01:03 +0200)
lib/python/Screens/Menu.py
lib/python/Screens/TimerEdit.py
lib/python/Screens/TimerSelection.py

index 2aa85a2..142a1ed 100644 (file)
@@ -249,8 +249,6 @@ class Menu(Screen, ProtectedScreen):
                                return self.menuID == "mainmenu"
                        elif config.ParentalControl.config_sections.configuration.value and self.menuID == "setup":
                                return True
-                       elif config.ParentalControl.config_sections.timer_menu.value and self.menuID == "timermenu":
-                               return True
                        elif config.ParentalControl.config_sections.standby_menu.value and self.menuID == "shutdown":
                                return True
 class MainMenu(Menu):
index 5d21e8c..fb99b83 100644 (file)
@@ -9,6 +9,7 @@ from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT
 from Screen import Screen
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
+from Screens.InputBox import PinInput
 from ServiceReference import ServiceReference
 from TimerEntry import TimerEntry, TimerLog
 from Tools.BoundFunction import boundFunction
@@ -56,6 +57,20 @@ class TimerEditList(Screen):
                self.setTitle(_("Timer overview"))
                self.session.nav.RecordTimer.on_state_change.append(self.onStateChange)
                self.onShown.append(self.updateState)
+               if self.isProtected() and config.ParentalControl.servicepin[0].value:
+                       self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList=[x.value for x in config.ParentalControl.servicepin], triesEntry=config.ParentalControl.retries.servicepin, title=_("Please enter the correct pin code"), windowTitle=_("Enter pin code")))
+
+       def isProtected(self):
+               return config.ParentalControl.setuppinactive.value and not config.ParentalControl.config_sections.main_menu.value and config.ParentalControl.config_sections.timer_menu.value
+
+       def pinEntered(self, result):
+               if result is None:
+                       self.closeProtectedScreen()
+               elif not result:
+                       self.session.openWithCallback(self.close(), MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR, timeout=3)
+
+       def closeProtectedScreen(self, result=None):
+               self.close(None)
 
        def up(self):
                self["timerlist"].instance.moveSelection(self["timerlist"].instance.moveUp)
index 64de776..588b6d8 100644 (file)
@@ -17,7 +17,6 @@ class TimerSelection(Screen):
                                "cancel": self.leave,
                        }, -1)
 
-
        def leave(self):
                self.close(None)