fix inverted setting (meaning was inverted too)
[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         switch (event)
13         {       
14         case iPlayableService::evEnd:
15                 m_event(this, evEnd);
16                 break;
17         case iPlayableService::evStart:
18                 m_event(this, evNewService);
19                 break;
20         case iPlayableService::evUpdatedEventInfo:
21                 m_event(this, evUpdatedEventInfo);
22                 break;
23         case iPlayableService::evUpdatedInfo:
24                 m_event(this, evUpdatedInfo);
25                 break;
26         case iPlayableService::evSeekableStatusChanged:
27                 m_event(this, evSeekableStatusChanged);
28                 break;
29         default:
30                 break;
31         }
32 }
33
34 RESULT eNavigation::playService(const eServiceReference &service)
35 {
36         stopService();
37         
38         assert(m_servicehandler);
39         RESULT res = m_servicehandler->play(service, m_runningService);
40         if (m_runningService)
41         {
42                 m_runningService->connectEvent(slot(*this, &eNavigation::serviceEvent), m_service_event_conn);
43                 res = m_runningService->start();
44         }
45         return res;
46 }
47
48 RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection)
49 {
50         connection = new eConnection(this, m_event.connect(event));
51         return 0;
52 }
53
54 RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
55 {
56         service = m_runningService;
57         return 0;
58 }
59
60 RESULT eNavigation::stopService(void)
61 {
62                 /* check if there is a running service... */
63         if (!m_runningService)
64                 return 1;
65                         /* send stop event */
66         m_event(this, evStopService);
67
68                 /* kill service. */
69         m_runningService = 0;
70         m_service_event_conn = 0;
71         return 0;
72 }
73
74 RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
75 {
76         assert(m_servicehandler);
77         RESULT res = m_servicehandler->record(ref, service);
78         eDebug("record: %d", res);
79         if (res)
80                 service = 0;
81         return res;
82 }
83
84 RESULT eNavigation::pause(int dop)
85 {
86         if (!m_runningService)
87                 return -1;
88         ePtr<iPauseableService> p;
89         if (m_runningService->pause(p))
90                 return -2;
91         if (dop)
92                 return p->pause();
93         else
94                 return p->unpause();
95 }
96
97 eNavigation::eNavigation(iServiceHandler *serviceHandler)
98 {
99         assert(serviceHandler);
100         m_servicehandler = serviceHandler;
101 }
102
103 eNavigation::~eNavigation()
104 {
105 }
106
107 DEFINE_REF(eNavigation);