Merge branch 'bug_615_replace_rawfile' into experimental
[vuplus_dvbapp] / lib / python / Screens / ParentalControlSetup.py
old mode 100755 (executable)
new mode 100644 (file)
index a123d2d..284294f
@@ -3,7 +3,7 @@ from Components.ConfigList import ConfigListScreen
 from Components.ActionMap import NumberActionMap
 from Components.config import config, getConfigListEntry, ConfigNothing, NoSave, ConfigPIN
 from Components.ParentalControlList import ParentalControlEntryComponent, ParentalControlList 
 from Components.ActionMap import NumberActionMap
 from Components.config import config, getConfigListEntry, ConfigNothing, NoSave, ConfigPIN
 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 Components.Sources.StaticText import StaticText
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
@@ -16,7 +16,7 @@ from operator import itemgetter
 class ProtectedScreen:
        def __init__(self):
                if self.isProtected():
 class ProtectedScreen:
        def __init__(self):
                if self.isProtected():
-                       self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.protectedWithPin()], triesEntry = self.getTriesEntry(), 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 = _("Enter pin code")))
 
        def getTriesEntry(self):
                return config.ParentalControl.retries.setuppin
 
        def getTriesEntry(self):
                return config.ParentalControl.retries.setuppin
@@ -48,11 +48,11 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
                self.list = []
                ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
                self.createSetup()
                self.list = []
                ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
                self.createSetup()
-
+               
                self["actions"] = NumberActionMap(["SetupActions"],
                {
                self["actions"] = NumberActionMap(["SetupActions"],
                {
-                       "cancel": self.keyCancel,
-                       "save": self.keyCancel
+                 "cancel": self.keyCancel,
+                 "save": self.keyCancel
                }, -2)
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("OK"))
                }, -2)
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("OK"))
@@ -63,34 +63,45 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
 
        def isProtected(self):
                return config.ParentalControl.setuppinactive.value and config.ParentalControl.configured.value
 
        def isProtected(self):
                return config.ParentalControl.setuppinactive.value and config.ParentalControl.configured.value
-
+       
        def createSetup(self):
                self.editListEntry = None
                self.changePin = None
                self.changeSetupPin = None
        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
                self.list = []
                self.list.append(getConfigListEntry(_("Enable parental control"), config.ParentalControl.configured))
                print "config.ParentalControl.configured.value", config.ParentalControl.configured.value
+               self.editBouquetListEntry = -1
+               self.reloadLists = -1
                if config.ParentalControl.configured.value:
                        #self.list.append(getConfigListEntry(_("Configuration mode"), config.ParentalControl.mode))
                        self.list.append(getConfigListEntry(_("Protect setup"), config.ParentalControl.setuppinactive))
                        if config.ParentalControl.setuppinactive.value:
                if config.ParentalControl.configured.value:
                        #self.list.append(getConfigListEntry(_("Configuration mode"), config.ParentalControl.mode))
                        self.list.append(getConfigListEntry(_("Protect setup"), config.ParentalControl.setuppinactive))
                        if config.ParentalControl.setuppinactive.value:
-                               self.changeSetupPin = getConfigListEntry(_("Change setup pin"), NoSave(ConfigNothing()))
+                               self.changeSetupPin = getConfigListEntry(_("Change setup PIN"), NoSave(ConfigNothing()))
                                self.list.append(self.changeSetupPin)
                        self.list.append(getConfigListEntry(_("Protect services"), config.ParentalControl.servicepinactive))
                        if config.ParentalControl.servicepinactive.value:
                                self.list.append(getConfigListEntry(_("Parental control type"), config.ParentalControl.type))
                                if config.ParentalControl.mode.value == "complex":
                                self.list.append(self.changeSetupPin)
                        self.list.append(getConfigListEntry(_("Protect services"), config.ParentalControl.servicepinactive))
                        if config.ParentalControl.servicepinactive.value:
                                self.list.append(getConfigListEntry(_("Parental control type"), config.ParentalControl.type))
                                if config.ParentalControl.mode.value == "complex":
-                                       self.changePin = getConfigListEntry(_("Change service pins"), NoSave(ConfigNothing()))
+                                       self.changePin = getConfigListEntry(_("Change service PINs"), NoSave(ConfigNothing()))
                                        self.list.append(self.changePin)
                                elif config.ParentalControl.mode.value == "simple":     
                                        self.list.append(self.changePin)
                                elif config.ParentalControl.mode.value == "simple":     
-                                       self.changePin = getConfigListEntry(_("Change service pin"), NoSave(ConfigNothing()))
+                                       self.changePin = getConfigListEntry(_("Change service PIN"), NoSave(ConfigNothing()))
                                        self.list.append(self.changePin)
                                        self.list.append(self.changePin)
