+#include <lib/dvb/metaparser.h>
+#include <lib/dvb/tstools.h>
+
+class eStaticServiceDVBInformation: public iStaticServiceInformation
+{
+ DECLARE_REF(eStaticServiceDVBInformation);
+public:
+ RESULT getName(const eServiceReference &ref, std::string &name);
+ int getLength(const eServiceReference &ref);
+};
+
+DEFINE_REF(eStaticServiceDVBInformation);
+
+RESULT eStaticServiceDVBInformation::getName(const eServiceReference &ref, std::string &name)
+{
+ if ( ref.name.length() )
+ {
+ name = ref.name;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+int eStaticServiceDVBInformation::getLength(const eServiceReference &ref)
+{
+ return -1;
+}
+
+class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation
+{
+ DECLARE_REF(eStaticServiceDVBBouquetInformation);
+public:
+ RESULT getName(const eServiceReference &ref, std::string &name);
+ int getLength(const eServiceReference &ref);
+};
+
+DEFINE_REF(eStaticServiceDVBBouquetInformation);
+
+RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref, std::string &name)
+{
+ ePtr<iDVBChannelList> db;
+ ePtr<eDVBResourceManager> res;
+
+ int err;
+ if ((err = eDVBResourceManager::getInstance(res)) != 0)
+ {
+ eDebug("eStaticServiceDVBBouquetInformation::getName failed.. no resource manager!");
+ return err;
+ }
+ if ((err = res->getChannelList(db)) != 0)
+ {
+ eDebug("eStaticServiceDVBBouquetInformation::getName failed.. no channel list!");
+ return err;
+ }
+
+ eBouquet *bouquet=0;
+ if ((err = db->getBouquet(ref, bouquet)) != 0)
+ {
+ eDebug("eStaticServiceDVBBouquetInformation::getName failed.. getBouquet failed!");
+ return -1;
+ }
+
+ if ( bouquet && bouquet->m_bouquet_name.length() )
+ {
+ name = "[Bouquet] " + bouquet->m_bouquet_name;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref)
+{
+ return -1;
+}
+
+class eStaticServiceDVBPVRInformation: public iStaticServiceInformation
+{
+ DECLARE_REF(eStaticServiceDVBPVRInformation);
+ eServiceReference m_ref;
+ eDVBMetaParser m_parser;
+public:
+ eStaticServiceDVBPVRInformation(const eServiceReference &ref);
+ RESULT getName(const eServiceReference &ref, std::string &name);
+ int getLength(const eServiceReference &ref);
+};
+
+DEFINE_REF(eStaticServiceDVBPVRInformation);
+
+eStaticServiceDVBPVRInformation::eStaticServiceDVBPVRInformation(const eServiceReference &ref)
+{
+ m_ref = ref;
+ m_parser.parseFile(ref.path);
+}
+
+RESULT eStaticServiceDVBPVRInformation::getName(const eServiceReference &ref, std::string &name)
+{
+ ASSERT(ref == m_ref);
+ name = m_parser.m_name.size() ? m_parser.m_name : ref.path;
+ return 0;
+}
+
+int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
+{
+ ASSERT(ref == m_ref);
+
+ eDVBTSTools tstools;
+
+ if (tstools.openFile(ref.path.c_str()))
+ return 0;
+
+ pts_t len;
+ if (tstools.calcLen(len))
+ return 0;
+
+ 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);
+ res.push_back(m_ref.path + ".meta");
+ return 0;
+}