move services in bouquets is now possible.. (bouquet save is missing yet)
[enigma2.git] / lib / service / servicedvb.cpp
index f3215d82f1059069a3e2a5d7f1cd07ff6e98d7fa..b1c18a1d719360311ad8b1ac591e2f68d62c6426 100644 (file)
@@ -66,7 +66,7 @@ RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref
                return err;
        }
 
-       const eBouquet *bouquet=0;
+       eBouquet *bouquet=0;
        if ((err = db->getBouquet(ref, bouquet)) != 0)
        {
                eDebug("eStaticServiceDVBBouquetInformation::getName failed.. getBouquet failed!");
@@ -173,11 +173,10 @@ RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list<std::string
 {
        res.clear();
        res.push_back(m_ref.path);
+       res.push_back(m_ref.path + ".meta");
        return 0;
 }
 
-
-
 DEFINE_REF(eServiceFactoryDVB)
 
 eServiceFactoryDVB::eServiceFactoryDVB()
@@ -227,7 +226,7 @@ RESULT eDVBServiceList::startQuery()
        
        ePtr<eDVBChannelQuery> q;
        
-       if (m_parent.path.size())
+       if (!m_parent.path.empty())
        {
                eDVBChannelQuery::compile(q, m_parent.path);
                if (!q)
@@ -271,6 +270,48 @@ 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;
+
+               if (db->getBouquet(m_parent, m_bouquet) != 0)
+                       return -1;
+
+               res = this;
+               
+               return 0;
+       }
+       res = 0;
+       return -1;
+}
+
+RESULT eDVBServiceList::addService(eServiceReference &ref)
+{
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->addService(ref);
+}
+
+RESULT eDVBServiceList::removeService(eServiceReference &ref)
+{
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->removeService(ref);
+}
+
+RESULT eDVBServiceList::moveService(eServiceReference &ref, int pos)
+{
+       if (!m_bouquet)
+               return -1;
+       return m_bouquet->moveService(ref, pos);
+}
+
 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
 {
        ePtr<eDVBService> service;
@@ -284,8 +325,15 @@ RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableServ
 
 RESULT eServiceFactoryDVB::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
 {
-       ptr = new eDVBServiceRecord((eServiceReferenceDVB&)ref);
-       return 0;
+       if (ref.path.empty())
+       {
+               ptr = new eDVBServiceRecord((eServiceReferenceDVB&)ref);
+               return 0;
+       } else
+       {
+               ptr = 0;
+               return -1;
+       }
 }
 
 RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
@@ -309,7 +357,7 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic
                ptr = new eStaticServiceDVBBouquetInformation;
                return 0;
        }
-       else if (ref.path.size())
+       else if (!ref.path.empty())
        {
                ptr = new eStaticServiceDVBPVRInformation(ref);
                return 0;
@@ -327,10 +375,17 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic
        }
 }
 
-RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
 {
-       ptr = 0;
-       return -1;
+       if (ref.path.empty())
+       {
+               ptr = 0;
+               return -1;
+       } else
+       {
+               ptr = new eDVBPVRServiceOfflineOperations(ref);
+               return 0;
+       }
 }
 
 RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
@@ -578,6 +633,18 @@ RESULT eDVBServicePlay::seekTo(pts_t to)
        return -1;
 }
 
+RESULT eDVBServicePlay::seekRelative(int direction, pts_t to)
+{
+       eDebug("eDVBServicePlay::seekRelative: jump %d, %lld", direction, to);
+
+       ePtr<iDVBPVRChannel> pvr_channel;
+       
+       if (m_service_handler.getPVRChannel(pvr_channel))
+               return -1;
+       
+       return pvr_channel->seekToPosition(SEEK_CUR, to);
+}
+
 RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
 {
        ePtr<iDVBPVRChannel> pvr_channel;