1 from Tools.Profile import profile
3 from Screen import Screen
4 from Components.Button import Button
5 from Components.ServiceList import ServiceList
6 from Components.ActionMap import NumberActionMap, ActionMap, HelpableActionMap
7 from Components.MenuList import MenuList
8 from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
9 profile("ChannelSelection.py 1")
10 from EpgSelection import EPGSelection
11 from enigma import eServiceReference, eEPGCache, eServiceCenter, eRCInput, eTimer, eDVBDB, iPlayableService, iServiceInformation, getPrevAsciiCode
12 from Components.config import config, ConfigSubsection, ConfigText
13 from Tools.NumericalTextInput import NumericalTextInput
14 profile("ChannelSelection.py 2")
15 from Components.NimManager import nimmanager
16 profile("ChannelSelection.py 2.1")
17 from Components.Sources.RdsDecoder import RdsDecoder
18 profile("ChannelSelection.py 2.2")
19 from Components.Sources.ServiceEvent import ServiceEvent
20 profile("ChannelSelection.py 2.3")
21 from Components.Input import Input
22 profile("ChannelSelection.py 3")
23 from Components.ParentalControl import parentalControl
24 from Screens.InputBox import InputBox, PinInput
25 from Screens.MessageBox import MessageBox
26 from Screens.ServiceInfo import ServiceInfo
27 profile("ChannelSelection.py 4")
28 from Screens.RdsDisplay import RassInteractive
29 from ServiceReference import ServiceReference
30 from Tools.BoundFunction import boundFunction
31 from re import compile
33 profile("ChannelSelection.py after imports")
35 FLAG_SERVICE_NEW_FOUND = 64 #define in lib/dvb/idvb.h as dxNewFound = 64
37 class BouquetSelector(Screen):
38 def __init__(self, session, bouquets, selectedFunc, enableWrapAround=False):
39 Screen.__init__(self, session)
41 self.selectedFunc=selectedFunc
43 self["actions"] = ActionMap(["OkCancelActions"],
45 "ok": self.okbuttonClick,
46 "cancel": self.cancelClick
48 entrys = [ (x[0], x[1]) for x in bouquets ]
49 self["menu"] = MenuList(entrys, enableWrapAround)
52 cur = self["menu"].getCurrent()
55 def okbuttonClick(self):
56 self.selectedFunc(self.getCurrent())
64 def cancelClick(self):
67 # csel.bouquet_mark_edit values
72 def append_when_current_valid(current, menu, args, level = 0):
73 if current and current.valid() and level <= config.usage.setup_level.index:
76 class ChannelContextMenu(Screen):
77 def __init__(self, session, csel):
78 Screen.__init__(self, session)
79 #raise Exception("we need a better summary screen here")
83 self["actions"] = ActionMap(["OkCancelActions"],
85 "ok": self.okbuttonClick,
86 "cancel": self.cancelClick
90 current = csel.getCurrentSelection()
91 current_root = csel.getRoot()
92 current_sel_path = current.getPath()
93 current_sel_flags = current.flags
94 inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
95 inBouquet = csel.getMutableList() is not None
96 haveBouquets = config.usage.multibouquet.value
98 if not (current_sel_path or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
99 append_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations), level = 2)
100 if csel.bouquet_mark_edit == OFF and not csel.movemode:
101 if not inBouquetRootList:
102 isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
104 if config.ParentalControl.configured.value:
105 if parentalControl.getProtectionLevel(csel.getCurrentSelection().toCompareString()) == -1:
106 append_when_current_valid(current, menu, (_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())), level = 0)
108 append_when_current_valid(current, menu, (_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())), level = 0)
110 append_when_current_valid(current, menu, (_("add service to bouquet"), self.addServiceToBouquetSelected), level = 0)
112 append_when_current_valid(current, menu, (_("add service to favourites"), self.addServiceToBouquetSelected), level = 0)
114 if current_root.getPath().find('FROM SATELLITES') != -1:
115 append_when_current_valid(current, menu, (_("remove selected satellite"), self.removeSatelliteServices), level = 0)
117 if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
118 append_when_current_valid(current, menu, (_("copy to bouquets"), self.copyCurrentToBouquetList), level = 0)
119 if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
120 append_when_current_valid(current, menu, (_("remove all new found flags"), self.removeAllNewFoundFlags), level = 0)
122 append_when_current_valid(current, menu, (_("remove entry"), self.removeCurrentService), level = 0)
123 if current_root and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
124 append_when_current_valid(current, menu, (_("remove new found flag"), self.removeNewFoundFlag), level = 0)
126 menu.append((_("add bouquet"), self.showBouquetInputBox))
127 append_when_current_valid(current, menu, (_("remove entry"), self.removeBouquet), level = 0)
129 if inBouquet: # current list is editable?
130 if csel.bouquet_mark_edit == OFF:
131 if not csel.movemode:
132 append_when_current_valid(current, menu, (_("enable move mode"), self.toggleMoveMode), level = 1)
133 if not inBouquetRootList and current_root and not (current_root.flags & eServiceReference.isGroup):
134 menu.append((_("add marker"), self.showMarkerInputBox))
136 append_when_current_valid(current, menu, (_("enable bouquet edit"), self.bouquetMarkStart), level = 0)
138 append_when_current_valid(current, menu, (_("enable favourite edit"), self.bouquetMarkStart), level = 0)
139 if current_sel_flags & eServiceReference.isGroup:
140 append_when_current_valid(current, menu, (_("edit alternatives"), self.editAlternativeServices), level = 2)
141 append_when_current_valid(current, menu, (_("show alternatives"), self.showAlternativeServices), level = 2)
142 append_when_current_valid(current, menu, (_("remove all alternatives"), self.removeAlternativeServices), level = 2)
143 elif not current_sel_flags & eServiceReference.isMarker:
144 append_when_current_valid(current, menu, (_("add alternatives"), self.addAlternativeServices), level = 2)
146 append_when_current_valid(current, menu, (_("disable move mode"), self.toggleMoveMode), level = 0)
148 if csel.bouquet_mark_edit == EDIT_BOUQUET:
150 append_when_current_valid(current, menu, (_("end bouquet edit"), self.bouquetMarkEnd), level = 0)
151 append_when_current_valid(current, menu, (_("abort bouquet edit"), self.bouquetMarkAbort), level = 0)
153 append_when_current_valid(current, menu, (_("end favourites edit"), self.bouquetMarkEnd), level = 0)
154 append_when_current_valid(current, menu, (_("abort favourites edit"), self.bouquetMarkAbort), level = 0)
156 append_when_current_valid(current, menu, (_("end alternatives edit"), self.bouquetMarkEnd), level = 0)
157 append_when_current_valid(current, menu, (_("abort alternatives edit"), self.bouquetMarkAbort), level = 0)
159 menu.append((_("back"), self.cancelClick))
160 self["menu"] = MenuList(menu)
162 def okbuttonClick(self):
163 self["menu"].getCurrent()[1]()
165 def cancelClick(self):
168 def showServiceInformations(self):
169 self.session.open( ServiceInfo, self.csel.getCurrentSelection() )
171 def showBouquetInputBox(self):
172 self.session.openWithCallback(self.bouquetInputCallback, InputBox, title=_("Please enter a name for the new bouquet"), text="bouquetname", maxSize=False, visible_width = 56, type=Input.TEXT)
174 def bouquetInputCallback(self, bouquet):
175 if bouquet is not None:
176 self.csel.addBouquet(bouquet, None)
179 def addParentalProtection(self, service):
180 parentalControl.protectService(service.toCompareString())
183 def removeParentalProtection(self, service):
184 self.session.openWithCallback(boundFunction(self.pinEntered, service.toCompareString()), PinInput, pinList = [config.ParentalControl.servicepin[0].value], triesEntry = config.ParentalControl.retries.servicepin, title = _("Enter the service pin"), windowTitle = _("Change pin code"))
186 def pinEntered(self, service, result):
188 parentalControl.unProtectService(service)
191 self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
193 def addServiceToBouquetSelected(self):
194 bouquets = self.csel.getBouquetList()
199 if cnt > 1: # show bouquet list
200 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, bouquets, self.addCurrentServiceToBouquet)
201 elif cnt == 1: # add to only one existing bouquet
202 self.addCurrentServiceToBouquet(bouquets[0][1])
204 def bouquetSelClosed(self, recursive):
209 def removeSatelliteServices(self):
210 curpath = self.csel.getCurrentSelection().getPath()
211 idx = curpath.find("satellitePosition == ")
213 tmp = curpath[idx+21:]
216 satpos = int(tmp[:idx])
217 eDVBDB.getInstance().removeServices(-1, -1, -1, satpos)
220 def copyCurrentToBouquetList(self):
221 self.csel.copyCurrentToBouquetList()
224 def removeBouquet(self):
225 self.csel.removeBouquet()
228 def showMarkerInputBox(self):
229 self.session.openWithCallback(self.markerInputCallback, InputBox, title=_("Please enter a name for the new marker"), text="markername", maxSize=False, visible_width = 56, type=Input.TEXT)
231 def markerInputCallback(self, marker):
232 if marker is not None:
233 self.csel.addMarker(marker)
236 def addCurrentServiceToBouquet(self, dest):
237 self.csel.addServiceToBouquet(dest)
238 if self.bsel is not None:
239 self.bsel.close(True)
241 self.close(True) # close bouquet selection
243 def removeCurrentService(self):
244 self.csel.removeCurrentService()
247 def toggleMoveMode(self):
248 self.csel.toggleMoveMode()
251 def bouquetMarkStart(self):
252 self.csel.startMarkedEdit(EDIT_BOUQUET)
255 def bouquetMarkEnd(self):
256 self.csel.endMarkedEdit(abort=False)
259 def bouquetMarkAbort(self):
260 self.csel.endMarkedEdit(abort=True)
263 def removeNewFoundFlag(self):
264 eDVBDB.getInstance().removeFlag(self.csel.getCurrentSelection(), FLAG_SERVICE_NEW_FOUND)
267 def removeAllNewFoundFlags(self):
268 curpath = self.csel.getCurrentSelection().getPath()
269 idx = curpath.find("satellitePosition == ")
271 tmp = curpath[idx+21:]
274 satpos = int(tmp[:idx])
275 eDVBDB.getInstance().removeFlags(FLAG_SERVICE_NEW_FOUND, -1, -1, -1, satpos)
278 def editAlternativeServices(self):
279 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
282 def showAlternativeServices(self):
283 self.csel.enterPath(self.csel.getCurrentSelection())
286 def removeAlternativeServices(self):
287 self.csel.removeAlternativeServices()
290 def addAlternativeServices(self):
291 self.csel.addAlternativeServices()
292 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
295 class SelectionEventInfo:
297 self["ServiceEvent"] = ServiceEvent()
298 self.servicelist.connectSelChanged(self.__selectionChanged)
299 self.timer = eTimer()
300 self.timer.callback.append(self.updateEventInfo)
301 self.onShown.append(self.__selectionChanged)
303 def __selectionChanged(self):
305 self.timer.start(100, True)
307 def updateEventInfo(self):
308 cur = self.getCurrentSelection()
309 self["ServiceEvent"].newService(cur)
311 class ChannelSelectionEPG:
313 self["ChannelSelectEPGActions"] = ActionMap(["ChannelSelectEPGActions"],
315 "showEPGList": self.showEPGList,
318 def showEPGList(self):
319 ref=self.getCurrentSelection()
321 self.savedService = ref
322 self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB=self.changeServiceCB)
324 def SingleServiceEPGClosed(self, ret=False):
325 self.setCurrentSelection(self.savedService)
327 def changeServiceCB(self, direction, epg):
328 beg = self.getCurrentSelection()
334 cur = self.getCurrentSelection()
335 if cur == beg or not (cur.flags & eServiceReference.isMarker):
337 epg.setService(ServiceReference(self.getCurrentSelection()))
339 class ChannelSelectionEdit:
341 self.entry_marked = False
342 self.movemode = False
343 self.bouquet_mark_edit = OFF
344 self.mutableList = None
346 self.saved_title = None
347 self.saved_root = None
349 class ChannelSelectionEditActionMap(ActionMap):
350 def __init__(self, csel, contexts = [ ], actions = { }, prio=0):
351 ActionMap.__init__(self, contexts, actions, prio)
354 def action(self, contexts, action):
355 if action == "cancel":
356 self.csel.handleEditCancel()
357 return 0 # fall-trough
359 return 0 # fall-trough
361 return ActionMap.action(self, contexts, action)
363 self["ChannelSelectEditActions"] = ChannelSelectionEditActionMap(self, ["ChannelSelectEditActions", "OkCancelActions"],
365 "contextMenu": self.doContext,
368 def getMutableList(self, root=eServiceReference()):
369 if not self.mutableList is None:
370 return self.mutableList
371 serviceHandler = eServiceCenter.getInstance()
374 list = root and serviceHandler.list(root)
376 return list.startEdit()
379 def buildBouquetID(self, str):
383 if (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9'):
389 def addMarker(self, name):
390 current = self.servicelist.getCurrent()
391 mutableList = self.getMutableList()
394 str = '1:64:%d:0:0:0:0:0:0:0::%s'%(cnt, name)
395 ref = eServiceReference(str)
396 if current and current.valid():
397 if not mutableList.addService(ref, current):
398 self.servicelist.addService(ref, True)
399 mutableList.flushChanges()
401 elif not mutableList.addService(ref):
402 self.servicelist.addService(ref, True)
403 mutableList.flushChanges()
407 def addAlternativeServices(self):
408 cur_service = ServiceReference(self.getCurrentSelection())
409 root = self.getRoot()
410 cur_root = root and ServiceReference(root)
411 mutableBouquet = cur_root.list().startEdit()
413 name = cur_service.getServiceName()
415 if self.mode == MODE_TV:
416 str = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name))
418 str = '1:134:2:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(name))
419 new_ref = ServiceReference(str)
420 if not mutableBouquet.addService(new_ref.ref, cur_service.ref):
421 mutableBouquet.removeService(cur_service.ref)
422 mutableBouquet.flushChanges()
423 eDVBDB.getInstance().reloadBouquets()
424 mutableAlternatives = new_ref.list().startEdit()
425 if mutableAlternatives:
426 mutableAlternatives.setListName(name)
427 if mutableAlternatives.addService(cur_service.ref):
428 print "add", cur_service.toString(), "to new alternatives failed"
429 mutableAlternatives.flushChanges()
430 self.servicelist.addService(new_ref.ref, True)
431 self.servicelist.removeCurrent()
432 self.servicelist.moveUp()
434 print "get mutable list for new created alternatives failed"
436 print "add", str, "to", cur_root.getServiceName(), "failed"
438 print "bouquetlist is not editable"
440 def addBouquet(self, bName, services):
441 serviceHandler = eServiceCenter.getInstance()
442 mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit()
443 if mutableBouquetList:
444 if self.mode == MODE_TV:
446 str = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName))
449 str = '1:7:2:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName))
450 new_bouquet_ref = eServiceReference(str)
451 if not mutableBouquetList.addService(new_bouquet_ref):
452 mutableBouquetList.flushChanges()
453 eDVBDB.getInstance().reloadBouquets()
454 mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit()
456 mutableBouquet.setListName(bName)
457 if services is not None:
458 for service in services:
459 if mutableBouquet.addService(service):
460 print "add", service.toString(), "to new bouquet failed"
461 mutableBouquet.flushChanges()
463 print "get mutable list for new created bouquet failed"
464 # do some voodoo to check if current_root is equal to bouquet_root
465 cur_root = self.getRoot();
466 str1 = cur_root and cur_root.toString()
467 pos1 = str1 and str1.find("FROM BOUQUET") or -1
468 pos2 = self.bouquet_rootstr.find("FROM BOUQUET")
469 if pos1 != -1 and pos2 != -1 and str1[pos1:] == self.bouquet_rootstr[pos2:]:
470 self.servicelist.addService(new_bouquet_ref)
472 print "add", str, "to bouquets failed"
474 print "bouquetlist is not editable"
476 def copyCurrentToBouquetList(self):
477 provider = ServiceReference(self.getCurrentSelection())
478 providerName = provider.getServiceName()
479 serviceHandler = eServiceCenter.getInstance()
480 services = serviceHandler.list(provider.ref)
481 self.addBouquet(providerName, services and services.getContent('R', True))
483 def removeAlternativeServices(self):
484 cur_service = ServiceReference(self.getCurrentSelection())
485 root = self.getRoot()
486 cur_root = root and ServiceReference(root)
487 list = cur_service.list()
488 first_in_alternative = list and list.getNext()
489 if first_in_alternative:
490 edit_root = cur_root and cur_root.list().startEdit()
492 if not edit_root.addService(first_in_alternative, cur_service.ref):
493 self.servicelist.addService(first_in_alternative, True)
495 print "couldn't add first alternative service to current root"
497 print "couldn't edit current root!!"
499 print "remove empty alternative list !!"
501 self.servicelist.moveUp()
503 def removeBouquet(self):
504 refstr = self.getCurrentSelection().toString()
505 print "removeBouquet", refstr
506 self.bouquetNumOffsetCache = { }
507 pos = refstr.find('FROM BOUQUET "')
510 refstr = refstr[pos+14:]
511 pos = refstr.find('"')
513 filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
514 self.removeCurrentService()
516 if filename is not None:
519 print "error during remove of", filename
521 # multiple marked entry stuff ( edit mode, later multiepg selection )
522 def startMarkedEdit(self, type):
523 self.savedPath = self.servicePath[:]
524 if type == EDIT_ALTERNATIVES:
525 self.enterPath(self.getCurrentSelection())
526 self.mutableList = self.getMutableList()
527 # add all services from the current list to internal marked set in listboxservicecontent
528 self.clearMarks() # this clears the internal marked set in the listboxservicecontent
529 self.saved_title = self.getTitle()
530 pos = self.saved_title.find(')')
531 new_title = self.saved_title[:pos+1]
532 if type == EDIT_ALTERNATIVES:
533 self.bouquet_mark_edit = EDIT_ALTERNATIVES
534 new_title += ' ' + _("[alternative edit]")
536 self.bouquet_mark_edit = EDIT_BOUQUET
537 if config.usage.multibouquet.value:
538 new_title += ' ' + _("[bouquet edit]")
540 new_title += ' ' + _("[favourite edit]")
541 self.setTitle(new_title)
542 self.__marked = self.servicelist.getRootServices()
543 for x in self.__marked:
544 self.servicelist.addMarked(eServiceReference(x))
545 self.showAllServices()
547 def endMarkedEdit(self, abort):
548 if not abort and self.mutableList is not None:
549 self.bouquetNumOffsetCache = { }
550 new_marked = set(self.servicelist.getMarked())
551 old_marked = set(self.__marked)
552 removed = old_marked - new_marked
553 added = new_marked - old_marked
557 self.mutableList.removeService(eServiceReference(x))
560 self.mutableList.addService(eServiceReference(x))
562 self.mutableList.flushChanges()
565 self.bouquet_mark_edit = OFF
566 self.mutableList = None
567 self.setTitle(self.saved_title)
568 self.saved_title = None
569 # self.servicePath is just a reference to servicePathTv or Radio...
570 # so we never ever do use the asignment operator in self.servicePath
571 del self.servicePath[:] # remove all elements
572 self.servicePath += self.savedPath # add saved elements
574 self.setRoot(self.servicePath[-1])
576 def clearMarks(self):
577 self.servicelist.clearMarks()
580 ref = self.servicelist.getCurrent()
581 if self.servicelist.isMarked(ref):
582 self.servicelist.removeMarked(ref)
584 self.servicelist.addMarked(ref)
586 def removeCurrentService(self):
587 ref = self.servicelist.getCurrent()
588 mutableList = self.getMutableList()
589 if ref.valid() and mutableList is not None:
590 if not mutableList.removeService(ref):
591 self.bouquetNumOffsetCache = { }
592 mutableList.flushChanges() #FIXME dont flush on each single removed service
593 self.servicelist.removeCurrent()
595 def addServiceToBouquet(self, dest, service=None):
596 mutableList = self.getMutableList(dest)
597 if not mutableList is None:
598 if service is None: #use current selected service
599 service = self.servicelist.getCurrent()
600 if not mutableList.addService(service):
601 self.bouquetNumOffsetCache = { }
602 mutableList.flushChanges()
603 # do some voodoo to check if current_root is equal to dest
604 cur_root = self.getRoot();
605 str1 = cur_root and cur_root.toString() or -1
606 str2 = dest.toString()
607 pos1 = str1.find("FROM BOUQUET")
608 pos2 = str2.find("FROM BOUQUET")
609 if pos1 != -1 and pos2 != -1 and str1[pos1:] == str2[pos2:]:
610 self.servicelist.addService(service)
612 def toggleMoveMode(self):
614 if self.entry_marked:
615 self.toggleMoveMarked() # unmark current entry
616 self.movemode = False
617 self.pathChangeDisabled = False # re-enable path change
618 self.mutableList.flushChanges() # FIXME add check if changes was made
619 self.mutableList = None
620 self.setTitle(self.saved_title)
621 self.saved_title = None
622 cur_root = self.getRoot()
623 if cur_root and cur_root == self.bouquet_root:
624 self.bouquetNumOffsetCache = { }
626 self.mutableList = self.getMutableList()
628 self.pathChangeDisabled = True # no path change allowed in movemode
629 self.saved_title = self.getTitle()
630 new_title = self.saved_title
631 pos = self.saved_title.find(')')
632 new_title = self.saved_title[:pos+1] + ' ' + _("[move mode]") + self.saved_title[pos+1:]
633 self.setTitle(new_title);
635 def handleEditCancel(self):
636 if self.movemode: #movemode active?
637 self.channelSelected() # unmark
638 self.toggleMoveMode() # disable move mode
639 elif self.bouquet_mark_edit != OFF:
640 self.endMarkedEdit(True) # abort edit mode
642 def toggleMoveMarked(self):
643 if self.entry_marked:
644 self.servicelist.setCurrentMarked(False)
645 self.entry_marked = False
647 self.servicelist.setCurrentMarked(True)
648 self.entry_marked = True
651 self.session.open(ChannelContextMenu, self)
656 # type 1 = digital television service
657 # type 4 = nvod reference service (NYI)
658 # type 17 = MPEG-2 HD digital television service
659 # type 22 = advanced codec SD digital television
660 # type 24 = advanced codec SD NVOD reference service (NYI)
661 # type 25 = advanced codec HD digital television
662 # type 27 = advanced codec HD NVOD reference service (NYI)
663 # type 2 = digital radio sound service
664 # type 10 = advanced codec digital radio sound service
666 service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 22) || (type == 25) || (type == 134) || (type == 195)'
667 service_types_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2) || (type == 10)'
669 class ChannelSelectionBase(Screen):
670 def __init__(self, session):
671 Screen.__init__(self, session)
673 self["key_red"] = Button(_("All"))
674 self["key_green"] = Button(_("Satellites"))
675 self["key_yellow"] = Button(_("Provider"))
676 self["key_blue"] = Button(_("Favourites"))
678 self["list"] = ServiceList()
679 self.servicelist = self["list"]
681 self.numericalTextInput = NumericalTextInput()
682 self.numericalTextInput.setUseableChars(u'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
684 self.servicePathTV = [ ]
685 self.servicePathRadio = [ ]
686 self.servicePath = [ ]
690 self.pathChangeDisabled = False
692 self.bouquetNumOffsetCache = { }
694 self["ChannelSelectBaseActions"] = NumberActionMap(["ChannelSelectBaseActions", "NumberActions", "InputAsciiActions"],
696 "showFavourites": self.showFavourites,
697 "showAllServices": self.showAllServices,
698 "showProviders": self.showProviders,
699 "showSatellites": self.showSatellites,
700 "nextBouquet": self.nextBouquet,
701 "prevBouquet": self.prevBouquet,
702 "nextMarker": self.nextMarker,
703 "prevMarker": self.prevMarker,
704 "gotAsciiCode": self.keyAsciiCode,
705 "1": self.keyNumberGlobal,
706 "2": self.keyNumberGlobal,
707 "3": self.keyNumberGlobal,
708 "4": self.keyNumberGlobal,
709 "5": self.keyNumberGlobal,
710 "6": self.keyNumberGlobal,
711 "7": self.keyNumberGlobal,
712 "8": self.keyNumberGlobal,
713 "9": self.keyNumberGlobal,
716 self.recallBouquetMode()
718 def getBouquetNumOffset(self, bouquet):
719 if not config.usage.multibouquet.value:
721 str = bouquet.toString()
723 if not self.bouquetNumOffsetCache.has_key(str):
724 serviceHandler = eServiceCenter.getInstance()
725 bouquetlist = serviceHandler.list(self.bouquet_root)
726 if not bouquetlist is None:
728 bouquetIterator = bouquetlist.getNext()
729 if not bouquetIterator.valid(): #end of list
731 self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
732 if not (bouquetIterator.flags & eServiceReference.isDirectory):
734 servicelist = serviceHandler.list(bouquetIterator)
735 if not servicelist is None:
737 serviceIterator = servicelist.getNext()
738 if not serviceIterator.valid(): #check if end of list
740 playable = not (serviceIterator.flags & (eServiceReference.isDirectory|eServiceReference.isMarker))
743 return self.bouquetNumOffsetCache.get(str, offsetCount)
745 def recallBouquetMode(self):
746 if self.mode == MODE_TV:
747 self.service_types = service_types_tv
748 if config.usage.multibouquet.value:
749 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
751 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
753 self.service_types = service_types_radio
754 if config.usage.multibouquet.value:
755 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
757 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
758 self.bouquet_root = eServiceReference(self.bouquet_rootstr)
762 self.servicePath = self.servicePathTV
763 self.recallBouquetMode()
764 title = self.getTitle()
765 pos = title.find(" (")
771 def setRadioMode(self):
772 self.mode = MODE_RADIO
773 self.servicePath = self.servicePathRadio
774 self.recallBouquetMode()
775 title = self.getTitle()
776 pos = title.find(" (")
782 def setRoot(self, root, justSet=False):
783 path = root.getPath()
784 inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
785 pos = path.find('FROM BOUQUET')
786 isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
787 if not inBouquetRootList and isBouquet:
788 self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
789 self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
791 self.servicelist.setMode(ServiceList.MODE_NORMAL)
792 self.servicelist.setRoot(root, justSet)
793 self.buildTitleString()
795 def removeModeStr(self, str):
796 if self.mode == MODE_TV:
797 pos = str.find(' (TV)')
799 pos = str.find(' (Radio)')
804 def getServiceName(self, ref):
805 str = self.removeModeStr(ServiceReference(ref).getServiceName())
807 pathstr = ref.getPath()
808 if 'FROM PROVIDERS' in pathstr:
810 if 'FROM SATELLITES' in pathstr:
811 return _("Satellites")
812 if ') ORDER BY name' in pathstr:
816 def buildTitleString(self):
817 titleStr = self.getTitle()
818 pos = titleStr.find(']')
820 pos = titleStr.find(')')
822 titleStr = titleStr[:pos+1]
823 Len = len(self.servicePath)
825 base_ref = self.servicePath[0]
827 end_ref = self.servicePath[Len-1]
830 nameStr = self.getServiceName(base_ref)
831 titleStr += ' ' + nameStr
832 if end_ref is not None:
837 nameStr = self.getServiceName(end_ref)
839 self.setTitle(titleStr)
842 self.servicelist.moveUp()
845 self.servicelist.moveDown()
848 del self.servicePath[:]
850 def enterPath(self, ref, justSet=False):
851 self.servicePath.append(ref)
852 self.setRoot(ref, justSet)
854 def pathUp(self, justSet=False):
855 prev = self.servicePath.pop()
857 current = self.servicePath[-1]
858 self.setRoot(current, justSet)
860 self.setCurrentSelection(prev)
863 def isBasePathEqual(self, ref):
864 if len(self.servicePath) > 1 and self.servicePath[0] == ref:
868 def isPrevPathEqual(self, ref):
869 length = len(self.servicePath)
870 if length > 1 and self.servicePath[length-2] == ref:
874 def preEnterPath(self, refstr):
877 def showAllServices(self):
878 if not self.pathChangeDisabled:
879 refstr = '%s ORDER BY name'%(self.service_types)
880 if not self.preEnterPath(refstr):
881 ref = eServiceReference(refstr)
882 currentRoot = self.getRoot()
883 if currentRoot is None or currentRoot != ref:
887 def showSatellites(self):
888 if not self.pathChangeDisabled:
889 refstr = '%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types)
890 if not self.preEnterPath(refstr):
891 ref = eServiceReference(refstr)
895 if self.isBasePathEqual(ref):
896 if self.isPrevPathEqual(ref):
898 prev = self.pathUp(justSet)
900 currentRoot = self.getRoot()
901 if currentRoot is None or currentRoot != ref:
904 self.enterPath(ref, True)
906 serviceHandler = eServiceCenter.getInstance()
907 servicelist = serviceHandler.list(ref)
908 if not servicelist is None:
910 service = servicelist.getNext()
911 if not service.valid(): #check if end of list
913 unsigned_orbpos = service.getUnsignedData(4) >> 16
914 orbpos = service.getData(4) >> 16
917 if service.getPath().find("FROM PROVIDER") != -1:
918 service_type = _("Providers")
919 elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
920 service_type = _("New")
922 service_type = _("Services")
924 # why we need this cast?
925 service_name = str(nimmanager.getSatDescription(orbpos))
927 if unsigned_orbpos == 0xFFFF: #Cable
928 service_name = _("Cable")
929 elif unsigned_orbpos == 0xEEEE: #Terrestrial
930 service_name = _("Terrestrial")
932 if orbpos > 1800: # west
933 orbpos = 3600 - orbpos
937 service_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
938 service.setName("%s - %s" % (service_name, service_type))
939 self.servicelist.addService(service)
940 cur_ref = self.session.nav.getCurrentlyPlayingServiceReference()
942 pos = self.service_types.rfind(':')
943 refstr = '%s (channelID == %08x%04x%04x) && %s ORDER BY name' %(self.service_types[:pos+1],
944 cur_ref.getUnsignedData(4), # NAMESPACE
945 cur_ref.getUnsignedData(2), # TSID
946 cur_ref.getUnsignedData(3), # ONID
947 self.service_types[pos+1:])
948 ref = eServiceReference(refstr)
949 ref.setName(_("Current Transponder"))
950 self.servicelist.addService(ref)
951 self.servicelist.finishFill()
953 self.setCurrentSelection(prev)
955 def showProviders(self):
956 if not self.pathChangeDisabled:
957 refstr = '%s FROM PROVIDERS ORDER BY name'%(self.service_types)
958 if not self.preEnterPath(refstr):
959 ref = eServiceReference(refstr)
960 if self.isBasePathEqual(ref):
963 currentRoot = self.getRoot()
964 if currentRoot is None or currentRoot != ref:
968 def changeBouquet(self, direction):
969 if not self.pathChangeDisabled:
970 if len(self.servicePath) > 1:
971 #when enter satellite root list we must do some magic stuff..
972 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
973 if self.isBasePathEqual(ref):
974 self.showSatellites()
981 ref = self.getCurrentSelection()
985 if self.servicePath and self.servicePath[0] == self.bouquet_root:
990 return self.servicelist.atBegin()
993 return self.servicelist.atEnd()
995 def nextBouquet(self):
996 self.changeBouquet(+1)
998 def prevBouquet(self):
999 self.changeBouquet(-1)
1001 def showFavourites(self):
1002 if not self.pathChangeDisabled:
1003 if not self.preEnterPath(self.bouquet_rootstr):
1004 if self.isBasePathEqual(self.bouquet_root):
1007 currentRoot = self.getRoot()
1008 if currentRoot is None or currentRoot != self.bouquet_root:
1010 self.enterPath(self.bouquet_root)
1012 def keyNumberGlobal(self, number):
1013 unichar = self.numericalTextInput.getKey(number)
1014 charstr = unichar.encode("utf-8")
1015 if len(charstr) == 1:
1016 self.servicelist.moveToChar(charstr[0])
1018 def keyAsciiCode(self):
1019 unichar = unichr(getPrevAsciiCode())
1020 charstr = unichar.encode("utf-8")
1021 if len(charstr) == 1:
1022 self.servicelist.moveToChar(charstr[0])
1025 return self.servicelist.getRoot()
1027 def getCurrentSelection(self):
1028 return self.servicelist.getCurrent()
1030 def setCurrentSelection(self, service):
1031 self.servicelist.setCurrent(service)
1033 def getBouquetList(self):
1035 serviceHandler = eServiceCenter.getInstance()
1036 if config.usage.multibouquet.value:
1037 list = serviceHandler.list(self.bouquet_root)
1043 if s.flags & eServiceReference.isDirectory:
1044 info = serviceHandler.info(s)
1046 bouquets.append((info.getName(s), s))
1049 info = serviceHandler.info(self.bouquet_root)
1051 bouquets.append((info.getName(self.bouquet_root), self.bouquet_root))
1055 def keyNumber0(self, num):
1056 if len(self.servicePath) > 1:
1059 self.keyNumberGlobal(num)
1062 if len(self.servicePath) > 1:
1063 if self.isBasePathEqual(self.bouquet_root):
1064 self.showFavourites()
1066 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
1067 if self.isBasePathEqual(ref):
1068 self.showSatellites()
1070 ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
1071 if self.isBasePathEqual(ref):
1072 self.showProviders()
1074 self.showAllServices()
1076 def nextMarker(self):
1077 self.servicelist.moveToNextMarker()
1079 def prevMarker(self):
1080 self.servicelist.moveToPrevMarker()
1084 #config for lastservice
1085 config.tv = ConfigSubsection()
1086 config.tv.lastservice = ConfigText()
1087 config.tv.lastroot = ConfigText()
1088 config.radio = ConfigSubsection()
1089 config.radio.lastservice = ConfigText()
1090 config.radio.lastroot = ConfigText()
1091 config.servicelist = ConfigSubsection()
1092 config.servicelist.lastmode = ConfigText(default = "tv")
1094 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, SelectionEventInfo):
1095 def __init__(self, session):
1096 ChannelSelectionBase.__init__(self,session)
1097 ChannelSelectionEdit.__init__(self)
1098 ChannelSelectionEPG.__init__(self)
1099 SelectionEventInfo.__init__(self)
1101 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1103 "cancel": self.cancel,
1104 "ok": self.channelSelected,
1105 "keyRadio": self.setModeRadio,
1106 "keyTV": self.setModeTv,
1109 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1111 iPlayableService.evStart: self.__evServiceStart,
1112 iPlayableService.evEnd: self.__evServiceEnd
1115 self.lastChannelRootTimer = eTimer()
1116 self.lastChannelRootTimer.callback.append(self.__onCreate)
1117 self.lastChannelRootTimer.start(100,True)
1119 self.history_tv = [ ]
1120 self.history_radio = [ ]
1121 self.history = self.history_tv
1122 self.history_pos = 0
1124 self.lastservice = config.tv.lastservice
1125 self.lastroot = config.tv.lastroot
1126 self.revertMode = None
1127 config.usage.multibouquet.addNotifier(self.multibouquet_config_changed)
1128 self.new_service_played = False
1129 self.onExecBegin.append(self.asciiOn)
1132 rcinput = eRCInput.getInstance()
1133 rcinput.setKeyboardMode(rcinput.kmAscii)
1136 rcinput = eRCInput.getInstance()
1137 rcinput.setKeyboardMode(rcinput.kmNone)
1139 def multibouquet_config_changed(self, val):
1140 self.recallBouquetMode()
1142 def __evServiceStart(self):
1143 service = self.session.nav.getCurrentService()
1145 info = service.info()
1147 refstr = info.getInfoString(iServiceInformation.sServiceref)
1148 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1150 def __evServiceEnd(self):
1151 self.servicelist.setPlayableIgnoreService(eServiceReference())
1155 lastservice=eServiceReference(self.lastservice.value)
1156 if lastservice.valid():
1157 self.setCurrentSelection(lastservice)
1159 def setModeTv(self):
1160 if self.revertMode is None and config.servicelist.lastmode.value == "radio":
1161 self.revertMode = MODE_RADIO
1162 self.history = self.history_tv
1163 self.lastservice = config.tv.lastservice
1164 self.lastroot = config.tv.lastroot
1165 config.servicelist.lastmode.value = "tv"
1169 def setModeRadio(self):
1170 if self.revertMode is None and config.servicelist.lastmode.value == "tv":
1171 self.revertMode = MODE_TV
1172 if config.usage.e1like_radio_mode.value:
1173 self.history = self.history_radio
1174 self.lastservice = config.radio.lastservice
1175 self.lastroot = config.radio.lastroot
1176 config.servicelist.lastmode.value = "radio"
1180 def __onCreate(self):
1181 if config.usage.e1like_radio_mode.value:
1182 if config.servicelist.lastmode.value == "tv":
1188 lastservice=eServiceReference(self.lastservice.value)
1189 if lastservice.valid():
1192 def channelSelected(self):
1193 ref = self.getCurrentSelection()
1195 self.toggleMoveMarked()
1196 elif (ref.flags & 7) == 7:
1198 elif self.bouquet_mark_edit != OFF:
1199 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1201 elif not (ref.flags & eServiceReference.isMarker): # no marker
1202 root = self.getRoot()
1203 if not root or not (root.flags & eServiceReference.isGroup):
1208 #called from infoBar and channelSelected
1210 self.revertMode=None
1211 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1212 nref = self.getCurrentSelection()
1213 if ref is None or ref != nref:
1214 self.new_service_played = True
1215 self.session.nav.playService(nref)
1217 self.saveChannel(nref)
1218 config.servicelist.lastmode.save()
1219 self.addToHistory(nref)
1221 def newServicePlayed(self):
1222 ret = self.new_service_played
1223 self.new_service_played = False
1226 def addToHistory(self, ref):
1227 if self.servicePath is not None:
1228 tmp=self.servicePath[:]
1231 del self.history[self.history_pos+1:]
1234 self.history.append(tmp)
1235 hlen = len(self.history)
1236 if hlen > HISTORYSIZE:
1239 self.history_pos = hlen-1
1241 def historyBack(self):
1242 hlen = len(self.history)
1243 if hlen > 1 and self.history_pos > 0:
1244 self.history_pos -= 1
1245 self.setHistoryPath()
1247 def historyNext(self):
1248 hlen = len(self.history)
1249 if hlen > 1 and self.history_pos < (hlen-1):
1250 self.history_pos += 1
1251 self.setHistoryPath()
1253 def setHistoryPath(self):
1254 path = self.history[self.history_pos][:]
1256 del self.servicePath[:]
1257 self.servicePath += path
1260 cur_root = self.getRoot()
1261 if cur_root and cur_root != root:
1263 self.session.nav.playService(ref)
1264 self.setCurrentSelection(ref)
1265 self.saveChannel(ref)
1269 for i in self.servicePath:
1270 path += i.toString()
1272 if path and path != self.lastroot.value:
1273 self.lastroot.value = path
1274 self.lastroot.save()
1276 def restoreRoot(self):
1278 re = compile('.+?;')
1279 tmp = re.findall(self.lastroot.value)
1282 self.servicePath.append(eServiceReference(i[:-1]))
1285 path = self.servicePath.pop()
1286 self.enterPath(path)
1288 self.showFavourites()
1291 def preEnterPath(self, refstr):
1292 if self.servicePath and self.servicePath[0] != eServiceReference(refstr):
1293 pathstr = self.lastroot.value
1294 if pathstr is not None and pathstr.find(refstr) == 0:
1296 lastservice=eServiceReference(self.lastservice.value)
1297 if lastservice.valid():
1298 self.setCurrentSelection(lastservice)
1302 def saveChannel(self, ref):
1304 refstr = ref.toString()
1307 if refstr != self.lastservice.value:
1308 self.lastservice.value = refstr
1309 self.lastservice.save()
1311 def setCurrentServicePath(self, path):
1313 self.history[self.history_pos] = path
1315 self.history.append(path)
1316 self.setHistoryPath()
1318 def getCurrentServicePath(self):
1320 return self.history[self.history_pos]
1323 def recallPrevService(self):
1324 hlen = len(self.history)
1326 if self.history_pos == hlen-1:
1327 tmp = self.history[self.history_pos]
1328 self.history[self.history_pos] = self.history[self.history_pos-1]
1329 self.history[self.history_pos-1] = tmp
1331 tmp = self.history[self.history_pos+1]
1332 self.history[self.history_pos+1] = self.history[self.history_pos]
1333 self.history[self.history_pos] = tmp
1334 self.setHistoryPath()
1337 if self.revertMode is None:
1339 lastservice=eServiceReference(self.lastservice.value)
1340 if lastservice.valid() and self.getCurrentSelection() != lastservice:
1341 self.setCurrentSelection(lastservice)
1342 elif self.revertMode == MODE_TV:
1344 elif self.revertMode == MODE_RADIO:
1346 self.revertMode = None
1350 class RadioInfoBar(Screen):
1351 def __init__(self, session):
1352 Screen.__init__(self, session)
1353 self["RdsDecoder"] = RdsDecoder(self.session.nav)
1355 class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, InfoBarBase):
1356 ALLOW_SUSPEND = True
1358 def __init__(self, session, infobar):
1359 ChannelSelectionBase.__init__(self, session)
1360 ChannelSelectionEdit.__init__(self)
1361 ChannelSelectionEPG.__init__(self)
1362 InfoBarBase.__init__(self)
1363 self.infobar = infobar
1364 self.onLayoutFinish.append(self.onCreate)
1366 self.info = session.instantiateDialog(RadioInfoBar) # our simple infobar
1368 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1370 "keyTV": self.closeRadio,
1371 "keyRadio": self.closeRadio,
1372 "cancel": self.closeRadio,
1373 "ok": self.channelSelected,
1376 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1378 iPlayableService.evStart: self.__evServiceStart,
1379 iPlayableService.evEnd: self.__evServiceEnd
1382 ########## RDS Radiotext / Rass Support BEGIN
1383 self.infobar = infobar # reference to real infobar (the one and only)
1384 self["RdsDecoder"] = self.info["RdsDecoder"]
1385 self["RdsActions"] = HelpableActionMap(self, "InfobarRdsActions",
1387 "startRassInteractive": (self.startRassInteractive, _("View Rass interactive..."))
1389 self["RdsActions"].setEnabled(False)
1390 infobar.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
1391 self.onClose.append(self.__onClose)
1393 def __onClose(self):
1394 lastservice=eServiceReference(config.tv.lastservice.value)
1395 self.session.nav.playService(lastservice)
1397 def startRassInteractive(self):
1399 self.infobar.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
1401 def RassInteractiveClosed(self):
1403 self.infobar.rass_interactive = None
1404 self.infobar.RassSlidePicChanged()
1406 def RassInteractivePossibilityChanged(self, state):
1407 self["RdsActions"].setEnabled(state)
1408 ########## RDS Radiotext / Rass Support END
1410 def closeRadio(self):
1411 self.infobar.rds_display.onRassInteractivePossibilityChanged.remove(self.RassInteractivePossibilityChanged)
1413 #set previous tv service
1416 def __evServiceStart(self):
1417 service = self.session.nav.getCurrentService()
1419 info = service.info()
1421 refstr = info.getInfoString(iServiceInformation.sServiceref)
1422 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1424 def __evServiceEnd(self):
1425 self.servicelist.setPlayableIgnoreService(eServiceReference())
1429 for i in self.servicePathRadio:
1430 path += i.toString()
1432 if path and path != config.radio.lastroot.value:
1433 config.radio.lastroot.value = path
1434 config.radio.lastroot.save()
1436 def restoreRoot(self):
1438 re = compile('.+?;')
1439 tmp = re.findall(config.radio.lastroot.value)
1442 self.servicePathRadio.append(eServiceReference(i[:-1]))
1445 path = self.servicePathRadio.pop()
1446 self.enterPath(path)
1448 self.showFavourites()
1451 def preEnterPath(self, refstr):
1452 if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr):
1453 pathstr = config.radio.lastroot.value
1454 if pathstr is not None and pathstr.find(refstr) == 0:
1456 lastservice=eServiceReference(config.radio.lastservice.value)
1457 if lastservice.valid():
1458 self.setCurrentSelection(lastservice)
1465 lastservice=eServiceReference(config.radio.lastservice.value)
1466 if lastservice.valid():
1467 self.servicelist.setCurrent(lastservice)
1468 self.session.nav.playService(lastservice)
1470 self.session.nav.stopService()
1473 def channelSelected(self): # just return selected service
1474 ref = self.getCurrentSelection()
1476 self.toggleMoveMarked()
1477 elif (ref.flags & 7) == 7:
1479 elif self.bouquet_mark_edit != OFF:
1480 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1482 elif not (ref.flags & eServiceReference.isMarker): # no marker
1483 cur_root = self.getRoot()
1484 if not cur_root or not (cur_root.flags & eServiceReference.isGroup):
1485 playingref = self.session.nav.getCurrentlyPlayingServiceReference()
1486 if playingref is None or playingref != ref:
1487 self.session.nav.playService(ref)
1488 config.radio.lastservice.value = ref.toString()
1489 config.radio.lastservice.save()
1492 class SimpleChannelSelection(ChannelSelectionBase):
1493 def __init__(self, session, title):
1494 ChannelSelectionBase.__init__(self, session)
1495 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1497 "cancel": self.close,
1498 "ok": self.channelSelected,
1499 "keyRadio": self.setModeRadio,
1500 "keyTV": self.setModeTv,
1503 self.onLayoutFinish.append(self.layoutFinished)
1505 def layoutFinished(self):
1508 def channelSelected(self): # just return selected service
1509 ref = self.getCurrentSelection()
1510 if (ref.flags & 7) == 7:
1512 elif not (ref.flags & eServiceReference.isMarker):
1513 ref = self.getCurrentSelection()
1516 def setModeTv(self):
1518 self.showFavourites()
1520 def setModeRadio(self):
1522 self.showFavourites()