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
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.Source import ObsoleteSource
18 profile("ChannelSelection.py 2.2")
19 from Components.Sources.RdsDecoder import RdsDecoder
20 profile("ChannelSelection.py 2.3")
21 from Components.Sources.ServiceEvent import ServiceEvent
22 profile("ChannelSelection.py 2.4")
23 from Components.Input import Input
24 profile("ChannelSelection.py 3")
25 from Components.ParentalControl import parentalControl
26 from Components.Pixmap import Pixmap
27 from Screens.InputBox import InputBox, PinInput
28 from Screens.MessageBox import MessageBox
29 from Screens.ServiceInfo import ServiceInfo
30 profile("ChannelSelection.py 4")
31 from Screens.RdsDisplay import RassInteractive
32 from ServiceReference import ServiceReference
33 from Tools.BoundFunction import boundFunction
34 from re import compile
36 profile("ChannelSelection.py after imports")
38 FLAG_SERVICE_NEW_FOUND = 64 #define in lib/dvb/idvb.h as dxNewFound = 64
40 class BouquetSelector(Screen):
41 def __init__(self, session, bouquets, selectedFunc, enableWrapAround=False):
42 Screen.__init__(self, session)
44 self.selectedFunc=selectedFunc
46 self["actions"] = ActionMap(["OkCancelActions"],
48 "ok": self.okbuttonClick,
49 "cancel": self.cancelClick
51 entrys = [ (x[0], x[1]) for x in bouquets ]
52 self["menu"] = MenuList(entrys, enableWrapAround)
55 cur = self["menu"].getCurrent()
58 def okbuttonClick(self):
59 self.selectedFunc(self.getCurrent())
67 def cancelClick(self):
70 # csel.bouquet_mark_edit values
75 def append_when_current_valid(current, menu, args, level = 0):
76 if current and current.valid() and level <= config.usage.setup_level.index:
79 class ChannelContextMenu(Screen):
80 def __init__(self, session, csel):
81 Screen.__init__(self, session)
82 #raise "we need a better summary screen here"
86 self["actions"] = ActionMap(["OkCancelActions"],
88 "ok": self.okbuttonClick,
89 "cancel": self.cancelClick
93 current = csel.getCurrentSelection()
94 current_root = csel.getRoot()
95 current_sel_path = current.getPath()
96 current_sel_flags = current.flags
97 inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
98 inBouquet = csel.getMutableList() is not None
99 haveBouquets = config.usage.multibouquet.value
101 if not (len(current_sel_path) or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
102 append_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations), level = 2)
103 if csel.bouquet_mark_edit == OFF and not csel.movemode:
104 if not inBouquetRootList:
105 isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
107 if config.ParentalControl.configured.value:
108 if parentalControl.getProtectionLevel(csel.getCurrentSelection().toCompareString()) == -1:
109 append_when_current_valid(current, menu, (_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())), level = 0)
111 append_when_current_valid(current, menu, (_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())), level = 0)
113 append_when_current_valid(current, menu, (_("add service to bouquet"), self.addServiceToBouquetSelected), level = 0)
115 append_when_current_valid(current, menu, (_("add service to favourites"), self.addServiceToBouquetSelected), level = 0)
118 if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
119 append_when_current_valid(current, menu, (_("copy to bouquets"), self.copyCurrentToBouquetList), level = 0)
120 if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
121 append_when_current_valid(current, menu, (_("remove all new found flags"), self.removeAllNewFoundFlags), level = 0)
123 append_when_current_valid(current, menu, (_("remove entry"), self.removeCurrentService), level = 0)
124 if current_root and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
125 append_when_current_valid(current, menu, (_("remove new found flag"), self.removeNewFoundFlag), level = 0)
127 menu.append((_("add bouquet"), self.showBouquetInputBox))
128 append_when_current_valid(current, menu, (_("remove entry"), self.removeBouquet), level = 0)
130 if inBouquet: # current list is editable?
131 if csel.bouquet_mark_edit == OFF:
132 if not csel.movemode:
133 append_when_current_valid(current, menu, (_("enable move mode"), self.toggleMoveMode), level = 1)
134 if not inBouquetRootList and current_root and not (current_root.flags & eServiceReference.isGroup):
135 menu.append((_("add marker"), self.showMarkerInputBox))
137 append_when_current_valid(current, menu, (_("enable bouquet edit"), self.bouquetMarkStart), level = 0)
139 append_when_current_valid(current, menu, (_("enable favourite edit"), self.bouquetMarkStart), level = 0)
140 if current_sel_flags & eServiceReference.isGroup:
141 append_when_current_valid(current, menu, (_("edit alternatives"), self.editAlternativeServices), level = 2)
142 append_when_current_valid(current, menu, (_("show alternatives"), self.showAlternativeServices), level = 2)
143 append_when_current_valid(current, menu, (_("remove all alternatives"), self.removeAlternativeServices), level = 2)
144 elif not current_sel_flags & eServiceReference.isMarker:
145 append_when_current_valid(current, menu, (_("add alternatives"), self.addAlternativeServices), level = 2)
147 append_when_current_valid(current, menu, (_("disable move mode"), self.toggleMoveMode), level = 0)
149 if csel.bouquet_mark_edit == EDIT_BOUQUET:
151 append_when_current_valid(current, menu, (_("end bouquet edit"), self.bouquetMarkEnd), level = 0)
152 append_when_current_valid(current, menu, (_("abort bouquet edit"), self.bouquetMarkAbort), level = 0)
154 append_when_current_valid(current, menu, (_("end favourites edit"), self.bouquetMarkEnd), level = 0)
155 append_when_current_valid(current, menu, (_("abort favourites edit"), self.bouquetMarkAbort), level = 0)
157 append_when_current_valid(current, menu, (_("end alternatives edit"), self.bouquetMarkEnd), level = 0)
158 append_when_current_valid(current, menu, (_("abort alternatives edit"), self.bouquetMarkAbort), level = 0)
160 menu.append((_("back"), self.cancelClick))
161 self["menu"] = MenuList(menu)
163 def okbuttonClick(self):
164 self["menu"].getCurrent()[1]()
166 def cancelClick(self):
169 def showServiceInformations(self):
170 self.session.open( ServiceInfo, self.csel.getCurrentSelection() )
172 def showBouquetInputBox(self):
173 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)
175 def bouquetInputCallback(self, bouquet):
176 if bouquet is not None:
177 self.csel.addBouquet(bouquet, None)
180 def addParentalProtection(self, service):
181 parentalControl.protectService(service.toCompareString())
184 def removeParentalProtection(self, service):
185 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"))
187 def pinEntered(self, service, result):
189 parentalControl.unProtectService(service)
192 self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
194 def addServiceToBouquetSelected(self):
195 bouquets = self.csel.getBouquetList()
200 if cnt > 1: # show bouquet list
201 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, bouquets, self.addCurrentServiceToBouquet)
202 elif cnt == 1: # add to only one existing bouquet
203 self.addCurrentServiceToBouquet(bouquets[0][1])
205 def bouquetSelClosed(self, recursive):
210 def copyCurrentToBouquetList(self):
211 self.csel.copyCurrentToBouquetList()
214 def removeBouquet(self):
215 self.csel.removeBouquet()
218 def showMarkerInputBox(self):
219 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)
221 def markerInputCallback(self, marker):
222 if marker is not None:
223 self.csel.addMarker(marker)
226 def addCurrentServiceToBouquet(self, dest):
227 self.csel.addServiceToBouquet(dest)
228 if self.bsel is not None:
229 self.bsel.close(True)
231 self.close(True) # close bouquet selection
233 def removeCurrentService(self):
234 self.csel.removeCurrentService()
237 def toggleMoveMode(self):
238 self.csel.toggleMoveMode()
241 def bouquetMarkStart(self):
242 self.csel.startMarkedEdit(EDIT_BOUQUET)
245 def bouquetMarkEnd(self):
246 self.csel.endMarkedEdit(abort=False)
249 def bouquetMarkAbort(self):
250 self.csel.endMarkedEdit(abort=True)
253 def removeNewFoundFlag(self):
254 eDVBDB.getInstance().removeFlag(self.csel.getCurrentSelection(), FLAG_SERVICE_NEW_FOUND)
257 def removeAllNewFoundFlags(self):
258 curpath = self.csel.getCurrentSelection().getPath()
259 idx = curpath.find("satellitePosition == ")
261 tmp = curpath[idx+21:]
264 satpos = int(tmp[:idx])
265 eDVBDB.getInstance().removeFlags(FLAG_SERVICE_NEW_FOUND, -1, -1, -1, satpos)
268 def editAlternativeServices(self):
269 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
272 def showAlternativeServices(self):
273 self.csel.enterPath(self.csel.getCurrentSelection())
276 def removeAlternativeServices(self):
277 self.csel.removeAlternativeServices()
280 def addAlternativeServices(self):
281 self.csel.addAlternativeServices()
282 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
285 class SelectionEventInfo:
287 self["ServiceEvent"] = ServiceEvent()
288 self.servicelist.connectSelChanged(self.__selectionChanged)
289 self.timer = eTimer()
290 self.timer.callback.append(self.updateEventInfo)
291 self.onShown.append(self.__selectionChanged)
293 def __selectionChanged(self):
295 self.timer.start(100, True)
297 def updateEventInfo(self):
298 cur = self.getCurrentSelection()
299 self["ServiceEvent"].newService(cur)
301 class ChannelSelectionEPG:
303 self["ChannelSelectEPGActions"] = ActionMap(["ChannelSelectEPGActions"],
305 "showEPGList": self.showEPGList,
308 def showEPGList(self):
309 ref=self.getCurrentSelection()
310 ptr=eEPGCache.getInstance()
311 if ptr.startTimeQuery(ref) != -1:
312 self.session.open(EPGSelection, ref)
314 print 'no epg for service', ref.toString()
316 class ChannelSelectionEdit:
318 self.entry_marked = False
319 self.movemode = False
320 self.bouquet_mark_edit = OFF
321 self.mutableList = None
323 self.saved_title = None
324 self.saved_root = None
326 class ChannelSelectionEditActionMap(ActionMap):
327 def __init__(self, csel, contexts = [ ], actions = { }, prio=0):
328 ActionMap.__init__(self, contexts, actions, prio)
331 def action(self, contexts, action):
332 if action == "cancel":
333 self.csel.handleEditCancel()
334 return 0 # fall-trough
336 return 0 # fall-trough
338 return ActionMap.action(self, contexts, action)
340 self["ChannelSelectEditActions"] = ChannelSelectionEditActionMap(self, ["ChannelSelectEditActions", "OkCancelActions"],
342 "contextMenu": self.doContext,
345 def getMutableList(self, root=eServiceReference()):
346 if not self.mutableList is None:
347 return self.mutableList
348 serviceHandler = eServiceCenter.getInstance()
351 list = root and serviceHandler.list(root)
353 return list.startEdit()
356 def buildBouquetID(self, str):
360 if (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9'):
366 def addMarker(self, name):
367 current = self.servicelist.getCurrent()
368 mutableList = self.getMutableList()
371 str = '1:64:%d:0:0:0:0:0:0:0::%s'%(cnt, name)
372 ref = eServiceReference(str)
373 if current and current.valid():
374 if not mutableList.addService(ref, current):
375 self.servicelist.addService(ref, True)
376 mutableList.flushChanges()
378 elif not mutableList.addService(ref):
379 self.servicelist.addService(ref, True)
380 mutableList.flushChanges()
384 def addAlternativeServices(self):
385 cur_service = ServiceReference(self.getCurrentSelection())
386 root = self.getRoot()
387 cur_root = root and ServiceReference(root)
388 mutableBouquet = cur_root.list().startEdit()
390 name = cur_service.getServiceName()
392 if self.mode == MODE_TV:
393 str = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name))
395 str = '1:134:2:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(name))
396 new_ref = ServiceReference(str)
397 if not mutableBouquet.addService(new_ref.ref, cur_service.ref):
398 mutableBouquet.removeService(cur_service.ref)
399 mutableBouquet.flushChanges()
400 eDVBDB.getInstance().reloadBouquets()
401 mutableAlternatives = new_ref.list().startEdit()
402 if mutableAlternatives:
403 mutableAlternatives.setListName(name)
404 if mutableAlternatives.addService(cur_service.ref):
405 print "add", cur_service.toString(), "to new alternatives failed"
406 mutableAlternatives.flushChanges()
407 self.servicelist.addService(new_ref.ref, True)
408 self.servicelist.removeCurrent()
409 self.servicelist.moveUp()
411 print "get mutable list for new created alternatives failed"
413 print "add", str, "to", cur_root.getServiceName(), "failed"
415 print "bouquetlist is not editable"
417 def addBouquet(self, bName, services):
418 serviceHandler = eServiceCenter.getInstance()
419 mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit()
420 if mutableBouquetList:
421 if self.mode == MODE_TV:
423 str = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName))
426 str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName))
427 new_bouquet_ref = eServiceReference(str)
428 if not mutableBouquetList.addService(new_bouquet_ref):
429 mutableBouquetList.flushChanges()
430 eDVBDB.getInstance().reloadBouquets()
431 mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit()
433 mutableBouquet.setListName(bName)
434 if services is not None:
435 for service in services:
436 if mutableBouquet.addService(service):
437 print "add", service.toString(), "to new bouquet failed"
438 mutableBouquet.flushChanges()
440 print "get mutable list for new created bouquet failed"
441 # do some voodoo to check if current_root is equal to bouquet_root
442 cur_root = self.getRoot();
443 str1 = cur_root and cur_root.toString()
444 pos1 = str1 and str1.find("FROM BOUQUET") or -1
445 pos2 = self.bouquet_rootstr.find("FROM BOUQUET")
446 if pos1 != -1 and pos2 != -1 and str1[pos1:] == self.bouquet_rootstr[pos2:]:
447 self.servicelist.addService(new_bouquet_ref)
449 print "add", str, "to bouquets failed"
451 print "bouquetlist is not editable"
453 def copyCurrentToBouquetList(self):
454 provider = ServiceReference(self.getCurrentSelection())
455 providerName = provider.getServiceName()
456 serviceHandler = eServiceCenter.getInstance()
457 services = serviceHandler.list(provider.ref)
458 self.addBouquet(providerName, services and services.getContent('R', True))
460 def removeAlternativeServices(self):
461 cur_service = ServiceReference(self.getCurrentSelection())
462 root = self.getRoot()
463 cur_root = root and ServiceReference(root)
464 list = cur_service.list()
465 first_in_alternative = list and list.getNext()
466 if first_in_alternative:
467 edit_root = cur_root and cur_root.list().startEdit()
469 if not edit_root.addService(first_in_alternative, cur_service.ref):
470 self.servicelist.addService(first_in_alternative, True)
472 print "couldn't add first alternative service to current root"
474 print "couldn't edit current root!!"
476 print "remove empty alternative list !!"
478 self.servicelist.moveUp()
480 def removeBouquet(self):
481 refstr = self.getCurrentSelection().toString()
482 print "removeBouquet", refstr
483 self.bouquetNumOffsetCache = { }
484 pos = refstr.find('FROM BOUQUET "')
487 refstr = refstr[pos+14:]
488 pos = refstr.find('"')
490 filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
491 self.removeCurrentService()
493 if filename is not None:
496 print "error during remove of", filename
498 # multiple marked entry stuff ( edit mode, later multiepg selection )
499 def startMarkedEdit(self, type):
500 self.savedPath = self.servicePath[:]
501 if type == EDIT_ALTERNATIVES:
502 self.enterPath(self.getCurrentSelection())
503 self.mutableList = self.getMutableList()
504 # add all services from the current list to internal marked set in listboxservicecontent
505 self.clearMarks() # this clears the internal marked set in the listboxservicecontent
506 self.saved_title = self.instance.getTitle()
507 pos = self.saved_title.find(')')
508 new_title = self.saved_title[:pos+1]
509 if type == EDIT_ALTERNATIVES:
510 self.bouquet_mark_edit = EDIT_ALTERNATIVES
511 new_title += ' ' + _("[alternative edit]")
513 self.bouquet_mark_edit = EDIT_BOUQUET
514 if config.usage.multibouquet.value:
515 new_title += ' ' + _("[bouquet edit]")
517 new_title += ' ' + _("[favourite edit]")
518 self.setTitle(new_title)
519 self.__marked = self.servicelist.getRootServices()
520 for x in self.__marked:
521 self.servicelist.addMarked(eServiceReference(x))
522 self.showAllServices()
524 def endMarkedEdit(self, abort):
525 if not abort and self.mutableList is not None:
526 self.bouquetNumOffsetCache = { }
527 new_marked = set(self.servicelist.getMarked())
528 old_marked = set(self.__marked)
529 removed = old_marked - new_marked
530 added = new_marked - old_marked
534 self.mutableList.removeService(eServiceReference(x))
537 self.mutableList.addService(eServiceReference(x))
539 self.mutableList.flushChanges()
542 self.bouquet_mark_edit = OFF
543 self.mutableList = None
544 self.setTitle(self.saved_title)
545 self.saved_title = None
546 # self.servicePath is just a reference to servicePathTv or Radio...
547 # so we never ever do use the asignment operator in self.servicePath
548 del self.servicePath[:] # remove all elements
549 self.servicePath += self.savedPath # add saved elements
551 self.setRoot(self.servicePath[len(self.servicePath)-1])
553 def clearMarks(self):
554 self.servicelist.clearMarks()
557 ref = self.servicelist.getCurrent()
558 if self.servicelist.isMarked(ref):
559 self.servicelist.removeMarked(ref)
561 self.servicelist.addMarked(ref)
563 def removeCurrentService(self):
564 ref = self.servicelist.getCurrent()
565 mutableList = self.getMutableList()
566 if ref.valid() and mutableList is not None:
567 if not mutableList.removeService(ref):
568 self.bouquetNumOffsetCache = { }
569 mutableList.flushChanges() #FIXME dont flush on each single removed service
570 self.servicelist.removeCurrent()
572 def addServiceToBouquet(self, dest, service=None):
573 mutableList = self.getMutableList(dest)
574 if not mutableList is None:
575 if service is None: #use current selected service
576 service = self.servicelist.getCurrent()
577 if not mutableList.addService(service):
578 self.bouquetNumOffsetCache = { }
579 mutableList.flushChanges()
580 # do some voodoo to check if current_root is equal to dest
581 cur_root = self.getRoot();
582 str1 = cur_root and cur_root.toString() or -1
583 str2 = dest.toString()
584 pos1 = str1.find("FROM BOUQUET")
585 pos2 = str2.find("FROM BOUQUET")
586 if pos1 != -1 and pos2 != -1 and str1[pos1:] == str2[pos2:]:
587 self.servicelist.addService(service)
589 def toggleMoveMode(self):
591 if self.entry_marked:
592 self.toggleMoveMarked() # unmark current entry
593 self.movemode = False
594 self.pathChangeDisabled = False # re-enable path change
595 self.mutableList.flushChanges() # FIXME add check if changes was made
596 self.mutableList = None
597 self.setTitle(self.saved_title)
598 self.saved_title = None
599 cur_root = self.getRoot()
600 if cur_root and cur_root == self.bouquet_root:
601 self.bouquetNumOffsetCache = { }
603 self.mutableList = self.getMutableList()
605 self.pathChangeDisabled = True # no path change allowed in movemode
606 self.saved_title = self.instance.getTitle()
607 new_title = self.saved_title
608 pos = self.saved_title.find(')')
609 new_title = self.saved_title[:pos+1] + ' ' + _("[move mode]") + self.saved_title[pos+1:]
610 self.setTitle(new_title);
612 def handleEditCancel(self):
613 if self.movemode: #movemode active?
614 self.channelSelected() # unmark
615 self.toggleMoveMode() # disable move mode
616 elif self.bouquet_mark_edit != OFF:
617 self.endMarkedEdit(True) # abort edit mode
619 def toggleMoveMarked(self):
620 if self.entry_marked:
621 self.servicelist.setCurrentMarked(False)
622 self.entry_marked = False
624 self.servicelist.setCurrentMarked(True)
625 self.entry_marked = True
628 self.session.open(ChannelContextMenu, self)
633 # this makes it much simple to implement a selectable radio or tv mode :)
634 service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25)'
635 service_types_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)'
637 class ChannelSelectionBase(Screen):
638 def __init__(self, session):
639 Screen.__init__(self, session)
641 self["key_red"] = Button(_("All"))
642 self["key_green"] = Button(_("Satellites"))
643 self["key_yellow"] = Button(_("Provider"))
644 self["key_blue"] = Button(_("Favourites"))
646 self["list"] = ServiceList()
647 self.servicelist = self["list"]
649 self.numericalTextInput = NumericalTextInput()
650 self.numericalTextInput.setUseableChars(u'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
652 self.servicePathTV = [ ]
653 self.servicePathRadio = [ ]
654 self.servicePath = [ ]
658 self.pathChangeDisabled = False
660 self.bouquetNumOffsetCache = { }
662 self["ChannelSelectBaseActions"] = NumberActionMap(["ChannelSelectBaseActions", "NumberActions", "InputAsciiActions"],
664 "showFavourites": self.showFavourites,
665 "showAllServices": self.showAllServices,
666 "showProviders": self.showProviders,
667 "showSatellites": self.showSatellites,
668 "nextBouquet": self.nextBouquet,
669 "prevBouquet": self.prevBouquet,
670 "nextMarker": self.nextMarker,
671 "prevMarker": self.prevMarker,
672 "gotAsciiCode": self.keyAsciiCode,
673 "1": self.keyNumberGlobal,
674 "2": self.keyNumberGlobal,
675 "3": self.keyNumberGlobal,
676 "4": self.keyNumberGlobal,
677 "5": self.keyNumberGlobal,
678 "6": self.keyNumberGlobal,
679 "7": self.keyNumberGlobal,
680 "8": self.keyNumberGlobal,
681 "9": self.keyNumberGlobal,
684 self.recallBouquetMode()
686 def getBouquetNumOffset(self, bouquet):
687 if not config.usage.multibouquet.value:
689 str = bouquet.toString()
691 if not self.bouquetNumOffsetCache.has_key(str):
692 serviceHandler = eServiceCenter.getInstance()
693 bouquetlist = serviceHandler.list(self.bouquet_root)
694 if not bouquetlist is None:
696 bouquetIterator = bouquetlist.getNext()
697 if not bouquetIterator.valid(): #end of list
699 self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
700 if not (bouquetIterator.flags & eServiceReference.isDirectory):
702 servicelist = serviceHandler.list(bouquetIterator)
703 if not servicelist is None:
705 serviceIterator = servicelist.getNext()
706 if not serviceIterator.valid(): #check if end of list
708 playable = not (serviceIterator.flags & (eServiceReference.isDirectory|eServiceReference.isMarker))
711 return self.bouquetNumOffsetCache.get(str, offsetCount)
713 def recallBouquetMode(self):
714 if self.mode == MODE_TV:
715 self.service_types = service_types_tv
716 if config.usage.multibouquet.value:
717 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
719 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
721 self.service_types = service_types_radio
722 if config.usage.multibouquet.value:
723 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
725 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
726 self.bouquet_root = eServiceReference(self.bouquet_rootstr)
730 self.servicePath = self.servicePathTV
731 self.recallBouquetMode()
732 title = self.instance.getTitle()
733 pos = title.find(" (")
739 def setRadioMode(self):
740 self.mode = MODE_RADIO
741 self.servicePath = self.servicePathRadio
742 self.recallBouquetMode()
743 title = self.instance.getTitle()
744 pos = title.find(" (")
750 def setRoot(self, root, justSet=False):
751 path = root.getPath()
752 inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
753 pos = path.find('FROM BOUQUET')
754 isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
755 if not inBouquetRootList and isBouquet:
756 self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
757 self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
759 self.servicelist.setMode(ServiceList.MODE_NORMAL)
760 self.servicelist.setRoot(root, justSet)
761 self.buildTitleString()
763 def removeModeStr(self, str):
764 if self.mode == MODE_TV:
765 pos = str.find(' (TV)')
767 pos = str.find(' (Radio)')
772 def getServiceName(self, ref):
773 str = self.removeModeStr(ServiceReference(ref).getServiceName())
775 pathstr = ref.getPath()
776 if pathstr.find('FROM PROVIDERS') != -1:
778 if pathstr.find('FROM SATELLITES') != -1:
779 return _("Satellites")
780 if pathstr.find(') ORDER BY name') != -1:
784 def buildTitleString(self):
785 titleStr = self.instance.getTitle()
786 pos = titleStr.find(']')
788 pos = titleStr.find(')')
790 titleStr = titleStr[:pos+1]
791 Len = len(self.servicePath)
793 base_ref = self.servicePath[0]
795 end_ref = self.servicePath[Len-1]
798 nameStr = self.getServiceName(base_ref)
799 titleStr += ' ' + nameStr
800 if end_ref is not None:
805 nameStr = self.getServiceName(end_ref)
807 self.setTitle(titleStr)
810 self.servicelist.moveUp()
813 self.servicelist.moveDown()
816 del self.servicePath[:]
818 def enterPath(self, ref, justSet=False):
819 self.servicePath.append(ref)
820 self.setRoot(ref, justSet)
822 def pathUp(self, justSet=False):
823 prev = self.servicePath.pop()
824 length = len(self.servicePath)
826 current = self.servicePath[length-1]
827 self.setRoot(current, justSet)
829 self.setCurrentSelection(prev)
832 def isBasePathEqual(self, ref):
833 if len(self.servicePath) > 1 and self.servicePath[0] == ref:
837 def isPrevPathEqual(self, ref):
838 length = len(self.servicePath)
839 if length > 1 and self.servicePath[length-2] == ref:
843 def preEnterPath(self, refstr):
846 def showAllServices(self):
847 if not self.pathChangeDisabled:
848 refstr = '%s ORDER BY name'%(self.service_types)
849 if not self.preEnterPath(refstr):
850 ref = eServiceReference(refstr)
851 currentRoot = self.getRoot()
852 if currentRoot is None or currentRoot != ref:
856 def showSatellites(self):
857 if not self.pathChangeDisabled:
858 refstr = '%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types)
859 if not self.preEnterPath(refstr):
860 ref = eServiceReference(refstr)
864 if self.isBasePathEqual(ref):
865 if self.isPrevPathEqual(ref):
867 prev = self.pathUp(justSet)
869 currentRoot = self.getRoot()
870 if currentRoot is None or currentRoot != ref:
873 self.enterPath(ref, True)
875 serviceHandler = eServiceCenter.getInstance()
876 servicelist = serviceHandler.list(ref)
877 if not servicelist is None:
879 service = servicelist.getNext()
880 if not service.valid(): #check if end of list
882 unsigned_orbpos = service.getUnsignedData(4) >> 16
883 orbpos = service.getData(4) >> 16
886 if service.getPath().find("FROM PROVIDER") != -1:
887 service_type = _("Providers")
888 elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
889 service_type = _("New")
891 service_type = _("Services")
893 # why we need this cast?
894 service_name = str(nimmanager.getSatDescription(orbpos))
896 if unsigned_orbpos == 0xFFFF: #Cable
897 service_name = _("Cable")
898 elif unsigned_orbpos == 0xEEEE: #Terrestrial
899 service_name = _("Terrestrial")
901 if orbpos > 1800: # west
902 orbpos = 3600 - orbpos
906 service_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
907 service.setName("%s - %s" % (service_name, service_type))
908 self.servicelist.addService(service)
909 cur_ref = self.session.nav.getCurrentlyPlayingServiceReference()
911 pos = self.service_types.rfind(':')
912 refstr = '%s (channelID == %08x%04x%04x) && %s ORDER BY name' %(self.service_types[:pos+1],
913 cur_ref.getUnsignedData(4), # NAMESPACE
914 cur_ref.getUnsignedData(2), # TSID
915 cur_ref.getUnsignedData(3), # ONID
916 self.service_types[pos+1:])
917 ref = eServiceReference(refstr)
918 ref.setName(_("Current Transponder"))
919 self.servicelist.addService(ref)
920 self.servicelist.finishFill()
922 self.setCurrentSelection(prev)
924 def showProviders(self):
925 if not self.pathChangeDisabled:
926 refstr = '%s FROM PROVIDERS ORDER BY name'%(self.service_types)
927 if not self.preEnterPath(refstr):
928 ref = eServiceReference(refstr)
929 if self.isBasePathEqual(ref):
932 currentRoot = self.getRoot()
933 if currentRoot is None or currentRoot != ref:
937 def changeBouquet(self, direction):
938 if not self.pathChangeDisabled:
939 if len(self.servicePath) > 1:
940 #when enter satellite root list we must do some magic stuff..
941 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
942 if self.isBasePathEqual(ref):
943 self.showSatellites()
950 ref = self.getCurrentSelection()
954 if len(self.servicePath) > 0 and self.servicePath[0] == self.bouquet_root:
959 return self.servicelist.atBegin()
962 return self.servicelist.atEnd()
964 def nextBouquet(self):
965 self.changeBouquet(+1)
967 def prevBouquet(self):
968 self.changeBouquet(-1)
970 def showFavourites(self):
971 if not self.pathChangeDisabled:
972 if not self.preEnterPath(self.bouquet_rootstr):
973 if self.isBasePathEqual(self.bouquet_root):
976 currentRoot = self.getRoot()
977 if currentRoot is None or currentRoot != self.bouquet_root:
979 self.enterPath(self.bouquet_root)
981 def keyNumberGlobal(self, number):
982 unichar = self.numericalTextInput.getKey(number)
983 charstr = unichar.encode("utf-8")
984 if len(charstr) == 1:
985 self.servicelist.moveToChar(charstr[0])
987 def keyAsciiCode(self):
988 unichar = unichr(getPrevAsciiCode())
989 charstr = unichar.encode("utf-8")
990 if len(charstr) == 1:
991 self.servicelist.moveToChar(charstr[0])
994 return self.servicelist.getRoot()
996 def getCurrentSelection(self):
997 return self.servicelist.getCurrent()
999 def setCurrentSelection(self, service):
1000 servicepath = service.getPath()
1001 pos = servicepath.find(" FROM BOUQUET")
1003 if self.mode == MODE_TV:
1004 servicepath = '(type == 1)' + servicepath[pos:]
1006 servicepath = '(type == 2)' + servicepath[pos:]
1007 service.setPath(servicepath)
1008 self.servicelist.setCurrent(service)
1010 def getBouquetList(self):
1012 serviceHandler = eServiceCenter.getInstance()
1013 if config.usage.multibouquet.value:
1014 list = serviceHandler.list(self.bouquet_root)
1020 if s.flags & eServiceReference.isDirectory:
1021 info = serviceHandler.info(s)
1023 bouquets.append((info.getName(s), s))
1026 info = serviceHandler.info(self.bouquet_root)
1028 bouquets.append((info.getName(self.bouquet_root), self.bouquet_root))
1032 def keyNumber0(self, num):
1033 if len(self.servicePath) > 1:
1036 self.keyNumberGlobal(num)
1039 if len(self.servicePath) > 1:
1040 if self.isBasePathEqual(self.bouquet_root):
1041 self.showFavourites()
1043 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
1044 if self.isBasePathEqual(ref):
1045 self.showSatellites()
1047 ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
1048 if self.isBasePathEqual(ref):
1049 self.showProviders()
1051 self.showAllServices()
1053 def nextMarker(self):
1054 self.servicelist.moveToNextMarker()
1056 def prevMarker(self):
1057 self.servicelist.moveToPrevMarker()
1061 #config for lastservice
1062 config.tv = ConfigSubsection()
1063 config.tv.lastservice = ConfigText()
1064 config.tv.lastroot = ConfigText()
1065 config.radio = ConfigSubsection()
1066 config.radio.lastservice = ConfigText()
1067 config.radio.lastroot = ConfigText()
1068 config.servicelist = ConfigSubsection()
1069 config.servicelist.lastmode = ConfigText(default = "tv")
1071 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, SelectionEventInfo):
1072 def __init__(self, session):
1073 ChannelSelectionBase.__init__(self,session)
1074 ChannelSelectionEdit.__init__(self)
1075 ChannelSelectionEPG.__init__(self)
1076 SelectionEventInfo.__init__(self)
1078 self["CurrentTime"] = ObsoleteSource(new_source = "global.CurrentTime", removal_date = "2008-01")
1080 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1082 "cancel": self.cancel,
1083 "ok": self.channelSelected,
1084 "keyRadio": self.setModeRadio,
1085 "keyTV": self.setModeTv,
1088 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1090 iPlayableService.evStart: self.__evServiceStart,
1091 iPlayableService.evEnd: self.__evServiceEnd
1094 self.lastChannelRootTimer = eTimer()
1095 self.lastChannelRootTimer.callback.append(self.__onCreate)
1096 self.lastChannelRootTimer.start(100,True)
1098 self.history_tv = [ ]
1099 self.history_radio = [ ]
1100 self.history = self.history_tv
1101 self.history_pos = 0
1103 self.lastservice = config.tv.lastservice
1104 self.lastroot = config.tv.lastroot
1105 self.revertMode = None
1106 config.usage.multibouquet.addNotifier(self.multibouquet_config_changed)
1107 self.new_service_played = False
1108 self.onExecBegin.append(self.asciiOn)
1111 rcinput = eRCInput.getInstance()
1112 rcinput.setKeyboardMode(rcinput.kmAscii)
1115 rcinput = eRCInput.getInstance()
1116 rcinput.setKeyboardMode(rcinput.kmNone)
1118 def multibouquet_config_changed(self, val):
1119 self.recallBouquetMode()
1121 def __evServiceStart(self):
1122 service = self.session.nav.getCurrentService()
1124 info = service.info()
1126 refstr = info.getInfoString(iServiceInformation.sServiceref)
1127 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1129 def __evServiceEnd(self):
1130 self.servicelist.setPlayableIgnoreService(eServiceReference())
1134 lastservice=eServiceReference(self.lastservice.value)
1135 if lastservice.valid():
1136 self.setCurrentSelection(lastservice)
1138 def setModeTv(self):
1139 if self.revertMode is None and config.servicelist.lastmode.value == "radio":
1140 self.revertMode = MODE_RADIO
1141 self.history = self.history_tv
1142 self.lastservice = config.tv.lastservice
1143 self.lastroot = config.tv.lastroot
1144 config.servicelist.lastmode.value = "tv"
1148 def setModeRadio(self):
1149 if self.revertMode is None and config.servicelist.lastmode.value == "tv":
1150 self.revertMode = MODE_TV
1151 if config.usage.e1like_radio_mode.value:
1152 self.history = self.history_radio
1153 self.lastservice = config.radio.lastservice
1154 self.lastroot = config.radio.lastroot
1155 config.servicelist.lastmode.value = "radio"
1159 def __onCreate(self):
1160 if config.usage.e1like_radio_mode.value:
1161 if config.servicelist.lastmode.value == "tv":
1167 lastservice=eServiceReference(self.lastservice.value)
1168 if lastservice.valid():
1171 def channelSelected(self):
1172 ref = self.getCurrentSelection()
1174 self.toggleMoveMarked()
1175 elif (ref.flags & 7) == 7:
1177 elif self.bouquet_mark_edit != OFF:
1178 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1180 elif not (ref.flags & eServiceReference.isMarker): # no marker
1181 root = self.getRoot()
1182 if not root or not (root.flags & eServiceReference.isGroup):
1187 #called from infoBar and channelSelected
1189 self.revertMode=None
1190 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1191 nref = self.getCurrentSelection()
1192 if ref is None or ref != nref:
1193 self.new_service_played = True
1194 self.session.nav.playService(nref)
1196 self.saveChannel(nref)
1197 config.servicelist.lastmode.save()
1198 self.addToHistory(nref)
1200 def newServicePlayed(self):
1201 ret = self.new_service_played
1202 self.new_service_played = False
1205 def addToHistory(self, ref):
1206 if self.servicePath is not None:
1207 tmp=self.servicePath[:]
1210 del self.history[self.history_pos+1:]
1213 self.history.append(tmp)
1214 hlen = len(self.history)
1215 if hlen > HISTORYSIZE:
1218 self.history_pos = hlen-1
1220 def historyBack(self):
1221 hlen = len(self.history)
1222 if hlen > 1 and self.history_pos > 0:
1223 self.history_pos -= 1
1224 self.setHistoryPath()
1226 def historyNext(self):
1227 hlen = len(self.history)
1228 if hlen > 1 and self.history_pos < (hlen-1):
1229 self.history_pos += 1
1230 self.setHistoryPath()
1232 def setHistoryPath(self):
1233 path = self.history[self.history_pos][:]
1235 del self.servicePath[:]
1236 self.servicePath += path
1240 cur_root = self.getRoot()
1241 if cur_root and cur_root != root:
1243 self.session.nav.playService(ref)
1244 self.setCurrentSelection(ref)
1245 self.saveChannel(ref)
1249 for i in self.servicePath:
1250 path += i.toString()
1252 if len(path) and path != self.lastroot.value:
1253 self.lastroot.value = path
1254 self.lastroot.save()
1256 def restoreRoot(self):
1258 re = compile('.+?;')
1259 tmp = re.findall(self.lastroot.value)
1262 self.servicePath.append(eServiceReference(i[:len(i)-1]))
1265 path = self.servicePath.pop()
1266 self.enterPath(path)
1268 self.showFavourites()
1271 def preEnterPath(self, refstr):
1272 if len(self.servicePath) and self.servicePath[0] != eServiceReference(refstr):
1273 pathstr = self.lastroot.value
1274 if pathstr is not None and pathstr.find(refstr) == 0:
1276 lastservice=eServiceReference(self.lastservice.value)
1277 if lastservice.valid():
1278 self.setCurrentSelection(lastservice)
1282 def saveChannel(self, ref):
1284 refstr = ref.toString()
1287 if refstr != self.lastservice.value:
1288 self.lastservice.value = refstr
1289 self.lastservice.save()
1291 def setCurrentServicePath(self, path):
1292 hlen = len(self.history)
1294 self.history[self.history_pos] = path
1296 self.history.append(path)
1297 self.setHistoryPath()
1299 def getCurrentServicePath(self):
1300 hlen = len(self.history)
1302 return self.history[self.history_pos]
1305 def recallPrevService(self):
1306 hlen = len(self.history)
1308 if self.history_pos == hlen-1:
1309 tmp = self.history[self.history_pos]
1310 self.history[self.history_pos] = self.history[self.history_pos-1]
1311 self.history[self.history_pos-1] = tmp
1313 tmp = self.history[self.history_pos+1]
1314 self.history[self.history_pos+1] = self.history[self.history_pos]
1315 self.history[self.history_pos] = tmp
1316 self.setHistoryPath()
1319 if self.revertMode is None:
1321 lastservice=eServiceReference(self.lastservice.value)
1322 if lastservice.valid() and self.getCurrentSelection() != lastservice:
1323 self.setCurrentSelection(lastservice)
1324 elif self.revertMode == MODE_TV:
1326 elif self.revertMode == MODE_RADIO:
1328 self.revertMode = None
1332 from Screens.InfoBarGenerics import InfoBarEvent, InfoBarServiceName
1334 class RadioInfoBar(Screen, InfoBarEvent, InfoBarServiceName):
1335 def __init__(self, session):
1336 Screen.__init__(self, session)
1337 InfoBarEvent.__init__(self)
1338 InfoBarServiceName.__init__(self)
1339 self["CurrentTime"] = ObsoleteSource(new_source = "global.CurrentTime", removal_date = "2008-01")
1340 self["RdsDecoder"] = RdsDecoder(self.session.nav)
1341 self["BlinkingPoint"] = Pixmap()
1342 self["BlinkingPoint"].hide()
1344 class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
1345 ALLOW_SUSPEND = True
1347 def __init__(self, session, infobar):
1348 ChannelSelectionBase.__init__(self, session)
1349 ChannelSelectionEdit.__init__(self)
1350 ChannelSelectionEPG.__init__(self)
1351 self.infobar = infobar
1352 self.onLayoutFinish.append(self.onCreate)
1354 self.info = session.instantiateDialog(RadioInfoBar) # our simple infobar
1356 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1358 "keyTV": self.closeRadio,
1359 "keyRadio": self.closeRadio,
1360 "cancel": self.closeRadio,
1361 "ok": self.channelSelected,
1364 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1366 iPlayableService.evStart: self.__evServiceStart,
1367 iPlayableService.evEnd: self.__evServiceEnd
1370 ########## RDS Radiotext / Rass Support BEGIN
1371 self.infobar = infobar # reference to real infobar (the one and only)
1372 self["RdsDecoder"] = self.info["RdsDecoder"]
1373 self["RdsActions"] = HelpableActionMap(self, "InfobarRdsActions",
1375 "startRassInteractive": (self.startRassInteractive, _("View Rass interactive..."))
1377 self["RdsActions"].setEnabled(False)
1378 infobar.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
1380 def startRassInteractive(self):
1382 self.infobar.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
1384 def RassInteractiveClosed(self):
1386 self.infobar.rass_interactive = None
1387 self.infobar.RassSlidePicChanged()
1389 def RassInteractivePossibilityChanged(self, state):
1390 self["RdsActions"].setEnabled(state)
1391 ########## RDS Radiotext / Rass Support END
1393 def closeRadio(self):
1394 self.infobar.rds_display.onRassInteractivePossibilityChanged.remove(self.RassInteractivePossibilityChanged)
1396 #set previous tv service
1397 lastservice=eServiceReference(config.tv.lastservice.value)
1398 self.session.nav.playService(lastservice)
1401 def __evServiceStart(self):
1402 service = self.session.nav.getCurrentService()
1404 info = service.info()
1406 refstr = info.getInfoString(iServiceInformation.sServiceref)
1407 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1409 def __evServiceEnd(self):
1410 self.servicelist.setPlayableIgnoreService(eServiceReference())
1414 for i in self.servicePathRadio:
1415 path += i.toString()
1417 if len(path) and path != config.radio.lastroot.value:
1418 config.radio.lastroot.value = path
1419 config.radio.lastroot.save()
1421 def restoreRoot(self):
1423 re = compile('.+?;')
1424 tmp = re.findall(config.radio.lastroot.value)
1427 self.servicePathRadio.append(eServiceReference(i[:len(i)-1]))
1430 path = self.servicePathRadio.pop()
1431 self.enterPath(path)
1433 self.showFavourites()
1436 def preEnterPath(self, refstr):
1437 if len(self.servicePathRadio) and self.servicePathRadio[0] != eServiceReference(refstr):
1438 pathstr = config.radio.lastroot.value
1439 if pathstr is not None and pathstr.find(refstr) == 0:
1441 lastservice=eServiceReference(config.radio.lastservice.value)
1442 if lastservice.valid():
1443 self.setCurrentSelection(lastservice)
1450 lastservice=eServiceReference(config.radio.lastservice.value)
1451 if lastservice.valid():
1452 self.servicelist.setCurrent(lastservice)
1453 self.session.nav.playService(lastservice)
1455 self.session.nav.stopService()
1458 def channelSelected(self): # just return selected service
1459 ref = self.getCurrentSelection()
1461 self.toggleMoveMarked()
1462 elif (ref.flags & 7) == 7:
1464 elif self.bouquet_mark_edit != OFF:
1465 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1467 elif not (ref.flags & eServiceReference.isMarker): # no marker
1468 cur_root = self.getRoot()
1469 if not cur_root or not (cur_root.flags & eServiceReference.isGroup):
1470 playingref = self.session.nav.getCurrentlyPlayingServiceReference()
1471 if playingref is None or playingref != ref:
1472 self.session.nav.playService(ref)
1473 config.radio.lastservice.value = ref.toString()
1474 config.radio.lastservice.save()
1477 class SimpleChannelSelection(ChannelSelectionBase):
1478 def __init__(self, session, title):
1479 ChannelSelectionBase.__init__(self, session)
1481 self.onShown.append(self.__onExecCallback)
1483 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1485 "cancel": self.close,
1486 "ok": self.channelSelected,
1487 "keyRadio": self.setModeRadio,
1488 "keyTV": self.setModeTv,
1491 def __onExecCallback(self):
1492 self.setTitle(self.title)
1495 def channelSelected(self): # just return selected service
1496 ref = self.getCurrentSelection()
1497 if (ref.flags & 7) == 7:
1499 elif not (ref.flags & eServiceReference.isMarker):
1500 ref = self.getCurrentSelection()
1503 def setModeTv(self):
1505 self.showFavourites()
1507 def setModeRadio(self):
1509 self.showFavourites()