void CBouquetManager::makeRemainingChannelsBouquet(void) { ZapitChannelList unusedChannels; //FIXME services loaded before config. //bool tomake = CZapit::getInstance()->makeRemainingChannelsBouquet(); /* reset channel number and has_bouquet flag */ CServiceManager::getInstance()->ResetChannelNumbers(); //int i = 1, j = 1; int i = CServiceManager::getInstance()->GetMaxNumber(false); int j = CServiceManager::getInstance()->GetMaxNumber(true); /* FIXME temp debug */ printf("############## CBouquetManager::makeRemainingChannelsBouquet: numbers start at: tv %d radio %d ############\n", i, j); for (vector<CZapitBouquet*>::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { renumChannels((*it)->tvChannels, i, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); renumChannels((*it)->radioChannels, j, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); } if(/*!tomake ||*/ CServiceManager::getInstance()->GetAllUnusedChannels(unusedChannels) == false) return; sort(unusedChannels.begin(), unusedChannels.end(), CmpChannelByChName()); // TODO: use locales remainChannels = addBouquet( Bouquets.empty() ? "All Channels" : "Other", false); // UTF-8 encoded remainChannels->bOther = true; for (ZapitChannelList::const_iterator it = unusedChannels.begin(); it != unusedChannels.end(); ++it) { remainChannels->addService(*it); } renumChannels(remainChannels->tvChannels, i); renumChannels(remainChannels->radioChannels, j); }
void CBouquetManager::makeRemainingChannelsBouquet(void) { ZapitChannelList unusedChannels; set<t_channel_id> chans_processed; bool tomake = config.getBool("makeRemainingChannelsBouquet", true); for (tallchans::iterator it = allchans.begin(); it != allchans.end(); it++) it->second.number = 0; int i = 1, j = 1; for (vector<CZapitBouquet*>::const_iterator it = Bouquets.begin(); it != Bouquets.end(); it++) { for (vector<CZapitChannel*>::iterator jt = (*it)->tvChannels.begin(); jt != (*it)->tvChannels.end(); jt++) { if(tomake) chans_processed.insert((*jt)->getChannelID()); if(!(*jt)->number) (*jt)->number = i++; if(!(*jt)->pname && !(*it)->bUser) (*jt)->pname = (char *) (*it)->Name.c_str(); } for (vector<CZapitChannel*>::iterator jt = (*it) ->radioChannels.begin(); jt != (*it)->radioChannels.end(); jt++) { if(tomake) chans_processed.insert((*jt)->getChannelID()); if(!(*jt)->number) (*jt)->number = j++; if(!(*jt)->pname && !(*it)->bUser) (*jt)->pname = (char *) (*it)->Name.c_str(); } } if(!tomake) return; // TODO: use locales remainChannels = addBouquet((Bouquets.size() == 0) ? "All Channels" : "Other", false); // UTF-8 encoded for (tallchans::iterator it = allchans.begin(); it != allchans.end(); it++) if (chans_processed.find(it->first) == chans_processed.end()) unusedChannels.push_back(&(it->second)); sort(unusedChannels.begin(), unusedChannels.end(), CmpChannelByChName()); for (ZapitChannelList::const_iterator it = unusedChannels.begin(); it != unusedChannels.end(); it++) { remainChannels->addService(findChannelByChannelID((*it)->getChannelID())); } if ((remainChannels->tvChannels.empty()) && (remainChannels->radioChannels.empty())) { deleteBouquet(remainChannels); remainChannels = NULL; return; } for (vector<CZapitChannel*>::iterator jt = remainChannels->tvChannels.begin(); jt != remainChannels->tvChannels.end(); jt++) if(!(*jt)->number) (*jt)->number = i++; for (vector<CZapitChannel*>::iterator jt = remainChannels->radioChannels.begin(); jt != remainChannels->radioChannels.end(); jt++) if(!(*jt)->number) (*jt)->number = j++; }
void CZapitBouquet::removeService(CZapitChannel* oldChannel) { if (oldChannel != NULL) { ZapitChannelList* channels = &tvChannels; switch (oldChannel->getServiceType()) { case ST_DIGITAL_TELEVISION_SERVICE: case ST_NVOD_REFERENCE_SERVICE: case ST_NVOD_TIME_SHIFTED_SERVICE: channels = &tvChannels; break; case ST_DIGITAL_RADIO_SOUND_SERVICE: channels = &radioChannels; break; } (*channels).erase(remove(channels->begin(), channels->end(), oldChannel), channels->end()); } }
bool CZapitBouquet::getChannels(ZapitChannelList &list, bool tv, int flags) { list.clear(); ZapitChannelList *current = tv ? &tvChannels : &radioChannels; for (ZapitChannelList::iterator it = current->begin(); it != current->end(); ++it) { if ((*it)->flags & flags) list.push_back(*it); } return (!list.empty()); }
void CBouquetManager::renumChannels(ZapitChannelList &list, int & counter, char * pname) { for(zapit_list_it_t it = list.begin(); it != list.end(); it++) { if(!(*it)->number) (*it)->number = counter++; if(!(*it)->pname && pname) (*it)->pname = pname; if ((*it)->pname) (*it)->has_bouquet = true; } }
//------------------------------------------------------------------------- // func: Bouquet Edit //------------------------------------------------------------------------- std::string CNeutrinoYParser::func_set_bouquet_edit_form(CyhookHandler *hh, std::string) { if (!(hh->ParamList["selected"].empty())) { int selected = atoi(hh->ParamList["selected"].c_str()) - 1; int mode = NeutrinoAPI->Zapit->getMode(); ZapitChannelList* channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[selected]->tvChannels) : &(g_bouquetManager->Bouquets[selected]->radioChannels); for(int j = 0; j < (int) channels->size(); j++) { hh->ParamList["bouquet_channels"] += string_printf("<option value=\"" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\">%s</option>\n", (*channels)[j]->channel_id, (*channels)[j]->getName().c_str()); } ZapitChannelList Channels; Channels.clear(); if (mode == CZapitClient::MODE_RADIO) { for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++) if (it->second.getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE) Channels.push_back(&(it->second)); } else { for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++) if (it->second.getServiceType() != ST_DIGITAL_RADIO_SOUND_SERVICE) Channels.push_back(&(it->second)); } sort(Channels.begin(), Channels.end(), CmpChannelByChName()); for (int i = 0; i < (int) Channels.size(); i++) { if (!g_bouquetManager->existsChannelInBouquet(selected, Channels[i]->channel_id)){ hh->ParamList["all_channels"] += string_printf("<option value=\"" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\">%s</option>\n", Channels[i]->channel_id, Channels[i]->getName().c_str()); } } return ""; } else return "No Bouquet selected"; }
//------------------------------------------------------------------------- // func: Bouquet Edit //------------------------------------------------------------------------- std::string CNeutrinoYParser::func_set_bouquet_edit_form(CyhookHandler *hh, std::string) { if (!(hh->ParamList["selected"].empty())) { int selected = atoi(hh->ParamList["selected"].c_str()) - 1; int mode = NeutrinoAPI->Zapit->getMode(); ZapitChannelList* channels = mode == CZapitClient::MODE_TV ? &(g_bouquetManager->Bouquets[selected]->tvChannels) : &(g_bouquetManager->Bouquets[selected]->radioChannels); for(int j = 0; j < (int) channels->size(); j++) { hh->ParamList["bouquet_channels"] += string_printf("<option value=\"" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\">%s</option>\n", (*channels)[j]->channel_id, (*channels)[j]->getName().c_str()); } ZapitChannelList Channels; Channels.clear(); if (mode == CZapitClient::MODE_RADIO) CServiceManager::getInstance()->GetAllRadioChannels(Channels); else CServiceManager::getInstance()->GetAllTvChannels(Channels); sort(Channels.begin(), Channels.end(), CmpChannelByChName()); for (int i = 0; i < (int) Channels.size(); i++) { if (!g_bouquetManager->existsChannelInBouquet(selected, Channels[i]->channel_id)){ hh->ParamList["all_channels"] += string_printf("<option value=\"" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\">%s</option>\n", Channels[i]->channel_id, Channels[i]->getName().c_str()); } } return ""; } else return "No Bouquet selected"; }
void CBouquetManager::writeChannels(FILE * bouq_fd, ZapitChannelList &list) { for(zapit_list_it_t it = list.begin(); it != list.end(); it++) (*it)->dumpBouquetXml(bouq_fd); }