parental locking fixes
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 7 Feb 2007 01:05:54 +0000 (01:05 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 7 Feb 2007 01:05:54 +0000 (01:05 +0000)
Navigation.py
lib/python/Components/ParentalControl.py
lib/python/Screens/ParentalControlSetup.py

index 0262a46..37f3fbf 100644 (file)
@@ -51,12 +51,12 @@ class Navigation:
                if ref is None:
                        self.stopService()
                        return 0
                if ref is None:
                        self.stopService()
                        return 0
-               if not checkParentalControl or parentalControl.isServicePlayable(ref.toCompareString(), boundFunction(self.playService, checkParentalControl = False)):
+               if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
                        if ref.flags & eServiceReference.isGroup:
                                if not oldref:
                                        oldref = eServiceReference()
                                playref = getBestPlayableServiceReference(ref, oldref)
                        if ref.flags & eServiceReference.isGroup:
                                if not oldref:
                                        oldref = eServiceReference()
                                playref = getBestPlayableServiceReference(ref, oldref)
-                               if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref.toCompareString(), boundFunction(self.playService, checkParentalControl = False))):
+                               if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
                                        self.stopService()
                                        return 0
                        else:
                                        self.stopService()
                                        return 0
                        else:
index c323880..bf97181 100644 (file)
@@ -61,15 +61,16 @@ class ParentalControl:
                self.blacklist.remove(service)
                if self.serviceLevel.has_key(service):
                        self.serviceLevel.remove(service)
                self.blacklist.remove(service)
                if self.serviceLevel.has_key(service):
                        self.serviceLevel.remove(service)
-                               
-       def isServicePlayable(self, service, callback):
+
+       def isServicePlayable(self, ref, callback):
                if not config.ParentalControl.configured.value or not config.ParentalControl.servicepinactive.value:
                        return True
                #print "whitelist:", self.whitelist
                #print "blacklist:", self.blacklist
                #print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                #print "not in whitelist:", (service not in self.whitelist)
                if not config.ParentalControl.configured.value or not config.ParentalControl.servicepinactive.value:
                        return True
                #print "whitelist:", self.whitelist
                #print "blacklist:", self.blacklist
                #print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                #print "not in whitelist:", (service not in self.whitelist)
-               #print "checking parental control for service:", service
+               #print "checking parental control for service:", ref.toString()
+               service = ref.toCompareString()
                if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
                        self.callback = callback
                        #print "service:", ServiceReference(service).getServiceName()
                if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
                        self.callback = callback
                        #print "service:", ServiceReference(service).getServiceName()
@@ -77,7 +78,7 @@ class ParentalControl:
                        if self.serviceLevel.has_key(service):
                                levelNeeded = self.serviceLevel[service]
                        pinList = self.getPinList()[:levelNeeded + 1]
                        if self.serviceLevel.has_key(service):
                                levelNeeded = self.serviceLevel[service]
                        pinList = self.getPinList()[:levelNeeded + 1]
-                       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"))
+                       Notifications.AddNotificationWithCallback(boundFunction(self.servicePinEntered, ref), PinInput, triesEntry = config.ParentalControl.retries.servicepin, pinList = pinList, service = ServiceReference(ref).getServiceName(), title = _("this service is protected by a parental control pin"), windowTitle = _("Parental control"))
                        return False
                else:
                        return True
                        return False
                else:
                        return True
@@ -135,7 +136,7 @@ class ParentalControl:
                #if pin is not None and int(pin) in pinList:
                if result is not None and result:
                        #print "pin ok, playing service"
                #if pin is not None and int(pin) in pinList:
                if result is not None and result:
                        #print "pin ok, playing service"
-                       self.callback(ref = ServiceReference(service).ref)
+                       self.callback(ref = service)
                else:
                        if result is not None:
                                Notifications.AddNotification(MessageBox,  _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
                else:
                        if result is not None:
                                Notifications.AddNotification(MessageBox,  _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
@@ -153,7 +154,8 @@ class ParentalControl:
                        file = open(resolveFilename(SCOPE_CONFIG, "whitelist"), 'r')
                        lines = file.readlines()
                        for x in lines:
                        file = open(resolveFilename(SCOPE_CONFIG, "whitelist"), 'r')
                        lines = file.readlines()
                        for x in lines:
-                               self.whitelist.append(x.strip().upper())
+                               ref = ServiceReference(x.strip())
+                               self.whitelist.append(str(ref))
                        file.close
                except:
                        pass
                        file.close
                except:
                        pass
@@ -170,7 +172,8 @@ class ParentalControl:
                        file = open(resolveFilename(SCOPE_CONFIG, "blacklist"), 'r')
                        lines = file.readlines()
                        for x in lines:
                        file = open(resolveFilename(SCOPE_CONFIG, "blacklist"), 'r')
                        lines = file.readlines()
                        for x in lines:
-                               self.blacklist.append(x.strip().upper())
+                               ref = ServiceReference(x.strip())
+                               self.blacklist.append(str(ref))
                        file.close
                except:
                        pass
                        file.close
                except:
                        pass
@@ -183,4 +186,4 @@ class ParentalControl:
                self.openBlacklist()
                self.openWhitelist()
 
                self.openBlacklist()
                self.openWhitelist()
 
-parentalControl = ParentalControl()
\ No newline at end of file
+parentalControl = ParentalControl()
index 38c937f..c0561b5 100644 (file)
@@ -192,10 +192,7 @@ class ParentalControlEditor(Screen):
                if list is not None:
                        services = list.getContent("CN", True) #(servicecomparestring, name)
                        for s in services:
                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)
                                if key < 'a' or key > 'z':
                                        key = chr(SPECIAL_CHAR)
                                #key = str(key)