1 #include <lib/base/eerror.h>
2 #include <lib/base/estring.h>
3 #include <lib/python/python.h>
4 #include <lib/service/service.h>
5 #include <lib/base/init_num.h>
6 #include <lib/base/init.h>
7 #include <lib/python/python.h>
9 eServiceReference::eServiceReference(const std::string &string)
11 const char *c=string.c_str();
16 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 )
18 memset( data, 0, sizeof(data) );
19 eDebug("find old format eServiceReference string");
20 if ( sscanf(c, "%d:%d:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &pathl) < 2 )
26 const char *pathstr = c+pathl;
27 const char *namestr = strchr(pathstr, ':');
30 if (pathstr != namestr)
31 path.assign(pathstr, namestr-pathstr);
40 std::string eServiceReference::toString() const
46 for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
47 ret+=":"+ getNum(data[i], 0x10);
54 std::string eServiceReference::toCompareString() const
59 for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
60 ret+=":"+getNum(data[i], 0x10);
65 eServiceCenter *eServiceCenter::instance;
67 eServiceCenter::eServiceCenter()
71 eDebug("settings instance.");
76 eServiceCenter::~eServiceCenter()
80 eDebug("clear instance");
85 DEFINE_REF(eServiceCenter);
87 RESULT eServiceCenter::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
89 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
90 if (i == handler.end())
95 return i->second->play(ref, ptr);
98 RESULT eServiceCenter::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
100 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
101 if (i == handler.end())
106 return i->second->record(ref, ptr);
109 RESULT eServiceCenter::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
111 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
112 if (i == handler.end())
117 return i->second->list(ref, ptr);
120 RESULT eServiceCenter::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
122 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
123 if (i == handler.end())
128 return i->second->info(ref, ptr);
131 RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
133 std::map<int,ePtr<iServiceHandler> >::iterator i = handler.find(ref.type);
134 if (i == handler.end())
139 return i->second->offlineOperations(ref, ptr);
142 RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd)
144 handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
148 RESULT eServiceCenter::removeServiceFactory(int id)
154 /* default handlers */
155 RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr)
161 #include <lib/service/event.h>
163 RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
169 int iStaticServiceInformation::getLength(const eServiceReference &ref)
174 int iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
179 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
185 int iStaticServiceInformation::getInfo(const eServiceReference &ref, int w)
190 std::string iStaticServiceInformation::getInfoString(const eServiceReference &ref, int w)
195 int iServiceInformation::getInfo(int w)
200 std::string iServiceInformation::getInfoString(int w)
205 PyObject* iServiceInformation::getInfoObject(int w)
211 int iStaticServiceInformation::setInfo(const eServiceReference &ref, int w, int v)
216 int iStaticServiceInformation::setInfoString(const eServiceReference &ref, int w, const char *v)
221 int iServiceInformation::setInfo(int w, int v)
226 int iServiceInformation::setInfoString(int w, const char *v)
231 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");