TranscodingSetup : fix misspelling name.
[vuplus_dvbapp] / lib / base / nconfig.cpp
1 #include <lib/base/nconfig.h>
2 #include <lib/python/python.h>
3
4 ePyObject ePythonConfigQuery::m_queryFunc;
5
6 void ePythonConfigQuery::setQueryFunc(ePyObject queryFunc)
7 {
8         if (m_queryFunc)
9                 Py_DECREF(m_queryFunc);
10         m_queryFunc = queryFunc;
11         if (m_queryFunc)
12                 Py_INCREF(m_queryFunc);
13 }
14
15 RESULT ePythonConfigQuery::getConfigValue(const char *key, std::string &value)
16 {
17         if (key && PyCallable_Check(m_queryFunc))
18         {
19                 ePyObject pArgs = PyTuple_New(1);
20                 PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(key));
21                 ePyObject pRet = PyObject_CallObject(m_queryFunc, pArgs);
22                 Py_DECREF(pArgs);
23                 if (pRet)
24                 {
25                         if (PyString_Check(pRet))
26                         {
27                                 value.assign(PyString_AS_STRING(pRet));
28                                 Py_DECREF(pRet);
29                                 return 0;
30                         }
31                         Py_DECREF(pRet);
32                 }
33         }
34         return -1;
35 }