more generic Components/Network.py for allowing other interface names (thx to Reichi)
[enigma2.git] / lib / python / Screens / ChannelSelection.py
index 0eff5967d90dec913c424db9588f04ac9f71ee7a..5a0f11775781c8e107ef690067850d06595b6956 100644 (file)
@@ -5,7 +5,7 @@ from Components.ActionMap import NumberActionMap, ActionMap
 from Components.MenuList import MenuList
 from Components.ServiceEventTracker import ServiceEventTracker
 from EpgSelection import EPGSelection
 from Components.MenuList import MenuList
 from Components.ServiceEventTracker import ServiceEventTracker
 from EpgSelection import EPGSelection
-from enigma import eServiceReference, eEPGCache, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer, eDVBDB, iPlayableService, iServiceInformation
+from enigma import eServiceReference, eEPGCache, eServiceCenter, eTimer, eDVBDB, iPlayableService, iServiceInformation
 from Components.config import config, ConfigSubsection, ConfigText
 from Screens.FixedMenu import FixedMenu
 from Tools.NumericalTextInput import NumericalTextInput
 from Components.config import config, ConfigSubsection, ConfigText
 from Screens.FixedMenu import FixedMenu
 from Tools.NumericalTextInput import NumericalTextInput
@@ -15,6 +15,7 @@ from Components.Input import Input
 from Components.ParentalControl import parentalControl
 from Screens.InputBox import InputBox, PinInput
 from Screens.MessageBox import MessageBox
 from Components.ParentalControl import parentalControl
 from Screens.InputBox import InputBox, PinInput
 from Screens.MessageBox import MessageBox
+from Screens.ServiceInfo import ServiceInfo
 from ServiceReference import ServiceReference
 from Tools.BoundFunction import boundFunction
 from re import *
 from ServiceReference import ServiceReference
 from Tools.BoundFunction import boundFunction
 from re import *
@@ -35,9 +36,7 @@ class BouquetSelector(Screen):
                                "ok": self.okbuttonClick,
                                "cancel": self.cancelClick
                        })
                                "ok": self.okbuttonClick,
                                "cancel": self.cancelClick
                        })
-               entrys = [ ]
-               for x in bouquets:
-                       entrys.append((x[0], x[1]))
+               entrys = [ (x[0], x[1]) for x in bouquets ]
                self["menu"] = MenuList(entrys, enableWrapAround)
 
        def getCurrent(self):
                self["menu"] = MenuList(entrys, enableWrapAround)
 
        def getCurrent(self):
@@ -61,6 +60,10 @@ OFF = 0
 EDIT_BOUQUET = 1
 EDIT_ALTERNATIVES = 2
 
 EDIT_BOUQUET = 1
 EDIT_ALTERNATIVES = 2
 
+def apend_when_current_valid(current, menu, args):
+       if current and current.valid():
+               menu.append(args)
+
 class ChannelContextMenu(Screen):
        def __init__(self, session, csel):
                Screen.__init__(self, session)
 class ChannelContextMenu(Screen):
        def __init__(self, session, csel):
                Screen.__init__(self, session)
@@ -74,69 +77,72 @@ class ChannelContextMenu(Screen):
                        })
                menu = [ ]
 
                        })
                menu = [ ]
 
+               current = csel.getCurrentSelection()
                current_root = csel.getRoot()
                current_root = csel.getRoot()
-               current_sel_path = csel.getCurrentSelection().getPath()
-               current_sel_flags = csel.getCurrentSelection().flags
+               current_sel_path = current.getPath()
+               current_sel_flags = current.flags
                inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
                inBouquet = csel.getMutableList() is not None
                haveBouquets = config.usage.multibouquet.value
 
                inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
                inBouquet = csel.getMutableList() is not None
                haveBouquets = config.usage.multibouquet.value
 
