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 0a4a801..3a59d44 100644 (file)
@@ -101,6 +101,17 @@ RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInf
        return i->second->info(ref, ptr);
 }
 
        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));
 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
 {
        handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
index 2dd01ac..e08c2ad 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 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; }
        
                // eServiceCenter
        static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; }
index cb5b4b7..64e62ca 100644 (file)
@@ -54,6 +54,55 @@ int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
        return len / 90000;
 }
 
        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()
 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
 RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
 {
                        // TODO: handle the listing itself
index 1dd66e4..accdd20 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 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);
 };
 private:
        RESULT lookupService(ePtr<eDVBService> &ptr, const eServiceReference &ref);
 };
index 67b99c0..5b5957e 100644 (file)
@@ -12,7 +12,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
 #include <sys/stat.h>
 #include <unistd.h>
 
-
 class eStaticServiceFSInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceFSInformation);
 class eStaticServiceFSInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceFSInformation);
@@ -77,6 +76,12 @@ RESULT eServiceFactoryFS::info(const eServiceReference &ref, ePtr<iStaticService
        return 0;
 }
 
        return 0;
 }
 
+RESULT eServiceFactoryFS::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
 // eServiceFS
 
 DEFINE_REF(eServiceFS);
 // eServiceFS
 
 DEFINE_REF(eServiceFS);
@@ -148,7 +153,10 @@ RESULT eServiceFS::getNext(eServiceReference &ptr)
        }
        
        if (!m_list.size())
        }
        
        if (!m_list.size())
+       {
+               ptr = eServiceReference();
                return -ERANGE;
                return -ERANGE;
+       }
        
        ptr = m_list.front();
        m_list.pop_front();
        
        ptr = m_list.front();
        m_list.pop_front();
index e87b53a..73bfd98 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 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;
 };
 private:
        ePtr<iStaticServiceInformation> m_service_information;
 };
index 549a288..b0e30f7 100644 (file)
@@ -57,6 +57,13 @@ RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServic
        return 0;
 }
 
        return 0;
 }
 
+RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
+
 // eStaticServiceMP3Info
 
 
 // eStaticServiceMP3Info
 
 
index 9211785..558fd81 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 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;
 };
 private:
        ePtr<eStaticServiceMP3Info> m_service_info;
 };