finish and polish diseqc tester plugin
[enigma2.git] / lib / dvb / db.cpp
index c6c2e855cd692eeaf5a4619990a6d737845cf610..e5a943927fc6130d662dd23858ca73cde5424a1f 100644 (file)
@@ -497,7 +497,7 @@ void eDVBDB::saveServicelist(const char *file)
                {
                        if (sat.system == eDVBFrontendParametersSatellite::System::DVB_S2)
                        {
-                               fprintf(f, "\ts %d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
+                               fprintf(f, "\ts %d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d\n",
                                        sat.frequency, sat.symbol_rate,
                                        sat.polarisation, sat.fec,
                                        sat.orbital_position > 1800 ? sat.orbital_position - 3600 : sat.orbital_position,
@@ -505,11 +505,8 @@ void eDVBDB::saveServicelist(const char *file)
                                        flags,
                                        sat.system,
                                        sat.modulation,
-                                       sat.rolloff);
-                               if (sat.modulation == eDVBFrontendParametersSatellite::Modulation::M8PSK)
-                                       fprintf(f, ":%d\n", sat.pilot);
-                               else
-                                       fprintf(f, "\n");
+                                       sat.rolloff,
+                                       sat.pilot);
                        }
                        else
                        {
@@ -789,7 +786,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                return Py_False;
        }
        int tmp, *dest = NULL,
-               modulation, system, freq, sr, pol, fec, inv, pilot, rolloff;
+               modulation, system, freq, sr, pol, fec, inv, pilot, rolloff, tsid, onid;
        char *end_ptr;
        const Attribute *at;
        std::string name;
@@ -854,9 +851,12 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                inv = 2; // AUTO default
                                pilot = 2; // AUTO default
                                rolloff = 0; // alpha 0.35
+                               tsid = -1;
+                               onid = -1;
+
                                for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it)
                                {
-//                                     eDebug("\t\tattr: %s", at->name().c_str());
+                                       //eDebug("\t\tattr: %s", at->name().c_str());
                                        at = *it;
                                        name = at->name();
                                        if (name == "modulation") dest = &modulation;
@@ -868,6 +868,8 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                        else if (name == "inversion") dest = &inv;
                                        else if (name == "rolloff") dest = &rolloff;
                                        else if (name == "pilot") dest = &pilot;
+                                       else if (name == "tsid") dest = &tsid;
+                                       else if (name == "onid") dest = &onid;
                                        if (dest)
                                        {
                                                tmp = strtol(at->value().c_str(), &end_ptr, 10);
@@ -877,7 +879,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                }
                                if (freq && sr && pol != -1)
                                {
-                                       tuple = PyTuple_New(10);
+                                       tuple = PyTuple_New(12);
                                        PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(0));
                                        PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(freq));
                                        PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(sr));
@@ -888,6 +890,8 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                        PyTuple_SET_ITEM(tuple, 7, PyInt_FromLong(inv));
                                        PyTuple_SET_ITEM(tuple, 8, PyInt_FromLong(rolloff));
                                        PyTuple_SET_ITEM(tuple, 9, PyInt_FromLong(pilot));
+                                       PyTuple_SET_ITEM(tuple, 10, PyInt_FromLong(tsid));
+                                       PyTuple_SET_ITEM(tuple, 11, PyInt_FromLong(onid));
                                        PyList_Append(tplist, tuple);
                                        Py_DECREF(tuple);
                                }
