move services in bouquets is now possible.. (bouquet save is missing yet)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 13 Nov 2005 18:25:34 +0000 (18:25 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 13 Nov 2005 18:25:34 +0000 (18:25 +0000)
lib/dvb/db.cpp
lib/dvb/db.h
lib/dvb/idvb.h
lib/service/listboxservice.cpp
lib/service/servicedvb.cpp

index 70d512c..a9329f1 100644 (file)
 
 DEFINE_REF(eDVBService);
 
 
 DEFINE_REF(eDVBService);
 
+// the following three methodes are declared in idvb.h
+RESULT eBouquet::addService(const eServiceReference &ref)
+{
+       list::iterator it =
+               std::find(m_services.begin(), m_services.end(), ref);
+       if ( it != m_services.end() )
+               return -1;
+       m_services.push_back(ref);
+       return 0;
+}
+
+RESULT eBouquet::removeService(const eServiceReference &ref)
+{
+       list::iterator it =
+               std::find(m_services.begin(), m_services.end(), ref);
+       if ( it == m_services.end() )
+               return -1;
+       m_services.erase(it);
+       return 0;
+}
+
+RESULT eBouquet::moveService(const eServiceReference &ref, unsigned int pos)
+{
+       if ( pos < 0 || pos >= m_services.size() )
+               return -1;
+       list::iterator source=m_services.end();
+       list::iterator dest=m_services.end();
+       for (list::iterator it(m_services.begin()); it != m_services.end(); ++it)
+       {
+               if (dest == m_services.end() && !pos--)
+                       dest = it;
+               if (*it == ref)
+                       source = it;
+               if (dest != m_services.end() && source != m_services.end())
+                       break;
+       }
+       if (dest == m_services.end() || source == m_services.end() || source == dest)
+               return -1;
+       std::iter_swap(source,dest);
+       return 0;
+}
+
 eDVBService::eDVBService()
 {
 }
 eDVBService::eDVBService()
 {
 }
@@ -507,7 +549,7 @@ RESULT eDVBDB::getService(const eServiceReferenceDVB &reference, ePtr<eDVBServic
        return 0;
 }
 
        return 0;
 }
 
-RESULT eDVBDB::getBouquet(const eServiceReference &ref, const eBouquet* &bouquet)
+RESULT eDVBDB::getBouquet(const eServiceReference &ref, eBouquet* &bouquet)
 {
        std::string str = ref.path;
        if (str.empty())
 {
        std::string str = ref.path;
        if (str.empty())
index 265c597..a7350e7 100644 (file)
@@ -45,7 +45,7 @@ public:
 
        RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
 
 
        RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source);
 
-       RESULT getBouquet(const eServiceReference &ref, const eBouquet* &bouquet);
+       RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet);
 };
 
        // we have to add a possibility to invalidate here.
 };
 
        // we have to add a possibility to invalidate here.
index de481d7..6b65711 100644 (file)
@@ -19,7 +19,12 @@ struct eBouquet
 {
        std::string m_bouquet_name;
        std::string m_path;
 {
        std::string m_bouquet_name;
        std::string m_path;
-       std::list<eServiceReference> m_services;
+       typedef std::list<eServiceReference> list;
+       list m_services;
+// the following three methods are implemented in db.cpp
+       RESULT addService(const eServiceReference &);
+       RESULT removeService(const eServiceReference &);
+       RESULT moveService(const eServiceReference &, unsigned int);
 };
 
                // bitte KEINE operator int() definieren, sonst bringt das ganze nix!
 };
 
                // bitte KEINE operator int() definieren, sonst bringt das ganze nix!
@@ -262,7 +267,7 @@ public:
        virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0;
        virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
 
        virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0;
        virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
 
-       virtual RESULT getBouquet(const eServiceReference &ref, const eBouquet* &bouquet)=0;
+       virtual RESULT getBouquet(const eServiceReference &ref,  eBouquet* &bouquet)=0;
 
        virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source)=0;
 };
 
        virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source)=0;
 };
index f413f2e..19ff693 100644 (file)
@@ -155,7 +155,37 @@ int eListboxServiceContent::setCurrentMarked(bool state)
        m_current_marked = state;
 
        if (state != prev && m_listbox)
        m_current_marked = state;
 
        if (state != prev && m_listbox)
+       {
                m_listbox->entryChanged(m_cursor_number);
                m_listbox->entryChanged(m_cursor_number);
+               if (!state)
+               {
+                       ePtr<iListableService> lst;
+                       if (m_service_center->list(m_root, lst))
+                               eDebug("no list available!");
+                       else
+                       {
+                               ePtr<iMutableServiceList> list;
+                               if (lst->startEdit(list))
+                                       eDebug("no editable list");
+                               else
+                               {
+                                       eServiceReference ref;
+                                       getCurrent(ref);
+                                       if(!ref)
+                                               eDebug("no valid service selected");
+                                       else
+                                       {
+                                               int pos = cursorGet();
+                                               eDebugNoNewLine("move %s to %d ", ref.toString().c_str(), pos);
+                                               if (list->moveService(ref, cursorGet()))
+                                                       eDebug("failed");
+                                               else
+                                                       eDebug("ok");
+                                       }
+                               }
+                       }
+               }
+       }
 
        return 0;
 }
 
        return 0;
 }
index 94833f4..b1c18a1 100644 (file)
@@ -66,7 +66,7 @@ RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref
                return err;
        }
 
                return err;
        }
 
-       const eBouquet *bouquet=0;
+       eBouquet *bouquet=0;
        if ((err = db->getBouquet(ref, bouquet)) != 0)
        {
                eDebug("eStaticServiceDVBBouquetInformation::getName failed.. getBouquet failed!");
        if ((err = db->getBouquet(ref, bouquet)) != 0)
        {
                eDebug("eStaticServiceDVBBouquetInformation::getName failed.. getBouquet failed!");
@@ -280,10 +280,9 @@ RESULT eDVBServiceList::startEdit(ePtr<iMutableServiceList> &res)
                if (eDVBResourceManager::getInstance(resm) || resm->getChannelList(db))
                        return -1;
 
                if (eDVBResourceManager::getInstance(resm) || resm->getChannelList(db))
                        return -1;
 
-                       // FIXME!
-               if (db->getBouquet(m_parent, (const eBouquet*&)m_bouquet) != 0)
+               if (db->getBouquet(m_parent, m_bouquet) != 0)
                        return -1;
                        return -1;
-               
+
                res = this;
                
                return 0;
                res = this;
                
                return 0;
@@ -294,24 +293,23 @@ RESULT eDVBServiceList::startEdit(ePtr<iMutableServiceList> &res)
 
 RESULT eDVBServiceList::addService(eServiceReference &ref)
 {
 
 RESULT eDVBServiceList::addService(eServiceReference &ref)
 {
-       ASSERT(m_bouquet);
-//     return m_bouquet->addService(ref);
-       return -1;
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->addService(ref);
 }
 
 RESULT eDVBServiceList::removeService(eServiceReference &ref)
 {
 }
 
 RESULT eDVBServiceList::removeService(eServiceReference &ref)
 {
-       ASSERT(m_bouquet);
-//     return m_bouquet->removeService(ref);
-       return -1;
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->removeService(ref);
 }
 
 RESULT eDVBServiceList::moveService(eServiceReference &ref, int pos)
 {
 }
 
 RESULT eDVBServiceList::moveService(eServiceReference &ref, int pos)
 {
-       ASSERT(m_bouquet);
-       
-//     return m_bouquet->moveService(ref, pos);
-       return -1;
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->moveService(ref, pos);
 }
 
 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
 }
 
 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)