-                               #self.list.append(getConfigListEntry(_("Remember service pin"), config.ParentalControl.storeservicepin))        
+                               #Added Option to remember the service pin
+                               self.list.append(getConfigListEntry(_("Remember service PIN"), config.ParentalControl.storeservicepin)) 
+                               #Added Option to remember the cancellation of service pin entry
+                               self.list.append(getConfigListEntry(_("Remember service PIN cancel"), config.ParentalControl.storeservicepincancel))    
                                self.editListEntry = getConfigListEntry(_("Edit services list"), NoSave(ConfigNothing()))
                                self.list.append(self.editListEntry)
                                self.editListEntry = getConfigListEntry(_("Edit services list"), NoSave(ConfigNothing()))
                                self.list.append(self.editListEntry)
-
+                               #New funtion: Possibility to add Bouquets to whitelist / blacklist
+                               self.editBouquetListEntry = getConfigListEntry(_("Edit bouquets list"), NoSave(ConfigNothing()))
+                               self.list.append(self.editBouquetListEntry)
+                               #New option to reload service lists (for example if bouquets have changed)
+                               self.reloadLists = getConfigListEntry(_("Reload Black-/Whitelists"), NoSave(ConfigNothing()))
+                               self.list.append(self.reloadLists)
+                               
                self["config"].list = self.list
                self["config"].setList(self.list)
 
                self["config"].list = self.list
                self["config"].setList(self.list)
 
@@ -98,13 +109,18 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
                print "self[\"config\"].l.getCurrentSelection()", self["config"].l.getCurrentSelection()
                if self["config"].l.getCurrentSelection() == self.editListEntry:
                        self.session.open(ParentalControlEditor)
                print "self[\"config\"].l.getCurrentSelection()", self["config"].l.getCurrentSelection()
                if self["config"].l.getCurrentSelection() == self.editListEntry:
                        self.session.open(ParentalControlEditor)
+               elif self["config"].l.getCurrentSelection() == self.editBouquetListEntry:
+                       self.session.open(ParentalControlBouquetEditor)
                elif self["config"].l.getCurrentSelection() == self.changePin:
                        if config.ParentalControl.mode.value == "complex":
                                pass
                        else:
                elif self["config"].l.getCurrentSelection() == self.changePin:
                        if config.ParentalControl.mode.value == "complex":
                                pass
                        else:
-                               self.session.open(ParentalControlChangePin, config.ParentalControl.servicepin[0], _("service pin"))
+                               self.session.open(ParentalControlChangePin, config.ParentalControl.servicepin[0], _("service PIN"))
                elif self["config"].l.getCurrentSelection() == self.changeSetupPin:
                elif self["config"].l.getCurrentSelection() == self.changeSetupPin:
-                       self.session.open(ParentalControlChangePin, config.ParentalControl.setuppin, _("setup pin"))
+                       self.session.open(ParentalControlChangePin, config.ParentalControl.setuppin, _("setup PIN"))
+               elif self["config"].l.getCurrentSelection() == self.reloadLists:
+                       from Components.ParentalControl import parentalControl
+                       parentalControl.open()
                else:
                        ConfigListScreen.keyRight(self)
                        print "current selection:", self["config"].l.getCurrentSelection()
                else:
                        ConfigListScreen.keyRight(self)
                        print "current selection:", self["config"].l.getCurrentSelection()
@@ -122,14 +138,14 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
 
        def SetupPinMessageCallback(self, value):
                if value:
 
        def SetupPinMessageCallback(self, value):
                if value:
-                       self.session.openWithCallback(self.cancelCB, ParentalControlChangePin, config.ParentalControl.setuppin, _("setup pin"))
+                       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:
                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"))
+                       self.session.openWithCallback(self.cancelCB, ParentalControlChangePin, config.ParentalControl.servicepin[0], _("service PIN"))
                else:
                        config.ParentalControl.servicepinactive.value = False
                        self.keyCancel()
                else:
                        config.ParentalControl.servicepinactive.value = False
                        self.keyCancel()
@@ -149,6 +165,7 @@ class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
 
        def keyNumberGlobal(self, number):
                pass
 
        def keyNumberGlobal(self, number):
                pass
+
        # for summary:
        def changedEntry(self):
                for x in self.onChangedEntry:
        # for summary:
        def changedEntry(self):
                for x in self.onChangedEntry:
@@ -224,13 +241,13 @@ class ParentalControlEditor(Screen):
                                if not self.servicesList.has_key(key):
                                        self.servicesList[key] = []
                                self.servicesList[key].append(s)
                                if not self.servicesList.has_key(key):
                                        self.servicesList[key] = []
                                self.servicesList[key].append(s)
-
+                       
        def chooseLetter(self):
                print "choose letter"
                mylist = []
                for x in self.servicesList.keys():
                        if x == chr(SPECIAL_CHAR):
        def chooseLetter(self):
                print "choose letter"
                mylist = []
                for x in self.servicesList.keys():
                        if x == chr(SPECIAL_CHAR):
