aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-10-11 15:16:56 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-10-11 15:16:56 +0000
commit681c113336426914342cf68fb03e7cd399c29c9a (patch)
treeb0595ec9c407f8f28694c152756c516d83db3edb /lib/python
parent88078e7ac2ee289a0dfc321d71c7494657c4457c (diff)
downloadenigma2-681c113336426914342cf68fb03e7cd399c29c9a.tar.gz
enigma2-681c113336426914342cf68fb03e7cd399c29c9a.zip
improve parental control retry count
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/ParentalControl.py19
-rw-r--r--lib/python/Components/config.py2
-rw-r--r--lib/python/Screens/InputBox.py64
-rw-r--r--lib/python/Screens/ParentalControlSetup.py10
4 files changed, 67 insertions, 28 deletions
diff --git a/lib/python/Components/ParentalControl.py b/lib/python/Components/ParentalControl.py
index ac786fcd..bcd788d7 100644
--- a/lib/python/Components/ParentalControl.py
+++ b/lib/python/Components/ParentalControl.py
@@ -1,4 +1,4 @@
-from Components.config import config, ConfigSubsection, ConfigSelection, ConfigPIN, ConfigYesNo, ConfigSubList
+from Components.config import config, ConfigSubsection, ConfigSelection, ConfigPIN, ConfigYesNo, ConfigSubList, ConfigInteger
from Components.Input import Input
from Screens.InputBox import InputBox, PinInput
from Screens.MessageBox import MessageBox
@@ -16,6 +16,14 @@ def InitParentalControl():
config.ParentalControl.setuppinactive = ConfigYesNo(default = False)
config.ParentalControl.type = ConfigSelection(default = "blacklist", choices = [("whitelist", _("whitelist")), ("blacklist", _("blacklist"))])
config.ParentalControl.setuppin = ConfigPIN(default = -1)
+
+ config.ParentalControl.retries = ConfigSubsection()
+ config.ParentalControl.retries.setuppin = ConfigSubsection()
+ config.ParentalControl.retries.setuppin.tries = ConfigInteger(default = 3)
+ config.ParentalControl.retries.setuppin.time = ConfigInteger(default = 3)
+ config.ParentalControl.retries.servicepin = ConfigSubsection()
+ config.ParentalControl.retries.servicepin.tries = ConfigInteger(default = 3)
+ config.ParentalControl.retries.servicepin.time = ConfigInteger(default = 3)
# config.ParentalControl.configured = configElement("config.ParentalControl.configured", configSelection, 1, (("yes", _("yes")), ("no", _("no"))))
#config.ParentalControl.mode = configElement("config.ParentalControl.mode", configSelection, 0, (("simple", _("simple")), ("complex", _("complex"))))
#config.ParentalControl.storeservicepin = configElement("config.ParentalControl.storeservicepin", configSelection, 0, (("never", _("never")), ("5_minutes", _("5 minutes")), ("30_minutes", _("30 minutes")), ("60_minutes", _("60 minutes")), ("restart", _("until restart"))))
@@ -34,7 +42,6 @@ class ParentalControl:
def __init__(self):
self.open()
self.serviceLevel = {}
- self.tries = 3
def addWhitelistService(self, service):
self.whitelist.append(service)
@@ -70,7 +77,7 @@ class ParentalControl:
if self.serviceLevel.has_key(service):
levelNeeded = self.serviceLevel[service]
pinList = self.getPinList()[:levelNeeded + 1]
- Notifications.AddNotificationWithCallback(boundFunction(self.servicePinEntered, service), PinInput, tries = self.tries, pinList = pinList, service = ServiceReference(service).getServiceName(), title = _("this service is protected by a parental control pin"), windowTitle = _("Parental control"))
+ Notifications.AddNotificationWithCallback(boundFunction(self.servicePinEntered, service), PinInput, triesEntry = config.ParentalControl.retries.servicepin, pinList = pinList, service = ServiceReference(service).getServiceName(), title = _("this service is protected by a parental control pin"), windowTitle = _("Parental control"))
return False
else:
return True
@@ -126,13 +133,11 @@ class ParentalControl:
#
# print "pin entered for service", service, "and pin was", pin
#if pin is not None and int(pin) in pinList:
- if result[0] is not None and result[0]:
+ if result is not None and result:
print "pin ok, playing service"
- self.tries = 3
self.callback(ref = ServiceReference(service).ref)
else:
- self.tries = result[1]
- if result[0] is not None:
+ if result is not None:
Notifications.AddNotification(MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
print "wrong pin entered"
diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py
index e9c8b1c1..38a23146 100644
--- a/lib/python/Components/config.py
+++ b/lib/python/Components/config.py
@@ -428,7 +428,7 @@ class ConfigClock(ConfigSequence):
ConfigSequence.__init__(self, seperator = ":", limits = [(0,23),(0,59)], default = [t.tm_hour, t.tm_min])
class ConfigInteger(ConfigSequence):
- def __init__(self, default, limits):
+ def __init__(self, default, limits = (0, 10000000000)):
ConfigSequence.__init__(self, seperator = ":", limits = [limits], default = default)
# you need to override this to do input validation
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):