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::addServiceFactory(int id, iServiceHandler *hnd)
106 handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
110 RESULT eServiceCenter::removeServiceFactory(int id)
116 /* default handlers */
117 RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
123 #include <lib/service/event.h>
125 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
132 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");