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();
14 else 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 )
16 memset( data, 0, sizeof(data) );
17 eDebug("find old format eServiceReference string");
18 if ( sscanf(c, "%d:%d:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &pathl) < 2 )
24 const char *pathstr = c+pathl;
25 const char *namestr = strchr(pathstr, ':');
28 if (pathstr != namestr)
29 path.assign(pathstr, namestr-pathstr);
38 std::string eServiceReference::toString() const
44 for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
45 ret+=":"+ getNum(data[i], 0x10);
53 eServiceCenter *eServiceCenter::instance;
55 eServiceCenter::eServiceCenter()
59 eDebug("settings instance.");
64 eServiceCenter::~eServiceCenter()
68 eDebug("clear instance");
73 DEFINE_REF(eServiceCenter);
75 RESULT eServiceCenter::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
77 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
78 if (i == handler.end())
83 return i->second->play(ref, ptr);
86 RESULT eServiceCenter::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
88 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
89 if (i == handler.end())
94 return i->second->record(ref, ptr);
97 RESULT eServiceCenter::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
99 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
100 if (i == handler.end())
105 return i->second->list(ref, ptr);
108 RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
110 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
111 if (i == handler.end())
116 return i->second->info(ref, ptr);
119 RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
121 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
122 if (i == handler.end())
127 return i->second->offlineOperations(ref, ptr);
130 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
132 handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
136 RESULT eServiceCenter::removeServiceFactory(int id)
142 /* default handlers */
143 RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
149 #include <lib/service/event.h>
151 RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
157 int iStaticServiceInformation::getLength(const eServiceReference &ref)
162 bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
167 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
173 int iStaticServiceInformation::getInfo(const eServiceReference &ref, int w)
178 std::string iStaticServiceInformation::getInfoString(const eServiceReference &ref, int w)
183 int iServiceInformation::getInfo(int w)
188 std::string iServiceInformation::getInfoString(int w)
193 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");