From 4cdeb9ebe328382bb4ef6a01b67ff840adcc84ad Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Sun, 8 Jan 2006 14:55:16 +0000 Subject: [PATCH 1/1] add subservice selection to timer (when linkage services are avail for the selected event) better layout in timerlist (more space for service name and event description) --- RecordTimer.py | 3 ++- data/skin.xml | 2 +- lib/python/Components/TimerList.py | 14 +++++++------- lib/python/Screens/SubserviceSelection.py | 21 +++++++++++++++------ lib/python/Screens/TimerEntry.py | 17 +++++++++++++++-- lib/service/event.cpp | 21 ++++++++++++++++++++- lib/service/event.h | 2 +- lib/service/service.cpp | 22 +++++++++++++++++----- lib/service/servicedvb.cpp | 23 +---------------------- 9 files changed, 79 insertions(+), 46 deletions(-) diff --git a/RecordTimer.py b/RecordTimer.py index 37aecdbd..2234bfc3 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -8,6 +8,7 @@ import timer import xml.dom.minidom from Screens.MessageBox import MessageBox +from Screens.SubserviceSelection import SubserviceSelection import NavigationInstance from Tools.XMLTools import elementsWithTag @@ -26,7 +27,7 @@ def parseEvent(ev): description = ev.getShortDescription() begin = ev.getBeginTime() end = begin + ev.getDuration() - eit = None + eit = ev.getEventId() return (begin, end, name, description, eit) class RecordTimerEntry(timer.TimerEntry): diff --git a/data/skin.xml b/data/skin.xml index 9a4eaa13..5c4482b5 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -139,7 +139,7 @@ - + diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index e48b7a0d..47c49d3f 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -26,7 +26,9 @@ RT_WRAP = 32 def TimerEntryComponent(timer, processed): res = [ timer ] - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 220, 30, 0, RT_HALIGN_LEFT, timer.service_ref.getServiceName())) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 560, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.service_ref.getServiceName())) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, 560, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.name)) + repeatedtext = "" days = [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] if (timer.repeated != 0): @@ -39,12 +41,10 @@ def TimerEntryComponent(timer, processed): repeatedtext += days[x] count += 1 flags = flags >> 1 - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, 300, 20, 1, RT_HALIGN_LEFT, repeatedtext + (" %s ... %s" % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1])))) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 300, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (" %s ... %s" % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1])))) else: - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, 300, 20, 1, RT_HALIGN_LEFT, repeatedtext + ("%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:])))) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 300, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ("%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:])))) - res.append((eListboxPythonMultiContent.TYPE_TEXT, 240, 0, 320, 20, 1, RT_HALIGN_RIGHT, timer.name)) - if not processed: if timer.state == TimerEntry.StateWait: state = "waiting" @@ -57,7 +57,7 @@ def TimerEntryComponent(timer, processed): else: state = "done!" - res.append((eListboxPythonMultiContent.TYPE_TEXT, 320, 30, 240, 20, 1, RT_HALIGN_RIGHT, state)) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 320, 50, 240, 20, 1, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, state)) return res @@ -75,7 +75,7 @@ class TimerList(HTMLComponent, GUIComponent): def GUIcreate(self, parent): self.instance = eListbox(parent) self.instance.setContent(self.l) - self.instance.setItemHeight(50) + self.instance.setItemHeight(70) def GUIdelete(self): self.instance.setContent(None) diff --git a/lib/python/Screens/SubserviceSelection.py b/lib/python/Screens/SubserviceSelection.py index a73cf0e4..0aa34b61 100644 --- a/lib/python/Screens/SubserviceSelection.py +++ b/lib/python/Screens/SubserviceSelection.py @@ -2,7 +2,7 @@ from Screen import Screen from Components.ActionMap import ActionMap from Components.MenuList import MenuList from Components.Label import Label -from enigma import eServiceReferencePtr, eServiceReference +from enigma import eServiceReferencePtr, eServiceReference, iSubserviceListPtr, eServiceEventPtrPtr class SubserviceSelection(Screen): def KeyOk(self): @@ -10,7 +10,7 @@ class SubserviceSelection(Screen): self.close(selection[1]) def Cancel(self): self.close(None) - def __init__(self, session, subservices): + def __init__(self, session, subservices, parent=None): Screen.__init__(self, session) self["actions"] = ActionMap(["OkCancelActions"], @@ -21,10 +21,19 @@ class SubserviceSelection(Screen): self.subservices = subservices + print subservices tlist = [] - n = subservices.getNumberOfSubservices() - for x in range(n): - i = subservices.getSubservice(x) - tlist.append((i.getName(), i)) + if isinstance(subservices, iSubserviceListPtr): + n = subservices.getNumberOfSubservices() + for x in range(n): + i = subservices.getSubservice(x) + tlist.append((i.getName(), i)) + elif isinstance(subservices, eServiceEventPtrPtr): + n = subservices.getNumOfLinkageServices() + for x in range(n): + i = subservices.getLinkageService(parent, x) + tlist.append((i.getName(), i)) + else: + print "unknown type of subservices" self["subservices"] = MenuList(tlist) diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index ea18d892..703e4aba 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -7,6 +7,8 @@ from Components.ConfigList import ConfigList from Components.NimManager import nimmanager from Components.Label import Label from Components.Pixmap import Pixmap +from Screens.SubserviceSelection import SubserviceSelection +from enigma import eEPGCache import time import datetime @@ -256,8 +258,19 @@ class TimerEntry(Screen): if (config.timerentry.day[x].value == 0): self.timer.setRepeated(x) self.timer.begin = self.getTimestamp(time.time(), config.timerentry.starttime.value) - self.timer.end = self.getTimestamp(time.time(), config.timerentry.endtime.value) - + self.timer.end = self.getTimestamp(time.time(), config.timerentry.endtime.value) + + if self.timer.eit is not None: + event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) + if event is not None: + if event.getNumOfLinkageServices() > 0: + self.session.openWithCallback(self.subserviceSelected, SubserviceSelection, event, self.timer.service_ref.ref) + return + self.close((True, self.timer)) + + def subserviceSelected(self, service): + if not service is None: + self.timer.service_ref = ServiceReference(service) self.close((True, self.timer)) def keyCancel(self): diff --git a/lib/service/event.cpp b/lib/service/event.cpp index f84c38b7..2d0f83a4 100644 --- a/lib/service/event.cpp +++ b/lib/service/event.cpp @@ -204,7 +204,7 @@ RESULT eServiceEvent::getComponentData(ePtr &dest, int tagnum) c return -1; } -RESULT eServiceEvent::getLinkageService(eServiceReference &service, int num) const +RESULT eServiceEvent::getLinkageService(eServiceReference &service, eServiceReference &parent, int num) const { std::list::const_iterator it = m_linkage_services.begin(); @@ -213,6 +213,25 @@ RESULT eServiceEvent::getLinkageService(eServiceReference &service, int num) con if ( it != m_linkage_services.end() ) { service = *it; + eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) service; + eServiceReferenceDVB ¤t = (eServiceReferenceDVB&) parent; + subservice.setDVBNamespace(current.getDVBNamespace()); + if ( current.getParentTransportStreamID().get() ) + { + subservice.setParentTransportStreamID( current.getParentTransportStreamID() ); + subservice.setParentServiceID( current.getParentServiceID() ); + } + else + { + subservice.setParentTransportStreamID( current.getTransportStreamID() ); + subservice.setParentServiceID( current.getServiceID() ); + } + if ( subservice.getParentTransportStreamID() == subservice.getTransportStreamID() && + subservice.getParentServiceID() == subservice.getServiceID() ) + { + subservice.setParentTransportStreamID( eTransportStreamID(0) ); + subservice.setParentServiceID( eServiceID(0) ); + } return 0; } service.type = eServiceReference::idInvalid; diff --git a/lib/service/event.h b/lib/service/event.h index 0a6891aa..9ee6538b 100644 --- a/lib/service/event.h +++ b/lib/service/event.h @@ -53,7 +53,7 @@ public: std::string getBeginTimeString() const; SWIG_VOID(RESULT) getComponentData(ePtr &SWIG_OUTPUT, int tagnum) const; int getNumOfLinkageServices() const { return m_linkage_services.size(); } - SWIG_VOID(RESULT) getLinkageService(eServiceReference &SWIG_OUTPUT, int num) const; + SWIG_VOID(RESULT) getLinkageService(eServiceReference &SWIG_OUTPUT, eServiceReference &parent, int num) const; }; TEMPLATE_TYPEDEF(ePtr, eServiceEventPtr); diff --git a/lib/service/service.cpp b/lib/service/service.cpp index 150a0cd3..a490c3d7 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -7,8 +7,8 @@ eServiceReference::eServiceReference(const std::string &string) { const char *c=string.c_str(); - int pathl=-1; - + int pathl=0; + if ( sscanf(c, "%d:%d:%x:%x:%x:%x:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7], &pathl) < 8 ) { memset( data, 0, sizeof(data) ); @@ -17,7 +17,19 @@ eServiceReference::eServiceReference(const std::string &string) } if (pathl) - path=c+pathl; + { + const char *pathstr = c+pathl; + const char *namestr = strchr(pathstr, ':'); + if (namestr) + { + if (pathstr != namestr) + path.assign(pathstr, namestr-pathstr); + if (*(namestr+1)) + name=namestr+1; + } + else + path=pathstr; + } } std::string eServiceReference::toString() const @@ -27,10 +39,10 @@ std::string eServiceReference::toString() const ret += ":"; ret += getNum(flags); for (unsigned int i=0; i evt; if (!m_event_handler.getEvent(evt, 0)) { - if (!evt->getLinkageService(sub, n)) - { - eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) sub; - eServiceReferenceDVB ¤t = (eServiceReferenceDVB&) m_reference; - subservice.setDVBNamespace(current.getDVBNamespace()); - if ( current.getParentTransportStreamID().get() ) - { - subservice.setParentTransportStreamID( current.getParentTransportStreamID() ); - subservice.setParentServiceID( current.getParentServiceID() ); - } - else - { - subservice.setParentTransportStreamID( current.getTransportStreamID() ); - subservice.setParentServiceID( current.getServiceID() ); - } - if ( subservice.getParentTransportStreamID() == subservice.getTransportStreamID() && - subservice.getParentServiceID() == subservice.getServiceID() ) - { - subservice.setParentTransportStreamID( eTransportStreamID(0) ); - subservice.setParentServiceID( eServiceID(0) ); - } + if (!evt->getLinkageService(sub, m_reference, n)) return 0; - } } sub.type=eServiceReference::idInvalid; return -1; -- 2.30.2