+ self.servicelist.addMarked(ref)
+
+ def removeCurrentService(self):
+ ref = self.servicelist.getCurrent()
+ mutableList = self.getMutableList()
+ if ref.valid() and mutableList is not None:
+ if not mutableList.removeService(ref):
+ mutableList.flushChanges() #FIXME dont flush on each single removed service
+ self.setRoot(self.servicelist.getRoot())
+
+ def addCurrentServiceToBouquet(self, dest):
+ mutableList = self.getMutableList(dest)
+ if not mutableList is None:
+ if not mutableList.addService(self.servicelist.getCurrent()):
+ mutableList.flushChanges()
+ self.close()
+
+ def searchNumberHelper(self, serviceHandler, num, bouquet):
+ servicelist = serviceHandler.list(bouquet)
+ if not servicelist is None:
+ while num:
+ serviceIterator = servicelist.getNext()
+ if not serviceIterator.valid(): #check end of list
+ break
+ if serviceIterator.flags: #assume normal dvb service have no flags set
+ continue
+ num -= 1;
+ if not num: #found service with searched number ?
+ return serviceIterator, 0
+ return None, num
+
+ def zapToNumber(self, number):
+ bouquet = self.bouquet_root
+ service = None
+ serviceHandler = eServiceCenter.getInstance()
+ if bouquet.toString().find('FROM BOUQUET "bouquets.') == -1: #FIXME HACK
+ service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
+ else:
+ bouquetlist = serviceHandler.list(bouquet)
+ if not bouquetlist is None:
+ while number:
+ bouquet = bouquetlist.getNext()
+ if not bouquet.valid(): #check end of list
+ break
+ if ((bouquet.flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory):
+ continue
+ service, number = self.searchNumberHelper(serviceHandler, number, bouquet)
+ if not service is None:
+ self.session.nav.playService(service) #play service
+ if self.servicelist.getRoot() != bouquet: #already in correct bouquet?
+ self.setRoot(bouquet)
+ self.servicelist.setCurrent(service) #select the service in servicelist
+
+ def getBouquetNumOffset(self, bouquet):
+ if self.bouquet_root.toString().find('FROM BOUQUET "bouquets.') == -1: #FIXME HACK
+ return 0
+ offsetCount = 0
+ serviceHandler = eServiceCenter.getInstance()
+ bouquetlist = serviceHandler.list(self.bouquet_root)
+ if not bouquetlist is None:
+ while True:
+ bouquetIterator = bouquetlist.getNext()
+ if not bouquetIterator.valid() or bouquetIterator == bouquet: #end of list or bouquet found
+ break
+ if ((bouquetIterator.flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory):
+ continue
+ servicelist = serviceHandler.list(bouquetIterator)
+ if not servicelist is None:
+ while True:
+ serviceIterator = servicelist.getNext()
+ if not serviceIterator.valid(): #check if end of list
+ break
+ if serviceIterator.flags: #playable services have no flags
+ continue
+ offsetCount += 1
+ return offsetCount
+
+ def setRoot(self, root):
+ if not self.movemode: # dont change root when movemode is enabled
+ inBouquetRootList = root.toString().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
+ if not inBouquetRootList and ((root.flags & eServiceReference.flagDirectory) == eServiceReference.flagDirectory):
+ self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
+ self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
+ else:
+ self.servicelist.setMode(ServiceList.MODE_NORMAL)
+ self.servicelist.setRoot(root)
+