+               if not (len(current_sel_path) or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
+                       apend_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations))
                if csel.bouquet_mark_edit == OFF and not csel.movemode:
                        if not inBouquetRootList:
                                isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
                                if isPlayable:
                                        if config.ParentalControl.configured.value:
                                                if parentalControl.getProtectionLevel(csel.getCurrentSelection().toCompareString()) == -1:
                if csel.bouquet_mark_edit == OFF and not csel.movemode:
                        if not inBouquetRootList:
                                isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
                                if isPlayable:
                                        if config.ParentalControl.configured.value:
                                                if parentalControl.getProtectionLevel(csel.getCurrentSelection().toCompareString()) == -1:
-                                                       menu.append((_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())))
+                                                       apend_when_current_valid(current, menu, (_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())))
                                                else:
                                                else:
-                                                       menu.append((_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())))
+                                                       apend_when_current_valid(current, menu, (_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())))
                                        if haveBouquets:
                                        if haveBouquets:
-                                               menu.append((_("add service to bouquet"), self.addServiceToBouquetSelected))
+                                               apend_when_current_valid(current, menu, (_("add service to bouquet"), self.addServiceToBouquetSelected))
                                        else:
                                        else:
-                                               menu.append((_("add service to favourites"), self.addServiceToBouquetSelected))
+                                               apend_when_current_valid(current, menu, (_("add service to favourites"), self.addServiceToBouquetSelected))
                                else:
                                        if haveBouquets:
                                                if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
                                else:
                                        if haveBouquets:
                                                if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
-                                                       menu.append((_("copy to bouquets"), self.copyCurrentToBouquetList))
+                                                       apend_when_current_valid(current, menu, (_("copy to bouquets"), self.copyCurrentToBouquetList))
                                        if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
                                        if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
-                                               menu.append((_("remove all new found flags"), self.removeAllNewFoundFlags))
+                                               apend_when_current_valid(current, menu, (_("remove all new found flags"), self.removeAllNewFoundFlags))
                                if inBouquet:
                                if inBouquet:
-                                       menu.append((_("remove entry"), self.removeCurrentService))
-                               if current_root is not None and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
-                                       menu.append((_("remove new found flag"), self.removeNewFoundFlag))
+                                       apend_when_current_valid(current, menu, (_("remove entry"), self.removeCurrentService))
+                               if current_root and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
+                                       apend_when_current_valid(current, menu, (_("remove new found flag"), self.removeNewFoundFlag))
                        else:
                                        menu.append((_("add bouquet"), self.showBouquetInputBox))
                        else:
                                        menu.append((_("add bouquet"), self.showBouquetInputBox))
-                                       menu.append((_("remove entry"), self.removeBouquet))
+                                       apend_when_current_valid(current, menu, (_("remove entry"), self.removeBouquet))
 
                if inBouquet: # current list is editable?
                        if csel.bouquet_mark_edit == OFF:
                                if not csel.movemode:
 
                if inBouquet: # current list is editable?
                        if csel.bouquet_mark_edit == OFF:
                                if not csel.movemode:
-                                       menu.append((_("enable move mode"), self.toggleMoveMode))
-                                       if not inBouquetRootList and not current_root.flags & eServiceReference.isGroup:
+                                       apend_when_current_valid(current, menu, (_("enable move mode"), self.toggleMoveMode))
+                                       if not inBouquetRootList and current_root and not (current_root.flags & eServiceReference.isGroup):
                                                menu.append((_("add marker"), self.showMarkerInputBox))
                                                if haveBouquets:
                                                menu.append((_("add marker"), self.showMarkerInputBox))
                                                if haveBouquets:
-                                                       menu.append((_("enable bouquet edit"), self.bouquetMarkStart))
+                                                       apend_when_current_valid(current, menu, (_("enable bouquet edit"), self.bouquetMarkStart))
                                                else:
                                                else:
-                                                       menu.append((_("enable favourite edit"), self.bouquetMarkStart))
+                                                       apend_when_current_valid(current, menu, (_("enable favourite edit"), self.bouquetMarkStart))
                                                if current_sel_flags & eServiceReference.isGroup:
                                                if current_sel_flags & eServiceReference.isGroup:
