add SeekableStatusChanged event
[enigma2.git] / lib / nav / core.cpp
index b5c229c79665d5617d5f1d6ecb0f6778783cecdc..957983d9acfd1f9f4002d19d08af4c230f1322d0 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/nav/core.h>
+#include <lib/base/eerror.h>
 
 void eNavigation::serviceEvent(iPlayableService* service, int event)
 {
@@ -9,23 +10,22 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
        }
 
        switch (event)
-       {
+       {       
        case iPlayableService::evEnd:
-                       /* our running main service stopped. */
-               if (!m_playlist.empty())
-                       m_playlist.erase(m_playlist.begin());
-               if (!m_playlist.empty())
-               {
-                       RESULT res;
-                       res = playService(m_playlist.front());
-                       if (res)
-                               m_event(this, evPlayFailed);
-               } else
-                       m_event(this, evPlaylistDone);
+//             m_event(this, ev);
                break;
        case iPlayableService::evStart:
                m_event(this, evNewService);
                break;
+       case iPlayableService::evUpdatedEventInfo:
+               m_event(this, evUpdatedEventInfo);
+               break;
+       case iPlayableService::evUpdatedInfo:
+               m_event(this, evUpdatedInfo);
+               break;
+       case iPlayableService::evSeekableStatusChanged:
+               m_event(this, evSeekableStatusChanged);
+               break;
        default:
                break;
        }
@@ -33,6 +33,9 @@ void eNavigation::serviceEvent(iPlayableService* service, int event)
 
 RESULT eNavigation::playService(const eServiceReference &service)
 {
+       stopService();
+       
+       assert(m_servicehandler);
        RESULT res = m_servicehandler->play(service, m_runningService);
        if (m_runningService)
        {
@@ -42,33 +45,48 @@ RESULT eNavigation::playService(const eServiceReference &service)
        return res;
 }
 
-RESULT eNavigation::enqueueService(const eServiceReference &service)
+RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection)
 {
-       int doplay = m_playlist.empty();
-       m_playlist.push_back(service);
-       if (doplay)
-               return playService(m_playlist.front());
+       connection = new eConnection(this, m_event.connect(event));
        return 0;
 }
 
-RESULT eNavigation::connectEvent(const Slot2<void,eNavigation*,int> &event, ePtr<eConnection> &connection)
+RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
 {
-       connection = new eConnection(m_event.connect(event));
+       service = m_runningService;
        return 0;
 }
 
-RESULT eNavigation::getCurrentService(ePtr<iPlayableService> &service)
+RESULT eNavigation::stopService(void)
 {
-       service = m_runningService;
+               /* check if there is a running service... */
+       if (!m_runningService)
+               return 1;
+                       /* send stop event */
+       m_event(this, evStopService);
+
+               /* kill service. */
+       m_runningService = 0;
+       m_service_event_conn = 0;
        return 0;
 }
 
+RESULT eNavigation::recordService(const eServiceReference &ref, ePtr<iRecordableService> &service)
+{
+       assert(m_servicehandler);
+       RESULT res = m_servicehandler->record(ref, service);
+       eDebug("record: %d", res);
+       if (res)
+               service = 0;
+       return res;
+}
+
 RESULT eNavigation::pause(int dop)
 {
        if (!m_runningService)
                return -1;
        ePtr<iPauseableService> p;
-       if (m_runningService->getIPausableService(p))
+       if (m_runningService->pause(p))
                return -2;
        if (dop)
                return p->pause();
@@ -78,6 +96,7 @@ RESULT eNavigation::pause(int dop)
 
 eNavigation::eNavigation(iServiceHandler *serviceHandler)
 {
+       assert(serviceHandler);
        m_servicehandler = serviceHandler;
 }