remove new found flags when do a automatic scan and "clear before scan" was
[enigma2.git] / lib / service / service.cpp
index d079965b7fe90a96a42083e903628b2baf66ec35..a044c66a0ec3480edcad4dd174c7b57120ed30ef 100644 (file)
@@ -1,8 +1,55 @@
 #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 <lib/python/python.h>
+
+static std::string encode(const std::string s)
+{
+       int len = s.size();
+       std::string res;
+       int i;
+       for (i=0; i<len; ++i)
+       {
+               unsigned char c = s[i];
+               if ((c == ':') || (c < 32) || (c == '%'))
+               {
+                       res += "%";
+                       char hex[8];
+                       snprintf(hex, 8, "%02x", c);
+                       res += hex;
+               } else
+                       res += c;
+       }
+       return res;
+}
+
+static std::string decode(const std::string s)
+{
+       int len = s.size();
+       std::string res;
+       int i;
+       for (i=0; i<len; ++i)
+       {
+               unsigned char c = s[i];
+               if (c != '%')
+                       res += c;
+               else
+               {
+                       i += 2;
+                       if (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)
 {
@@ -33,6 +80,9 @@ eServiceReference::eServiceReference(const std::string &string)
                else
                        path=pathstr;
        }
+       
+       path = decode(path);
+       name = decode(name);
 }
 
 std::string eServiceReference::toString() const
@@ -43,12 +93,22 @@ std::string eServiceReference::toString() const
        ret += getNum(flags);
        for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
                ret+=":"+ getNum(data[i], 0x10);
-       ret+=":"+path;
+       ret+=":"+encode(path); /* we absolutely have a problem when the path contains a ':' (for example: http://). we need an encoding here. */
        if (name.length())
-               ret+=":"+name;
+               ret+=":"+encode(name);
        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+=":"+encode(path);
+       return ret;
+}
 
 eServiceCenter *eServiceCenter::instance;
 
@@ -159,9 +219,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)
 {
-       return true;
+       return 0;
 }
 
 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
@@ -180,6 +240,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;
@@ -190,4 +255,29 @@ 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<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");