-                                                       menu.append((_("edit alternatives"), self.editAlternativeServices))
-                                                       menu.append((_("show alternatives"), self.showAlternativeServices))
-                                                       menu.append((_("remove all alternatives"), self.removeAlternativeServices))
-                                               else:
-                                                       menu.append((_("add alternatives"), self.addAlternativeServices))
+                                                       apend_when_current_valid(current, menu, (_("edit alternatives"), self.editAlternativeServices))
+                                                       apend_when_current_valid(current, menu, (_("show alternatives"), self.showAlternativeServices))
+                                                       apend_when_current_valid(current, menu, (_("remove all alternatives"), self.removeAlternativeServices))
+                                               elif not current_sel_flags & eServiceReference.isMarker:
+                                                       apend_when_current_valid(current, menu, (_("add alternatives"), self.addAlternativeServices))
                                else:
                                else:
-                                       menu.append((_("disable move mode"), self.toggleMoveMode))
+                                       apend_when_current_valid(current, menu, (_("disable move mode"), self.toggleMoveMode))
                        else:
                                if csel.bouquet_mark_edit == EDIT_BOUQUET:
                                        if haveBouquets:
                        else:
                                if csel.bouquet_mark_edit == EDIT_BOUQUET:
                                        if haveBouquets:
-                                               menu.append((_("end bouquet edit"), self.bouquetMarkEnd))
-                                               menu.append((_("abort bouquet edit"), self.bouquetMarkAbort))
+                                               apend_when_current_valid(current, menu, (_("end bouquet edit"), self.bouquetMarkEnd))
+                                               apend_when_current_valid(current, menu, (_("abort bouquet edit"), self.bouquetMarkAbort))
                                        else:
                                        else:
-                                               menu.append((_("end favourites edit"), self.bouquetMarkEnd))
-                                               menu.append((_("abort favourites edit"), self.bouquetMarkAbort))
+                                               apend_when_current_valid(current, menu, (_("end favourites edit"), self.bouquetMarkEnd))
+                                               apend_when_current_valid(current, menu, (_("abort favourites edit"), self.bouquetMarkAbort))
                                else:
                                else:
-                                               menu.append((_("end alternatives edit"), self.bouquetMarkEnd))
-                                               menu.append((_("abort alternatives edit"), self.bouquetMarkAbort))
+                                               apend_when_current_valid(current, menu, (_("end alternatives edit"), self.bouquetMarkEnd))
+                                               apend_when_current_valid(current, menu, (_("abort alternatives edit"), self.bouquetMarkAbort))
 
                menu.append((_("back"), self.cancelClick))
                self["menu"] = MenuList(menu)
 
                menu.append((_("back"), self.cancelClick))
                self["menu"] = MenuList(menu)
@@ -146,7 +152,10 @@ class ChannelContextMenu(Screen):
 
        def cancelClick(self):
                self.close(False)
 
        def cancelClick(self):
                self.close(False)
-               
+
+       def showServiceInformations(self):
+               self.session.open( ServiceInfo, self.csel.getCurrentSelection() )
+
        def showBouquetInputBox(self):
                self.session.openWithCallback(self.bouquetInputCallback, InputBox, title=_("Please enter a name for the new bouquet"), text="bouquetname", maxSize=False, type=Input.TEXT)
 
        def showBouquetInputBox(self):
                self.session.openWithCallback(self.bouquetInputCallback, InputBox, title=_("Please enter a name for the new bouquet"), text="bouquetname", maxSize=False, type=Input.TEXT)
 
@@ -345,15 +354,16 @@ class ChannelSelectionEdit:
 
        def addAlternativeServices(self):
                cur_service = ServiceReference(self.getCurrentSelection())
 
        def addAlternativeServices(self):
                cur_service = ServiceReference(self.getCurrentSelection())
-               cur_root = ServiceReference(self.getRoot())
+               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:
                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:(type == 1) FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name))
+                               str = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name))
                        else:
                        else:
-                               str = '1:134:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"alternatives.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(name))
+                               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)
                        new_ref = ServiceReference(str)
                        if not mutableBouquet.addService(new_ref.ref, cur_service.ref):
                                mutableBouquet.removeService(cur_service.ref)
