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.instance.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.instance.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 # this makes it much simple to implement a selectable radio or tv mode :)
657 service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) || (type == 134)'
658 service_types_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)'
660 class ChannelSelectionBase(Screen):
661 def __init__(self, session):
662 Screen.__init__(self, session)
664 self["key_red"] = Button(_("All"))
665 self["key_green"] = Button(_("Satellites"))
666 self["key_yellow"] = Button(_("Provider"))
667 self["key_blue"] = Button(_("Favourites"))
669 self["list"] = ServiceList()
670 self.servicelist = self["list"]
672 self.numericalTextInput = NumericalTextInput()
673 self.numericalTextInput.setUseableChars(u'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
675 self.servicePathTV = [ ]
676 self.servicePathRadio = [ ]
677 self.servicePath = [ ]
681 self.pathChangeDisabled = False
683 self.bouquetNumOffsetCache = { }
685 self["ChannelSelectBaseActions"] = NumberActionMap(["ChannelSelectBaseActions", "NumberActions", "InputAsciiActions"],
687 "showFavourites": self.showFavourites,
688 "showAllServices": self.showAllServices,
689 "showProviders": self.showProviders,
690 "showSatellites": self.showSatellites,
691 "nextBouquet": self.nextBouquet,
692 "prevBouquet": self.prevBouquet,
693 "nextMarker": self.nextMarker,
694 "prevMarker": self.prevMarker,
695 "gotAsciiCode": self.keyAsciiCode,
696 "1": self.keyNumberGlobal,
697 "2": self.keyNumberGlobal,
698 "3": self.keyNumberGlobal,
699 "4": self.keyNumberGlobal,
700 "5": self.keyNumberGlobal,
701 "6": self.keyNumberGlobal,
702 "7": self.keyNumberGlobal,
703 "8": self.keyNumberGlobal,
704 "9": self.keyNumberGlobal,
707 self.recallBouquetMode()
709 def getBouquetNumOffset(self, bouquet):
710 if not config.usage.multibouquet.value:
712 str = bouquet.toString()
714 if not self.bouquetNumOffsetCache.has_key(str):
715 serviceHandler = eServiceCenter.getInstance()
716 bouquetlist = serviceHandler.list(self.bouquet_root)
717 if not bouquetlist is None:
719 bouquetIterator = bouquetlist.getNext()
720 if not bouquetIterator.valid(): #end of list
722 self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
723 if not (bouquetIterator.flags & eServiceReference.isDirectory):
725 servicelist = serviceHandler.list(bouquetIterator)
726 if not servicelist is None:
728 serviceIterator = servicelist.getNext()
729 if not serviceIterator.valid(): #check if end of list
731 playable = not (serviceIterator.flags & (eServiceReference.isDirectory|eServiceReference.isMarker))
734 return self.bouquetNumOffsetCache.get(str, offsetCount)
736 def recallBouquetMode(self):
737 if self.mode == MODE_TV:
738 self.service_types = service_types_tv
739 if config.usage.multibouquet.value:
740 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
742 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
744 self.service_types = service_types_radio
745 if config.usage.multibouquet.value:
746 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
748 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
749 self.bouquet_root = eServiceReference(self.bouquet_rootstr)
753 self.servicePath = self.servicePathTV
754 self.recallBouquetMode()
755 title = self.instance.getTitle()
756 pos = title.find(" (")
762 def setRadioMode(self):
763 self.mode = MODE_RADIO
764 self.servicePath = self.servicePathRadio
765 self.recallBouquetMode()
766 title = self.instance.getTitle()
767 pos = title.find(" (")
773 def setRoot(self, root, justSet=False):
774 path = root.getPath()
775 inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
776 pos = path.find('FROM BOUQUET')
777 isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
778 if not inBouquetRootList and isBouquet:
779 self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
780 self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
782 self.servicelist.setMode(ServiceList.MODE_NORMAL)
783 self.servicelist.setRoot(root, justSet)
784 self.buildTitleString()
786 def removeModeStr(self, str):
787 if self.mode == MODE_TV:
788 pos = str.find(' (TV)')
790 pos = str.find(' (Radio)')
795 def getServiceName(self, ref):
796 str = self.removeModeStr(ServiceReference(ref).getServiceName())
798 pathstr = ref.getPath()
799 if 'FROM PROVIDERS' in pathstr:
801 if 'FROM SATELLITES' in pathstr:
802 return _("Satellites")
803 if ') ORDER BY name' in pathstr:
807 def buildTitleString(self):
808 titleStr = self.instance.getTitle()
809 pos = titleStr.find(']')
811 pos = titleStr.find(')')
813 titleStr = titleStr[:pos+1]
814 Len = len(self.servicePath)
816 base_ref = self.servicePath[0]
818 end_ref = self.servicePath[Len-1]
821 nameStr = self.getServiceName(base_ref)
822 titleStr += ' ' + nameStr
823 if end_ref is not None:
828 nameStr = self.getServiceName(end_ref)
830 self.setTitle(titleStr)
833 self.servicelist.moveUp()
836 self.servicelist.moveDown()
839 del self.servicePath[:]
841 def enterPath(self, ref, justSet=False):
842 self.servicePath.append(ref)
843 self.setRoot(ref, justSet)
845 def pathUp(self, justSet=False):
846 prev = self.servicePath.pop()
848 current = self.servicePath[-1]
849 self.setRoot(current, justSet)
851 self.setCurrentSelection(prev)
854 def isBasePathEqual(self, ref):
855 if len(self.servicePath) > 1 and self.servicePath[0] == ref:
859 def isPrevPathEqual(self, ref):
860 length = len(self.servicePath)
861 if length > 1 and self.servicePath[length-2] == ref:
865 def preEnterPath(self, refstr):
868 def showAllServices(self):
869 if not self.pathChangeDisabled:
870 refstr = '%s ORDER BY name'%(self.service_types)
871 if not self.preEnterPath(refstr):
872 ref = eServiceReference(refstr)
873 currentRoot = self.getRoot()
874 if currentRoot is None or currentRoot != ref:
878 def showSatellites(self):
879 if not self.pathChangeDisabled:
880 refstr = '%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types)
881 if not self.preEnterPath(refstr):
882 ref = eServiceReference(refstr)
886 if self.isBasePathEqual(ref):
887 if self.isPrevPathEqual(ref):
889 prev = self.pathUp(justSet)
891 currentRoot = self.getRoot()
892 if currentRoot is None or currentRoot != ref:
895 self.enterPath(ref, True)
897 serviceHandler = eServiceCenter.getInstance()
898 servicelist = serviceHandler.list(ref)
899 if not servicelist is None:
901 service = servicelist.getNext()
902 if not service.valid(): #check if end of list
904 unsigned_orbpos = service.getUnsignedData(4) >> 16
905 orbpos = service.getData(4) >> 16
908 if service.getPath().find("FROM PROVIDER") != -1:
909 service_type = _("Providers")
910 elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
911 service_type = _("New")
913 service_type = _("Services")
915 # why we need this cast?
916 service_name = str(nimmanager.getSatDescription(orbpos))
918 if unsigned_orbpos == 0xFFFF: #Cable
919 service_name = _("Cable")
920 elif unsigned_orbpos == 0xEEEE: #Terrestrial
921 service_name = _("Terrestrial")
923 if orbpos > 1800: # west
924 orbpos = 3600 - orbpos
928 service_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
929 service.setName("%s - %s" % (service_name, service_type))
930 self.servicelist.addService(service)
931 cur_ref = self.session.nav.getCurrentlyPlayingServiceReference()
933 pos = self.service_types.rfind(':')
934 refstr = '%s (channelID == %08x%04x%04x) && %s ORDER BY name' %(self.service_types[:pos+1],
935 cur_ref.getUnsignedData(4), # NAMESPACE
936 cur_ref.getUnsignedData(2), # TSID
937 cur_ref.getUnsignedData(3), # ONID
938 self.service_types[pos+1:])
939 ref = eServiceReference(refstr)
940 ref.setName(_("Current Transponder"))
941 self.servicelist.addService(ref)
942 self.servicelist.finishFill()
944 self.setCurrentSelection(prev)
946 def showProviders(self):
947 if not self.pathChangeDisabled:
948 refstr = '%s FROM PROVIDERS ORDER BY name'%(self.service_types)
949 if not self.preEnterPath(refstr):
950 ref = eServiceReference(refstr)
951 if self.isBasePathEqual(ref):
954 currentRoot = self.getRoot()
955 if currentRoot is None or currentRoot != ref:
959 def changeBouquet(self, direction):
960 if not self.pathChangeDisabled:
961 if len(self.servicePath) > 1:
962 #when enter satellite root list we must do some magic stuff..
963 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
964 if self.isBasePathEqual(ref):
965 self.showSatellites()
972 ref = self.getCurrentSelection()
976 if self.servicePath and self.servicePath[0] == self.bouquet_root:
981 return self.servicelist.atBegin()
984 return self.servicelist.atEnd()
986 def nextBouquet(self):
987 self.changeBouquet(+1)
989 def prevBouquet(self):
990 self.changeBouquet(-1)
992 def showFavourites(self):
993 if not self.pathChangeDisabled:
994 if not self.preEnterPath(self.bouquet_rootstr):
995 if self.isBasePathEqual(self.bouquet_root):
998 currentRoot = self.getRoot()
999 if currentRoot is None or currentRoot != self.bouquet_root:
1001 self.enterPath(self.bouquet_root)
1003 def keyNumberGlobal(self, number):
1004 unichar = self.numericalTextInput.getKey(number)
1005 charstr = unichar.encode("utf-8")
1006 if len(charstr) == 1:
1007 self.servicelist.moveToChar(charstr[0])
1009 def keyAsciiCode(self):
1010 unichar = unichr(getPrevAsciiCode())
1011 charstr = unichar.encode("utf-8")
1012 if len(charstr) == 1:
1013 self.servicelist.moveToChar(charstr[0])
1016 return self.servicelist.getRoot()
1018 def getCurrentSelection(self):
1019 return self.servicelist.getCurrent()
1021 def setCurrentSelection(self, service):
1022 self.servicelist.setCurrent(service)
1024 def getBouquetList(self):
1026 serviceHandler = eServiceCenter.getInstance()
1027 if config.usage.multibouquet.value:
1028 list = serviceHandler.list(self.bouquet_root)
1034 if s.flags & eServiceReference.isDirectory:
1035 info = serviceHandler.info(s)
1037 bouquets.append((info.getName(s), s))
1040 info = serviceHandler.info(self.bouquet_root)
1042 bouquets.append((info.getName(self.bouquet_root), self.bouquet_root))
1046 def keyNumber0(self, num):
1047 if len(self.servicePath) > 1:
1050 self.keyNumberGlobal(num)
1053 if len(self.servicePath) > 1:
1054 if self.isBasePathEqual(self.bouquet_root):
1055 self.showFavourites()
1057 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
1058 if self.isBasePathEqual(ref):
1059 self.showSatellites()
1061 ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
1062 if self.isBasePathEqual(ref):
1063 self.showProviders()
1065 self.showAllServices()
1067 def nextMarker(self):
1068 self.servicelist.moveToNextMarker()
1070 def prevMarker(self):
1071 self.servicelist.moveToPrevMarker()
1075 #config for lastservice
1076 config.tv = ConfigSubsection()
1077 config.tv.lastservice = ConfigText()
1078 config.tv.lastroot = ConfigText()
1079 config.radio = ConfigSubsection()
1080 config.radio.lastservice = ConfigText()
1081 config.radio.lastroot = ConfigText()
1082 config.servicelist = ConfigSubsection()
1083 config.servicelist.lastmode = ConfigText(default = "tv")
1085 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, SelectionEventInfo):
1086 def __init__(self, session):
1087 ChannelSelectionBase.__init__(self,session)
1088 ChannelSelectionEdit.__init__(self)
1089 ChannelSelectionEPG.__init__(self)
1090 SelectionEventInfo.__init__(self)
1092 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1094 "cancel": self.cancel,
1095 "ok": self.channelSelected,
1096 "keyRadio": self.setModeRadio,
1097 "keyTV": self.setModeTv,
1100 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1102 iPlayableService.evStart: self.__evServiceStart,
1103 iPlayableService.evEnd: self.__evServiceEnd
1106 self.lastChannelRootTimer = eTimer()
1107 self.lastChannelRootTimer.callback.append(self.__onCreate)
1108 self.lastChannelRootTimer.start(100,True)
1110 self.history_tv = [ ]
1111 self.history_radio = [ ]
1112 self.history = self.history_tv
1113 self.history_pos = 0
1115 self.lastservice = config.tv.lastservice
1116 self.lastroot = config.tv.lastroot
1117 self.revertMode = None
1118 config.usage.multibouquet.addNotifier(self.multibouquet_config_changed)
1119 self.new_service_played = False
1120 self.onExecBegin.append(self.asciiOn)
1123 rcinput = eRCInput.getInstance()
1124 rcinput.setKeyboardMode(rcinput.kmAscii)
1127 rcinput = eRCInput.getInstance()
1128 rcinput.setKeyboardMode(rcinput.kmNone)
1130 def multibouquet_config_changed(self, val):
1131 self.recallBouquetMode()
1133 def __evServiceStart(self):
1134 service = self.session.nav.getCurrentService()
1136 info = service.info()
1138 refstr = info.getInfoString(iServiceInformation.sServiceref)
1139 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1141 def __evServiceEnd(self):
1142 self.servicelist.setPlayableIgnoreService(eServiceReference())
1146 lastservice=eServiceReference(self.lastservice.value)
1147 if lastservice.valid():
1148 self.setCurrentSelection(lastservice)
1150 def setModeTv(self):
1151 if self.revertMode is None and config.servicelist.lastmode.value == "radio":
1152 self.revertMode = MODE_RADIO
1153 self.history = self.history_tv
1154 self.lastservice = config.tv.lastservice
1155 self.lastroot = config.tv.lastroot
1156 config.servicelist.lastmode.value = "tv"
1160 def setModeRadio(self):
1161 if self.revertMode is None and config.servicelist.lastmode.value == "tv":
1162 self.revertMode = MODE_TV
1163 if config.usage.e1like_radio_mode.value:
1164 self.history = self.history_radio
1165 self.lastservice = config.radio.lastservice
1166 self.lastroot = config.radio.lastroot
1167 config.servicelist.lastmode.value = "radio"
1171 def __onCreate(self):
1172 if config.usage.e1like_radio_mode.value:
1173 if config.servicelist.lastmode.value == "tv":
1179 lastservice=eServiceReference(self.lastservice.value)
1180 if lastservice.valid():
1183 def channelSelected(self):
1184 ref = self.getCurrentSelection()
1186 self.toggleMoveMarked()
1187 elif (ref.flags & 7) == 7:
1189 elif self.bouquet_mark_edit != OFF:
1190 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1192 elif not (ref.flags & eServiceReference.isMarker): # no marker
1193 root = self.getRoot()
1194 if not root or not (root.flags & eServiceReference.isGroup):
1199 #called from infoBar and channelSelected
1201 self.revertMode=None
1202 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1203 nref = self.getCurrentSelection()
1204 if ref is None or ref != nref:
1205 self.new_service_played = True
1206 self.session.nav.playService(nref)
1208 self.saveChannel(nref)
1209 config.servicelist.lastmode.save()
1210 self.addToHistory(nref)
1212 def newServicePlayed(self):
1213 ret = self.new_service_played
1214 self.new_service_played = False
1217 def addToHistory(self, ref):
1218 if self.servicePath is not None:
1219 tmp=self.servicePath[:]
1222 del self.history[self.history_pos+1:]
1225 self.history.append(tmp)
1226 hlen = len(self.history)
1227 if hlen > HISTORYSIZE:
1230 self.history_pos = hlen-1
1232 def historyBack(self):
1233 hlen = len(self.history)
1234 if hlen > 1 and self.history_pos > 0:
1235 self.history_pos -= 1
1236 self.setHistoryPath()
1238 def historyNext(self):
1239 hlen = len(self.history)
1240 if hlen > 1 and self.history_pos < (hlen-1):
1241 self.history_pos += 1
1242 self.setHistoryPath()
1244 def setHistoryPath(self):
1245 path = self.history[self.history_pos][:]
1247 del self.servicePath[:]
1248 self.servicePath += path
1251 cur_root = self.getRoot()
1252 if cur_root and cur_root != root:
1254 self.session.nav.playService(ref)
1255 self.setCurrentSelection(ref)
1256 self.saveChannel(ref)
1260 for i in self.servicePath:
1261 path += i.toString()
1263 if path and path != self.lastroot.value:
1264 self.lastroot.value = path
1265 self.lastroot.save()
1267 def restoreRoot(self):
1269 re = compile('.+?;')
1270 tmp = re.findall(self.lastroot.value)
1273 self.servicePath.append(eServiceReference(i[:-1]))
1276 path = self.servicePath.pop()
1277 self.enterPath(path)
1279 self.showFavourites()
1282 def preEnterPath(self, refstr):
1283 if self.servicePath and self.servicePath[0] != eServiceReference(refstr):
1284 pathstr = self.lastroot.value
1285 if pathstr is not None and pathstr.find(refstr) == 0:
1287 lastservice=eServiceReference(self.lastservice.value)
1288 if lastservice.valid():
1289 self.setCurrentSelection(lastservice)
1293 def saveChannel(self, ref):
1295 refstr = ref.toString()
1298 if refstr != self.lastservice.value:
1299 self.lastservice.value = refstr
1300 self.lastservice.save()
1302 def setCurrentServicePath(self, path):
1304 self.history[self.history_pos] = path
1306 self.history.append(path)
1307 self.setHistoryPath()
1309 def getCurrentServicePath(self):
1311 return self.history[self.history_pos]
1314 def recallPrevService(self):
1315 hlen = len(self.history)
1317 if self.history_pos == hlen-1:
1318 tmp = self.history[self.history_pos]
1319 self.history[self.history_pos] = self.history[self.history_pos-1]
1320 self.history[self.history_pos-1] = tmp
1322 tmp = self.history[self.history_pos+1]
1323 self.history[self.history_pos+1] = self.history[self.history_pos]
1324 self.history[self.history_pos] = tmp
1325 self.setHistoryPath()
1328 if self.revertMode is None:
1330 lastservice=eServiceReference(self.lastservice.value)
1331 if lastservice.valid() and self.getCurrentSelection() != lastservice:
1332 self.setCurrentSelection(lastservice)
1333 elif self.revertMode == MODE_TV:
1335 elif self.revertMode == MODE_RADIO:
1337 self.revertMode = None
1341 class RadioInfoBar(Screen):
1342 def __init__(self, session):
1343 Screen.__init__(self, session)
1344 self["RdsDecoder"] = RdsDecoder(self.session.nav)
1346 class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, InfoBarBase):
1347 ALLOW_SUSPEND = True
1349 def __init__(self, session, infobar):
1350 ChannelSelectionBase.__init__(self, session)
1351 ChannelSelectionEdit.__init__(self)
1352 ChannelSelectionEPG.__init__(self)
1353 InfoBarBase.__init__(self)
1354 self.infobar = infobar
1355 self.onLayoutFinish.append(self.onCreate)
1357 self.info = session.instantiateDialog(RadioInfoBar) # our simple infobar
1359 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1361 "keyTV": self.closeRadio,
1362 "keyRadio": self.closeRadio,
1363 "cancel": self.closeRadio,
1364 "ok": self.channelSelected,
1367 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1369 iPlayableService.evStart: self.__evServiceStart,
1370 iPlayableService.evEnd: self.__evServiceEnd
1373 ########## RDS Radiotext / Rass Support BEGIN
1374 self.infobar = infobar # reference to real infobar (the one and only)
1375 self["RdsDecoder"] = self.info["RdsDecoder"]
1376 self["RdsActions"] = HelpableActionMap(self, "InfobarRdsActions",
1378 "startRassInteractive": (self.startRassInteractive, _("View Rass interactive..."))
1380 self["RdsActions"].setEnabled(False)
1381 infobar.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
1382 self.onClose.append(self.__onClose)
1384 def __onClose(self):
1385 lastservice=eServiceReference(config.tv.lastservice.value)
1386 self.session.nav.playService(lastservice)
1388 def startRassInteractive(self):
1390 self.infobar.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
1392 def RassInteractiveClosed(self):
1394 self.infobar.rass_interactive = None
1395 self.infobar.RassSlidePicChanged()
1397 def RassInteractivePossibilityChanged(self, state):
1398 self["RdsActions"].setEnabled(state)
1399 ########## RDS Radiotext / Rass Support END
1401 def closeRadio(self):
1402 self.infobar.rds_display.onRassInteractivePossibilityChanged.remove(self.RassInteractivePossibilityChanged)
1404 #set previous tv service
1407 def __evServiceStart(self):
1408 service = self.session.nav.getCurrentService()
1410 info = service.info()
1412 refstr = info.getInfoString(iServiceInformation.sServiceref)
1413 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1415 def __evServiceEnd(self):
1416 self.servicelist.setPlayableIgnoreService(eServiceReference())
1420 for i in self.servicePathRadio:
1421 path += i.toString()
1423 if path and path != config.radio.lastroot.value:
1424 config.radio.lastroot.value = path
1425 config.radio.lastroot.save()
1427 def restoreRoot(self):
1429 re = compile('.+?;')
1430 tmp = re.findall(config.radio.lastroot.value)
1433 self.servicePathRadio.append(eServiceReference(i[:-1]))
1436 path = self.servicePathRadio.pop()
1437 self.enterPath(path)
1439 self.showFavourites()
1442 def preEnterPath(self, refstr):
1443 if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr):
1444 pathstr = config.radio.lastroot.value
1445 if pathstr is not None and pathstr.find(refstr) == 0:
1447 lastservice=eServiceReference(config.radio.lastservice.value)
1448 if lastservice.valid():
1449 self.setCurrentSelection(lastservice)
1456 lastservice=eServiceReference(config.radio.lastservice.value)
1457 if lastservice.valid():
1458 self.servicelist.setCurrent(lastservice)
1459 self.session.nav.playService(lastservice)
1461 self.session.nav.stopService()
1464 def channelSelected(self): # just return selected service
1465 ref = self.getCurrentSelection()
1467 self.toggleMoveMarked()
1468 elif (ref.flags & 7) == 7:
1470 elif self.bouquet_mark_edit != OFF:
1471 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1473 elif not (ref.flags & eServiceReference.isMarker): # no marker
1474 cur_root = self.getRoot()
1475 if not cur_root or not (cur_root.flags & eServiceReference.isGroup):
1476 playingref = self.session.nav.getCurrentlyPlayingServiceReference()
1477 if playingref is None or playingref != ref:
1478 self.session.nav.playService(ref)
1479 config.radio.lastservice.value = ref.toString()
1480 config.radio.lastservice.save()
1483 class SimpleChannelSelection(ChannelSelectionBase):
1484 def __init__(self, session, title):
1485 ChannelSelectionBase.__init__(self, session)
1487 self.onShown.append(self.__onExecCallback)
1489 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1491 "cancel": self.close,
1492 "ok": self.channelSelected,
1493 "keyRadio": self.setModeRadio,
1494 "keyTV": self.setModeTv,
1497 def __onExecCallback(self):
1498 self.setTitle(self.title)
1501 def channelSelected(self): # just return selected service
1502 ref = self.getCurrentSelection()
1503 if (ref.flags & 7) == 7:
1505 elif not (ref.flags & eServiceReference.isMarker):
1506 ref = self.getCurrentSelection()
1509 def setModeTv(self):
1511 self.showFavourites()
1513 def setModeRadio(self):
1515 self.showFavourites()