diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 32a5b8d2b..d53bee84f 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1515,12 +1515,14 @@ void CNeutrinoApp::channelsInit(bool bOnly) AllFavBouquetList->addBouquet(b); } } +#if 0 if (!webtvList.empty()) { /* provider */ CBouquet* webtvBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_WEBTV), false, true); webtvBouquet->channelList->SetChannelList(&webtvList); TVbouquetList->Bouquets.push_back(webtvBouquet); } +#endif printf("[neutrino] got %d TV and %d RADIO bouquets\n", tvi, ri); fflush(stdout); TIMER_STOP("[neutrino] took"); diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 7d44d2931..bca049475 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -119,6 +119,7 @@ class CBouquetManager void renumServices(); CZapitBouquet* addBouquet(const std::string & name, bool ub = false, bool myfav = false, bool to_begin = false); + CZapitBouquet* addBouquetIfNotExist(const std::string & name); void deleteBouquet(const unsigned int id); void deleteBouquet(const CZapitBouquet* bouquet); int existsBouquet(char const * const name, bool ignore_user = false); @@ -132,6 +133,7 @@ class CBouquetManager void sortBouquets(void); void setBouquetLock(const unsigned int id, bool state); void setBouquetLock(CZapitBouquet* bouquet, bool state); + void loadWebtv(); //bouquet writeChannelsNames selection options enum{ BWN_NEVER, diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index 03f278133..0f5e68a31 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -493,6 +493,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile) } parseBouquetsXml(UBOUQUETS_XML, true); + loadWebtv(); renumServices(); TIMER_STOP("[zapit] bouquet loading took"); } @@ -778,6 +779,69 @@ void CBouquetManager::deletePosition(t_satellite_position satellitePosition) Bouquets = tmplist; } +CZapitBouquet* CBouquetManager::addBouquetIfNotExist(const std::string &name) +{ + CZapitBouquet* bouquet = NULL; + + int bouquetId = existsBouquet(name.c_str(), true); + if (bouquetId == -1) + bouquet = addBouquet(name, false); + else + bouquet = Bouquets[bouquetId]; + + return bouquet; +} + +void CBouquetManager::loadWebtv() +{ + std::list *webtv_xml = CZapit::getInstance()->GetWebTVXML(); + if (!webtv_xml) + return; + + for (std::list::iterator it = webtv_xml->begin(); it != webtv_xml->end(); ++it) { + if (!access((*it).c_str(), R_OK)) { + INFO("Loading webtv from %s ...", (*it).c_str()); + xmlDocPtr parser = parseXmlFile((*it).c_str()); + if (parser == NULL) + continue; + + xmlNodePtr l0 = xmlDocGetRootElement(parser); + xmlNodePtr l1 = xmlChildrenNode(l0); + if (l1) { + CZapitBouquet* pbouquet = NULL; + const char *prov = xmlGetAttribute(l0, "name"); + if (!prov) + prov = "WebTV"; + pbouquet = addBouquetIfNotExist(prov); + + while ((xmlGetNextOccurence(l1, "webtv"))) { + const char *title = xmlGetAttribute(l1, "title"); + const char *url = xmlGetAttribute(l1, "url"); + const char *desc = xmlGetAttribute(l1, "description"); + const char *genre = xmlGetAttribute(l1, "genre"); + + CZapitBouquet* gbouquet = pbouquet; + if (genre) { + std::string bname = prov ? std::string(std::string(prov) + " ") + genre : genre; + gbouquet = addBouquetIfNotExist(bname); + } + if (title && url) { + t_channel_id chid = create_channel_id64(0, 0, 0, 0, 0, url); + CZapitChannel * channel = new CZapitChannel(title, chid, url, desc); + CServiceManager::getInstance()->AddChannel(channel); + channel->flags = CZapitChannel::UPDATED; + if (gbouquet) + gbouquet->addService(channel); + } + + l1 = xmlNextNode(l1); + } + } + xmlFreeDoc(parser); + } + } +} + CBouquetManager::ChannelIterator::ChannelIterator(CBouquetManager* owner, const bool TV) { Owner = owner; diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index 501f73cba..7f4bcd662 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -867,21 +867,10 @@ bool CServiceManager::LoadServices(bool only_current) xmlDocPtr parser; service_count = 0; printf("[zapit] Loading services, channel size %d ..\n", (int)sizeof(CZapitChannel)); - //frontendType = CFEManager::getInstance()->getLiveFE()->getInfo()->type; - - std::list *webtv_xml = CZapit::getInstance()->GetWebTVXML(); if(only_current) goto do_current; -#if 0 // FIXME: obsolete ? - static bool satcleared = 0;//clear only once, because menu is static - if(!satcleared) { - satellitePositions.clear(); - satcleared = 1; - } -#endif - TIMER_START(); allchans.clear(); transponders.clear(); @@ -938,41 +927,6 @@ bool CServiceManager::LoadServices(bool only_current) xmlFreeDoc(parser); } - if (webtv_xml) { - for (std::list::iterator it = webtv_xml->begin(); it != webtv_xml->end(); ++it) { - if (!access((*it).c_str(), R_OK)) { - INFO("Loading webtv from %s ...", (*it).c_str()); - parser = parseXmlFile((*it).c_str()); - if (parser == NULL) - continue; - - xmlNodePtr l0 = xmlDocGetRootElement(parser); - xmlNodePtr l1 = xmlChildrenNode(l0); - if (l1) { - while ((xmlGetNextOccurence(l1, "webtv"))) { - const char *title = xmlGetAttribute(l1, "title"); - const char *url = xmlGetAttribute(l1, "url"); - const char *desc = xmlGetAttribute(l1, "description"); - if (title && url) { - t_channel_id chid = create_channel_id64(0, 0, 0, 0, 0, url); - CZapitChannel * channel = new CZapitChannel(title, chid, url, desc); - AddChannel(channel); - channel->flags = CZapitChannel::UPDATED; - } - - l1 = xmlNextNode(l1); - } - } - xmlFreeDoc(parser); - } - } - } -#if 0 - if (CFEManager::getInstance()->haveSat()) { - LoadMotorPositions(); - } -#endif - LoadProviderMap(); printf("[zapit] %d services loaded (%d)...\n", service_count, (int)allchans.size()); TIMER_STOP("[zapit] service loading took");