add function to get a comparable service reference string (useable to
[enigma2.git] / lib / service / service.cpp
index a490c3d7ba099d7177328435532d240c5d0ca81f..aa1ee4d855a0152a99b966f202b0bce57c635389 100644 (file)
@@ -1,19 +1,24 @@
 #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=0;
 
-       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 )
+       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)
@@ -46,6 +51,16 @@ std::string eServiceReference::toString() const
        return ret;
 }
 
+std::string eServiceReference::toCompareString() const
+{
+       std::string ret;
+       ret += getNum(type);
+       ret += ":0";
+       for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
+               ret+=":"+getNum(data[i], 0x10);
+       ret+=":"+path;
+       return ret;
+}
 
 eServiceCenter *eServiceCenter::instance;
 
@@ -187,4 +202,10 @@ 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");