From: Andreas Monzner Date: Wed, 1 Oct 2008 09:38:58 +0000 (+0000) Subject: add possibility to delete all playable files in movielist.. X-Git-Tag: 2.6.0~832 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/c2065c013a7cd519374f5179ea71a3416cea9a3f add possibility to delete all playable files in movielist.. --- 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 #include #include +#include #include #include #include @@ -73,12 +74,63 @@ RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr &ptr) +class eMP3ServiceOfflineOperations: public iServiceOfflineOperations +{ + DECLARE_REF(eMP3ServiceOfflineOperations); + eServiceReference m_ref; +public: + eMP3ServiceOfflineOperations(const eServiceReference &ref); + + RESULT deleteFromDisk(int simulate); + RESULT getListOfFilenames(std::list &); +}; + +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 res; + if (getListOfFilenames(res)) + return -1; + + eBackgroundFileEraser *eraser = eBackgroundFileEraser::getInstance(); + if (!eraser) + eDebug("FATAL !! can't get background file eraser"); + + for (std::list::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 &res) +{ + res.clear(); + res.push_back(m_ref.path); + return 0; +} + + +RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &ref, ePtr &ptr) +{ + ptr = new eMP3ServiceOfflineOperations(ref); + return 0; +} // eStaticServiceMP3Info