diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-10-11 15:16:56 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-10-11 15:16:56 +0000 |
| commit | 681c113336426914342cf68fb03e7cd399c29c9a (patch) | |
| tree | b0595ec9c407f8f28694c152756c516d83db3edb /lib/python/Screens | |
| parent | 88078e7ac2ee289a0dfc321d71c7494657c4457c (diff) | |
| download | enigma2-681c113336426914342cf68fb03e7cd399c29c9a.tar.gz enigma2-681c113336426914342cf68fb03e7cd399c29c9a.zip | |
improve parental control retry count
Diffstat (limited to 'lib/python/Screens')
| -rw-r--r-- | lib/python/Screens/InputBox.py | 64 | ||||
| -rw-r--r-- | lib/python/Screens/ParentalControlSetup.py | 10 |
2 files changed, 54 insertions, 20 deletions
diff --git a/lib/python/Screens/InputBox.py b/lib/python/Screens/InputBox.py index e73215c3..bb8b63d9 100644 --- a/lib/python/Screens/InputBox.py +++ b/lib/python/Screens/InputBox.py @@ -6,6 +6,7 @@ from Components.Label import Label from Components.Input import Input from Components.GUIComponent import * from Tools.BoundFunction import boundFunction +from time import time import os @@ -89,19 +90,28 @@ class InputBox(Screen): self["input"].toggleOverwrite() class PinInput(InputBox): - def __init__(self, session, service = "", tries = 1, pinList = [], *args, **kwargs): + def __init__(self, session, service = "", triesEntry = None, pinList = [], *args, **kwargs): InputBox.__init__(self, session = session, text="9876", maxSize=True, type=Input.PIN, *args, **kwargs) - self.showTries = True - if tries == 1: - self.showTries = False - + self.waitTime = 15 + + self.triesEntry = triesEntry + self.pinList = pinList self["service"] = Label(service) + if self.getTries() == 0: + if (self.triesEntry.time.value + (self.waitTime * 60)) > time(): + remaining = (self.triesEntry.time.value + (self.waitTime * 60)) - time() + remainingMinutes = int(remaining / 60) + remainingSeconds = int(remaining % 60) + self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.closePinCancel, MessageBox, _("You have to wait for") + " " + str(remainingMinutes) + " " + _("minutes and") + " " + str(remainingSeconds) + " " + _("seconds."), MessageBox.TYPE_ERROR)) + else: + self.setTries(3) + self["tries"] = Label("") - self.onShown.append(boundFunction(self.setTries, tries)) - + self.onShown.append(self.showTries) + def keyNumberGlobal(self, number): if self["input"].currPos == len(self["input"]) - 1: InputBox.keyNumberGlobal(self, number) @@ -115,22 +125,44 @@ class PinInput(InputBox): return False def go(self): + self.triesEntry.time.value = int(time()) + self.triesEntry.time.save() if self.checkPin(self["input"].getText()): - self.close((True, self.tries)) + self.setTries(3) + self.closePinCorrect() else: self.keyHome() - self.setTries(self.tries - 1) - if self.tries == 0: - self.close((False, self.tries)) + self.decTries() + if self.getTries() == 0: + self.closePinWrong() else: pass + + def closePinWrong(self, *args): + print "args:", args + self.close(False) + + def closePinCorrect(self, *args): + self.close(True) + + def closePinCancel(self, *args): + self.close(None) def cancel(self): rcinput = eRCInput.getInstance() rcinput.setKeyboardMode(rcinput.kmNone) - self.close((None, self.tries)) - + self.closePinCancel() + + def getTries(self): + return self.triesEntry.tries.value + + def decTries(self): + self.setTries(self.triesEntry.tries.value - 1) + self.showTries() + def setTries(self, tries): - self.tries = tries - if self.showTries: - self["tries"].setText(_("Tries left:") + " " + str(tries))
\ No newline at end of file + self.triesEntry.tries.value = tries + self.triesEntry.tries.save() + + def showTries(self): + self["tries"].setText(_("Tries left:") + " " + str(self.getTries()))
\ No newline at end of file diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py index c3c0cb0b..d4911953 100644 --- a/lib/python/Screens/ParentalControlSetup.py +++ b/lib/python/Screens/ParentalControlSetup.py @@ -19,7 +19,10 @@ import operator class ProtectedScreen: def __init__(self): if self.isProtected(): - self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.protectedWithPin()], title = self.getPinText(), windowTitle = _("Change pin code"))) + self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.protectedWithPin()], triesEntry = self.getTriesEntry(), title = self.getPinText(), windowTitle = _("Change pin code"))) + + def getTriesEntry(self): + return config.ParentalControl.retries.setuppin def getPinText(self): return _("Please enter the correct pin code") @@ -31,10 +34,9 @@ class ProtectedScreen: return config.ParentalControl.setuppin.value def pinEntered(self, result): - if result[0] is None: + if result is None: self.close() - if not result[0]: - print result, "-", self.protectedWithPin() + elif not result: self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR) class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen): |
