1 #include <lib/base/eerror.h>
2 #include <lib/base/estring.h>
3 #include <lib/service/service.h>
4 #include <lib/base/init_num.h>
5 #include <lib/base/init.h>
7 eServiceReference::eServiceReference(const std::string &string)
9 const char *c=string.c_str();
12 if ( sscanf(c, "%d:%d:%x:%x:%x:%x:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7], &pathl) < 8 )
14 memset( data, 0, sizeof(data) );
15 eDebug("find old format eServiceReference string");
16 sscanf(c, "%d:%d:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &pathl);
23 std::string eServiceReference::toString() const
29 for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
31 ret+=":"+ getNum(data[i], 0x10);
38 eServiceCenter *eServiceCenter::instance;
40 eServiceCenter::eServiceCenter()
44 eDebug("settings instance.");
49 eServiceCenter::~eServiceCenter()
53 eDebug("clear instance");
58 DEFINE_REF(eServiceCenter);
60 RESULT eServiceCenter::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
62 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
63 if (i == handler.end())
68 return i->second->play(ref, ptr);
71 RESULT eServiceCenter::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
73 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
74 if (i == handler.end())
79 return i->second->record(ref, ptr);
82 RESULT eServiceCenter::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
84 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
85 if (i == handler.end())
90 return i->second->list(ref, ptr);
93 RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
95 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
96 if (i == handler.end())
101 return i->second->info(ref, ptr);
104 RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
106 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
107 if (i == handler.end())
112 return i->second->offlineOperations(ref, ptr);
115 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
117 handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
121 RESULT eServiceCenter::removeServiceFactory(int id)
127 /* default handlers */
128 RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
134 #include <lib/service/event.h>
136 RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt)
142 int iStaticServiceInformation::getLength(const eServiceReference &ref)
147 bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
152 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
158 int iServiceInformation::getInfo(int w)
163 std::string iServiceInformation::getInfoString(int w)
168 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");