X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ddc3964ed95d01e72229dc9af968a327cd84e56c..7606810b356e9b3fbe1fbf7c7ca6da2e15e32a0e:/lib/service/service.cpp diff --git a/lib/service/service.cpp b/lib/service/service.cpp index d18b8eee..a044c66a 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -1,23 +1,88 @@ #include #include +#include #include #include #include +#include + +static std::string encode(const std::string s) +{ + int len = s.size(); + std::string res; + int i; + for (i=0; i= len) + break; + char s[3] = {s[i - 1], s[i], 0}; + unsigned char r = strtoul(s, 0, 0x10); + if (r) + res += r; + } + } + return res; +} + eServiceReference::eServiceReference(const std::string &string) { const char *c=string.c_str(); - int pathl=-1; - - 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 ) + int pathl=0; + + if (!string.length()) + type = idInvalid; + 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 ) { memset( data, 0, sizeof(data) ); eDebug("find old format eServiceReference string"); - sscanf(c, "%d:%d:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &pathl); + if ( sscanf(c, "%d:%d:%x:%x:%x:%x:%n", &type, &flags, &data[0], &data[1], &data[2], &data[3], &pathl) < 2 ) + type = idInvalid; } if (pathl) - path=c+pathl; + { + const char *pathstr = c+pathl; + const char *namestr = strchr(pathstr, ':'); + if (namestr) + { + if (pathstr != namestr) + path.assign(pathstr, namestr-pathstr); + if (*(namestr+1)) + name=namestr+1; + } + else + path=pathstr; + } + + path = decode(path); + name = decode(name); } std::string eServiceReference::toString() const @@ -27,13 +92,23 @@ std::string eServiceReference::toString() const ret += ":"; ret += getNum(flags); for (unsigned int i=0; i return i->second->list(ref, ptr); } +RESULT eServiceCenter::info(const eServiceReference &ref, ePtr &ptr) +{ + std::map >::iterator i = handler.find(ref.type); + if (i == handler.end()) + { + ptr = 0; + return -1; + } + return i->second->info(ref, ptr); +} + +RESULT eServiceCenter::offlineOperations(const eServiceReference &ref, ePtr &ptr) +{ + std::map >::iterator i = handler.find(ref.type); + if (i == handler.end()) + { + ptr = 0; + return -1; + } + return i->second->offlineOperations(ref, ptr); +} + RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd) { handler.insert(std::pair >(id, hnd)); @@ -102,4 +199,85 @@ RESULT eServiceCenter::removeServiceFactory(int id) return 0; } + /* default handlers */ +RESULT iServiceHandler::info(const eServiceReference &, ePtr &ptr) +{ + ptr = 0; + return -1; +} + +#include + +RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr &evt, time_t start_time) +{ + evt = 0; + return -1; +} + +int iStaticServiceInformation::getLength(const eServiceReference &ref) +{ + return -1; +} + +int iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) +{ + return 0; +} + +RESULT iServiceInformation::getEvent(ePtr &evt, int m_nownext) +{ + evt = 0; + return -1; +} + +int iStaticServiceInformation::getInfo(const eServiceReference &ref, int w) +{ + return -1; +} + +std::string iStaticServiceInformation::getInfoString(const eServiceReference &ref, int w) +{ + return ""; +} + +PyObject *iStaticServiceInformation::getInfoObject(const eServiceReference &ref, int w) +{ + Py_RETURN_NONE; +} + +int iServiceInformation::getInfo(int w) +{ + return -1; +} + +std::string iServiceInformation::getInfoString(int w) +{ + return ""; +} + +PyObject* iServiceInformation::getInfoObject(int w) +{ + Py_RETURN_NONE; +} + +int iStaticServiceInformation::setInfo(const eServiceReference &ref, int w, int v) +{ + return -1; +} + +int iStaticServiceInformation::setInfoString(const eServiceReference &ref, int w, const char *v) +{ + return -1; +} + +int iServiceInformation::setInfo(int w, int v) +{ + return -1; +} + +int iServiceInformation::setInfoString(int w, const char *v) +{ + return -1; +} + eAutoInitPtr init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");