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 Components.ChoiceList import ChoiceList, ChoiceEntryComponent
25 from Components.SystemInfo import SystemInfo
26 from Screens.InputBox import InputBox, PinInput
27 from Screens.MessageBox import MessageBox
28 from Screens.ServiceInfo import ServiceInfo
29 profile("ChannelSelection.py 4")
30 from Screens.PictureInPicture import PictureInPicture
31 from Screens.RdsDisplay import RassInteractive
32 from ServiceReference import ServiceReference
33 from Tools.BoundFunction import boundFunction
35 profile("ChannelSelection.py after imports")
37 FLAG_SERVICE_NEW_FOUND = 64 #define in lib/dvb/idvb.h as dxNewFound = 64
39 class BouquetSelector(Screen):
40 def __init__(self, session, bouquets, selectedFunc, enableWrapAround=False):
41 Screen.__init__(self, session)
43 self.selectedFunc=selectedFunc
45 self["actions"] = ActionMap(["OkCancelActions"],
47 "ok": self.okbuttonClick,
48 "cancel": self.cancelClick
50 entrys = [ (x[0], x[1]) for x in bouquets ]
51 self["menu"] = MenuList(entrys, enableWrapAround)
54 cur = self["menu"].getCurrent()
57 def okbuttonClick(self):
58 self.selectedFunc(self.getCurrent())
66 def cancelClick(self):
69 # csel.bouquet_mark_edit values
74 def append_when_current_valid(current, menu, args, level = 0, key = ""):
75 if current and current.valid() and level <= config.usage.setup_level.index:
76 menu.append(ChoiceEntryComponent(key, args))
78 class ChannelContextMenu(Screen):
79 def __init__(self, session, csel):
80 Screen.__init__(self, session)
81 #raise Exception("we need a better summary screen here")
85 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "NumberActions"],
87 "ok": self.okbuttonClick,
88 "cancel": self.cancelClick,
89 "blue": self.showServiceInPiP
93 self.pipAvailable = False
94 current = csel.getCurrentSelection()
95 current_root = csel.getRoot()
96 current_sel_path = current.getPath()
97 current_sel_flags = current.flags
98 inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
99 inBouquet = csel.getMutableList() is not None
100 haveBouquets = config.usage.multibouquet.value
102 if not (current_sel_path or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
103 append_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations), level = 2)
104 if csel.bouquet_mark_edit == OFF and not csel.movemode:
105 if not inBouquetRootList:
106 isPlayable = not (current_sel_flags & (eServiceReference.isMarker|eServiceReference.isDirectory))
108 if config.ParentalControl.configured.value:
109 if parentalControl.getProtectionLevel(csel.getCurrentSelection().toCompareString()) == -1:
110 append_when_current_valid(current, menu, (_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())), level = 0)
112 append_when_current_valid(current, menu, (_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())), level = 0)
114 append_when_current_valid(current, menu, (_("add service to bouquet"), self.addServiceToBouquetSelected), level = 0)
116 append_when_current_valid(current, menu, (_("add service to favourites"), self.addServiceToBouquetSelected), level = 0)
118 if current_root.getPath().find('FROM SATELLITES') != -1:
119 append_when_current_valid(current, menu, (_("remove selected satellite"), self.removeSatelliteServices), level = 0)
121 if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
122 append_when_current_valid(current, menu, (_("copy to bouquets"), self.copyCurrentToBouquetList), level = 0)
123 if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
124 append_when_current_valid(current, menu, (_("remove all new found flags"), self.removeAllNewFoundFlags), level = 0)
126 append_when_current_valid(current, menu, (_("remove entry"), self.removeCurrentService), level = 0)
127 if current_root and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
128 append_when_current_valid(current, menu, (_("remove new found flag"), self.removeNewFoundFlag), level = 0)
129 if isPlayable and SystemInfo.get("NumVideoDecoders", 1) > 1:
130 append_when_current_valid(current, menu, (_("Activate Picture in Picture"), self.showServiceInPiP), level = 0, key = "blue")
131 self.pipAvailable = True
133 menu.append(ChoiceEntryComponent(text = (_("add bouquet"), self.showBouquetInputBox)))
134 append_when_current_valid(current, menu, (_("remove entry"), self.removeBouquet), level = 0)
136 if inBouquet: # current list is editable?
137 if csel.bouquet_mark_edit == OFF:
138 if not csel.movemode:
139 append_when_current_valid(current, menu, (_("enable move mode"), self.toggleMoveMode), level = 1)
140 if not inBouquetRootList and current_root and not (current_root.flags & eServiceReference.isGroup):
141 menu.append(ChoiceEntryComponent(text = (_("add marker"), self.showMarkerInputBox)))
143 append_when_current_valid(current, menu, (_("enable bouquet edit"), self.bouquetMarkStart), level = 0)
145 append_when_current_valid(current, menu, (_("enable favourite edit"), self.bouquetMarkStart), level = 0)
146 if current_sel_flags & eServiceReference.isGroup:
147 append_when_current_valid(current, menu, (_("edit alternatives"), self.editAlternativeServices), level = 2)
148 append_when_current_valid(current, menu, (_("show alternatives"), self.showAlternativeServices), level = 2)
149 append_when_current_valid(current, menu, (_("remove all alternatives"), self.removeAlternativeServices), level = 2)
150 elif not current_sel_flags & eServiceReference.isMarker:
151 append_when_current_valid(current, menu, (_("add alternatives"), self.addAlternativeServices), level = 2)
153 append_when_current_valid(current, menu, (_("disable move mode"), self.toggleMoveMode), level = 0)
155 if csel.bouquet_mark_edit == EDIT_BOUQUET:
157 append_when_current_valid(current, menu, (_("end bouquet edit"), self.bouquetMarkEnd), level = 0)
158 append_when_current_valid(current, menu, (_("abort bouquet edit"), self.bouquetMarkAbort), level = 0)
160 append_when_current_valid(current, menu, (_("end favourites edit"), self.bouquetMarkEnd), level = 0)
161 append_when_current_valid(current, menu, (_("abort favourites edit"), self.bouquetMarkAbort), level = 0)
163 append_when_current_valid(current, menu, (_("end alternatives edit"), self.bouquetMarkEnd), level = 0)
164 append_when_current_valid(current, menu, (_("abort alternatives edit"), self.bouquetMarkAbort), level = 0)
166 menu.append(ChoiceEntryComponent(text = (_("back"), self.cancelClick)))
167 self["menu"] = ChoiceList(menu)
169 def okbuttonClick(self):
170 self["menu"].getCurrent()[0][1]()
172 def cancelClick(self):
175 def showServiceInformations(self):
176 self.session.open( ServiceInfo, self.csel.getCurrentSelection() )
178 def showBouquetInputBox(self):
179 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)
181 def bouquetInputCallback(self, bouquet):
182 if bouquet is not None:
183 self.csel.addBouquet(bouquet, None)
186 def addParentalProtection(self, service):
187 parentalControl.protectService(service.toCompareString())
190 def removeParentalProtection(self, service):
191 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"))
193 def pinEntered(self, service, result):
195 parentalControl.unProtectService(service)
198 self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
200 def showServiceInPiP(self):
201 if not self.pipAvailable:
203 if self.session.pipshown:
205 self.session.pip = self.session.instantiateDialog(PictureInPicture)
206 self.session.pip.show()
207 newservice = self.csel.servicelist.getCurrent()
208 if self.session.pip.playService(newservice):
209 self.session.pipshown = True
210 self.session.pip.servicePath = self.csel.getCurrentServicePath()
213 self.session.pipshown = False
215 self.session.openWithCallback(self.close, MessageBox, _("Could not open Picture in Picture"), MessageBox.TYPE_ERROR)
217 def addServiceToBouquetSelected(self):
218 bouquets = self.csel.getBouquetList()
223 if cnt > 1: # show bouquet list
224 self.bsel = self.session.openWithCallback(self.bouquetSelClosed, BouquetSelector, bouquets, self.addCurrentServiceToBouquet)
225 elif cnt == 1: # add to only one existing bouquet
226 self.addCurrentServiceToBouquet(bouquets[0][1])
228 def bouquetSelClosed(self, recursive):
233 def removeSatelliteServices(self):
234 curpath = self.csel.getCurrentSelection().getPath()
235 idx = curpath.find("satellitePosition == ")
237 tmp = curpath[idx+21:]
240 satpos = int(tmp[:idx])
241 eDVBDB.getInstance().removeServices(-1, -1, -1, satpos)
244 def copyCurrentToBouquetList(self):
245 self.csel.copyCurrentToBouquetList()
248 def removeBouquet(self):
249 self.csel.removeBouquet()
252 def showMarkerInputBox(self):
253 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)
255 def markerInputCallback(self, marker):
256 if marker is not None:
257 self.csel.addMarker(marker)
260 def addCurrentServiceToBouquet(self, dest):
261 self.csel.addServiceToBouquet(dest)
262 if self.bsel is not None:
263 self.bsel.close(True)
265 self.close(True) # close bouquet selection
267 def removeCurrentService(self):
268 self.csel.removeCurrentService()
271 def toggleMoveMode(self):
272 self.csel.toggleMoveMode()
275 def bouquetMarkStart(self):
276 self.csel.startMarkedEdit(EDIT_BOUQUET)
279 def bouquetMarkEnd(self):
280 self.csel.endMarkedEdit(abort=False)
283 def bouquetMarkAbort(self):
284 self.csel.endMarkedEdit(abort=True)
287 def removeNewFoundFlag(self):
288 eDVBDB.getInstance().removeFlag(self.csel.getCurrentSelection(), FLAG_SERVICE_NEW_FOUND)
291 def removeAllNewFoundFlags(self):
292 curpath = self.csel.getCurrentSelection().getPath()
293 idx = curpath.find("satellitePosition == ")
295 tmp = curpath[idx+21:]
298 satpos = int(tmp[:idx])
299 eDVBDB.getInstance().removeFlags(FLAG_SERVICE_NEW_FOUND, -1, -1, -1, satpos)
302 def editAlternativeServices(self):
303 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
306 def showAlternativeServices(self):
307 self.csel.enterPath(self.csel.getCurrentSelection())
310 def removeAlternativeServices(self):
311 self.csel.removeAlternativeServices()
314 def addAlternativeServices(self):
315 self.csel.addAlternativeServices()
316 self.csel.startMarkedEdit(EDIT_ALTERNATIVES)
319 class SelectionEventInfo:
321 self["ServiceEvent"] = ServiceEvent()
322 self.servicelist.connectSelChanged(self.__selectionChanged)
323 self.timer = eTimer()
324 self.timer.callback.append(self.updateEventInfo)
325 self.onShown.append(self.__selectionChanged)
327 def __selectionChanged(self):
329 self.timer.start(100, True)
331 def updateEventInfo(self):
332 cur = self.getCurrentSelection()
333 self["ServiceEvent"].newService(cur)
335 class ChannelSelectionEPG:
337 self["ChannelSelectEPGActions"] = ActionMap(["ChannelSelectEPGActions"],
339 "showEPGList": self.showEPGList,
342 def showEPGList(self):
343 ref=self.getCurrentSelection()
345 self.savedService = ref
346 self.session.openWithCallback(self.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB=self.changeServiceCB)
348 def SingleServiceEPGClosed(self, ret=False):
349 self.setCurrentSelection(self.savedService)
351 def changeServiceCB(self, direction, epg):
352 beg = self.getCurrentSelection()
358 cur = self.getCurrentSelection()
359 if cur == beg or not (cur.flags & eServiceReference.isMarker):
361 epg.setService(ServiceReference(self.getCurrentSelection()))
363 class ChannelSelectionEdit:
365 self.entry_marked = False
366 self.movemode = False
367 self.bouquet_mark_edit = OFF
368 self.mutableList = None
370 self.saved_title = None
371 self.saved_root = None
373 class ChannelSelectionEditActionMap(ActionMap):
374 def __init__(self, csel, contexts = [ ], actions = { }, prio=0):
375 ActionMap.__init__(self, contexts, actions, prio)
378 def action(self, contexts, action):
379 if action == "cancel":
380 self.csel.handleEditCancel()
381 return 0 # fall-trough
383 return 0 # fall-trough
385 return ActionMap.action(self, contexts, action)
387 self["ChannelSelectEditActions"] = ChannelSelectionEditActionMap(self, ["ChannelSelectEditActions", "OkCancelActions"],
389 "contextMenu": self.doContext,
392 def getMutableList(self, root=eServiceReference()):
393 if not self.mutableList is None:
394 return self.mutableList
395 serviceHandler = eServiceCenter.getInstance()
398 list = root and serviceHandler.list(root)
400 return list.startEdit()
403 def buildBouquetID(self, str):
407 if (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9'):
413 def addMarker(self, name):
414 current = self.servicelist.getCurrent()
415 mutableList = self.getMutableList()
418 str = '1:64:%d:0:0:0:0:0:0:0::%s'%(cnt, name)
419 ref = eServiceReference(str)
420 if current and current.valid():
421 if not mutableList.addService(ref, current):
422 self.servicelist.addService(ref, True)
423 mutableList.flushChanges()
425 elif not mutableList.addService(ref):
426 self.servicelist.addService(ref, True)
427 mutableList.flushChanges()
431 def addAlternativeServices(self):
432 cur_service = ServiceReference(self.getCurrentSelection())
433 root = self.getRoot()
434 cur_root = root and ServiceReference(root)
435 mutableBouquet = cur_root.list().startEdit()
437 name = cur_service.getServiceName()
439 if self.mode == MODE_TV:
440 str = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(name))
442 str = '1:134:2:0:0:0:0:0:0:0:FROM BOUQUET \"alternatives.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(name))
443 new_ref = ServiceReference(str)
444 if not mutableBouquet.addService(new_ref.ref, cur_service.ref):
445 mutableBouquet.removeService(cur_service.ref)
446 mutableBouquet.flushChanges()
447 eDVBDB.getInstance().reloadBouquets()
448 mutableAlternatives = new_ref.list().startEdit()
449 if mutableAlternatives:
450 mutableAlternatives.setListName(name)
451 if mutableAlternatives.addService(cur_service.ref):
452 print "add", cur_service.ref.toString(), "to new alternatives failed"
453 mutableAlternatives.flushChanges()
454 self.servicelist.addService(new_ref.ref, True)
455 self.servicelist.removeCurrent()
456 self.servicelist.moveUp()
458 print "get mutable list for new created alternatives failed"
460 print "add", str, "to", cur_root.getServiceName(), "failed"
462 print "bouquetlist is not editable"
464 def addBouquet(self, bName, services):
465 serviceHandler = eServiceCenter.getInstance()
466 mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit()
467 if mutableBouquetList:
468 if self.mode == MODE_TV:
470 str = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(bName))
473 str = '1:7:2:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(bName))
474 new_bouquet_ref = eServiceReference(str)
475 if not mutableBouquetList.addService(new_bouquet_ref):
476 mutableBouquetList.flushChanges()
477 eDVBDB.getInstance().reloadBouquets()
478 mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit()
480 mutableBouquet.setListName(bName)
481 if services is not None:
482 for service in services:
483 if mutableBouquet.addService(service):
484 print "add", service.toString(), "to new bouquet failed"
485 mutableBouquet.flushChanges()
487 print "get mutable list for new created bouquet failed"
488 # do some voodoo to check if current_root is equal to bouquet_root
489 cur_root = self.getRoot();
490 str1 = cur_root and cur_root.toString()
491 pos1 = str1 and str1.find("FROM BOUQUET") or -1
492 pos2 = self.bouquet_rootstr.find("FROM BOUQUET")
493 if pos1 != -1 and pos2 != -1 and str1[pos1:] == self.bouquet_rootstr[pos2:]:
494 self.servicelist.addService(new_bouquet_ref)
496 print "add", str, "to bouquets failed"
498 print "bouquetlist is not editable"
500 def copyCurrentToBouquetList(self):
501 provider = ServiceReference(self.getCurrentSelection())
502 providerName = provider.getServiceName()
503 serviceHandler = eServiceCenter.getInstance()
504 services = serviceHandler.list(provider.ref)
505 self.addBouquet(providerName, services and services.getContent('R', True))
507 def removeAlternativeServices(self):
508 cur_service = ServiceReference(self.getCurrentSelection())
509 root = self.getRoot()
510 cur_root = root and ServiceReference(root)
511 list = cur_service.list()
512 first_in_alternative = list and list.getNext()
513 if first_in_alternative:
514 edit_root = cur_root and cur_root.list().startEdit()
516 if not edit_root.addService(first_in_alternative, cur_service.ref):
517 self.servicelist.addService(first_in_alternative, True)
519 print "couldn't add first alternative service to current root"
521 print "couldn't edit current root!!"
523 print "remove empty alternative list !!"
525 self.servicelist.moveUp()
527 def removeBouquet(self):
528 refstr = self.getCurrentSelection().toString()
529 print "removeBouquet", refstr
530 self.bouquetNumOffsetCache = { }
531 pos = refstr.find('FROM BOUQUET "')
534 refstr = refstr[pos+14:]
535 pos = refstr.find('"')
537 filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
538 self.removeCurrentService()
540 if filename is not None:
543 print "error during remove of", filename
545 # multiple marked entry stuff ( edit mode, later multiepg selection )
546 def startMarkedEdit(self, type):
547 self.savedPath = self.servicePath[:]
548 if type == EDIT_ALTERNATIVES:
549 self.enterPath(self.getCurrentSelection())
550 self.mutableList = self.getMutableList()
551 # add all services from the current list to internal marked set in listboxservicecontent
552 self.clearMarks() # this clears the internal marked set in the listboxservicecontent
553 self.saved_title = self.getTitle()
554 pos = self.saved_title.find(')')
555 new_title = self.saved_title[:pos+1]
556 if type == EDIT_ALTERNATIVES:
557 self.bouquet_mark_edit = EDIT_ALTERNATIVES
558 new_title += ' ' + _("[alternative edit]")
560 self.bouquet_mark_edit = EDIT_BOUQUET
561 if config.usage.multibouquet.value:
562 new_title += ' ' + _("[bouquet edit]")
564 new_title += ' ' + _("[favourite edit]")
565 self.setTitle(new_title)
566 self.__marked = self.servicelist.getRootServices()
567 for x in self.__marked:
568 self.servicelist.addMarked(eServiceReference(x))
569 self.showAllServices()
571 def endMarkedEdit(self, abort):
572 if not abort and self.mutableList is not None:
573 self.bouquetNumOffsetCache = { }
574 new_marked = set(self.servicelist.getMarked())
575 old_marked = set(self.__marked)
576 removed = old_marked - new_marked
577 added = new_marked - old_marked
581 self.mutableList.removeService(eServiceReference(x))
584 self.mutableList.addService(eServiceReference(x))
586 self.mutableList.flushChanges()
589 self.bouquet_mark_edit = OFF
590 self.mutableList = None
591 self.setTitle(self.saved_title)
592 self.saved_title = None
593 # self.servicePath is just a reference to servicePathTv or Radio...
594 # so we never ever do use the asignment operator in self.servicePath
595 del self.servicePath[:] # remove all elements
596 self.servicePath += self.savedPath # add saved elements
598 self.setRoot(self.servicePath[-1])
600 def clearMarks(self):
601 self.servicelist.clearMarks()
604 ref = self.servicelist.getCurrent()
605 if self.servicelist.isMarked(ref):
606 self.servicelist.removeMarked(ref)
608 self.servicelist.addMarked(ref)
610 def removeCurrentService(self):
611 ref = self.servicelist.getCurrent()
612 mutableList = self.getMutableList()
613 if ref.valid() and mutableList is not None:
614 if not mutableList.removeService(ref):
615 self.bouquetNumOffsetCache = { }
616 mutableList.flushChanges() #FIXME dont flush on each single removed service
617 self.servicelist.removeCurrent()
619 def addServiceToBouquet(self, dest, service=None):
620 mutableList = self.getMutableList(dest)
621 if not mutableList is None:
622 if service is None: #use current selected service
623 service = self.servicelist.getCurrent()
624 if not mutableList.addService(service):
625 self.bouquetNumOffsetCache = { }
626 mutableList.flushChanges()
627 # do some voodoo to check if current_root is equal to dest
628 cur_root = self.getRoot();
629 str1 = cur_root and cur_root.toString() or -1
630 str2 = dest.toString()
631 pos1 = str1.find("FROM BOUQUET")
632 pos2 = str2.find("FROM BOUQUET")
633 if pos1 != -1 and pos2 != -1 and str1[pos1:] == str2[pos2:]:
634 self.servicelist.addService(service)
636 def toggleMoveMode(self):
638 if self.entry_marked:
639 self.toggleMoveMarked() # unmark current entry
640 self.movemode = False
641 self.pathChangeDisabled = False # re-enable path change
642 self.mutableList.flushChanges() # FIXME add check if changes was made
643 self.mutableList = None
644 self.setTitle(self.saved_title)
645 self.saved_title = None
646 cur_root = self.getRoot()
647 if cur_root and cur_root == self.bouquet_root:
648 self.bouquetNumOffsetCache = { }
650 self.mutableList = self.getMutableList()
652 self.pathChangeDisabled = True # no path change allowed in movemode
653 self.saved_title = self.getTitle()
654 new_title = self.saved_title
655 pos = self.saved_title.find(')')
656 new_title = self.saved_title[:pos+1] + ' ' + _("[move mode]") + self.saved_title[pos+1:]
657 self.setTitle(new_title);
659 def handleEditCancel(self):
660 if self.movemode: #movemode active?
661 self.channelSelected() # unmark
662 self.toggleMoveMode() # disable move mode
663 elif self.bouquet_mark_edit != OFF:
664 self.endMarkedEdit(True) # abort edit mode
666 def toggleMoveMarked(self):
667 if self.entry_marked:
668 self.servicelist.setCurrentMarked(False)
669 self.entry_marked = False
671 self.servicelist.setCurrentMarked(True)
672 self.entry_marked = True
675 self.session.openWithCallback(self.exitContext, ChannelContextMenu, self)
677 def exitContext(self, close = False):
684 # type 1 = digital television service
685 # type 4 = nvod reference service (NYI)
686 # type 17 = MPEG-2 HD digital television service
687 # type 22 = advanced codec SD digital television
688 # type 24 = advanced codec SD NVOD reference service (NYI)
689 # type 25 = advanced codec HD digital television
690 # type 27 = advanced codec HD NVOD reference service (NYI)
691 # type 2 = digital radio sound service
692 # type 10 = advanced codec digital radio sound service
694 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)'
695 service_types_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2) || (type == 10)'
697 class ChannelSelectionBase(Screen):
698 def __init__(self, session):
699 Screen.__init__(self, session)
701 self["key_red"] = Button(_("All"))
702 self["key_green"] = Button(_("Satellites"))
703 self["key_yellow"] = Button(_("Provider"))
704 self["key_blue"] = Button(_("Favourites"))
706 self["list"] = ServiceList()
707 self.servicelist = self["list"]
709 self.numericalTextInput = NumericalTextInput()
710 self.numericalTextInput.setUseableChars(u'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
712 self.servicePathTV = [ ]
713 self.servicePathRadio = [ ]
714 self.servicePath = [ ]
715 self.rootChanged = False
719 self.pathChangeDisabled = False
721 self.bouquetNumOffsetCache = { }
723 self["ChannelSelectBaseActions"] = NumberActionMap(["ChannelSelectBaseActions", "NumberActions", "InputAsciiActions"],
725 "showFavourites": self.showFavourites,
726 "showAllServices": self.showAllServices,
727 "showProviders": self.showProviders,
728 "showSatellites": self.showSatellites,
729 "nextBouquet": self.nextBouquet,
730 "prevBouquet": self.prevBouquet,
731 "nextMarker": self.nextMarker,
732 "prevMarker": self.prevMarker,
733 "gotAsciiCode": self.keyAsciiCode,
734 "1": self.keyNumberGlobal,
735 "2": self.keyNumberGlobal,
736 "3": self.keyNumberGlobal,
737 "4": self.keyNumberGlobal,
738 "5": self.keyNumberGlobal,
739 "6": self.keyNumberGlobal,
740 "7": self.keyNumberGlobal,
741 "8": self.keyNumberGlobal,
742 "9": self.keyNumberGlobal,
745 self.recallBouquetMode()
747 def getBouquetNumOffset(self, bouquet):
748 if not config.usage.multibouquet.value:
750 str = bouquet.toString()
752 if not self.bouquetNumOffsetCache.has_key(str):
753 serviceHandler = eServiceCenter.getInstance()
754 bouquetlist = serviceHandler.list(self.bouquet_root)
755 if not bouquetlist is None:
757 bouquetIterator = bouquetlist.getNext()
758 if not bouquetIterator.valid(): #end of list
760 self.bouquetNumOffsetCache[bouquetIterator.toString()]=offsetCount
761 if not (bouquetIterator.flags & eServiceReference.isDirectory):
763 servicelist = serviceHandler.list(bouquetIterator)
764 if not servicelist is None:
766 serviceIterator = servicelist.getNext()
767 if not serviceIterator.valid(): #check if end of list
769 playable = not (serviceIterator.flags & (eServiceReference.isDirectory|eServiceReference.isMarker))
772 return self.bouquetNumOffsetCache.get(str, offsetCount)
774 def recallBouquetMode(self):
775 if self.mode == MODE_TV:
776 self.service_types = service_types_tv
777 if config.usage.multibouquet.value:
778 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
780 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types)
782 self.service_types = service_types_radio
783 if config.usage.multibouquet.value:
784 self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet'
786 self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types)
787 self.bouquet_root = eServiceReference(self.bouquet_rootstr)
791 self.servicePath = self.servicePathTV
792 self.recallBouquetMode()
793 title = self.getTitle()
794 pos = title.find(" (")
800 def setRadioMode(self):
801 self.mode = MODE_RADIO
802 self.servicePath = self.servicePathRadio
803 self.recallBouquetMode()
804 title = self.getTitle()
805 pos = title.find(" (")
811 def setRoot(self, root, justSet=False):
812 path = root.getPath()
813 inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
814 pos = path.find('FROM BOUQUET')
815 isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
816 if not inBouquetRootList and isBouquet:
817 self.servicelist.setMode(ServiceList.MODE_FAVOURITES)
818 self.servicelist.setNumberOffset(self.getBouquetNumOffset(root))
820 self.servicelist.setMode(ServiceList.MODE_NORMAL)
821 self.servicelist.setRoot(root, justSet)
822 self.rootChanged = True
823 self.buildTitleString()
825 def removeModeStr(self, str):
826 if self.mode == MODE_TV:
827 pos = str.find(' (TV)')
829 pos = str.find(' (Radio)')
834 def getServiceName(self, ref):
835 str = self.removeModeStr(ServiceReference(ref).getServiceName())
837 pathstr = ref.getPath()
838 if 'FROM PROVIDERS' in pathstr:
840 if 'FROM SATELLITES' in pathstr:
841 return _("Satellites")
842 if ') ORDER BY name' in pathstr:
846 def buildTitleString(self):
847 titleStr = self.getTitle()
848 pos = titleStr.find(']')
850 pos = titleStr.find(')')
852 titleStr = titleStr[:pos+1]
853 Len = len(self.servicePath)
855 base_ref = self.servicePath[0]
857 end_ref = self.servicePath[Len-1]
860 nameStr = self.getServiceName(base_ref)
861 titleStr += ' ' + nameStr
862 if end_ref is not None:
867 nameStr = self.getServiceName(end_ref)
869 self.setTitle(titleStr)
872 self.servicelist.moveUp()
875 self.servicelist.moveDown()
878 del self.servicePath[:]
880 def enterPath(self, ref, justSet=False):
881 self.servicePath.append(ref)
882 self.setRoot(ref, justSet)
884 def pathUp(self, justSet=False):
885 prev = self.servicePath.pop()
887 current = self.servicePath[-1]
888 self.setRoot(current, justSet)
890 self.setCurrentSelection(prev)
893 def isBasePathEqual(self, ref):
894 if len(self.servicePath) > 1 and self.servicePath[0] == ref:
898 def isPrevPathEqual(self, ref):
899 length = len(self.servicePath)
900 if length > 1 and self.servicePath[length-2] == ref:
904 def preEnterPath(self, refstr):
907 def showAllServices(self):
908 if not self.pathChangeDisabled:
909 refstr = '%s ORDER BY name'%(self.service_types)
910 if not self.preEnterPath(refstr):
911 ref = eServiceReference(refstr)
912 currentRoot = self.getRoot()
913 if currentRoot is None or currentRoot != ref:
917 def showSatellites(self):
918 if not self.pathChangeDisabled:
919 refstr = '%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types)
920 if not self.preEnterPath(refstr):
921 ref = eServiceReference(refstr)
925 if self.isBasePathEqual(ref):
926 if self.isPrevPathEqual(ref):
928 prev = self.pathUp(justSet)
930 currentRoot = self.getRoot()
931 if currentRoot is None or currentRoot != ref:
934 self.enterPath(ref, True)
936 serviceHandler = eServiceCenter.getInstance()
937 servicelist = serviceHandler.list(ref)
938 if not servicelist is None:
940 service = servicelist.getNext()
941 if not service.valid(): #check if end of list
943 unsigned_orbpos = service.getUnsignedData(4) >> 16
944 orbpos = service.getData(4) >> 16
947 if service.getPath().find("FROM PROVIDER") != -1:
948 service_type = _("Providers")
949 elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
950 service_type = _("New")
952 service_type = _("Services")
954 # why we need this cast?
955 service_name = str(nimmanager.getSatDescription(orbpos))
957 if unsigned_orbpos == 0xFFFF: #Cable
958 service_name = _("Cable")
959 elif unsigned_orbpos == 0xEEEE: #Terrestrial
960 service_name = _("Terrestrial")
962 if orbpos > 1800: # west
963 orbpos = 3600 - orbpos
967 service_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
968 service.setName("%s - %s" % (service_name, service_type))
969 self.servicelist.addService(service)
970 cur_ref = self.session.nav.getCurrentlyPlayingServiceReference()
972 pos = self.service_types.rfind(':')
973 refstr = '%s (channelID == %08x%04x%04x) && %s ORDER BY name' %(self.service_types[:pos+1],
974 cur_ref.getUnsignedData(4), # NAMESPACE
975 cur_ref.getUnsignedData(2), # TSID
976 cur_ref.getUnsignedData(3), # ONID
977 self.service_types[pos+1:])
978 ref = eServiceReference(refstr)
979 ref.setName(_("Current Transponder"))
980 self.servicelist.addService(ref)
981 self.servicelist.finishFill()
983 self.setCurrentSelection(prev)
985 def showProviders(self):
986 if not self.pathChangeDisabled:
987 refstr = '%s FROM PROVIDERS ORDER BY name'%(self.service_types)
988 if not self.preEnterPath(refstr):
989 ref = eServiceReference(refstr)
990 if self.isBasePathEqual(ref):
993 currentRoot = self.getRoot()
994 if currentRoot is None or currentRoot != ref:
998 def changeBouquet(self, direction):
999 if not self.pathChangeDisabled:
1000 if len(self.servicePath) > 1:
1001 #when enter satellite root list we must do some magic stuff..
1002 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
1003 if self.isBasePathEqual(ref):
1004 self.showSatellites()
1011 ref = self.getCurrentSelection()
1014 def inBouquet(self):
1015 if self.servicePath and self.servicePath[0] == self.bouquet_root:
1020 return self.servicelist.atBegin()
1023 return self.servicelist.atEnd()
1025 def nextBouquet(self):
1026 self.changeBouquet(+1)
1028 def prevBouquet(self):
1029 self.changeBouquet(-1)
1031 def showFavourites(self):
1032 if not self.pathChangeDisabled:
1033 if not self.preEnterPath(self.bouquet_rootstr):
1034 if self.isBasePathEqual(self.bouquet_root):
1037 currentRoot = self.getRoot()
1038 if currentRoot is None or currentRoot != self.bouquet_root:
1040 self.enterPath(self.bouquet_root)
1042 def keyNumberGlobal(self, number):
1043 unichar = self.numericalTextInput.getKey(number)
1044 charstr = unichar.encode("utf-8")
1045 if len(charstr) == 1:
1046 self.servicelist.moveToChar(charstr[0])
1048 def keyAsciiCode(self):
1049 unichar = unichr(getPrevAsciiCode())
1050 charstr = unichar.encode("utf-8")
1051 if len(charstr) == 1:
1052 self.servicelist.moveToChar(charstr[0])
1055 return self.servicelist.getRoot()
1057 def getCurrentSelection(self):
1058 return self.servicelist.getCurrent()
1060 def setCurrentSelection(self, service):
1061 self.servicelist.setCurrent(service)
1063 def getBouquetList(self):
1065 serviceHandler = eServiceCenter.getInstance()
1066 if config.usage.multibouquet.value:
1067 list = serviceHandler.list(self.bouquet_root)
1073 if s.flags & eServiceReference.isDirectory:
1074 info = serviceHandler.info(s)
1076 bouquets.append((info.getName(s), s))
1079 info = serviceHandler.info(self.bouquet_root)
1081 bouquets.append((info.getName(self.bouquet_root), self.bouquet_root))
1085 def keyNumber0(self, num):
1086 if len(self.servicePath) > 1:
1089 self.keyNumberGlobal(num)
1092 if len(self.servicePath) > 1:
1093 if self.isBasePathEqual(self.bouquet_root):
1094 self.showFavourites()
1096 ref = eServiceReference('%s FROM SATELLITES ORDER BY satellitePosition'%(self.service_types))
1097 if self.isBasePathEqual(ref):
1098 self.showSatellites()
1100 ref = eServiceReference('%s FROM PROVIDERS ORDER BY name'%(self.service_types))
1101 if self.isBasePathEqual(ref):
1102 self.showProviders()
1104 self.showAllServices()
1106 def nextMarker(self):
1107 self.servicelist.moveToNextMarker()
1109 def prevMarker(self):
1110 self.servicelist.moveToPrevMarker()
1114 #config for lastservice
1115 config.tv = ConfigSubsection()
1116 config.tv.lastservice = ConfigText()
1117 config.tv.lastroot = ConfigText()
1118 config.radio = ConfigSubsection()
1119 config.radio.lastservice = ConfigText()
1120 config.radio.lastroot = ConfigText()
1121 config.servicelist = ConfigSubsection()
1122 config.servicelist.lastmode = ConfigText(default = "tv")
1124 class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, SelectionEventInfo):
1125 def __init__(self, session):
1126 ChannelSelectionBase.__init__(self,session)
1127 ChannelSelectionEdit.__init__(self)
1128 ChannelSelectionEPG.__init__(self)
1129 SelectionEventInfo.__init__(self)
1131 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1133 "cancel": self.cancel,
1134 "ok": self.channelSelected,
1135 "keyRadio": self.setModeRadio,
1136 "keyTV": self.setModeTv,
1139 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1141 iPlayableService.evStart: self.__evServiceStart,
1142 iPlayableService.evEnd: self.__evServiceEnd
1145 self.lastChannelRootTimer = eTimer()
1146 self.lastChannelRootTimer.callback.append(self.__onCreate)
1147 self.lastChannelRootTimer.start(100,True)
1149 self.history_tv = [ ]
1150 self.history_radio = [ ]
1151 self.history = self.history_tv
1152 self.history_pos = 0
1154 self.lastservice = config.tv.lastservice
1155 self.lastroot = config.tv.lastroot
1156 self.revertMode = None
1157 config.usage.multibouquet.addNotifier(self.multibouquet_config_changed)
1158 self.new_service_played = False
1159 self.onExecBegin.append(self.asciiOn)
1162 rcinput = eRCInput.getInstance()
1163 rcinput.setKeyboardMode(rcinput.kmAscii)
1166 rcinput = eRCInput.getInstance()
1167 rcinput.setKeyboardMode(rcinput.kmNone)
1169 def multibouquet_config_changed(self, val):
1170 self.recallBouquetMode()
1172 def __evServiceStart(self):
1173 service = self.session.nav.getCurrentService()
1175 info = service.info()
1177 refstr = info.getInfoString(iServiceInformation.sServiceref)
1178 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1180 def __evServiceEnd(self):
1181 self.servicelist.setPlayableIgnoreService(eServiceReference())
1184 self.rootChanged = True
1186 lastservice=eServiceReference(self.lastservice.value)
1187 if lastservice.valid():
1188 self.setCurrentSelection(lastservice)
1190 def setModeTv(self):
1191 if self.revertMode is None and config.servicelist.lastmode.value == "radio":
1192 self.revertMode = MODE_RADIO
1193 self.history = self.history_tv
1194 self.lastservice = config.tv.lastservice
1195 self.lastroot = config.tv.lastroot
1196 config.servicelist.lastmode.value = "tv"
1200 def setModeRadio(self):
1201 if self.revertMode is None and config.servicelist.lastmode.value == "tv":
1202 self.revertMode = MODE_TV
1203 if config.usage.e1like_radio_mode.value:
1204 self.history = self.history_radio
1205 self.lastservice = config.radio.lastservice
1206 self.lastroot = config.radio.lastroot
1207 config.servicelist.lastmode.value = "radio"
1211 def __onCreate(self):
1212 if config.usage.e1like_radio_mode.value:
1213 if config.servicelist.lastmode.value == "tv":
1219 lastservice=eServiceReference(self.lastservice.value)
1220 if lastservice.valid():
1223 def channelSelected(self):
1224 ref = self.getCurrentSelection()
1226 self.toggleMoveMarked()
1227 elif (ref.flags & 7) == 7:
1229 elif self.bouquet_mark_edit != OFF:
1230 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1232 elif not (ref.flags & eServiceReference.isMarker): # no marker
1233 root = self.getRoot()
1234 if not root or not (root.flags & eServiceReference.isGroup):
1239 #called from infoBar and channelSelected
1241 self.revertMode=None
1242 ref = self.session.nav.getCurrentlyPlayingServiceReference()
1243 nref = self.getCurrentSelection()
1244 if ref is None or ref != nref:
1245 self.new_service_played = True
1246 self.session.nav.playService(nref)
1248 self.saveChannel(nref)
1249 config.servicelist.lastmode.save()
1250 self.addToHistory(nref)
1252 def newServicePlayed(self):
1253 ret = self.new_service_played
1254 self.new_service_played = False
1257 def addToHistory(self, ref):
1258 if self.servicePath is not None:
1259 tmp=self.servicePath[:]
1262 del self.history[self.history_pos+1:]
1265 self.history.append(tmp)
1266 hlen = len(self.history)
1267 if hlen > HISTORYSIZE:
1270 self.history_pos = hlen-1
1272 def historyBack(self):
1273 hlen = len(self.history)
1274 if hlen > 1 and self.history_pos > 0:
1275 self.history_pos -= 1
1276 self.setHistoryPath()
1278 def historyNext(self):
1279 hlen = len(self.history)
1280 if hlen > 1 and self.history_pos < (hlen-1):
1281 self.history_pos += 1
1282 self.setHistoryPath()
1284 def setHistoryPath(self):
1285 path = self.history[self.history_pos][:]
1287 del self.servicePath[:]
1288 self.servicePath += path
1291 cur_root = self.getRoot()
1292 if cur_root and cur_root != root:
1294 self.session.nav.playService(ref)
1295 self.setCurrentSelection(ref)
1296 self.saveChannel(ref)
1300 for i in self.servicePath:
1301 path += i.toString()
1303 if path and path != self.lastroot.value:
1304 self.lastroot.value = path
1305 self.lastroot.save()
1307 def restoreRoot(self):
1308 tmp = [x for x in self.lastroot.value.split(';') if x != '']
1309 current = [x.toString() for x in self.servicePath]
1310 if tmp != current or self.rootChanged:
1314 self.servicePath.append(eServiceReference(i))
1317 path = self.servicePath.pop()
1318 self.enterPath(path)
1320 self.showFavourites()
1322 self.rootChanged = False
1324 def preEnterPath(self, refstr):
1325 if self.servicePath and self.servicePath[0] != eServiceReference(refstr):
1326 pathstr = self.lastroot.value
1327 if pathstr is not None and pathstr.find(refstr) == 0:
1329 lastservice=eServiceReference(self.lastservice.value)
1330 if lastservice.valid():
1331 self.setCurrentSelection(lastservice)
1335 def saveChannel(self, ref):
1337 refstr = ref.toString()
1340 if refstr != self.lastservice.value:
1341 self.lastservice.value = refstr
1342 self.lastservice.save()
1344 def setCurrentServicePath(self, path):
1346 self.history[self.history_pos] = path
1348 self.history.append(path)
1349 self.setHistoryPath()
1351 def getCurrentServicePath(self):
1353 return self.history[self.history_pos]
1356 def recallPrevService(self):
1357 hlen = len(self.history)
1359 if self.history_pos == hlen-1:
1360 tmp = self.history[self.history_pos]
1361 self.history[self.history_pos] = self.history[self.history_pos-1]
1362 self.history[self.history_pos-1] = tmp
1364 tmp = self.history[self.history_pos+1]
1365 self.history[self.history_pos+1] = self.history[self.history_pos]
1366 self.history[self.history_pos] = tmp
1367 self.setHistoryPath()
1370 if self.revertMode is None:
1372 lastservice=eServiceReference(self.lastservice.value)
1373 if lastservice.valid() and self.getCurrentSelection() != lastservice:
1374 self.setCurrentSelection(lastservice)
1375 elif self.revertMode == MODE_TV:
1377 elif self.revertMode == MODE_RADIO:
1379 self.revertMode = None
1383 class RadioInfoBar(Screen):
1384 def __init__(self, session):
1385 Screen.__init__(self, session)
1386 self["RdsDecoder"] = RdsDecoder(self.session.nav)
1388 class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG, InfoBarBase):
1389 ALLOW_SUSPEND = True
1391 def __init__(self, session, infobar):
1392 ChannelSelectionBase.__init__(self, session)
1393 ChannelSelectionEdit.__init__(self)
1394 ChannelSelectionEPG.__init__(self)
1395 InfoBarBase.__init__(self)
1396 self.infobar = infobar
1397 self.onLayoutFinish.append(self.onCreate)
1399 self.info = session.instantiateDialog(RadioInfoBar) # our simple infobar
1401 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1403 "keyTV": self.closeRadio,
1404 "keyRadio": self.closeRadio,
1405 "cancel": self.closeRadio,
1406 "ok": self.channelSelected,
1409 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
1411 iPlayableService.evStart: self.__evServiceStart,
1412 iPlayableService.evEnd: self.__evServiceEnd
1415 ########## RDS Radiotext / Rass Support BEGIN
1416 self.infobar = infobar # reference to real infobar (the one and only)
1417 self["RdsDecoder"] = self.info["RdsDecoder"]
1418 self["RdsActions"] = HelpableActionMap(self, "InfobarRdsActions",
1420 "startRassInteractive": (self.startRassInteractive, _("View Rass interactive..."))
1422 self["RdsActions"].setEnabled(False)
1423 infobar.rds_display.onRassInteractivePossibilityChanged.append(self.RassInteractivePossibilityChanged)
1424 self.onClose.append(self.__onClose)
1426 def __onClose(self):
1427 lastservice=eServiceReference(config.tv.lastservice.value)
1428 self.session.nav.playService(lastservice)
1430 def startRassInteractive(self):
1432 self.infobar.rass_interactive = self.session.openWithCallback(self.RassInteractiveClosed, RassInteractive)
1434 def RassInteractiveClosed(self):
1436 self.infobar.rass_interactive = None
1437 self.infobar.RassSlidePicChanged()
1439 def RassInteractivePossibilityChanged(self, state):
1440 self["RdsActions"].setEnabled(state)
1441 ########## RDS Radiotext / Rass Support END
1443 def closeRadio(self):
1444 self.infobar.rds_display.onRassInteractivePossibilityChanged.remove(self.RassInteractivePossibilityChanged)
1446 #set previous tv service
1449 def __evServiceStart(self):
1450 service = self.session.nav.getCurrentService()
1452 info = service.info()
1454 refstr = info.getInfoString(iServiceInformation.sServiceref)
1455 self.servicelist.setPlayableIgnoreService(eServiceReference(refstr))
1457 def __evServiceEnd(self):
1458 self.servicelist.setPlayableIgnoreService(eServiceReference())
1462 for i in self.servicePathRadio:
1463 path += i.toString()
1465 if path and path != config.radio.lastroot.value:
1466 config.radio.lastroot.value = path
1467 config.radio.lastroot.save()
1469 def restoreRoot(self):
1470 tmp = [x for x in config.radio.lastroot.value.split(';') if x != '']
1471 current = [x.toString() for x in self.servicePath]
1472 if tmp != current or self.rootChanged:
1475 self.servicePathRadio.append(eServiceReference(i))
1478 path = self.servicePathRadio.pop()
1479 self.enterPath(path)
1481 self.showFavourites()
1483 self.rootChanged = False
1485 def preEnterPath(self, refstr):
1486 if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr):
1487 pathstr = config.radio.lastroot.value
1488 if pathstr is not None and pathstr.find(refstr) == 0:
1490 lastservice=eServiceReference(config.radio.lastservice.value)
1491 if lastservice.valid():
1492 self.setCurrentSelection(lastservice)
1499 lastservice=eServiceReference(config.radio.lastservice.value)
1500 if lastservice.valid():
1501 self.servicelist.setCurrent(lastservice)
1502 self.session.nav.playService(lastservice)
1504 self.session.nav.stopService()
1507 def channelSelected(self): # just return selected service
1508 ref = self.getCurrentSelection()
1510 self.toggleMoveMarked()
1511 elif (ref.flags & 7) == 7:
1513 elif self.bouquet_mark_edit != OFF:
1514 if not (self.bouquet_mark_edit == EDIT_ALTERNATIVES and ref.flags & eServiceReference.isGroup):
1516 elif not (ref.flags & eServiceReference.isMarker): # no marker
1517 cur_root = self.getRoot()
1518 if not cur_root or not (cur_root.flags & eServiceReference.isGroup):
1519 playingref = self.session.nav.getCurrentlyPlayingServiceReference()
1520 if playingref is None or playingref != ref:
1521 self.session.nav.playService(ref)
1522 config.radio.lastservice.value = ref.toString()
1523 config.radio.lastservice.save()
1526 class SimpleChannelSelection(ChannelSelectionBase):
1527 def __init__(self, session, title):
1528 ChannelSelectionBase.__init__(self, session)
1529 self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
1531 "cancel": self.close,
1532 "ok": self.channelSelected,
1533 "keyRadio": self.setModeRadio,
1534 "keyTV": self.setModeTv,
1537 self.onLayoutFinish.append(self.layoutFinished)
1539 def layoutFinished(self):
1542 def channelSelected(self): # just return selected service
1543 ref = self.getCurrentSelection()
1544 if (ref.flags & 7) == 7:
1546 elif not (ref.flags & eServiceReference.isMarker):
1547 ref = self.getCurrentSelection()
1550 def setModeTv(self):
1552 self.showFavourites()
1554 def setModeRadio(self):
1556 self.showFavourites()