def addAlternativeServices(self): cur_service = ServiceReference(self.getCurrentSelection()) root = self.getRoot() cur_root = root and ServiceReference(root) mutableBouquet = cur_root.list().startEdit() if mutableBouquet: name = cur_service.getServiceName() print "NAME", name if self.mode == MODE_TV: str = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name)) else: str = '1:134:2:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(name)) new_ref = ServiceReference(str) if not mutableBouquet.addService(new_ref.ref, cur_service.ref): mutableBouquet.removeService(cur_service.ref) mutableBouquet.flushChanges() eDVBDB.getInstance().reloadBouquets() mutableAlternatives = new_ref.list().startEdit() if mutableAlternatives: mutableAlternatives.setListName(name) if mutableAlternatives.addService(cur_service.ref): print "add", cur_service.toString(), "to new alternatives failed" mutableAlternatives.flushChanges() self.servicelist.addService(new_ref.ref, True) self.servicelist.removeCurrent() self.servicelist.moveUp() else: print "get mutable list for new created alternatives failed" else: print "add", str, "to", cur_root.getServiceName(), "failed" else: print "bouquetlist is not editable"
def removeAlternativeServices(self, param): print( "[WebComponents.BouquetEditor] removeAlternativeServices with param = ", param) sBouquetRef = param["sBouquetRef"] if sBouquetRef is None: return (False, _("No bouquet given!")) sRef = None if "sRef" in param: if param["sRef"] is not None: sRef = param["sRef"] if sRef is None: return (False, _("No service given!")) cur_ref = eServiceReference(sRef) # check if service is an alternative if cur_ref.flags & eServiceReference.isGroup: cur_service = ServiceReference(cur_ref) list = cur_service.list() first_in_alternative = list and list.getNext() if first_in_alternative: mutableBouquetList = self.getMutableList( eServiceReference(sBouquetRef)) if mutableBouquetList is not None: if mutableBouquetList.addService(first_in_alternative, cur_service.ref): print( "couldn't add first alternative service to current root" ) else: print("couldn't edit current root") else: print("remove empty alternative list") else: return (False, _("Service is not an alternative.")) new_param = {} new_param["sBouquetRef"] = sRef new_param["mode"] = None # of no interest when passing BouquetRefRoot new_param["BouquetRefRoot"] = sBouquetRef returnValue = self.removeBouquet(new_param) if returnValue[0]: self.setRoot(sBouquetRef) return (True, _("All alternative services deleted.")) else: return returnValue
def removeAlternativeServices(self): cur_service = ServiceReference(self.getCurrentSelection()) root = self.getRoot() cur_root = root and ServiceReference(root) list = cur_service.list() first_in_alternative = list and list.getNext() if first_in_alternative: edit_root = cur_root and cur_root.list().startEdit() if edit_root: if not edit_root.addService(first_in_alternative, cur_service.ref): self.servicelist.addService(first_in_alternative, True) else: print "couldn't add first alternative service to current root" else: print "couldn't edit current root!!" else: print "remove empty alternative list !!" self.removeBouquet() self.servicelist.moveUp()
def removeAlternativeServices(self, param): print "[WebComponents.BouquetEditor] removeAlternativeServices with param = ", param sBouquetRef = param["sBouquetRef"] if sBouquetRef is None: return (False, "No bouquet given!") sRef = None if "sRef" in param: if param["sRef"] is not None: sRef =param["sRef"] if sRef is None: return (False, "No service given!") cur_ref = eServiceReference(sRef) # check if service is an alternative if cur_ref.flags & eServiceReference.isGroup: cur_service = ServiceReference(cur_ref) list = cur_service.list() first_in_alternative = list and list.getNext() if first_in_alternative: mutableBouquetList = self.getMutableList(eServiceReference(sBouquetRef)) if mutableBouquetList is not None: if mutableBouquetList.addService(first_in_alternative, cur_service.ref): print "couldn't add first alternative service to current root" else: print "couldn't edit current root" else: print "remove empty alternative list" else: return (False, "Service is not an alternative.") new_param = {} new_param["sBouquetRef"] = sRef new_param["mode"] = None # of no interest when passing BouquetRefRoot new_param["BouquetRefRoot"] = sBouquetRef returnValue = self.removeBouquet(new_param) if returnValue[0]: self.setRoot(sBouquetRef) return (True,"All alternative services deleted.") else: return returnValue