add offline operations to services
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 29 Sep 2005 22:12:32 +0000 (22:12 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 29 Sep 2005 22:12:32 +0000 (22:12 +0000)
lib/service/service.cpp
lib/service/service.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicefs.cpp
lib/service/servicefs.h
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index 0a4a80127f58f3927008689f0831666e41c6fe33..3a59d444fb6b5d5295563b4a59eabfd394282182 100644 (file)
@@ -101,6 +101,17 @@ RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInf
        return i->second->info(ref, ptr);
 }
 
+RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
+{
+       std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
+       if (i == handler.end())
+       {
+               ptr = 0;
+               return -1;
+       }
+       return i->second->offlineOperations(ref, ptr);
+}
+
 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
 {
        handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
index 2dd01acc261d7dd7a1468a41f16bea92e4c42c00..e08c2ada52370ba8ea596d476ef65b0ed56c8e48 100644 (file)
@@ -24,6 +24,7 @@ public:
        RESULT record(const eServiceReference &, iRecordableServicePtr &ptr);
        RESULT list(const eServiceReference &, iListableServicePtr &ptr);
        RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
+       RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
        
                // eServiceCenter
        static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; }
index cb5b4b727ea1255cdc8bf5b4b86d60feda45319d..64e62cacba817a452a8d4569dce0626cad4b6f94 100644 (file)
@@ -54,6 +54,55 @@ int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
        return len / 90000;
 }
 
+
+
+class eDVBPVRServiceOfflineOperations: public iServiceOfflineOperations
+{
+       DECLARE_REF(eDVBPVRServiceOfflineOperations);
+       eServiceReferenceDVB m_ref;
+public:
+       eDVBPVRServiceOfflineOperations(const eServiceReference &ref);
+       
+       RESULT deleteFromDisk(int simulate);
+       RESULT getListOfFilenames(std::list<std::string> &);
+};
+
+DEFINE_REF(eDVBPVRServiceOfflineOperations);
+
+eDVBPVRServiceOfflineOperations::eDVBPVRServiceOfflineOperations(const eServiceReference &ref): m_ref((const eServiceReferenceDVB&)ref)
+{
+}
+
+RESULT eDVBPVRServiceOfflineOperations::deleteFromDisk(int simulate)
+{
+       if (simulate)
+               return 0;
+       else
+       {
+               std::list<std::string> res;
+               if (getListOfFilenames(res))
+                       return -1;
+               
+                               /* TODO: deferred removing.. */
+               for (std::list<std::string>::iterator i(res.begin()); i != res.end(); ++i)
+               {
+                       eDebug("Removing %s...", i->c_str());
+                       ::unlink(i->c_str());
+               }
+               
+               return 0;
+       }
+}
+
+RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list<std::string> &res)
+{
+       res.clear();
+       res.push_back(m_ref.path);
+       return 0;
+}
+
+
+
 DEFINE_REF(eServiceFactoryDVB)
 
 eServiceFactoryDVB::eServiceFactoryDVB()
@@ -169,6 +218,12 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic
        }
 }
 
+RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
 RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
 {
                        // TODO: handle the listing itself
index 1dd66e4046a3e5989baf0bc8e78dbfbfc260a3c6..accdd20d33f23ca002c6b1c25eab97980396c4e1 100644 (file)
@@ -20,6 +20,7 @@ public:
        RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
        RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
        RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
+       RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
 private:
        RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
 };
index 67b99c0865b623a5968f3107861ac10846a6c26f..5b5957eba1fd6066af3835623797e46a21aeefcd 100644 (file)
@@ -12,7 +12,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-
 class eStaticServiceFSInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceFSInformation);
@@ -77,6 +76,12 @@ RESULT eServiceFactoryFS::info(const eServiceReference &ref, ePtr<iStaticService
        return 0;
 }
 
+RESULT eServiceFactoryFS::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
 // eServiceFS
 
 DEFINE_REF(eServiceFS);
@@ -148,7 +153,10 @@ RESULT eServiceFS::getNext(eServiceReference &ptr)
        }
        
        if (!m_list.size())
+       {
+               ptr = eServiceReference();
                return -ERANGE;
+       }
        
        ptr = m_list.front();
        m_list.pop_front();
index e87b53a2b6bfff1f8a415074ae9c695105e7b695..73bfd985d416991ddc326c547ec39a43ee2feceb 100644 (file)
@@ -16,6 +16,7 @@ public:
        RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
        RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
        RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
+       RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
 private:
        ePtr<iStaticServiceInformation> m_service_information;
 };
index 549a288ad3dc378b6d31e9a6b8dfb7c09ec2e6c6..b0e30f7a0a400e3c24ccdf3ea0936782641288b4 100644 (file)
@@ -57,6 +57,13 @@ RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServic
        return 0;
 }
 
+RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
+
 // eStaticServiceMP3Info
 
 
index 92117857815b9b5be8c02322d5f6d998dcd89252..558fd81844004fd6a61f4cfd1a2d162063fcb9e5 100644 (file)
@@ -18,6 +18,7 @@ public:
        RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
        RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
        RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
+       RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
 private:
        ePtr<eStaticServiceMP3Info> m_service_info;
 };