add iMutableServiceList
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Nov 2005 15:30:08 +0000 (15:30 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 13 Nov 2005 15:30:08 +0000 (15:30 +0000)
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicefs.cpp
lib/service/servicefs.h

index 15631fdac410f9e9aa9da4795573b4a19966fa52..5f861899249dcd43ecb76e63821d887b4f5e970b 100644 (file)
@@ -249,6 +249,20 @@ TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
 
 // TEMPLATE_TYPEDEF(std::list<eServiceReference>, eServiceReferenceList);
 
+class iMutableServiceList: public iObject
+{
+public:
+               /* adds a service to a list */
+       virtual RESULT addService(eServiceReference &ref)=0;
+               /* removes a service from a list */
+       virtual RESULT removeService(eServiceReference &ref)=0;
+               /* 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;
+};
+
+TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
+
 class iListableService: public iObject
 {
 public:
@@ -264,6 +278,8 @@ public:
                   (as well as a future "active" extension) won't be possible.
                */
        virtual int compareLessEqual(const eServiceReference &, const eServiceReference &)=0;
+       
+       virtual SWIG_VOID(RESULT) startEdit(ePtr<iMutableServiceList> &SWIG_OUTPUT)=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
index 76b0089c60feb06443e1fa588fcd899909ee1bbe..94833f446f75d7a3a55d768156a8e40c8a0064df 100644 (file)
@@ -270,6 +270,50 @@ int eDVBServiceList::compareLessEqual(const eServiceReference &a, const eService
        return m_query->compareLessEqual((const eServiceReferenceDVB&)a, (const eServiceReferenceDVB&)b);
 }
 
+RESULT eDVBServiceList::startEdit(ePtr<iMutableServiceList> &res)
+{
+       if (m_parent.flags & eServiceReference::flagDirectory) // bouquet
+       {
+               ePtr<iDVBChannelList> db;
+               ePtr<eDVBResourceManager> resm;
+
+               if (eDVBResourceManager::getInstance(resm) || resm->getChannelList(db))
+                       return -1;
+
+                       // FIXME!
+               if (db->getBouquet(m_parent, (const eBouquet*&)m_bouquet) != 0)
+                       return -1;
+               
+               res = this;
+               
+               return 0;
+       }
+       res = 0;
+       return -1;
+}
+
+RESULT eDVBServiceList::addService(eServiceReference &ref)
+{
+       ASSERT(m_bouquet);
+//     return m_bouquet->addService(ref);
+       return -1;
+}
+
+RESULT eDVBServiceList::removeService(eServiceReference &ref)
+{
+       ASSERT(m_bouquet);
+//     return m_bouquet->removeService(ref);
+       return -1;
+}
+
+RESULT eDVBServiceList::moveService(eServiceReference &ref, int pos)
+{
+       ASSERT(m_bouquet);
+       
+//     return m_bouquet->moveService(ref, pos);
+       return -1;
+}
+
 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
 {
        ePtr<eDVBService> service;
index 9ebd277345fad0e28bee25b42f0df09e9ec3eda8..165703dd07e57168f4a43215cfe5ccc9abe61de9 100644 (file)
@@ -25,7 +25,9 @@ private:
        RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
 };
 
-class eDVBServiceList: public iListableService
+class eBouquet;
+
+class eDVBServiceList: public iListableService, public iMutableServiceList
 {
 DECLARE_REF(eDVBServiceList);
 public:
@@ -33,12 +35,20 @@ public:
        RESULT getContent(std::list<eServiceReference> &list);
        RESULT getNext(eServiceReference &ptr);
        int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
+       
+       RESULT startEdit(ePtr<iMutableServiceList> &);
+       RESULT addService(eServiceReference &ref);
+       RESULT removeService(eServiceReference &ref);
+       RESULT moveService(eServiceReference &ref, int pos);
 private:
        RESULT startQuery();
        eServiceReference m_parent;
        friend class eServiceFactoryDVB;
        eDVBServiceList(const eServiceReference &parent);
        ePtr<iDVBChannelListQuery> m_query;
+       
+               /* for editing purposes. WARNING: lifetime issue! */
+       eBouquet *m_bouquet;
 };
 
 class eDVBServicePlay: public iPlayableService, public iPauseableService, public iSeekableService, public Object, public iServiceInformation
index cf3f31f62821e6606adf880d8544564cec7662a6..1afdd1697b129d3f3d87f0967be68a4af848fe03 100644 (file)
@@ -176,4 +176,10 @@ int eServiceFS::compareLessEqual(const eServiceReference &a, const eServiceRefer
                return a.path < b.path;
 }
 
+RESULT eServiceFS::startEdit(ePtr<iMutableServiceList> &res)
+{
+       res = 0;
+       return -1;
+}
+
 eAutoInitPtr<eServiceFactoryFS> init_eServiceFactoryFS(eAutoInitNumbers::service+1, "eServiceFactoryFS");
index 3400fb853752646f5110ba4e983f435d699f832c..46e8b890df61c1deeb4fac81158cbb3f7c03ccce 100644 (file)
@@ -37,6 +37,7 @@ public:
        RESULT getContent(std::list<eServiceReference> &list);
        RESULT getNext(eServiceReference &ptr);
        int compareLessEqual(const eServiceReference &, const eServiceReference &);
+       RESULT startEdit(ePtr<iMutableServiceList> &);
 };
 
 #endif