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);
21 const char *pathstr = c+pathl;
22 const char *namestr = strchr(pathstr, ':');
25 if (pathstr != namestr)
26 path.assign(pathstr, namestr-pathstr);
35 std::string eServiceReference::toString() const
41 for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
42 ret+=":"+ getNum(data[i], 0x10);
50 eServiceCenter *eServiceCenter::instance;
52 eServiceCenter::eServiceCenter()
56 eDebug("settings instance.");
61 eServiceCenter::~eServiceCenter()
65 eDebug("clear instance");
70 DEFINE_REF(eServiceCenter);
72 RESULT eServiceCenter::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
74 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
75 if (i == handler.end())
80 return i->second->play(ref, ptr);
83 RESULT eServiceCenter::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
85 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
86 if (i == handler.end())
91 return i->second->record(ref, ptr);
94 RESULT eServiceCenter::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
96 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
97 if (i == handler.end())
102 return i->second->list(ref, ptr);
105 RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
107 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
108 if (i == handler.end())
113 return i->second->info(ref, ptr);
116 RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
118 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
119 if (i == handler.end())
124 return i->second->offlineOperations(ref, ptr);
127 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
129 handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
133 RESULT eServiceCenter::removeServiceFactory(int id)
139 /* default handlers */
140 RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
146 #include <lib/service/event.h>
148 RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
154 int iStaticServiceInformation::getLength(const eServiceReference &ref)
159 bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
164 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
170 int iStaticServiceInformation::getInfo(const eServiceReference &ref, int w)
175 std::string iStaticServiceInformation::getInfoString(const eServiceReference &ref, int w)
180 int iServiceInformation::getInfo(int w)
185 std::string iServiceInformation::getInfoString(int w)
190 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");