From 0b0267de3c60f57474386c6af57041ed8a367e99 Mon Sep 17 00:00:00 2001 From: pieterg Date: Mon, 15 Aug 2011 15:40:23 +0200 Subject: [PATCH] pcore: add python wrapper for getRecordings And move it to a SWIG interface file --- lib/nav/core.cpp | 9 +++------ lib/nav/core.h | 2 +- lib/nav/pcore.cpp | 4 ++-- lib/nav/pcore.h | 2 +- lib/python/Makefile.inc | 3 ++- lib/python/enigma_python.i | 1 + lib/python/python_pcore.i | 13 +++++++++++++ 7 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 lib/python/python_pcore.i diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp index fc518cf056f..785d6c169f8 100644 --- a/lib/nav/core.cpp +++ b/lib/nav/core.cpp @@ -122,17 +122,14 @@ RESULT eNavigation::stopRecordService(ePtr &service) return -1; } -PyObject *eNavigation::getRecordings(bool simulate) +void eNavigation::getRecordings(std::vector > &recordings, bool simulate) { - ePyObject result = PyList_New(simulate ? m_simulate_recordings.size() : m_recordings.size()); - int pos=0; if (simulate) for (std::set >::iterator it(m_simulate_recordings.begin()); it != m_simulate_recordings.end(); ++it) - PyList_SET_ITEM(result, pos++, NEW_iRecordableServicePtr(*it)); + recordings.push_back(*it); else for (std::map, ePtr >::iterator it(m_recordings.begin()); it != m_recordings.end(); ++it) - PyList_SET_ITEM(result, pos++, NEW_iRecordableServicePtr(it->first)); - return result; + recordings.push_back(it->first); } RESULT eNavigation::pause(int dop) diff --git a/lib/nav/core.h b/lib/nav/core.h index 9f7be884dd1..4117b783406 100644 --- a/lib/nav/core.h +++ b/lib/nav/core.h @@ -33,7 +33,7 @@ class eNavigation: public iObject, public Object RESULT recordService(const eServiceReference &ref, ePtr &service, bool simulate=false); RESULT stopRecordService(ePtr &service); - PyObject *getRecordings(bool simulate=false); + void getRecordings(std::vector > &recordings, bool simulate=false); RESULT pause(int p); eNavigation(iServiceHandler *serviceHandler); diff --git a/lib/nav/pcore.cpp b/lib/nav/pcore.cpp index 264817ce0a0..78a8e27448d 100644 --- a/lib/nav/pcore.cpp +++ b/lib/nav/pcore.cpp @@ -47,9 +47,9 @@ RESULT pNavigation::stopRecordService(ePtr &service) return m_core->stopRecordService(service); } -PyObject *pNavigation::getRecordings(bool simulate) +void pNavigation::getRecordings(std::vector > &recordings, bool simulate) { - return m_core->getRecordings(simulate); + m_core->getRecordings(recordings, simulate); } void pNavigation::navEvent(int event) diff --git a/lib/nav/pcore.h b/lib/nav/pcore.h index c157e0dcc43..1e544ea3eff 100644 --- a/lib/nav/pcore.h +++ b/lib/nav/pcore.h @@ -22,7 +22,7 @@ class pNavigation: public iObject, public Object SWIG_VOID(RESULT) recordService(const eServiceReference &ref, ePtr &SWIG_OUTPUT, bool simulate); RESULT stopRecordService(ePtr &service); - PyObject *getRecordings(bool simulate=false); + void getRecordings(std::vector > &recordings, bool simulate=false); private: ePtr m_core; diff --git a/lib/python/Makefile.inc b/lib/python/Makefile.inc index f5d67f65a9e..510c6d424f0 100644 --- a/lib/python/Makefile.inc +++ b/lib/python/Makefile.inc @@ -26,7 +26,8 @@ EXTRA_DIST += \ python/python_dvb.i \ python/python_base.i \ python/python_console.i \ - python/python_pmt.i + python/python_pmt.i \ + python/python/pcore.i @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/python/enigma_python.Pcpp@am__quote@ diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 04e1ce58332..59203934150 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -149,6 +149,7 @@ typedef long time_t; %include %include %include +%include %immutable eSocketNotifier::activated; %include diff --git a/lib/python/python_pcore.i b/lib/python/python_pcore.i new file mode 100644 index 00000000000..38b65484aef --- /dev/null +++ b/lib/python/python_pcore.i @@ -0,0 +1,13 @@ +%extend pNavigation { +PyObject *getRecordings(bool simulate) +{ + std::vector > recordings; + self->getRecordings(recordings, simulate); + ePyObject result = PyList_New(recordings.size()); + for (unsigned int i = 0; i < recordings.size(); i++) + PyList_SET_ITEM(result, i, NEW_iRecordableServicePtr(recordings[i])); + return result; +} +}; + +%ignore pNavigation::getRecordings;