1 #include <lib/nav/core.h>
2 #include <lib/base/eerror.h>
5 void eNavigation::serviceEvent(iPlayableService* service, int event)
7 if (service != m_runningService)
9 eDebug("nav: event for other service");
15 void eNavigation::recordEvent(iRecordableService* service, int event)
17 if (m_recordings.find(service) == m_recordings.end())
19 eDebug("nav: event for non registered recording service");
22 m_record_event(service, event);
25 RESULT eNavigation::playService(const eServiceReference &service)
29 assert(m_servicehandler);
30 RESULT res = m_servicehandler->play(service, m_runningService);
33 m_runningService->connectEvent(slot(*this, &eNavigation::serviceEvent), m_service_event_conn);
34 res = m_runningService->start();
39 RESULT eNavigation::connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection)
41 connection = new eConnection(this, m_event.connect(event));
45 RESULT eNavigation::connectRecordEvent(const Slot2<void,ePtr<iRecordableService>,int> &event, ePtr<eConnection> &connection)
47 connection = new eConnection(this, m_record_event.connect(event));
51 RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
53 service = m_runningService;
57 RESULT eNavigation::stopService(void)
59 /* check if there is a running service... */
60 if (!m_runningService)
63 m_event(iPlayableService::evEnd);
65 m_runningService->stop();
68 m_service_event_conn = 0;
72 RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
74 assert(m_servicehandler);
75 RESULT res = m_servicehandler->record(ref, service);
76 eDebug("record: %d", res);
81 ePtr<eConnection> conn;
82 service->connectEvent(slot(*this, &eNavigation::recordEvent), conn);
83 m_recordings[service]=conn;
88 RESULT eNavigation::stopRecordService(ePtr<iRecordableService> &service)
91 std::map<ePtr<iRecordableService>, ePtr<eConnection> >::iterator it =
92 m_recordings.find(service);
93 if (it != m_recordings.end())
95 m_recordings.erase(it);
98 eDebug("try to stop non running recording!!"); // this should not happen
102 extern PyObject *New_iRecordableServicePtr(const ePtr<iRecordableService> &ref); // defined in enigma_python.i
104 PyObject *eNavigation::getRecordings(void)
106 PyObject *result = PyList_New(m_recordings.size());
108 for (std::map<ePtr<iRecordableService>, ePtr<eConnection> >::iterator it(m_recordings.begin()); it != m_recordings.end(); ++it)
109 PyList_SET_ITEM(result, pos++, New_iRecordableServicePtr(it->first));
113 RESULT eNavigation::pause(int dop)
115 if (!m_runningService)
117 ePtr<iPauseableService> p;
118 if (m_runningService->pause(p))
126 eNavigation::eNavigation(iServiceHandler *serviceHandler)
128 assert(serviceHandler);
129 m_servicehandler = serviceHandler;
132 eNavigation::~eNavigation()
137 DEFINE_REF(eNavigation);