X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d30355fd9062e6333af64e64a9a4847ac76ed73e..7e94237a4e4ee40e1dff230d1760dcaaba3d90e8:/lib/python/Screens/ParentalControlSetup.py diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py index 7c4c3ecf..6ae12cae 100644 --- a/lib/python/Screens/ParentalControlSetup.py +++ b/lib/python/Screens/ParentalControlSetup.py @@ -1,20 +1,16 @@ from Screen import Screen -from Components.ConfigList import ConfigList, ConfigListScreen +from Components.ConfigList import ConfigListScreen from Components.ActionMap import NumberActionMap from Components.config import config, getConfigListEntry, ConfigNothing, NoSave, ConfigPIN -from Components.ServiceList import ServiceList from Components.ParentalControlList import ParentalControlEntryComponent, ParentalControlList from Components.ParentalControl import parentalControl from Screens.ChoiceBox import ChoiceBox from Screens.MessageBox import MessageBox -from Screens.InputBox import InputBox, Input, PinInput +from Screens.InputBox import 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 -import os -import operator +from enigma import eServiceCenter, eTimer, eServiceReference +from operator import itemgetter class ProtectedScreen: def __init__(self): @@ -53,7 +49,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 @@ -111,10 +107,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 @@ -130,7 +148,7 @@ class ParentalControlEditor(Screen): self.currentLetter = chr(SPECIAL_CHAR) self.readServiceList() self.chooseLetterTimer = eTimer() - self.chooseLetterTimer.timeout.get().append(self.chooseLetter) + self.chooseLetterTimer.callback.append(self.chooseLetter) self.onLayoutFinish.append(self.LayoutFinished) self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions", "NumberActions"], @@ -172,10 +190,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) @@ -192,7 +207,7 @@ class ParentalControlEditor(Screen): 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) @@ -215,6 +230,8 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): self.list = [] self.pin1 = ConfigPIN(default = 1111, censor = "*") self.pin2 = ConfigPIN(default = 1112, censor = "*") + self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) + self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("New pin"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter new pin"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) @@ -228,6 +245,12 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): "cancel": self.cancel, }, -1) + def valueChanged(self, pin, value): + if pin == 1: + self["config"].setCurrentIndex(1) + elif pin == 2: + self.keyOK() + def getPinText(self): return _("Please enter the old pin code")