@@ -401,8 +411,8 @@ class ChannelSelectionEdit:
                                        print "get mutable list for new created bouquet failed"
                                # do some voodoo to check if current_root is equal to bouquet_root
                                cur_root = self.getRoot();
                                        print "get mutable list for new created bouquet failed"
                                # do some voodoo to check if current_root is equal to bouquet_root
                                cur_root = self.getRoot();
-                               str1 = cur_root.toString()
-                               pos1 = str1.find("FROM BOUQUET")
+                               str1 = cur_root and cur_root.toString()
+                               pos1 = str1 and str1.find("FROM BOUQUET") or -1
                                pos2 = self.bouquet_rootstr.find("FROM BOUQUET")
                                if pos1 != -1 and pos2 != -1 and str1[pos1:] == self.bouquet_rootstr[pos2:]:
                                        self.servicelist.addService(new_bouquet_ref)
                                pos2 = self.bouquet_rootstr.find("FROM BOUQUET")
                                if pos1 != -1 and pos2 != -1 and str1[pos1:] == self.bouquet_rootstr[pos2:]:
                                        self.servicelist.addService(new_bouquet_ref)
@@ -420,11 +430,12 @@ class ChannelSelectionEdit:
 
        def removeAlternativeServices(self):
                cur_service = ServiceReference(self.getCurrentSelection())
 
        def removeAlternativeServices(self):
                cur_service = ServiceReference(self.getCurrentSelection())
-               cur_root = ServiceReference(self.getRoot())
+               root = self.getRoot()
+               cur_root = root and ServiceReference(root)
                list = cur_service.list()
                first_in_alternative = list and list.getNext()
                if first_in_alternative:
                list = cur_service.list()
                first_in_alternative = list and list.getNext()
                if first_in_alternative:
-                       edit_root = cur_root.list().startEdit()
+                       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)
                        if edit_root:
                                if not edit_root.addService(first_in_alternative, cur_service.ref):
                                        self.servicelist.addService(first_in_alternative, True)
@@ -539,7 +550,7 @@ class ChannelSelectionEdit:
                                mutableList.flushChanges()
                                # do some voodoo to check if current_root is equal to dest
                                cur_root = self.getRoot();
                                mutableList.flushChanges()
                                # do some voodoo to check if current_root is equal to dest
                                cur_root = self.getRoot();
-                               str1 = cur_root.toString()
+                               str1 = cur_root and cur_root.toString() or -1
                                str2 = dest.toString()
                                pos1 = str1.find("FROM BOUQUET")
                                pos2 = str2.find("FROM BOUQUET")
                                str2 = dest.toString()
                                pos1 = str1.find("FROM BOUQUET")
                                pos2 = str2.find("FROM BOUQUET")
@@ -556,7 +567,8 @@ class ChannelSelectionEdit:
                        self.mutableList = None
                        self.setTitle(self.saved_title)
                        self.saved_title = None
                        self.mutableList = None
                        self.setTitle(self.saved_title)
                        self.saved_title = None
-                       if self.getRoot() == self.bouquet_root:
+                       cur_root = self.getRoot()
+                       if cur_root and cur_root == self.bouquet_root:
                                self.bouquetNumOffsetCache = { }
                else:
                        self.mutableList = self.getMutableList()
                                self.bouquetNumOffsetCache = { }
                else:
                        self.mutableList = self.getMutableList()
@@ -641,17 +653,9 @@ class ChannelSelectionBase(Screen):
                        })
                self.recallBouquetMode()
 
                        })
                self.recallBouquetMode()
 
-       def appendDVBTypes(self, ref):
-               path = ref.getPath()
-               pos = path.find(' FROM BOUQUET')
-               if pos != -1:
-                       return eServiceReference(self.service_types + path[pos:])
-               return ref
-
        def getBouquetNumOffset(self, bouquet):
                if not config.usage.multibouquet.value:
                        return 0
        def getBouquetNumOffset(self, bouquet):
                if not config.usage.multibouquet.value:
                        return 0
-               bouquet = self.appendDVBTypes(bouquet)
                str = bouquet.toString()
                offsetCount = 0
                if not self.bouquetNumOffsetCache.has_key(str):
                str = bouquet.toString()
                offsetCount = 0
                if not self.bouquetNumOffsetCache.has_key(str):
