+ if refstr != config.tv.lastservice.value:
+ config.tv.prevservice.value = config.tv.lastservice.value
+ config.tv.prevservice.save()
+ config.tv.lastservice.value = refstr
+ config.tv.lastservice.save()
+
+ def recallPrevService(self):
+ if len(config.tv.prevservice.value) and len(config.tv.prevroot.value):
+ if config.tv.lastroot.value != config.tv.prevroot.value:
+ tmp = config.tv.lastroot.value
+ config.tv.lastroot.value = config.tv.prevroot.value
+ config.tv.lastroot.save()
+ config.tv.prevroot.value = tmp
+ config.tv.prevroot.save()
+ self.restoreRoot()
+ if config.tv.lastservice.value != config.tv.prevservice.value:
+ tmp = config.tv.lastservice.value
+ config.tv.lastservice.value = config.tv.prevservice.value
+ config.tv.lastservice.save()
+ config.tv.prevservice.value = tmp
+ config.tv.prevservice.save()
+ lastservice=eServiceReference(config.tv.lastservice.value)
+ self.session.nav.playService(lastservice)
+ self.setCurrentSelection(lastservice)
+
+ def cancel(self):
+ self.close(None)
+ self.restoreRoot()
+ lastservice=eServiceReference(config.tv.lastservice.value)
+ if lastservice.valid() and self.getCurrentSelection() != lastservice:
+ self.setCurrentSelection(lastservice)
+
+from Screens.InfoBarGenerics import InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord
+
+class RadioInfoBar(Screen, InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+ InfoBarEvent.__init__(self)
+ InfoBarServiceName.__init__(self)
+ InfoBarInstantRecord.__init__(self)
+ self["Clock"] = Clock()
+
+class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
+ def __init__(self, session):
+ ChannelSelectionBase.__init__(self, session)
+ ChannelSelectionEdit.__init__(self)
+ ChannelSelectionEPG.__init__(self)
+
+ config.radio = ConfigSubsection();
+ config.radio.lastservice = configElement("config.radio.lastservice", configText, "", 0);
+ config.radio.lastroot = configElement("config.radio.lastroot", configText, "", 0);
+ self.onLayoutFinish.append(self.onCreate)
+
+ self.info = session.instantiateDialog(RadioInfoBar)
+
+ self["actions"] = ActionMap(["OkCancelActions", "TvRadioActions"],
+ {
+ "keyTV": self.closeRadio,
+ "keyRadio": self.closeRadio,
+ "cancel": self.closeRadio,
+ "ok": self.channelSelected,
+ })
+
+ def saveRoot(self):
+ path = ''
+ for i in self.servicePathRadio:
+ path += i.toString()
+ path += ';'
+ if len(path) and path != config.radio.lastroot.value:
+ config.radio.lastroot.value = path
+ config.radio.lastroot.save()
+
+ def restoreRoot(self):
+ self.clearPath()
+ re = compile('.+?;')
+ tmp = re.findall(config.radio.lastroot.value)
+ cnt = 0
+ for i in tmp:
+ self.servicePathRadio.append(eServiceReference(i[:len(i)-1]))
+ cnt += 1
+ if cnt:
+ path = self.servicePathRadio.pop()
+ self.enterPath(path)
+ else:
+ self.showFavourites()
+ self.saveRoot()
+
+ def preEnterPath(self, refstr):
+ if len(self.servicePathRadio) and self.servicePathRadio[0] != eServiceReference(refstr):
+ pathstr = config.radio.lastroot.value
+ if pathstr is not None and pathstr.find(refstr) == 0:
+ self.restoreRoot()
+ lastservice=eServiceReference(config.radio.lastservice.value)
+ if lastservice.valid():
+ self.setCurrentSelection(lastservice)
+ return True
+ return False