Add service flags and pid cache to recordings meta file. This adds possibility to...
[enigma2.git] / lib / dvb / db.cpp
index 110cedd8c3bc96ece8a4ea74fb3fc0dac3ce677d..ae30e3604507a72df50b20b8aeeda9770dbdb2a1 100644 (file)
@@ -265,6 +265,42 @@ void eDVBDB::reloadServicelist()
        loadServicelist(CONFIGDIR"/enigma2/lamedb");
 }
 
+void eDVBDB::parseServiceData(ePtr<eDVBService> s, std::string str)
+{
+       while ((!str.empty()) && str[1]==':') // new: p:, f:, c:%02d...
+       {
+               size_t c=str.find(',');
+               char p=str[0];
+               std::string v;
+               if (c == std::string::npos)
+               {
+                       v=str.substr(2);
+                       str="";
+               } else
+               {
+                       v=str.substr(2, c-2);
+                       str=str.substr(c+1);
+               }
+//             eDebug("%c ... %s", p, v.c_str());
+               if (p == 'p')
+                       s->m_provider_name=v;
+               else if (p == 'f')
+               {
+                       sscanf(v.c_str(), "%x", &s->m_flags);
+               } else if (p == 'c')
+               {
+                       int cid, val;
+                       sscanf(v.c_str(), "%02d%x", &cid, &val);
+                       s->setCacheEntry((eDVBService::cacheID)cid,val);
+               } else if (p == 'C')
+               {
+                       int val;
+                       sscanf(v.c_str(), "%04x", &val);
+                       s->m_ca.push_front((uint16_t)val);
+               }
+       }
+}
+
        /* THIS CODE IS BAD. it should be replaced by somethine better. */
 void eDVBDB::loadServicelist(const char *file)
 {
@@ -425,44 +461,10 @@ void eDVBDB::loadServicelist(const char *file)
                fgets(line, 256, f);
                if (strlen(line))
                        line[strlen(line)-1]=0;
-               std::string str=line;
-
-               if (str[1]!=':')        // old ... (only service_provider)
-               {
+               if (line[1]!=':')       // old ... (only service_provider)
                        s->m_provider_name=line;
-               } else
-                       while ((!str.empty()) && str[1]==':') // new: p:, f:, c:%02d...
-                       {
-                               size_t c=str.find(',');
-                               char p=str[0];
-                               std::string v;
-                               if (c == std::string::npos)
-                               {
-                                       v=str.substr(2);
-                                       str="";
-                               } else
-                               {
-                                       v=str.substr(2, c-2);
-                                       str=str.substr(c+1);
-                               }
-//                             eDebug("%c ... %s", p, v.c_str());
-                               if (p == 'p')
-                                       s->m_provider_name=v;
-                               else if (p == 'f')
-                               {
-                                       sscanf(v.c_str(), "%x", &s->m_flags);
-                               } else if (p == 'c')
-                               {
-                                       int cid, val;
-                                       sscanf(v.c_str(), "%02d%x", &cid, &val);
-                                       s->setCacheEntry((eDVBService::cacheID)cid,val);
-                               } else if (p == 'C')
-                               {
-                                       int val;
-                                       sscanf(v.c_str(), "%04x", &val);
-                                       s->m_ca.push_front((uint16_t)val);
-                               }
-                       }
+               else
+                       parseServiceData(s, line);
                addService(ref, s);
        }
 
@@ -839,7 +841,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                        PyDict_SetItem(tp_dict, sat_pos, tplist);
                        for (ElementConstIterator it(sat_elements.begin()); it != sat_elements.end(); ++it)
                        {
-//                             eDebug("\telement: %s", (*it)->name().c_str());
+                               //eDebug("\telement: %s", (*it)->name().c_str());
                                const AttributeList &tp_attributes = (*it)->getAttributeList();
                                AttributeConstIterator end = tp_attributes.end();
                                modulation = eDVBFrontendParametersSatellite::Modulation_QPSK;
@@ -856,8 +858,8 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
 
                                for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it)
                                {
-                                       //eDebug("\t\tattr: %s", at->name().c_str());
                                        at = *it;
+                                       //eDebug("\t\tattr: %s", at->name().c_str());
                                        name = at->name();
                                        if (name == "modulation") dest = &modulation;
                                        else if (name == "system") dest = &system;
@@ -872,6 +874,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                        else if (name == "onid") dest = &onid;
                                        if (dest)
                                        {
+                                               //eDebug("\t\t\tvalue: %s", at->value().c_str());
                                                tmp = strtol(at->value().c_str(), &end_ptr, 10);
                                                if (!*end_ptr)
                                                        *dest = tmp;
@@ -1373,7 +1376,7 @@ RESULT eDVBDB::addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters
 {
        channel ch;
        std::map<eDVBChannelID, channel>::iterator it = m_channels.find(id);
-       assert(feparm);
+       ASSERT(feparm);
        ch.m_frontendParameters = feparm;
        if (it != m_channels.end())
                it->second = ch;