more changes for service groups (replacement for zapping alternatives
[vuplus_dvbapp] / lib / service / servicedvb.cpp
index 4b7d63a..0a7a671 100644 (file)
@@ -106,17 +106,6 @@ int eStaticServiceDVBInformation::isPlayable(const eServiceReference &ref, const
        return false;
 }
 
-
-class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation
-{
-       DECLARE_REF(eStaticServiceDVBBouquetInformation);
-public:
-       eServiceReference m_playable_service;
-       RESULT getName(const eServiceReference &ref, std::string &name);
-       int getLength(const eServiceReference &ref);
-       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
-};
-
 DEFINE_REF(eStaticServiceDVBBouquetInformation);
 
 RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref, std::string &name)
@@ -162,34 +151,40 @@ int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref
                if (eDVBResourceManager::getInstance(res))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no resource manager!");
-                       return false;
+                       return 0;
                }
 
                if (res->getChannelList(db))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no channel list!");
-                       return false;
+                       return 0;
                }
 
                eBouquet *bouquet=0;
                if (db->getBouquet(ref, bouquet))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. getBouquet failed!");
-                       return false;
+                       return 0;
                }
 
+               int cur=0;
                eDVBChannelID chid, chid_ignore;
                ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore);
                for (std::list<eServiceReference>::iterator it(bouquet->m_services.begin()); it != bouquet->m_services.end(); ++it)
                {
-                       m_playable_service = *it;
                        ((const eServiceReferenceDVB&)*it).getChannelID(chid);
-                       if (res->canAllocateChannel(chid, chid_ignore))
-                               return true;
+                       int tmp=res->canAllocateChannel(chid, chid_ignore);
+                       if (tmp > cur)
+                       {
+                               m_playable_service = *it;
+                               cur = tmp;
+                       }
                }
+               if (cur)
+                       return cur;
        }
        m_playable_service = eServiceReference();
-       return false;
+       return 0;
 }
 
 int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref)
@@ -197,6 +192,13 @@ int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref)
        return -1;
 }
 
+#include <lib/dvb/epgcache.h>
+
+RESULT eStaticServiceDVBBouquetInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time)
+{
+       return eEPGCache::getInstance()->lookupEventTime(ref, start_time, ptr);
+}
+
 class eStaticServiceDVBPVRInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceDVBPVRInformation);
@@ -207,7 +209,7 @@ public:
        RESULT getName(const eServiceReference &ref, std::string &name);
        int getLength(const eServiceReference &ref);
        RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time);
-
+       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore) { return 1; }
        int getInfo(const eServiceReference &ref, int w);
        std::string getInfoString(const eServiceReference &ref,int w);
 };
@@ -550,7 +552,7 @@ RESULT eDVBServiceList::getNext(eServiceReference &ref)
 
 RESULT eDVBServiceList::startEdit(ePtr<iMutableServiceList> &res)
 {
-       if (m_parent.flags & eServiceReference::flagDirectory) // bouquet
+       if (m_parent.flags & eServiceReference::canDescent) // bouquet
        {
                ePtr<iDVBChannelList> db;
                ePtr<eDVBResourceManager> resm;
@@ -644,7 +646,7 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableServ
 RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
 {
        /* is a listable service? */
-       if ((ref.flags & eServiceReference::flagDirectory) == eServiceReference::flagDirectory) // bouquet
+       if (ref.flags & eServiceReference::canDescent) // bouquet
        {
                if ( !ref.name.empty() )  // satellites or providers list
                        ptr = m_StaticServiceDVBInfo;