Skip to content

Commit

Permalink
pcore: add python wrapper for getRecordings
Browse files Browse the repository at this point in the history
And move it to a SWIG interface file
  • Loading branch information
pieterg committed May 4, 2013
1 parent 23ba503 commit 0b0267d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
9 changes: 3 additions & 6 deletions lib/nav/core.cpp
Expand Up @@ -122,17 +122,14 @@ RESULT eNavigation::stopRecordService(ePtr<iRecordableService> &service)
return -1;
}

PyObject *eNavigation::getRecordings(bool simulate)
void eNavigation::getRecordings(std::vector<ePtr<iRecordableService> > &recordings, bool simulate)
{
ePyObject result = PyList_New(simulate ? m_simulate_recordings.size() : m_recordings.size());
int pos=0;
if (simulate)
for (std::set<ePtr<iRecordableService> >::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<iRecordableService>, ePtr<eConnection> >::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)
Expand Down
2 changes: 1 addition & 1 deletion lib/nav/core.h
Expand Up @@ -33,7 +33,7 @@ class eNavigation: public iObject, public Object

RESULT recordService(const eServiceReference &ref, ePtr<iRecordableService> &service, bool simulate=false);
RESULT stopRecordService(ePtr<iRecordableService> &service);
PyObject *getRecordings(bool simulate=false);
void getRecordings(std::vector<ePtr<iRecordableService> > &recordings, bool simulate=false);

RESULT pause(int p);
eNavigation(iServiceHandler *serviceHandler);
Expand Down
4 changes: 2 additions & 2 deletions lib/nav/pcore.cpp
Expand Up @@ -47,9 +47,9 @@ RESULT pNavigation::stopRecordService(ePtr<iRecordableService> &service)
return m_core->stopRecordService(service);
}

PyObject *pNavigation::getRecordings(bool simulate)
void pNavigation::getRecordings(std::vector<ePtr<iRecordableService> > &recordings, bool simulate)
{
return m_core->getRecordings(simulate);
m_core->getRecordings(recordings, simulate);
}

void pNavigation::navEvent(int event)
Expand Down
2 changes: 1 addition & 1 deletion lib/nav/pcore.h
Expand Up @@ -22,7 +22,7 @@ class pNavigation: public iObject, public Object

SWIG_VOID(RESULT) recordService(const eServiceReference &ref, ePtr<iRecordableService> &SWIG_OUTPUT, bool simulate);
RESULT stopRecordService(ePtr<iRecordableService> &service);
PyObject *getRecordings(bool simulate=false);
void getRecordings(std::vector<ePtr<iRecordableService> > &recordings, bool simulate=false);

private:
ePtr<eNavigation> m_core;
Expand Down
3 changes: 2 additions & 1 deletion lib/python/Makefile.inc
Expand Up @@ -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@

Expand Down
1 change: 1 addition & 0 deletions lib/python/enigma_python.i
Expand Up @@ -149,6 +149,7 @@ typedef long time_t;
%include <lib/python/python_dvb.i>
%include <lib/python/python_service.i>
%include <lib/python/python_pmt.i>
%include <lib/python/python_pcore.i>
%immutable eSocketNotifier::activated;
%include <lib/base/ebase.h>
Expand Down
13 changes: 13 additions & 0 deletions lib/python/python_pcore.i
@@ -0,0 +1,13 @@
%extend pNavigation {
PyObject *getRecordings(bool simulate)
{
std::vector<ePtr<iRecordableService> > 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;

0 comments on commit 0b0267d

Please sign in to comment.