X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/fe920f22aa518fba79c4580673b758c75754ba35..ba1b105a176e5f62faf9d6d1f4c1a4c19764a2e4:/lib/dvb/db.cpp diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index eb0721b6..dd942490 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -12,13 +12,19 @@ DEFINE_REF(eDVBService); -RESULT eBouquet::addService(const eServiceReference &ref) +RESULT eBouquet::addService(const eServiceReference &ref, eServiceReference before) { list::iterator it = std::find(m_services.begin(), m_services.end(), ref); if ( it != m_services.end() ) return -1; - m_services.push_back(ref); + if (before.valid()) + { + it = std::find(m_services.begin(), m_services.end(), before); + m_services.insert(it, ref); + } + else + m_services.push_back(ref); return 0; } @@ -75,7 +81,7 @@ RESULT eBouquet::flushChanges() { eServiceReference tmp = *i; std::string str = tmp.path; - if ( (i->flags&eServiceReference::flagDirectory) == eServiceReference::flagDirectory ) + if ( i->flags&eServiceReference::canDescent ) { unsigned int p1 = str.find("FROM BOUQUET \""); if (p1 == std::string::npos) @@ -162,7 +168,7 @@ RESULT eDVBService::getEvent(const eServiceReference &ref, ePtr & return eEPGCache::getInstance()->lookupEventTime(ref, start_time, ptr); } -bool eDVBService::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) +int eDVBService::isPlayable(const eServiceReference &ref, const eServiceReference &ignore) { ePtr res_mgr; if ( eDVBResourceManager::getInstance( res_mgr ) ) @@ -174,7 +180,7 @@ bool eDVBService::isPlayable(const eServiceReference &ref, const eServiceReferen ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore); return res_mgr->canAllocateChannel(chid, chid_ignore); } - return false; + return 0; } int eDVBService::checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query) @@ -449,7 +455,7 @@ void eDVBDB::reloadServicelist() } else if (p == 'c') { int cid, val; - sscanf(v.c_str(), "%02d%04x", &cid, &val); + sscanf(v.c_str(), "%02d%x", &cid, &val); s->setCacheEntry((eDVBService::cacheID)cid,val); } else if (p == 'C') { @@ -636,7 +642,7 @@ void eDVBDB::loadBouquet(const char *path) eDebug("only DVB Bouquets supported"); continue; } - if ( (tmp.flags&eServiceReference::flagDirectory) == eServiceReference::flagDirectory ) + if ( tmp.flags&eServiceReference::canDescent ) { unsigned int pos = tmp.path.rfind('/'); if ( pos != std::string::npos ) @@ -1009,21 +1015,43 @@ eDVBDBQueryBase::eDVBDBQueryBase(eDVBDB *db, const eServiceReference &source, eD int eDVBDBQueryBase::compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b) { ePtr a_service, b_service; - int sortmode = m_query ? m_query->m_sort : eDVBChannelQuery::tName; if ((sortmode == eDVBChannelQuery::tName) || (sortmode == eDVBChannelQuery::tProvider)) { - if (m_db->getService(a, a_service)) + if (a.name.empty() && m_db->getService(a, a_service)) return 1; - if (m_db->getService(b, b_service)) + if (b.name.empty() && m_db->getService(b, b_service)) return 1; } switch (sortmode) { case eDVBChannelQuery::tName: - return a_service->m_service_name_sort < b_service->m_service_name_sort; + if (a_service) + { + if (b_service) + return a_service->m_service_name_sort < b_service->m_service_name_sort; + else + { + std::string str = b.name; + makeUpper(str); + return a_service->m_service_name_sort < str; + } + } + else if (b_service) + { + std::string str = a.name; + makeUpper(str); + return str < b_service->m_service_name_sort; + } + else + { + std::string aa = a.name, bb = b.name; + makeUpper(aa); + makeUpper(bb); + return aa < bb; + } case eDVBChannelQuery::tProvider: return a_service->m_provider_name < b_service->m_provider_name; case eDVBChannelQuery::tType: @@ -1120,12 +1148,16 @@ int eDVBDBListQuery::compareLessEqual(const eServiceReferenceDVB &a, const eServ y -= 3600; return x < y; } - return a.name < b.name; + std::string aa = a.name, bb = b.name; + makeUpper(aa); + makeUpper(bb); + return aa < bb; } eDVBDBSatellitesQuery::eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query) :eDVBDBListQuery(db, source, query) { + std::set found; for (std::map >::iterator it(m_db->m_services.begin()); it != m_db->m_services.end(); ++it) { @@ -1133,15 +1165,9 @@ eDVBDBSatellitesQuery::eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference if (res) { unsigned int dvbnamespace = it->first.getDVBNamespace().get()&0xFFFF0000; - bool found=0; - for (std::list::iterator i(m_list.begin()); i != m_list.end(); ++i) - if ( (i->getDVBNamespace().get()&0xFFFF0000) == dvbnamespace ) - { - found=true; - break; - } - if (!found) + if (found.find(dvbnamespace) == found.end()) { + found.insert(dvbnamespace); eServiceReferenceDVB ref; ref.setDVBNamespace(dvbnamespace); ref.flags=eServiceReference::flagDirectory; @@ -1178,26 +1204,19 @@ eDVBDBSatellitesQuery::eDVBDBSatellitesQuery(eDVBDB *db, const eServiceReference eDVBDBProvidersQuery::eDVBDBProvidersQuery(eDVBDB *db, const eServiceReference &source, eDVBChannelQuery *query) :eDVBDBListQuery(db, source, query) { + std::set found; for (std::map >::iterator it(m_db->m_services.begin()); it != m_db->m_services.end(); ++it) { int res = it->second->checkFilter(it->first, *query); if (res) { - bool found=0; - const char *provider_name = it->second->m_provider_name.length() ? it->second->m_provider_name.c_str() : "Unknown"; - - for (std::list::iterator i(m_list.begin()); i != m_list.end(); ++i) - if (i->name == provider_name) - { - found=true; - break; - } - if (!found) + if (found.find(std::string(provider_name)) == found.end()) { + found.insert(std::string(provider_name)); eServiceReferenceDVB ref; char buf[64]; ref.name=provider_name;