update ca, sv language
[enigma2.git] / lib / nav / core.cpp
1 #include <lib/nav/core.h>
2 #include <lib/base/eerror.h>
3
4 void eNavigation::serviceEvent(iPlayableService* service, int event)
5 {
6         if (service != m_runningService)
7         {
8                 eDebug("nav: event for other service");
9                 return;
10         }
11
12         m_event(this, event);
13 }
14
15 RESULT eNavigation::playService(const eServiceReference &service)
16 {
17         stopService();
18         
19         assert(m_servicehandler);
20         RESULT res = m_servicehandler->play(service, m_runningService);
21         if (m_runningService)
22         {
23                 m_runningService->connectEvent(slot(*this, &eNavigation::serviceEvent), m_service_event_conn);
24                 res = m_runningService->start();
25         }
26         return res;
27 }
28
29 RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection)
30 {
31         connection = new eConnection(this, m_event.connect(event));
32         return 0;
33 }
34
35 RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
36 {
37         service = m_runningService;
38         return 0;
39 }
40
41 RESULT eNavigation::stopService(void)
42 {
43                 /* check if there is a running service... */
44         if (!m_runningService)
45                 return 1;
46                         /* send stop event */
47         m_event(this, iPlayableService::evEnd);
48
49         m_runningService->stop();
50                 /* kill service. */
51         m_runningService = 0;
52         m_service_event_conn = 0;
53         return 0;
54 }
55
56 RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
57 {
58         assert(m_servicehandler);
59         RESULT res = m_servicehandler->record(ref, service);
60         eDebug("record: %d", res);
61         if (res)
62                 service = 0;
63         return res;
64 }
65
66 RESULT eNavigation::pause(int dop)
67 {
68         if (!m_runningService)
69                 return -1;
70         ePtr<iPauseableService> p;
71         if (m_runningService->pause(p))
72                 return -2;
73         if (dop)
74                 return p->pause();
75         else
76                 return p->unpause();
77 }
78
79 eNavigation::eNavigation(iServiceHandler *serviceHandler)
80 {
81         assert(serviceHandler);
82         m_servicehandler = serviceHandler;
83 }
84
85 eNavigation::~eNavigation()
86 {
87         stopService();
88 }
89
90 DEFINE_REF(eNavigation);