+ if refstr != self.lastservice.value:
+ self.lastservice.value = refstr
+ self.lastservice.save()
+
+ def setCurrentServicePath(self, path):
+ hlen = len(self.history)
+ if hlen > 0:
+ self.history[self.history_pos] = path
+ else:
+ self.history.append(path)
+ self.setHistoryPath()
+
+ def getCurrentServicePath(self):
+ hlen = len(self.history)
+ if hlen > 0:
+ return self.history[self.history_pos]
+ return None
+
+ def recallPrevService(self):
+ hlen = len(self.history)
+ if hlen > 1:
+ if self.history_pos == hlen-1:
+ tmp = self.history[self.history_pos]
+ self.history[self.history_pos] = self.history[self.history_pos-1]
+ self.history[self.history_pos-1] = tmp
+ else:
+ tmp = self.history[self.history_pos+1]
+ self.history[self.history_pos+1] = self.history[self.history_pos]
+ self.history[self.history_pos] = tmp
+ self.setHistoryPath()
+
+ def cancel(self):
+ if self.revertMode is None:
+ self.restoreRoot()
+ lastservice=eServiceReference(self.lastservice.value)
+ if lastservice.valid() and self.getCurrentSelection() != lastservice:
+ self.setCurrentSelection(lastservice)
+ elif self.revertMode == MODE_TV:
+ self.setModeTv()
+ elif self.revertMode == MODE_RADIO:
+ self.setModeRadio()
+ self.revertMode = None
+ self.close(None)
+
+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["CurrentTime"] = Clock()
+
+class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelectionEPG):
+
+ ALLOW_SUSPEND = True
+
+ 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