@@ -1500,7 +1504,7 @@ int eDVBDBQueryBase::compareLessEqual(const eServiceReferenceDVB &a, const eServ
 {
        ePtr<eDVBService> a_service, b_service;
        int sortmode = m_query ? m_query->m_sort : eDVBChannelQuery::tName;
-       
+
        if ((sortmode == eDVBChannelQuery::tName) || (sortmode == eDVBChannelQuery::tProvider))
        {
                if (a.name.empty() && m_db->getService(a, a_service))
@@ -1508,7 +1512,7 @@ int eDVBDBQueryBase::compareLessEqual(const eServiceReferenceDVB &a, const eServ
                if (b.name.empty() && m_db->getService(b, b_service))
                        return 1;
        }
-       
+
        switch (sortmode)
        {
        case eDVBChannelQuery::tName:
@@ -1750,10 +1754,10 @@ static int decodeType(const std::string &type)
 RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::const_iterator begin, std::list<std::string>::const_iterator end)
 {
        std::list<std::string>::const_iterator end_of_exp;
-       
+
        if (begin == end)
                return 0;
-       
+
        if (*begin == "(")
        {
                end_of_exp = begin;
@@ -1762,36 +1766,36 @@ RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::cons
                                break;
                        else
                                ++end_of_exp;
-       
+
                if (end_of_exp == end)
                {
                        eDebug("expression parse: end of expression while searching for closing brace");
                        return -1;
                }
-               
+
                ++begin;
                // begin..end_of_exp
                int r = parseExpression(res, begin, end_of_exp);
                if (r)
                        return r;
                ++end_of_exp;
-               
+
                        /* we had only one sub expression */
                if (end_of_exp == end)
                {
 //                     eDebug("only one sub expression");
                        return 0;
                }
-               
+
                        /* otherwise we have an operator here.. */
-               
+
                ePtr<eDVBChannelQuery> r2 = res;
                res = new eDVBChannelQuery();
                res->m_sort = 0;
                res->m_p1 = r2;
                res->m_inverse = 0;
                r2 = 0;
-               
+
                if (*end_of_exp == "||")
                        res->m_type = eDVBChannelQuery::tOR;
                else if (*end_of_exp == "&&")
@@ -1802,18 +1806,18 @@ RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::cons
                        res = 0;
                        return 1;
                }
-               
+
                ++end_of_exp;
-               
+
                return parseExpression(res->m_p2, end_of_exp, end);
        }
-       
+
        // "begin" <op> "end"
        std::string type, op, val;
-       
+
        res = new eDVBChannelQuery();
        res->m_sort = 0;
-       
+
        int cnt = 0;
        while (begin != end)
        {
@@ -1835,23 +1839,23 @@ RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::cons
                ++begin;
                ++cnt;
        }
-       
+
        if (cnt != 3)
        {
                eDebug("malformed query: missing stuff");
                res = 0;
                return 1;
        }
-       
+
        res->m_type = decodeType(type);
-       
+
        if (res->m_type == -1)
        {
                eDebug("malformed query: invalid type %s", type.c_str());
                res = 0;
                return 1;
        }
-       
+
        if (op == "==")
                res->m_inverse = 0;
        else if (op == "!=")
@@ -1862,7 +1866,7 @@ RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::cons
                res = 0;
                return 1;
        }
-       
+
        res->m_string = val;
 
        if (res->m_type == eDVBChannelQuery::tChannelID)
@@ -1882,7 +1886,7 @@ RESULT parseExpression(ePtr<eDVBChannelQuery> &res, std::list<std::string>::cons
 RESULT eDVBChannelQuery::compile(ePtr<eDVBChannelQuery> &res, std::string query)
 {
        std::list<std::string> tokens;
-       
+
        std::string current_token;
        std::string bouquet_name;
 
@@ -1894,34 +1898,34 @@ RESULT eDVBChannelQuery::compile(ePtr<eDVBChannelQuery> &res, std::string query)
        {
                int c = (i < query.size()) ? query[i] : ' ';
                ++i;
-               
+
                int issplit = !!strchr(splitchars, c);
                int isaln = isalnum(c);
                int iswhite = c == ' ';
                int isquot = c == '\"';
-               
+
                if (quotemode)
                {
                        iswhite = issplit = 0;
                        isaln = lastalnum;
                }
-               
+
                if (issplit || iswhite || isquot || lastsplit || (lastalnum != isaln))
                {
                        if (current_token.size())
                                tokens.push_back(current_token);
                        current_token.clear();
                }
-               
+
                if (!(iswhite || isquot))
                        current_token += c;
-               
+
                if (isquot)
                        quotemode = !quotemode;
                lastsplit = issplit;
                lastalnum = isaln;
        }
-       
+
 //     for (std::list<std::string>::const_iterator a(tokens.begin()); a != tokens.end(); ++a)
 //     {
 //             printf("%s\n", a->c_str());
@@ -1973,12 +1977,12 @@ RESULT eDVBChannelQuery::compile(ePtr<eDVBChannelQuery> &res, std::string query)
                res = 0;
                return -1;
        }
-       
+
 //     eDebug("sort by %d", sort);
-       
+
                /* now we recursivly parse that. */
        int r = parseExpression(res, tokens.begin(), tokens.end());
-       
+
                /* we have an empty (but valid!) expression */
        if (!r && !res)
        {
@@ -1986,7 +1990,7 @@ RESULT eDVBChannelQuery::compile(ePtr<eDVBChannelQuery> &res, std::string query)
                res->m_inverse = 0;
                res->m_type = eDVBChannelQuery::tAny;
        }
-       
+
        if (res)
        {
                res->m_sort = sort;