-                               x = ("special characters", x)
+                               x = (_("special characters"), x)
                        else:
                                x = (x, x)
                        mylist.append(x)
                        else:
                                x = (x, x)
                        mylist.append(x)
@@ -239,15 +256,57 @@ class ParentalControlEditor(Screen):
                self.session.openWithCallback(self.letterChosen, ChoiceBox, title=_("Show services beginning with"), list=mylist, keys = [], selection = sel)
 
        def letterChosen(self, result):
                self.session.openWithCallback(self.letterChosen, ChoiceBox, title=_("Show services beginning with"), list=mylist, keys = [], selection = sel)
 
        def letterChosen(self, result):
+               from Components.ParentalControl import parentalControl
                if result is not None:
                        print "result:", result
                        self.currentLetter = result[1]
                if result is not None:
                        print "result:", result
                        self.currentLetter = result[1]
-                       self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1) for x in self.servicesList[result[1]]]
+                       #Replace getProtectionLevel by new getProtectionType
+                       self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionType(x[0])) for x in self.servicesList[result[1]]]
                        self.servicelist.setList(self.list)
                else:
                        parentalControl.save()
                        self.close()
 
                        self.servicelist.setList(self.list)
                else:
                        parentalControl.save()
                        self.close()
 
+class ParentalControlBouquetEditor(Screen):
+       #This new class allows adding complete bouquets to black- and whitelists
+       #The servicereference that is stored for bouquets is their refstr as listed in bouquets.tv
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self.skinName = "ParentalControlEditor"
+               self.list = []
+               self.bouquetslist = ParentalControlList(self.list)
+               self["servicelist"] = self.bouquetslist;
+               self.readBouquetList()
+               self.onLayoutFinish.append(self.selectBouquet)
+
+               self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"],
+               {
+                       "ok": self.select,
+                       "cancel": self.cancel
+               }, -1)
+
+       def cancel(self):
+               from Components.ParentalControl import parentalControl
+               parentalControl.save()
+               self.close()
+
+       def select(self):
+               self.bouquetslist.toggleSelectedLock()
+
+       def readBouquetList(self):
+               serviceHandler = eServiceCenter.getInstance()
+               refstr = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"bouquets.tv\" ORDER BY bouquet'
+               bouquetroot = eServiceReference(refstr)
+               self.bouquetlist = {}
+               list = serviceHandler.list(bouquetroot)
+               if list is not None:
+                       self.bouquetlist = list.getContent("CN", True)
+       
+       def selectBouquet(self):
+               from Components.ParentalControl import parentalControl
+               self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionType(x[0])) for x in self.bouquetlist]
+               self.bouquetslist.setList(self.list)
+
 class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
        def __init__(self, session, pin, pinname):
                Screen.__init__(self, session)
 class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
        def __init__(self, session, pin, pinname):
                Screen.__init__(self, session)
@@ -262,14 +321,14 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
                self.pin2 = ConfigPIN(default = 1112, censor = "*")
                self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1))
                self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2))
                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, session = self.session, on_change = self.changedEntry)
+               self.list.append(getConfigListEntry(_("New PIN"), NoSave(self.pin1)))
+               self.list.append(getConfigListEntry(_("Reenter new PIN"), NoSave(self.pin2)))
+               ConfigListScreen.__init__(self, self.list)
 #              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)
 #              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,
                self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"],
                {
                        "cancel": self.cancel,
@@ -290,7 +349,7 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
                        self.keyOK()
 
        def getPinText(self):
                        self.keyOK()
 
        def getPinText(self):
-               return _("Please enter the old pin code")
+               return _("Please enter the old PIN code")
 
        def isProtected(self):
                return (self.pin.value != "aaaa")
 
        def isProtected(self):
                return (self.pin.value != "aaaa")
@@ -309,9 +368,9 @@ class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen):
                if self.pin1.value == self.pin2.value:
                        self.pin.value = self.pin1.value
                        self.pin.save()
                if self.pin1.value == self.pin2.value:
                        self.pin.value = self.pin1.value
                        self.pin.save()
-                       self.session.openWithCallback(self.close, MessageBox, _("The pin code has been changed successfully."), MessageBox.TYPE_INFO)
+                       self.session.openWithCallback(self.close, MessageBox, _("The PIN code has been changed successfully."), MessageBox.TYPE_INFO)
                else:
                else:
-                       self.session.open(MessageBox, _("The pin codes you entered are different."), MessageBox.TYPE_ERROR)
+                       self.session.open(MessageBox, _("The PIN codes you entered are different."), MessageBox.TYPE_ERROR)
 
        def cancel(self):
                self.close(None)
 
        def cancel(self):
                self.close(None)