fill parental control list speedup
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 10 Oct 2006 12:19:52 +0000 (12:19 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 10 Oct 2006 12:19:52 +0000 (12:19 +0000)
lib/python/Components/ParentalControl.py
lib/python/Screens/ParentalControlSetup.py

index 86f188a..f8a6dff 100644 (file)
@@ -37,26 +37,26 @@ class ParentalControl:
                self.tries = 3
                
        def addWhitelistService(self, service):
                self.tries = 3
                
        def addWhitelistService(self, service):
-               self.whitelist.append(service.toString())
+               self.whitelist.append(service.toCompareString())
        
        def addBlacklistService(self, service):
        
        def addBlacklistService(self, service):
-               self.blacklist.append(service.toString())
+               self.blacklist.append(service.toCompareString())
 
        def setServiceLevel(self, service, level):
 
        def setServiceLevel(self, service, level):
-               self.serviceLevel[service.toString()] = level
+               self.serviceLevel[service.toCompareString()] = level
 
        def deleteWhitelistService(self, service):
 
        def deleteWhitelistService(self, service):
-               self.whitelist.remove(service.toString())
-               if self.serviceLevel.has_key(service.toString()):
-                       self.serviceLevel.remove(service.toString())
+               self.whitelist.remove(service.toCompareString())
+               if self.serviceLevel.has_key(service.toCompareString()):
+                       self.serviceLevel.remove(service.toCompareString())
        
        def deleteBlacklistService(self, service):
        
        def deleteBlacklistService(self, service):
-               self.blacklist.remove(service.toString())
-               if self.serviceLevel.has_key(service.toString()):
-                       self.serviceLevel.remove(service.toString())
+               self.blacklist.remove(service.toCompareString())
+               if self.serviceLevel.has_key(service.toCompareString()):
+                       self.serviceLevel.remove(service.toCompareString())
                                
        def isServicePlayable(self, serviceref, callback):
                                
        def isServicePlayable(self, serviceref, callback):
-               service = serviceref.toString()
+               service = serviceref.toCompareString()
                if not config.ParentalControl.configured.value:
                        return True
                print "whitelist:", self.whitelist
                if not config.ParentalControl.configured.value:
                        return True
                print "whitelist:", self.whitelist
@@ -80,10 +80,10 @@ class ParentalControl:
                print "protect"
                print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                if config.ParentalControl.type.value == "whitelist":
                print "protect"
                print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                if config.ParentalControl.type.value == "whitelist":
-                       if service.toString() in self.whitelist:
+                       if service.toCompareString() in self.whitelist:
                                self.deleteWhitelistService(service)
                else: # blacklist
                                self.deleteWhitelistService(service)
                else: # blacklist
-                       if service.toString() not in self.blacklist:
+                       if service.toCompareString() not in self.blacklist:
                                self.addBlacklistService(service)
                print "whitelist:", self.whitelist
                print "blacklist:", self.blacklist
                                self.addBlacklistService(service)
                print "whitelist:", self.whitelist
                print "blacklist:", self.blacklist
@@ -93,18 +93,16 @@ class ParentalControl:
                print "unprotect"
                print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                if config.ParentalControl.type.value == "whitelist":
                print "unprotect"
                print "config.ParentalControl.type.value:", config.ParentalControl.type.value
                if config.ParentalControl.type.value == "whitelist":
-                       if service.toString() not in self.whitelist:
+                       if service.toCompareString() not in self.whitelist:
                                self.addWhitelistService(service)
                else: # blacklist
                                self.addWhitelistService(service)
                else: # blacklist
-                       if service.toString() in self.blacklist:
+                       if service.toCompareString() in self.blacklist:
                                self.deleteBlacklistService(service)
                print "whitelist:", self.whitelist
                print "blacklist:", self.blacklist
 
                                self.deleteBlacklistService(service)
                print "whitelist:", self.whitelist
                print "blacklist:", self.blacklist
 
-
-               
        def getProtectionLevel(self, serviceref):
        def getProtectionLevel(self, serviceref):
-               service = serviceref.toString()
+               service = serviceref.toCompareString()
                if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
                        if self.serviceLevel.has_key(service):
                                return self.serviceLevel[service]
                if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
                        if self.serviceLevel.has_key(service):
                                return self.serviceLevel[service]
index 2a90746..77d592d 100644 (file)
@@ -170,21 +170,16 @@ class ParentalControlEditor(Screen):
                
                list = serviceHandler.list(self.root)
                if list is not None:
                
                list = serviceHandler.list(self.root)
                if list is not None:
-                       while 1:
-                               s = list.getNext()
-                               if s.valid():
-                                       service = s.toString()
-                                       name = ServiceReference(service).getServiceName()
-                                       key = name.lower()[0]
-                                       if key < 'a' or key > 'z':
-                                               key = '&'
-                                       #key = str(key)
-                                       if not self.servicesList.has_key(key):
-                                               self.servicesList[key] = []
-                                       # (servicestring, eServiceRef, name)
-                                       self.servicesList[key].append((service, s, name))
-                               else:
-                                       break
+                       services = list.getContent("CRN", True) #(servicecomparestring, eServiceRef, name)
+                       for s in services:
+                               key = s[2].lower()[0]
+                               if key < 'a' or key > 'z':
+                                       key = '&'
+                               #key = str(key)
+                               if not self.servicesList.has_key(key):
+                                       self.servicesList[key] = []
+                               self.servicesList[key].append(s)
+
                print self.servicesList
 
        def chooseLetter(self):
                print self.servicesList
 
        def chooseLetter(self):