diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-01 09:38:58 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-01 09:38:58 +0000 |
| commit | c2065c013a7cd519374f5179ea71a3416cea9a3f (patch) | |
| tree | ab4b19d904370c27690fe10e645a29cf0d3dae5b /lib | |
| parent | 2ec8de5ae8adc05f214b851adbb3529a6b65fd59 (diff) | |
| download | enigma2-c2065c013a7cd519374f5179ea71a3416cea9a3f.tar.gz enigma2-c2065c013a7cd519374f5179ea71a3416cea9a3f.zip | |
add possibility to delete all playable files in movielist..
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/service/servicemp3.cpp | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 1c062534..d94ced43 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -8,6 +8,7 @@ #include <string> #include <lib/service/servicemp3.h> #include <lib/service/service.h> +#include <lib/components/file_eraser.h> #include <lib/base/init_num.h> #include <lib/base/init.h> #include <gst/gst.h> @@ -73,12 +74,63 @@ RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServic return 0; } -RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr) +class eMP3ServiceOfflineOperations: public iServiceOfflineOperations +{ + DECLARE_REF(eMP3ServiceOfflineOperations); + eServiceReference m_ref; +public: + eMP3ServiceOfflineOperations(const eServiceReference &ref); + + RESULT deleteFromDisk(int simulate); + RESULT getListOfFilenames(std::list<std::string> &); +}; + +DEFINE_REF(eMP3ServiceOfflineOperations); + +eMP3ServiceOfflineOperations::eMP3ServiceOfflineOperations(const eServiceReference &ref): m_ref((const eServiceReference&)ref) { - ptr = 0; - return -1; } +RESULT eMP3ServiceOfflineOperations::deleteFromDisk(int simulate) +{ + if (simulate) + return 0; + else + { + std::list<std::string> res; + if (getListOfFilenames(res)) + return -1; + + eBackgroundFileEraser *eraser = eBackgroundFileEraser::getInstance(); + if (!eraser) + eDebug("FATAL !! can't get background file eraser"); + + for (std::list<std::string>::iterator i(res.begin()); i != res.end(); ++i) + { + eDebug("Removing %s...", i->c_str()); + if (eraser) + eraser->erase(i->c_str()); + else + ::unlink(i->c_str()); + } + + return 0; + } +} + +RESULT eMP3ServiceOfflineOperations::getListOfFilenames(std::list<std::string> &res) +{ + res.clear(); + res.push_back(m_ref.path); + return 0; +} + + +RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr) +{ + ptr = new eMP3ServiceOfflineOperations(ref); + return 0; +} // eStaticServiceMP3Info |
