diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-01-24 00:29:54 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-01-24 00:29:54 +0000 |
| commit | 5ff227c657e02ebe2bc719faf4bd2231a04850c8 (patch) | |
| tree | 8e7361161ee08db583147d47e2662b94219ed324 /lib/service | |
| parent | 3e9bd06034d9656d4346225e90e68a65327a4aa0 (diff) | |
| download | enigma2-5ff227c657e02ebe2bc719faf4bd2231a04850c8.tar.gz enigma2-5ff227c657e02ebe2bc719faf4bd2231a04850c8.zip | |
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
Diffstat (limited to 'lib/service')
| -rw-r--r-- | lib/service/iservice.h | 10 | ||||
| -rw-r--r-- | lib/service/servicedvb.cpp | 39 | ||||
| -rw-r--r-- | lib/service/servicedvb.h | 4 | ||||
| -rw-r--r-- | lib/service/servicefs.cpp | 29 | ||||
| -rw-r--r-- | lib/service/servicefs.h | 3 |
5 files changed, 79 insertions, 6 deletions
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 <lib/python/swig.h> +#include <lib/python/python.h> #include <lib/base/object.h> #include <string> #include <connection.h> @@ -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<iMutableServiceList>, iMutableServiceListPtr); @@ -454,8 +459,9 @@ class iListableService: public iObject #endif public: /* legacy interface: get a list */ - virtual RESULT getContent(std::list<eServiceReference> &list)=0; - + virtual RESULT getContent(std::list<eServiceReference> &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 <lib/service/servicedvbrecord.h> #include <lib/dvb/metaparser.h> #include <lib/dvb/tstools.h> +#include <lib/python/python.h> class eStaticServiceDVBInformation: public iStaticServiceInformation { @@ -305,7 +306,32 @@ RESULT eDVBServiceList::startQuery() return 0; } -RESULT eDVBServiceList::getContent(std::list<eServiceReference> &list) +RESULT eDVBServiceList::getContent(PyObject *list, bool sorted) +{ + eServiceReferenceDVB ref; + + if (!m_query || !list || !PyList_Check(list)) + return -1; + + std::list<eServiceReferenceDVB> tmplist; + + while (!m_query->getNextResult(ref)) + tmplist.push_back(ref); + + if (sorted) + tmplist.sort(iListableServiceCompare(this)); + + for (std::list<eServiceReferenceDVB>::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<eServiceReference> &list, bool sorted) { eServiceReferenceDVB ref; @@ -314,6 +340,10 @@ RESULT eDVBServiceList::getContent(std::list<eServiceReference> &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<iPlayableService> &ptr) { ePtr<eDVBService> 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<eServiceReference> &list); + RESULT getContent(std::list<eServiceReference> &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<eServiceReference> &list) +RESULT eServiceFS::getContent(std::list<eServiceReference> &list, bool sorted) { DIR *d=opendir(path.c_str()); if (!d) @@ -141,6 +141,33 @@ RESULT eServiceFS::getContent(std::list<eServiceReference> &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<eServiceReference> tmplist; + + getContent(tmplist, sorted); + + if (sorted) + tmplist.sort(iListableServiceCompare(this)); + + for (std::list<eServiceReference>::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<eServiceReference> &list); + RESULT getContent(std::list<eServiceReference> &list, bool sorted=false); + RESULT getContent(PyObject *list, bool sorted=false); RESULT getNext(eServiceReference &ptr); int compareLessEqual(const eServiceReference &, const eServiceReference &); RESULT startEdit(ePtr<iMutableServiceList> &); |
