void CBouquetManager::makeRemainingChannelsBouquet(void) { ChannelList unusedChannels; set<t_channel_id> chans_processed; for (vector<CBouquet*>::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { for (vector<CZapitChannel*>::iterator jt = (*it)->tvChannels.begin(); jt != (*it)->tvChannels.end(); ++jt) chans_processed.insert((*jt)->getChannelID()); for (vector<CZapitChannel*>::iterator jt = (*it) ->radioChannels.begin(); jt != (*it)->radioChannels.end(); ++jt) chans_processed.insert((*jt)->getChannelID()); } // TODO: use locales remainChannels = addBouquet(Bouquets.empty() ? "Alle Kan\xC3\xA4le" : "Andere"); // 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 (ChannelList::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; } }
void CBouquetManager::renumServices() { if(remainChannels) deleteBouquet(remainChannels); remainChannels = NULL; makeRemainingChannelsBouquet(); }
void CBouquetManager::renumServices() { #if 0 if(remainChannels) deleteBouquet(remainChannels); remainChannels = NULL; #endif if(remainChannels) { remainChannels->tvChannels.clear(); remainChannels->radioChannels.clear(); } makeRemainingChannelsBouquet(); }
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 CBouquetManager::deleteBouquet(const unsigned int id) { if (id < Bouquets.size() && Bouquets[id] != remainChannels) deleteBouquet(Bouquets[id]); }
void CBouquetManager::saveBouquets(const CZapitClient::bouquetMode bouquetMode) { /* // printf("[zapit] b size %d\n", Bouquets.size()); if (bouquetMode == CZapitClient::BM_CREATESATELLITEBOUQUET) { // printf("[zapit] b mode sat \n"); while (Bouquets.size() > 1) { BouquetList::iterator it = Bouquets.begin() + 1; Bouquets[0]->tvChannels.insert(Bouquets[0]->tvChannels.end(), (*it)->tvChannels.begin(), (*it)->tvChannels.end()); Bouquets[0]->radioChannels.insert(Bouquets[0]->radioChannels.end(), (*it)->radioChannels.begin(), (*it)->radioChannels.end()); delete (*it); Bouquets.erase(it); } // printf("[zapit] b mode sat \n"); if(Bouquets.size() > 0) Bouquets[0]->Name = providerName; } */ // printf("[zapit] b mode sat \n"); if ((bouquetMode == CZapitClient::BM_UPDATEBOUQUETS) || (bouquetMode == CZapitClient::BM_CREATESATELLITEBOUQUET)) { BouquetList storedBouquets; storedBouquets = Bouquets; Bouquets.clear(); remainChannels = NULL; LoadServices(frontend->getInfo()->type, frontend->getDiseqcType(), false); loadBouquets(); deleteBouquet(remainChannels); remainChannels = NULL; for (unsigned int i = 0; i < Bouquets.size(); i++) { unsigned int j; for (j = 0; j < Bouquets[i]->tvChannels.size(); j++) Bouquets[i]->tvChannels[j] = new CZapitChannel(*(Bouquets[i]->tvChannels[j])); for (j = 0; j < Bouquets[i]->radioChannels.size(); j++) Bouquets[i]->radioChannels[j] = new CZapitChannel(*(Bouquets[i]->radioChannels[j])); } allchans.clear(); while (!(storedBouquets.empty())) { int dest = existsBouquet(storedBouquets[0]->Name.c_str()); if (dest != -1) { while (!(storedBouquets[0]->tvChannels.empty())) { if (!(existsChannelInBouquet(dest, storedBouquets[0]->tvChannels[0]->getChannelID()))) { Bouquets[dest]->addService(storedBouquets[0]->tvChannels[0]); storedBouquets[0]->removeService(storedBouquets[0]->tvChannels[0]); } else { delete storedBouquets[0]->tvChannels[0]; storedBouquets[0]->tvChannels.erase(storedBouquets[0]->tvChannels.begin()); } } while (!(storedBouquets[0]->radioChannels.empty())) { if (!(existsChannelInBouquet(dest, storedBouquets[0]->radioChannels[0]->getChannelID()))) { Bouquets[dest]->addService(storedBouquets[0]->radioChannels[0]); storedBouquets[0]->removeService(storedBouquets[0]->radioChannels[0]); } else { delete storedBouquets[0]->radioChannels[0]; storedBouquets[0]->radioChannels.erase(storedBouquets[0]->radioChannels.begin()); } } delete storedBouquets[0]; } else { Bouquets.push_back(storedBouquets[0]); } storedBouquets.erase(storedBouquets.begin()); } } saveBouquets(); }
int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string&) { neutrino_msg_t msg; neutrino_msg_data_t data; int res = menu_return::RETURN_REPAINT; if (parent) { parent->hide(); } // getting all bouquets from zapit Bouquets.clear(); g_Zapit->getBouquets(Bouquets, true); paintHead(); paint(); paintFoot(); bouquetsChanged = false; unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); bool loop=true; while (loop) { g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat; if ( msg <= CRCInput::RC_MaxRC ) timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); if (msg == CRCInput::RC_timeout || msg == g_settings.key_channelList_cancel) { if (state == beDefault) { if (bouquetsChanged) { int result = ShowLocalizedMessage(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); switch( result ) { case CMessageBox::mbrYes : loop=false; saveChanges(); break; case CMessageBox::mbrNo : loop=false; discardChanges(); break; case CMessageBox::mbrCancel : paintHead(); paint(); paintFoot(); break; } } else { loop = false; } } else if (state == beMoving) { cancelMoveBouquet(); } } // // -- For more convenience: include browsing of list (paging) (rasc, 2002-04-02) // -- The keys should be configurable. Problem is: red/green key, which is the // -- default in neutrino is used as a function key here... so use left/right // else if (msg_repeatok==CRCInput::RC_up || msg_repeatok == g_settings.key_channelList_pageup) { if (!(Bouquets.empty())) { int step = 0; int prev_selected = selected; step = (msg_repeatok == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 selected -= step; if((prev_selected-step) < 0) // because of uint { selected = Bouquets.size()-1; } if (state == beDefault) { paintItem(prev_selected - liststart); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) { paint(); } else { paintItem(selected - liststart); } } else if (state == beMoving) { internalMoveBouquet(prev_selected, selected); } } } else if (msg_repeatok == CRCInput::RC_down || msg_repeatok == g_settings.key_channelList_pagedown) { unsigned int step = 0; int prev_selected = selected; step = (msg_repeatok == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 selected += step; if(selected >= Bouquets.size()) { if (((Bouquets.size() / listmaxshow) + 1) * listmaxshow == Bouquets.size() + listmaxshow) // last page has full entries selected = 0; else selected = ((step == listmaxshow) && (selected < (((Bouquets.size() / listmaxshow) + 1) * listmaxshow))) ? (Bouquets.size() - 1) : 0; } if (state == beDefault) { paintItem(prev_selected - liststart); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) { paint(); } else { paintItem(selected - liststart); } } else if (state == beMoving) { internalMoveBouquet(prev_selected, selected); } } else if(msg==CRCInput::RC_red) { if (state == beDefault) deleteBouquet(); } else if(msg==CRCInput::RC_green) { if (state == beDefault) addBouquet(); } else if(msg==CRCInput::RC_yellow) { if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */ { liststart = (selected/listmaxshow)*listmaxshow; if (state == beDefault) beginMoveBouquet(); paintItem(selected - liststart); } } else if(msg==CRCInput::RC_blue) { if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */ { if (state == beDefault) switch (blueFunction) { case beRename: renameBouquet(); break; case beHide: switchHideBouquet(); break; case beLock: switchLockBouquet(); break; } } } else if(msg==CRCInput::RC_setup) { if (state == beDefault) switch (blueFunction) { case beRename: blueFunction = beHide; break; case beHide: blueFunction = beLock; break; case beLock: blueFunction = beRename; break; } paintFoot(); } else if(msg==CRCInput::RC_ok) { if (state == beDefault) { if (selected < Bouquets.size()) /* Bouquets.size() might be 0 */ { CBEChannelWidget* channelWidget = new CBEChannelWidget(Bouquets[selected].name, selected); channelWidget->exec( this, ""); if (channelWidget->hasChanged()) bouquetsChanged = true; delete channelWidget; paintHead(); paint(); paintFoot(); } } else if (state == beMoving) { finishMoveBouquet(); } } else if( CRCInput::isNumeric(msg) ) { if (state == beDefault) { //kein pushback - wenn man versehentlich wo draufkommt is die edit-arbeit umsonst //selected = oldselected; //g_RCInput->postMsg( msg, data ); //loop=false; } else if (state == beMoving) { cancelMoveBouquet(); } } else { CNeutrinoApp::getInstance()->handleMsg( msg, data ); // kein canceling... } } hide(); return res; }