From 4bc08995411e21f3564f09e136809be68ddf96a8 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 31 Jan 2005 22:51:14 +0000 Subject: - fixed dvb scan - fixed dvbdb (reading/writing lamedb) - fixed (i.e. disallow) operator= in iObject (destroyed refcounts before) - implemented listboxcontent for servicelists - implemented getServiceInformation for non-playing services (still not happy with the result, though) - implemented first try of serviceSelector component --- lib/service/Makefile.am | 2 +- lib/service/iservice.h | 8 +++++++- lib/service/service.cpp | 18 ++++++++++++++++++ lib/service/service.h | 1 + lib/service/servicedvb.cpp | 2 +- lib/service/servicedvb.h | 2 +- lib/service/servicefs.cpp | 23 +++++++++++++++++++++++ lib/service/servicefs.h | 3 +++ lib/service/servicemp3.cpp | 33 +++++++++++++++++++++++++++++++-- lib/service/servicemp3.h | 16 +++++++++++++++- 10 files changed, 101 insertions(+), 7 deletions(-) (limited to 'lib/service') diff --git a/lib/service/Makefile.am b/lib/service/Makefile.am index 09ba4ce8..a3c05cfa 100644 --- a/lib/service/Makefile.am +++ b/lib/service/Makefile.am @@ -4,5 +4,5 @@ INCLUDES = \ noinst_LIBRARIES = libenigma_service.a libenigma_service_a_SOURCES = \ - service.cpp servicemp3.cpp servicedvb.cpp servicefs.cpp + listboxservice.cpp service.cpp servicemp3.cpp servicedvb.cpp servicefs.cpp diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 766d850e..01c61fcc 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -142,10 +142,15 @@ public: } }; + /* the reason we have the servicereference as additional argument is + that we don't have to create one object for every entry in a possibly + large list, provided that no state information is nessesary to deliver + the required information. Anyway - ref *must* be the same as the argument + to the info() or getIServiceInformation call! */ class iServiceInformation: public iObject { public: - virtual RESULT getName(std::string &name)=0; + virtual RESULT getName(const eServiceReference &ref, std::string &name)=0; }; typedef ePtr iServiceInformationPtr; @@ -203,6 +208,7 @@ public: virtual RESULT play(const eServiceReference &, ePtr &ptr)=0; virtual RESULT record(const eServiceReference &, ePtr &ptr)=0; virtual RESULT list(const eServiceReference &, ePtr &ptr)=0; + virtual RESULT info(const eServiceReference &, ePtr &ptr); }; typedef ePtr iServiceHandlerPtr; diff --git a/lib/service/service.cpp b/lib/service/service.cpp index d18b8eee..40cbf8df 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -90,6 +90,17 @@ RESULT eServiceCenter::list(const eServiceReference &ref, ePtr return i->second->list(ref, ptr); } +RESULT eServiceCenter::info(const eServiceReference &ref, ePtr &ptr) +{ + std::map >::iterator i = handler.find(ref.type); + if (i == handler.end()) + { + ptr = 0; + return -1; + } + return i->second->info(ref, ptr); +} + RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd) { handler.insert(std::pair >(id, hnd)); @@ -102,4 +113,11 @@ RESULT eServiceCenter::removeServiceFactory(int id) return 0; } + /* default handlers */ +RESULT iServiceHandler::info(const eServiceReference &, ePtr &ptr) +{ + ptr = 0; + return -1; +} + eAutoInitPtr init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter"); diff --git a/lib/service/service.h b/lib/service/service.h index fbe34278..c3f0c482 100644 --- a/lib/service/service.h +++ b/lib/service/service.h @@ -23,6 +23,7 @@ public: RESULT play(const eServiceReference &, iPlayableServicePtr &ptr); RESULT record(const eServiceReference &, iRecordableServicePtr &ptr); RESULT list(const eServiceReference &, iListableServicePtr &ptr); + RESULT info(const eServiceReference &, ePtr &ptr); // eServiceCenter static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; } diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 3b22ab7b..0c6d72bd 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -158,7 +158,7 @@ RESULT eDVBServicePlay::getIServiceInformation(ePtr &ptr) return 0; } -RESULT eDVBServicePlay::getName(std::string &name) +RESULT eDVBServicePlay::getName(const eServiceReference &ref, std::string &name) { name = "DVB service"; return 0; diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 42ca30f7..c54eb5c0 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -45,7 +45,7 @@ public: RESULT getIServiceInformation(ePtr &ptr); // iServiceInformation - RESULT getName(std::string &name); + RESULT getName(const eServiceReference &ref, std::string &name); }; #endif diff --git a/lib/service/servicefs.cpp b/lib/service/servicefs.cpp index f4a9b737..de75cc67 100644 --- a/lib/service/servicefs.cpp +++ b/lib/service/servicefs.cpp @@ -11,6 +11,21 @@ #include #include + +class eServiceFSInformation: public iServiceInformation +{ + DECLARE_REF; +public: + RESULT getName(const eServiceReference &ref, std::string &name); +}; + +DEFINE_REF(eServiceFSInformation); + +RESULT eServiceFSInformation::getName(const eServiceReference &ref, std::string &name) +{ + name = ref.path; +} + // eServiceFactoryFS eServiceFactoryFS::eServiceFactoryFS() @@ -20,6 +35,8 @@ eServiceFactoryFS::eServiceFactoryFS() eServiceCenter::getInstance(sc); if (sc) sc->addServiceFactory(eServiceFactoryFS::id, this); + + m_service_information = new eServiceFSInformation(); } eServiceFactoryFS::~eServiceFactoryFS() @@ -52,6 +69,12 @@ RESULT eServiceFactoryFS::list(const eServiceReference &ref, ePtr &ptr) +{ + ptr = m_service_information; + return 0; +} + // eServiceFS DEFINE_REF(eServiceFS); diff --git a/lib/service/servicefs.h b/lib/service/servicefs.h index 7e66ba21..d8e77609 100644 --- a/lib/service/servicefs.h +++ b/lib/service/servicefs.h @@ -15,6 +15,9 @@ public: RESULT play(const eServiceReference &, ePtr &ptr); RESULT record(const eServiceReference &, ePtr &ptr); RESULT list(const eServiceReference &, ePtr &ptr); + RESULT info(const eServiceReference &, ePtr &ptr); +private: + ePtr m_service_information; }; class eServiceFS: public iListableService diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index d1c9001d..1f883f94 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -16,6 +16,8 @@ eServiceFactoryMP3::eServiceFactoryMP3() eServiceCenter::getInstance(sc); if (sc) sc->addServiceFactory(eServiceFactoryMP3::id, this); + + m_service_info = new eServiceMP3Info(); } eServiceFactoryMP3::~eServiceFactoryMP3() @@ -49,8 +51,35 @@ RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr &ptr) +{ + ptr = m_service_info; + return 0; +} + +// eServiceMP3Info + + +// eServiceMP3Info is seperated from eServiceMP3 to give information +// about unopened files. + +// probably eServiceMP3 should use this class as well, and eServiceMP3Info +// should have a database backend where ID3-files etc. are cached. +// this would allow listing the mp3 database based on certain filters. +DEFINE_REF(eServiceMP3Info) + +eServiceMP3Info::eServiceMP3Info() +{ +} + +RESULT eServiceMP3Info::getName(const eServiceReference &ref, std::string &name) +{ + name = "MP3 file: " + ref.path; + return 0; +} + +// eServiceMP3 void eServiceMP3::test_end() { @@ -113,7 +142,7 @@ RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; } RESULT eServiceMP3::getIServiceInformation(ePtr&i) { i = this; return 0; } -RESULT eServiceMP3::getName(std::string &name) +RESULT eServiceMP3::getName(const eServiceReference &ref, std::string &name) { name = "MP3 File: " + filename; return 0; diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index cfca4242..7ef84025 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -3,6 +3,8 @@ #include +class eServiceMP3Info ; + class eServiceFactoryMP3: public iServiceHandler { DECLARE_REF; @@ -15,6 +17,18 @@ public: RESULT play(const eServiceReference &, ePtr &ptr); RESULT record(const eServiceReference &, ePtr &ptr); RESULT list(const eServiceReference &, ePtr &ptr); + RESULT info(const eServiceReference &, ePtr &ptr); +private: + ePtr m_service_info; +}; + +class eServiceMP3Info: public iServiceInformation +{ + DECLARE_REF; + friend class eServiceFactoryMP3; + eServiceMP3Info(); +public: + RESULT getName(const eServiceReference &ref, std::string &name); }; class eServiceMP3: public iPlayableService, public iPauseableService, public iServiceInformation, public Object @@ -48,7 +62,7 @@ public: RESULT getIServiceInformation(ePtr&); // iServiceInformation - RESULT getName(std::string &name); + RESULT getName(const eServiceReference &ref, std::string &name); }; #endif -- cgit v1.2.3