@@ -659,7 +663,7 @@ class ChannelSelectionBase(Screen):
                        bouquetlist = serviceHandler.list(self.bouquet_root)
                        if not bouquetlist is None:
                                while True:
                        bouquetlist = serviceHandler.list(self.bouquet_root)
                        if not bouquetlist is None:
                                while True:
-                                       bouquetIterator = self.appendDVBTypes(bouquetlist.getNext())
+                                       bouquetIterator = bouquetlist.getNext()
                                        if not bouquetIterator.valid(): #end of list
                                                break
                                        self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
                                        if not bouquetIterator.valid(): #end of list
                                                break
                                        self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
@@ -680,13 +684,13 @@ class ChannelSelectionBase(Screen):
                if self.mode == MODE_TV:
                        self.service_types = service_types_tv
                        if config.usage.multibouquet.value:
                if self.mode == MODE_TV:
                        self.service_types = service_types_tv
                        if config.usage.multibouquet.value:
-                               self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
+                               self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
                        else:
                                self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
                else:
                        self.service_types = service_types_radio
                        if config.usage.multibouquet.value:
                        else:
                                self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
                else:
                        self.service_types = service_types_radio
                        if config.usage.multibouquet.value:
-                               self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
+                               self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
                        else:
                                self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
                self.bouquet_root = eServiceReference(self.bouquet_rootstr)
                        else:
                                self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
                self.bouquet_root = eServiceReference(self.bouquet_rootstr)
@@ -716,13 +720,11 @@ class ChannelSelectionBase(Screen):
        def setRoot(self, root, justSet=False):
                path = root.getPath()
                inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
        def setRoot(self, root, justSet=False):
                path = root.getPath()
                inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
-               pos = path.find(' FROM BOUQUET')
+               pos = path.find('FROM BOUQUET')
                isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
                if not inBouquetRootList and isBouquet:
                        self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
                        self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
                isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
                if not inBouquetRootList and isBouquet:
                        self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
                        self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
-                       refstr = self.service_types + path[pos:]
-                       root = eServiceReference(refstr)
                else:
                        self.servicelist.setMode(ServiceList.MODE_NORMAL)
                self.servicelist.setRoot(root, justSet)
                else:
                        self.servicelist.setMode(ServiceList.MODE_NORMAL)
                self.servicelist.setRoot(root, justSet)
@@ -1111,7 +1113,8 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
                                self.doMark()
                elif not (ref.flags & eServiceReference.isMarker): # no marker
                        if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
                                self.doMark()
                elif not (ref.flags & eServiceReference.isMarker): # no marker
-                       if not (self.getRoot().flags & eServiceReference.isGroup):
+                       root = self.getRoot()
+                       if not root or not (root.flags & eServiceReference.isGroup):
                                self.zap()
                                self.close(ref)
 
                                self.zap()
                                self.close(ref)
 
@@ -1162,7 +1165,8 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                self.saveRoot()
                plen = len(path)
                root = path[plen-1]
                self.saveRoot()
                plen = len(path)
                root = path[plen-1]
-               if self.getRoot() != root:
+               cur_root = self.getRoot()
+               if cur_root and cur_root != root:
                        self.setRoot(root)
                self.session.nav.playService(ref)
                self.setCurrentSelection(ref)
                        self.setRoot(root)
                self.session.nav.playService(ref)
                self.setCurrentSelection(ref)
@@ -1358,7 +1362,8 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS
                        if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
                                self.doMark()
                elif not (ref.flags & eServiceReference.isMarker): # no marker
                        if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
                                self.doMark()
                elif not (ref.flags & eServiceReference.isMarker): # no marker
-                       if not (self.getRoot().flags & eServiceReference.isGroup):
+                       cur_root = self.getRoot()
+                       if not cur_root or not (cur_root.flags & eServiceReference.isGroup):
                                playingref = self.session.nav.getCurrentlyPlayingServiceReference()
                                if playingref is None or playingref != ref:
                                        self.session.nav.playService(ref)
                                playingref = self.session.nav.getCurrentlyPlayingServiceReference()
                                if playingref is None or playingref != ref:
                                        self.session.nav.playService(ref)