X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fservice%2Fservice.cpp;h=77bfda99517d31eeddba4e35d43216ff30b5d3c8;hb=dba8122997839f5084ebb20594f28ac9ceff207a;hp=181ec22f26ebf898075b649f01d9bb6fa7944272;hpb=6dcb75c26bbfec04b381bb99d75404f9fe50635d;p=vuplus_dvbapp diff --git a/lib/service/service.cpp b/lib/service/service.cpp old mode 100644 new mode 100755 index 181ec22..77bfda9 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -6,6 +6,51 @@ #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 t[3] = {s[i - 1], s[i], 0}; + unsigned char r = strtoul(t, 0, 0x10); + if (r) + res += r; + } + } + return res; +} + + eServiceReference::eServiceReference(const std::string &string) { const char *c=string.c_str(); @@ -20,21 +65,44 @@ eServiceReference::eServiceReference(const std::string &string) 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) { const char *pathstr = c+pathl; - const char *namestr = strchr(pathstr, ':'); + const char *namestr = NULL; + int found = strlen(pathstr)-1; + for(;found >= 0;found--) + { + if(pathstr[found] == ':') + break; + } + if (found != -1) + namestr = pathstr + found; if (namestr) { - if (pathstr != namestr) - path.assign(pathstr, namestr-pathstr); - if (*(namestr+1)) - name=namestr+1; + if (!strncmp(namestr, "://", 3)) // The path is a url (e.g. "http://...") + { + namestr = strchr(namestr, ' '); + if (namestr) + { + path.assign(pathstr, namestr - pathstr); + if (*(namestr + 1)) + name = namestr + 1; + } + } + else + { + 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 @@ -45,9 +113,9 @@ std::string eServiceReference::toString() const ret += getNum(flags); for (unsigned int i=0; isecond->offlineOperations(ref, ptr); } -RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd) +RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd, std::list &extensions) { handler.insert(std::pair >(id, hnd)); + this->extensions[id]=extensions; return 0; } RESULT eServiceCenter::removeServiceFactory(int id) { handler.erase(id); + extensions.erase(id); + return 0; +} + +RESULT eServiceCenter::addFactoryExtension(int id, const char *extension) +{ + std::map >::iterator it = extensions.find(id); + if (it == extensions.end()) + return -1; + it->second.push_back(extension); + return 0; +} + +RESULT eServiceCenter::removeFactoryExtension(int id, const char *extension) +{ + std::map >::iterator it = extensions.find(id); + if (it == extensions.end()) + return -1; + it->second.remove(extension); return 0; } + +int eServiceCenter::getServiceTypeForExtension(const char *str) +{ + for (std::map >::iterator sit(extensions.begin()); sit != extensions.end(); ++sit) + { + for (std::list::iterator eit(sit->second.begin()); eit != sit->second.end(); ++eit) + { + if (*eit == str) + return sit->first; + } + } + return -1; +} + +int eServiceCenter::getServiceTypeForExtension(const std::string &str) +{ + return getServiceTypeForExtension(str.c_str()); +} + /* default handlers */ RESULT iServiceHandler::info(const eServiceReference &, ePtr &ptr) { @@ -171,9 +278,9 @@ int iStaticServiceInformation::getLength(const eServiceReference &ref) return -1; } -bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) +int iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { - return true; + return 0; } RESULT iServiceInformation::getEvent(ePtr &evt, int m_nownext) @@ -192,6 +299,11 @@ std::string iStaticServiceInformation::getInfoString(const eServiceReference &re return ""; } +PyObject *iStaticServiceInformation::getInfoObject(const eServiceReference &ref, int w) +{ + Py_RETURN_NONE; +} + int iServiceInformation::getInfo(int w) { return -1; @@ -204,8 +316,7 @@ std::string iServiceInformation::getInfoString(int w) PyObject* iServiceInformation::getInfoObject(int w) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } int iStaticServiceInformation::setInfo(const eServiceReference &ref, int w, int v)