MoviePlayer: offer "help"
[enigma2.git] / lib / service / servicemp3.cpp
index a6d1928..dc038a8 100644 (file)
@@ -9,20 +9,22 @@
 
 // eServiceFactoryMP3
 
-eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
+eServiceFactoryMP3::eServiceFactoryMP3()
 {
        ePtr<eServiceCenter> sc;
        
-       eServiceCenter::getInstance(sc);
+       eServiceCenter::getPrivInstance(sc);
        if (sc)
                sc->addServiceFactory(eServiceFactoryMP3::id, this);
+
+       m_service_info = new eStaticServiceMP3Info();
 }
 
 eServiceFactoryMP3::~eServiceFactoryMP3()
 {
        ePtr<eServiceCenter> sc;
        
-       eServiceCenter::getInstance(sc);
+       eServiceCenter::getPrivInstance(sc);
        if (sc)
                sc->removeServiceFactory(eServiceFactoryMP3::id);
 }
@@ -49,8 +51,47 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService
        return -1;
 }
 
-// eServiceMP3
+RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
+{
+       ptr = m_service_info;
+       return 0;
+}
+
+RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+       ptr = 0;
+       return -1;
+}
+
+
+// eStaticServiceMP3Info
+
+
+// eStaticServiceMP3Info is seperated from eServiceMP3 to give information
+// about unopened files.
+
+// probably eServiceMP3 should use this class as well, and eStaticServiceMP3Info
+// should have a database backend where ID3-files etc. are cached.
+// this would allow listing the mp3 database based on certain filters.
 
+DEFINE_REF(eStaticServiceMP3Info)
+
+eStaticServiceMP3Info::eStaticServiceMP3Info()
+{
+}
+
+RESULT eStaticServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
+{
+       name = "MP3 file: " + ref.path;
+       return 0;
+}
+
+int eStaticServiceMP3Info::getLength(const eServiceReference &ref)
+{
+       return -1;
+}
+
+// eServiceMP3
 
 void eServiceMP3::test_end()
 {
@@ -58,7 +99,7 @@ void eServiceMP3::test_end()
        stop();
 }
 
-eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp)
+eServiceMP3::eServiceMP3(const char *filename): filename(filename), test(eApp)
 {
        m_state = stIdle;
        eDebug("SERVICEMP3 construct!");
@@ -75,7 +116,7 @@ DEFINE_REF(eServiceMP3);
 
 RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
 {
-       connection = new eConnection(this, m_event.connect(event));
+       connection = new eConnection((iPlayableService*)this, m_event.connect(event));
        return 0;
 }
 
@@ -105,15 +146,18 @@ RESULT eServiceMP3::stop()
        return 0;
 }
 
-RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
+RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
+RESULT eServiceMP3::seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; }
+
+RESULT eServiceMP3::audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; };
 
                // iPausableService
 RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; }
 RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; }
 
-RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; }
+RESULT eServiceMP3::info(ePtr<iServiceInformation>&i) { i = this; return 0; }
 
-RESULT eServiceMP3::getName(eString &name)
+RESULT eServiceMP3::getName(std::string &name)
 {
        name = "MP3 File: " + filename;
        return 0;