fix typo
[enigma2.git] / lib / service / service.cpp
index 3a59d444fb6b5d5295563b4a59eabfd394282182..11f88b1fe251c14170c233846e5f80ac1cd0fbc6 100644 (file)
@@ -1,23 +1,40 @@
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
+#include <lib/python/python.h>
 #include <lib/service/service.h>
 #include <lib/base/init_num.h>
 #include <lib/base/init.h>
+#include <Python.h>
 
 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;
+       }
 }
 
 std::string eServiceReference::toString() const
@@ -27,10 +44,10 @@ std::string eServiceReference::toString() const
        ret += ":";
        ret += getNum(flags);
        for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
-       {
                ret+=":"+ getNum(data[i], 0x10);
-       }
        ret+=":"+path;
+       if (name.length())
+               ret+=":"+name;
        return ret;
 }
 
@@ -133,11 +150,52 @@ RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInfor
 
 #include <lib/service/event.h>
 
+RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
+{
+       evt = 0;
+       return -1;
+}
+
+int iStaticServiceInformation::getLength(const eServiceReference &ref)
+{
+       return -1;
+}
+
+bool iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+{
+       return true;
+}
+
 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &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 "";
+}
+
+int iServiceInformation::getInfo(int w)
+{
+       return -1;
+}
+
+std::string iServiceInformation::getInfoString(int w)
+{
+       return "";
+}
+
+PyObject* iServiceInformation::getInfoObject(int w)
+{
+       Py_INCREF(Py_None);
+       return Py_None;
+}
 
 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");