From 5ff227c657e02ebe2bc719faf4bd2231a04850c8 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Tue, 24 Jan 2006 00:29:54 +0000 Subject: add ability to copy providers or all services from satellites to favourites (this creates a new bouquet) add ability to remove a complete bouquet both are just working with enabled multi bouquet mode --- lib/service/iservice.h | 10 ++++++++-- lib/service/servicedvb.cpp | 39 ++++++++++++++++++++++++++++++++++++++- lib/service/servicedvb.h | 4 +++- lib/service/servicefs.cpp | 29 ++++++++++++++++++++++++++++- lib/service/servicefs.h | 3 ++- 5 files changed, 79 insertions(+), 6 deletions(-) (limited to 'lib/service') diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 2b42510d..1f55fe49 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -2,6 +2,7 @@ #define __lib_dvb_iservice_h #include +#include #include #include #include @@ -166,6 +167,8 @@ public: SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference); +extern PyObject *New_eServiceReference(const eServiceReference &ref); // defined in enigma_python.i + typedef long long pts_t; /* the reason we have the servicereference as additional argument is @@ -442,6 +445,8 @@ public: /* moves a service in a list, only if list suppports a specific sort method. */ /* pos is the new, absolute position from 0..size-1 */ virtual RESULT moveService(eServiceReference &ref, int pos)=0; + /* set name of list, for bouquets this is the visible bouquet name */ + virtual RESULT setListName(const std::string &name)=0; }; TEMPLATE_TYPEDEF(ePtr, iMutableServiceListPtr); @@ -454,8 +459,9 @@ class iListableService: public iObject #endif public: /* legacy interface: get a list */ - virtual RESULT getContent(std::list &list)=0; - + virtual RESULT getContent(std::list &list, bool sorted=false)=0; + virtual RESULT getContent(PyObject *list, bool sorted=false)=0; + /* new, shiny interface: streaming. */ virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0; diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 61221ecb..827b7f36 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -13,6 +13,7 @@ #include #include #include +#include class eStaticServiceDVBInformation: public iStaticServiceInformation { @@ -305,7 +306,32 @@ RESULT eDVBServiceList::startQuery() return 0; } -RESULT eDVBServiceList::getContent(std::list &list) +RESULT eDVBServiceList::getContent(PyObject *list, bool sorted) +{ + eServiceReferenceDVB ref; + + if (!m_query || !list || !PyList_Check(list)) + return -1; + + std::list tmplist; + + while (!m_query->getNextResult(ref)) + tmplist.push_back(ref); + + if (sorted) + tmplist.sort(iListableServiceCompare(this)); + + for (std::list::iterator it(tmplist.begin()); + it != tmplist.end(); ++it) + { + PyObject *refobj = New_eServiceReference(*it); + PyList_Append(list, refobj); + Py_DECREF(refobj); + } + return 0; +} + +RESULT eDVBServiceList::getContent(std::list &list, bool sorted) { eServiceReferenceDVB ref; @@ -314,6 +340,10 @@ RESULT eDVBServiceList::getContent(std::list &list) while (!m_query->getNextResult(ref)) list.push_back(ref); + + if (sorted) + list.sort(iListableServiceCompare(this)); + return 0; } @@ -379,6 +409,13 @@ RESULT eDVBServiceList::flushChanges() return m_bouquet->flushChanges(); } +RESULT eDVBServiceList::setListName(const std::string &name) +{ + if (!m_bouquet) + return -1; + return m_bouquet->setListName(name); +} + RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr &ptr) { ePtr service; diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 61baf6a2..ba4f2fb5 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -32,7 +32,8 @@ class eDVBServiceList: public iListableService, public iMutableServiceList DECLARE_REF(eDVBServiceList); public: virtual ~eDVBServiceList(); - RESULT getContent(std::list &list); + RESULT getContent(std::list &list, bool sorted=false); + RESULT getContent(PyObject *list, bool sorted=false); RESULT getNext(eServiceReference &ptr); int compareLessEqual(const eServiceReference &a, const eServiceReference &b); @@ -41,6 +42,7 @@ public: RESULT addService(eServiceReference &ref); RESULT removeService(eServiceReference &ref); RESULT moveService(eServiceReference &ref, int pos); + RESULT setListName(const std::string &name); private: RESULT startQuery(); eServiceReference m_parent; diff --git a/lib/service/servicefs.cpp b/lib/service/servicefs.cpp index a22b88d3..8254e63b 100644 --- a/lib/service/servicefs.cpp +++ b/lib/service/servicefs.cpp @@ -96,7 +96,7 @@ eServiceFS::~eServiceFS() { } -RESULT eServiceFS::getContent(std::list &list) +RESULT eServiceFS::getContent(std::list &list, bool sorted) { DIR *d=opendir(path.c_str()); if (!d) @@ -141,6 +141,33 @@ RESULT eServiceFS::getContent(std::list &list) } } closedir(d); + + if (sorted) + list.sort(iListableServiceCompare(this)); + + return 0; +} + +RESULT eServiceFS::getContent(PyObject *list, bool sorted) +{ + if (!list || !PyList_Check(list)) + return -1; + + std::list tmplist; + + getContent(tmplist, sorted); + + if (sorted) + tmplist.sort(iListableServiceCompare(this)); + + for (std::list::iterator it(tmplist.begin()); + it != tmplist.end(); ++it) + { + PyObject *refobj = New_eServiceReference(*it); + PyList_Append(list, refobj); + Py_DECREF(refobj); + } + return 0; } diff --git a/lib/service/servicefs.h b/lib/service/servicefs.h index 46e8b890..4257f2ac 100644 --- a/lib/service/servicefs.h +++ b/lib/service/servicefs.h @@ -34,7 +34,8 @@ private: public: virtual ~eServiceFS(); - RESULT getContent(std::list &list); + RESULT getContent(std::list &list, bool sorted=false); + RESULT getContent(PyObject *list, bool sorted=false); RESULT getNext(eServiceReference &ptr); int compareLessEqual(const eServiceReference &, const eServiceReference &); RESULT startEdit(ePtr &); -- cgit v1.2.3