X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FScreens%2FParentalControlSetup.py;h=a123d2d350a0603e5ceeaf455d87e0f9258d2a21;hp=045e8fb72d0b40dcb326fdfb183150272732ef44;hb=f8b2c3b18b2719f33a940576b408f66a54a7c223;hpb=ed40f6f85c9c07c3c1224ae20601082c0309a631 diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py old mode 100644 new mode 100755 index 045e8fb..a123d2d --- a/lib/python/Screens/ParentalControlSetup.py +++ b/lib/python/Screens/ParentalControlSetup.py @@ -1,17 +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 Components.Sources.StaticText import StaticText 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.BoundFunction import boundFunction -from ServiceReference import ServiceReference -from enigma import eServiceCenter, eServiceReference, eTimer +from enigma import eServiceCenter, eTimer, eServiceReference from operator import itemgetter class ProtectedScreen: @@ -41,23 +40,35 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen): def __init__(self, session): Screen.__init__(self, session) ProtectedScreen.__init__(self) + # for the skin: first try ParentalControlSetup, then Setup, this allows individual skinning + self.skinName = ["ParentalControlSetup", "Setup" ] + self.setup_title = _("Parental control setup") + self.onChangedEntry = [ ] + self.list = [] - ConfigListScreen.__init__(self, self.list) + ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry) self.createSetup() - + self["actions"] = NumberActionMap(["SetupActions"], { - "cancel": self.keyCancel + "cancel": self.keyCancel, + "save": self.keyCancel }, -2) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("OK")) + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setTitle(self.setup_title) def isProtected(self): - return config.ParentalControl.setuppinactive.value - + return config.ParentalControl.setuppinactive.value and config.ParentalControl.configured.value + def createSetup(self): self.editListEntry = None self.changePin = None self.changeSetupPin = None - + self.list = [] self.list.append(getConfigListEntry(_("Enable parental control"), config.ParentalControl.configured)) print "config.ParentalControl.configured.value", config.ParentalControl.configured.value @@ -79,7 +90,7 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen): #self.list.append(getConfigListEntry(_("Remember service pin"), config.ParentalControl.storeservicepin)) self.editListEntry = getConfigListEntry(_("Edit services list"), NoSave(ConfigNothing())) self.list.append(self.editListEntry) - + self["config"].list = self.list self["config"].setList(self.list) @@ -109,13 +120,49 @@ 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 + # for summary: + def changedEntry(self): + for x in self.onChangedEntry: + x() + + def getCurrentEntry(self): + return self["config"].getCurrent()[0] + + def getCurrentValue(self): + return str(self["config"].getCurrent()[1].getText()) + + def createSummary(self): + from Screens.Setup import SetupSummary + return SetupSummary SPECIAL_CHAR = 96 class ParentalControlEditor(Screen): @@ -128,7 +175,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"], @@ -170,10 +217,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) @@ -198,9 +242,7 @@ class ParentalControlEditor(Screen): if result is not None: print "result:", result self.currentLetter = result[1] - self.list = [] - for x in self.servicesList[result[1]]: - self.list.append(ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1)) + self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1) for x in self.servicesList[result[1]]] self.servicelist.setList(self.list) else: parentalControl.save() @@ -209,22 +251,43 @@ class ParentalControlEditor(Screen): class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): def __init__(self, session, pin, pinname): Screen.__init__(self, session) + # for the skin: first try ParentalControlChangePin, then Setup, this allows individual skinning + self.skinName = ["ParentalControlChangePin", "Setup" ] + self.setup_title = _("Change pin code") + self.onChangedEntry = [ ] + self.pin = pin 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) + ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry) # print "old pin:", pin #if pin.value != "aaaa": #self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.pin.value], title = _("please enter the old pin"), windowTitle = _("Change pin code"))) ProtectedScreen.__init__(self) - + self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"], { "cancel": self.cancel, + "red": self.cancel, + "save": self.keyOK, }, -1) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("OK")) + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setTitle(self.setup_title) + + 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") @@ -256,3 +319,17 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) + # for summary: + def changedEntry(self): + for x in self.onChangedEntry: + x() + + def getCurrentEntry(self): + return self["config"].getCurrent()[0] + + def getCurrentValue(self): + return str(self["config"].getCurrent()[1].getText()) + + def createSummary(self): + from Screens.Setup import SetupSummary + return SetupSummary