X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/40d02f130ec7ce66be08013e33b2006fa1453299..29f1104e0e69589c5d78e3bdf4811fa6362fb4aa:/lib/python/Screens/ChannelSelection.py diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index 6bc04c80..bbd4fd3f 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -18,6 +18,8 @@ from ServiceReference import ServiceReference from re import * from os import remove +FLAG_SERVICE_NEW_FOUND = 64 #define in lib/dvb/idvb.h as dxNewFound = 64 + import xml.dom.minidom class BouquetSelector(Screen): @@ -66,6 +68,8 @@ class ChannelContextMenu(Screen): menu = [ ] current_root = csel.getRoot() + current_sel_path = csel.getCurrentSelection().getPath() + current_sel_flags = csel.getCurrentSelection().flags inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK inBouquet = csel.getMutableList() is not None haveBouquets = csel.bouquet_root.getPath().find('FROM BOUQUET "bouquets.') != -1 @@ -77,11 +81,16 @@ class ChannelContextMenu(Screen): menu.append((_("add service to bouquet"), self.addServiceToBouquetSelected)) else: menu.append((_("add service to favourites"), self.addServiceToBouquetSelected)) - elif haveBouquets: - if not inBouquet and csel.getCurrentSelection().getPath().find("PROVIDERS") == -1: - menu.append((_("copy to favourites"), self.copyCurrentToBouquetList)) + else: + if haveBouquets: + if not inBouquet and current_sel_path.find("PROVIDERS") == -1: + menu.append((_("copy to favourites"), self.copyCurrentToBouquetList)) + if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1: + menu.append((_("remove all new found flags"), self.removeAllNewFoundFlags)) if inBouquet: menu.append((_("remove service"), self.removeCurrentService)) + if current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1: + menu.append((_("remove new found flag"), self.removeNewFoundFlag)) elif haveBouquets: menu.append((_("remove bouquet"), self.removeBouquet)) @@ -119,7 +128,7 @@ class ChannelContextMenu(Screen): def bouquetInputCallback(self, bouquet): if bouquet is not None: - self.csel.addBouquet(bouquet) + self.csel.addBouquet(bouquet, True) def addServiceToBouquetSelected(self): bouquets = self.csel.getBouquetList() @@ -174,6 +183,21 @@ class ChannelContextMenu(Screen): self.csel.endMarkedEdit(abort=True) self.close() + def removeNewFoundFlag(self): + eDVBDB.getInstance().removeFlag(self.csel.getCurrentSelection(), FLAG_SERVICE_NEW_FOUND) + self.close() + + def removeAllNewFoundFlags(self): + curpath = self.csel.getCurrentSelection().getPath() + idx = curpath.find("satellitePosition == ") + if idx != -1: + tmp = curpath[idx+21:] + idx = tmp.find(')') + if idx != -1: + satpos = int(tmp[:idx]) + eDVBDB.getInstance().removeFlags(FLAG_SERVICE_NEW_FOUND, -1, -1, -1, satpos) + self.close() + class ChannelSelectionEPG: def __init__(self): self["ChannelSelectEPGActions"] = ActionMap(["ChannelSelectEPGActions"], @@ -238,17 +262,17 @@ class ChannelSelectionEdit: else: name += '_' return name - - def addBouquet(self, providerName): + + def addBouquet(self, bName, services, refresh=False): serviceHandler = eServiceCenter.getInstance() mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit() if mutableBouquetList: if self.mode == MODE_TV: - providerName += " (TV)" - str = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(providerName)) + bName += " (TV)" + str = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName)) else: - providerName += " (Radio)" - str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(providerName)) + bName += " (Radio)" + str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName)) new_bouquet_ref = eServiceReference(str) if not mutableBouquetList.addService(new_bouquet_ref): self.bouquetNumOffsetCache = { } @@ -256,9 +280,14 @@ class ChannelSelectionEdit: eDVBDB.getInstance().reloadBouquets() mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit() if mutableBouquet: - mutableBouquet.setListName(providerName) + mutableBouquet.setListName(bName) + if services is not None: + for service in services: + if mutableBouquet.addService(service): + print "add", service.toString(), "to new bouquet failed" mutableBouquet.flushChanges() - self.setRoot(self.getRoot()) + if refresh: + self.setRoot(self.getRoot()) else: print "get mutable list for new created bouquet failed" else: @@ -268,37 +297,10 @@ class ChannelSelectionEdit: def copyCurrentToBouquetList(self): provider = ServiceReference(self.getCurrentSelection()) + providerName = provider.getServiceName() serviceHandler = eServiceCenter.getInstance() - mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit() - if mutableBouquetList: - providerName = provider.getServiceName() - if self.mode == MODE_TV: - str = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(providerName)) - else: - str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(providerName)) - new_bouquet_ref = eServiceReference(str) - if not mutableBouquetList.addService(new_bouquet_ref): - self.bouquetNumOffsetCache = { } - mutableBouquetList.flushChanges() - eDVBDB.getInstance().reloadBouquets() - mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit() - if mutableBouquet: - mutableBouquet.setListName(providerName) - services = serviceHandler.list(provider.ref) - if not services is None: - list = services.getContent('R', True) - for service in list: - if mutableBouquet.addService(service): - print "add", service.toString(), "to new bouquet failed" - mutableBouquet.flushChanges() - else: - print "list provider", providerName, "failed" - else: - print "get mutable list for new created bouquet failed" - else: - print "add", str, "to bouquets failed" - else: - print "bouquetlist is not editable" + services = serviceHandler.list(provider.ref) + self.addBouquet(providerName, services and services.getContent('R', True)) def removeBouquet(self): refstr = self.getCurrentSelection().toString() @@ -692,6 +694,8 @@ class ChannelSelectionBase(Screen): orbpos = service.getUnsignedData(4) >> 16 if service.getPath().find("FROM PROVIDER") != -1: service_name = _("Providers") + elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1: + service_name = _("New") else: service_name = _("Services") try: @@ -893,9 +897,12 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect self.session.nav.playService(nref) self.saveRoot() self.saveChannel() + self.addToHistory(nref) + + def addToHistory(self, ref): if self.servicePath is not None: tmp=self.servicePath[:] - tmp.append(nref) + tmp.append(ref) try: del self.history[self.history_pos+1:] except: