diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index aafb0099f..f3bb7d116 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -211,11 +211,18 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* step = (msg==(neutrino_msg_t)g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 selected -= step; +#if 0 if((prev_selected-step) < 0) // because of uint { selected = Channels->size() - 1; } - +#endif + if((prev_selected-step) < 0) { + if(prev_selected != 0 && step != 1) + selected = 0; + else + selected = Channels->size() - 1; + } if (state == beDefault) { paintItem(prev_selected - liststart); @@ -243,7 +250,7 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* step = (msg==(neutrino_msg_t)g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 selected += step; - +#if 0 if(selected >= Channels->size()) { if (((Channels->size() / listmaxshow) + 1) * listmaxshow == Channels->size() + listmaxshow) // last page has full entries @@ -251,7 +258,15 @@ int CBEChannelWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* else selected = ((step == listmaxshow) && (selected < (((Channels->size() / listmaxshow) + 1) * listmaxshow))) ? (Channels->size() - 1) : 0; } - +#endif + if(selected >= Channels->size()) { + if((Channels->size() - listmaxshow -1 < prev_selected) && (prev_selected != (Channels->size() - 1)) && (step != 1)) + selected = Channels->size() - 1; + else if (((Channels->size() / listmaxshow) + 1) * listmaxshow == Channels->size() + listmaxshow) // last page has full entries + selected = 0; + else + selected = ((step == listmaxshow) && (selected < (((Channels->size() / listmaxshow)+1) * listmaxshow))) ? (Channels->size() - 1) : 0; + } if (state == beDefault) { paintItem(prev_selected - liststart); diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index 8e5985d08..da1b9ad65 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -56,6 +56,7 @@ #include extern CBouquetManager *g_bouquetManager; +extern int g_channel_list_changed; CBouquetList::CBouquetList(const char * const Name) { @@ -136,6 +137,7 @@ bool CBouquetList::hasChannelID(t_channel_id channel_id) return false; } +extern CBouquetList * TVfavList; bool CBouquetList::adjustToChannelID(t_channel_id channel_id) { printf("CBouquetList::adjustToChannelID [%s] to %llx, selected %d size %d\n", name.c_str(), channel_id, selected, Bouquets.size()); @@ -360,6 +362,7 @@ int CBouquetList::show(bool bShowChannelList) else if ( msg == CRCInput::RC_setup) { int ret = doMenu(); if(ret > 0) { + g_channel_list_changed = true; res = -4; loop = false; } else if(ret < 0) diff --git a/src/gui/bouquetlist.h b/src/gui/bouquetlist.h index 11f796764..748aff917 100644 --- a/src/gui/bouquetlist.h +++ b/src/gui/bouquetlist.h @@ -106,7 +106,6 @@ class CBouquetList std::vector Bouquets; - CChannelList* orgChannelList; CBouquet* addBouquet(const char * const name, int BouquetKey=-1, bool locked=false ); CBouquet* addBouquet(CZapitBouquet * zapitBouquet); void deleteBouquet(CBouquet* bouquet); diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 133767f1d..481c1d58f 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -79,6 +79,7 @@ extern CBouquetList * RADIObouquetList; extern CBouquetList * RADIOsatList; extern CBouquetList * RADIOfavList; extern CBouquetList * RADIOallList; +extern tallchans allchans; #define PIC_W 52 #define PIC_H 39 @@ -108,6 +109,7 @@ CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vl zapProtection = NULL; this->historyMode = phistoryMode; vlist = _vlist; + selected_chid = 0; //printf("************ NEW LIST %s : %x\n", name.c_str(), this);fflush(stdout); } @@ -130,6 +132,11 @@ void CChannelList::setSize(int newsize) //chanlist.resize(newsize); } +void CChannelList::SetChannelList(ZapitChannelList* channels) +{ + chanlist = *channels; +} + void CChannelList::addChannel(CZapitChannel* channel, int num) { //printf("************ %s : addChannel: %s %x\n", name.c_str(), channel->getName().c_str(), channel);fflush(stdout); @@ -348,7 +355,11 @@ int CChannelList::doChannelMenu(void) if(result == CMessageBox::mbrYes) { bouquet_id = bouquetList->getActiveBouquetNumber(); - bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + if(!strcmp(bouquetList->Bouquets[bouquet_id]->channelList->getName(), g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME))) + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + else + bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + if (bouquet_id == -1) return 0; if(g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { @@ -387,7 +398,12 @@ int CChannelList::doChannelMenu(void) hide(); if(bouquet_id < 0) return 0; - bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + + if(!strcmp(bouquetList->Bouquets[bouquet_id]->channelList->getName(), g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME))) + bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); + else + bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); + if (bouquet_id == -1) return 0; if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { @@ -419,7 +435,11 @@ int CChannelList::exec() displayNext = 0; // always start with current events int nNewChannel = show(); if ( nNewChannel > -1) { +#if 1 CNeutrinoApp::getInstance ()->channelList->zapTo(getKey(nNewChannel)-1); +#else + CNeutrinoApp::getInstance ()->channelList->NewZap(chanlist[nNewChannel]->channel_id); +#endif } return nNewChannel; @@ -762,8 +782,10 @@ int CChannelList::show() if(NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode()) return -1; - if(zapOnExit) + if(zapOnExit) { res = selected; + //selected_chid = chanlist[selected]->channel_id; + } printf("CChannelList::show *********** res %d\n", res); return(res); @@ -835,10 +857,12 @@ int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) return messages_return::unhandled; } /* bToo default to true */ +/* TODO make this member of CNeutrinoApp, because this only called from "whole" list ? */ bool CChannelList::adjustToChannelID(const t_channel_id channel_id, bool bToo) { unsigned int i; + selected_chid = channel_id; printf("CChannelList::adjustToChannelID me %x [%s] list size %d channel_id %llx\n", (int) this, getName(), chanlist.size(), channel_id);fflush(stdout); for (i = 0; i < chanlist.size(); i++) { if(chanlist[i] == NULL) { @@ -917,7 +941,10 @@ int CChannelList::hasChannelID(t_channel_id channel_id) // for adjusting bouquet's channel list after numzap or quickzap void CChannelList::setSelected( int nChannelNr) { +printf("CChannelList::setSelected me %s %d -> %s\n", name.c_str(), nChannelNr, (nChannelNr < chanlist.size() && chanlist[nChannelNr] != NULL) ? chanlist[nChannelNr]->getName().c_str() : "********* NONE *********"); selected = nChannelNr; + //FIXME real difference between tuned and selected ?! + tuned = nChannelNr; } // -- Zap to channel with channel_id @@ -934,6 +961,7 @@ printf("**************************** CChannelList::zapTo_ChannelID %llx\n", chan } /* forceStoreToLastChannels defaults to false */ +/* TODO make this private to call only from "current" list, where selected/pos not means channel number */ void CChannelList::zapTo(int pos, bool forceStoreToLastChannels) { if (chanlist.empty()) { @@ -951,14 +979,16 @@ printf("**************************** CChannelList::zapTo me %x %s tuned %d new % g_RemoteControl->zapTo_ChannelID(chan->channel_id, chan->name, !chan->bAlwaysLocked); // UTF-8 } if(!new_mode_active) { - selected= pos; + selected = pos; + /* TODO lastChList.store also called in adjustToChannelID, which is called + only from "whole" channel list. Why here too ? */ lastChList.store (selected, chan->channel_id, forceStoreToLastChannels); /* remove recordModeActive from infobar */ if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); } - //g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); + // TODO check is it possible bouquetList is NULL ? if (bouquetList != NULL) { CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->channel_id); } @@ -966,6 +996,30 @@ printf("**************************** CChannelList::zapTo me %x %s tuned %d new % } } +/* to replace zapTo_ChannelID and zapTo from "whole" list ? */ +void CChannelList::NewZap(t_channel_id channel_id) +{ + tallchans_iterator it = allchans.find(channel_id); + + if(it == allchans.end()) + return; + + CZapitChannel* chan = &it->second; +printf("**************************** CChannelList::NewZap me %x %s tuned %d new %s -> %llx\n", (int) this, name.c_str(), tuned, chan->name.c_str(), chan->channel_id); + + if(selected_chid != chan->channel_id) { + selected_chid = chan->channel_id; + g_RemoteControl->zapTo_ChannelID(chan->channel_id, chan->name, !chan->bAlwaysLocked); + /* remove recordModeActive from infobar */ + if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { + g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); + } + CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->channel_id); + g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); + } +} + +/* Called only from "all" channel list */ int CChannelList::numericZap(int key) { neutrino_msg_t msg; @@ -1163,6 +1217,7 @@ void CChannelList::virtual_zap_mode(bool up) chn = 1; if (chn == 0) chn = (int)chanlist.size(); + int lastchan= -1; bool doZap = true; bool showEPG = false; @@ -1297,7 +1352,13 @@ printf("CChannelList::quickZap: selected %d total %d active bouquet %d total %d\ selected = cactive; } printf("CChannelList::quickZap: new selected %d total %d active bouquet %d total %d\n", cactive, bouquetList->Bouquets[bactive]->channelList->getSize(), bactive, bsize); +#if 1 CNeutrinoApp::getInstance()->channelList->zapTo(bouquetList->Bouquets[bactive]->channelList->getKey(cactive)-1); +#else + CZapitChannel* chan = bouquetList->Bouquets[bactive]->channelList->getChannelFromIndex(cactive); + if(chan != NULL) + CNeutrinoApp::getInstance ()->channelList->NewZap(chan->channel_id); +#endif } else { if ( (key==g_settings.key_quickzap_down) || (key == CRCInput::RC_left)) { if(selected == 0) @@ -1308,7 +1369,11 @@ printf("CChannelList::quickZap: new selected %d total %d active bouquet %d total else if ((key==g_settings.key_quickzap_up) || (key == CRCInput::RC_right)) { selected = (selected+1)%chanlist.size(); } +#if 1 CNeutrinoApp::getInstance()->channelList->zapTo(getKey(selected)-1); +#else + CNeutrinoApp::getInstance ()->channelList->NewZap(chanlist[selected]->channel_id); +#endif } g_RCInput->clearRCMsg(); //FIXME test for n.103 } diff --git a/src/gui/channellist.h b/src/gui/channellist.h index ccd58ec11..59b75f7bd 100644 --- a/src/gui/channellist.h +++ b/src/gui/channellist.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ class CChannelList private: CFrameBuffer *frameBuffer; unsigned int selected; + t_channel_id selected_chid; CLastChannel lastChList; unsigned int liststart; unsigned int listmaxshow; @@ -64,7 +66,7 @@ class CChannelList int buttonHeight; std::string name; - std::vector chanlist; + ZapitChannelList chanlist; CZapProtection* zapProtection; int width; @@ -89,6 +91,7 @@ class CChannelList CChannelList(const char * const Name, bool historyMode = false, bool _vlist = false ); ~CChannelList(); + void SetChannelList(ZapitChannelList* channels); void addChannel(CZapitChannel* chan, int num = 0); void putChannel(CZapitChannel* chan); @@ -105,6 +108,7 @@ class CChannelList t_channel_id getActiveChannel_ChannelID(void) const; void zapTo(int pos, bool forceStoreToLastChannels = false); + void NewZap(t_channel_id channel_id); void virtual_zap_mode(bool up); bool zapTo_ChannelID(const t_channel_id channel_id); bool adjustToChannelID(const t_channel_id channel_id, bool bToo = true); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index e29546324..6879b0424 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1655,8 +1655,11 @@ void CNeutrinoApp::firstChannel() extern tallchans allchans; extern CBouquetManager *g_bouquetManager; -void CNeutrinoApp::channelsInit(bool /*bOnly*/) +void CNeutrinoApp::channelsInit(bool bOnly) { + int bnum; + CBouquet* tmp; + printf("[neutrino] Creating channels lists...\n"); TIMER_START(); @@ -1670,13 +1673,11 @@ void CNeutrinoApp::channelsInit(bool /*bOnly*/) if(g_bouquetManager->existsUBouquet(fav_bouquetname, true) == -1) g_bouquetManager->addBouquet(fav_bouquetname, true, true); - if(TVallList) delete TVallList; - if(RADIOallList) delete RADIOallList; + if(TVbouquetList) delete TVbouquetList; - if(TVsatList) delete TVsatList; - if(TVfavList) delete TVfavList; if(RADIObouquetList) delete RADIObouquetList; - if(RADIOsatList) delete RADIOsatList; + + if(TVfavList) delete TVfavList; if(RADIOfavList) delete RADIOfavList; if(TVchannelList) delete TVchannelList; @@ -1686,18 +1687,10 @@ void CNeutrinoApp::channelsInit(bool /*bOnly*/) RADIOchannelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD), false, true); TVbouquetList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_PROVS)); - TVbouquetList->orgChannelList = TVchannelList; - TVsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); - TVsatList->orgChannelList = TVchannelList; TVfavList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_FAVS)); - TVfavList->orgChannelList = TVchannelList; RADIObouquetList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_PROVS)); - RADIObouquetList->orgChannelList = RADIOchannelList; - RADIOsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); - RADIOsatList->orgChannelList = RADIOchannelList; RADIOfavList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_FAVS)); - RADIOfavList->orgChannelList = RADIOchannelList; uint32_t i; i = 1; @@ -1734,53 +1727,63 @@ void CNeutrinoApp::channelsInit(bool /*bOnly*/) if(hi) hdBouquet->channelList->SortSat(); + TIMER_STOP("[neutrino] all channels took"); + printf("[neutrino] got %d TV (%d is HD) and %d RADIO channels\n", tvi, hi, ri); fflush(stdout); - CBouquet* tmp; + /* unless we will do real channel delete from allchans, needed once ? */ + if(!bOnly) { + if(TVallList) delete TVallList; + if(RADIOallList) delete RADIOallList; - TVallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); - tmp = TVallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); - //*(tmp->channelList) = *TVchannelList; - tmp->channelList = new CChannelList(*TVchannelList); - tmp->channelList->SortAlpha(); - TVallList->orgChannelList = TVchannelList; + TVallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp = TVallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp->channelList = new CChannelList(*TVchannelList); + tmp->channelList->SortAlpha(); - RADIOallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); - tmp = RADIOallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); - //*(tmp->channelList) = *RADIOchannelList; - tmp->channelList = new CChannelList(*RADIOchannelList); - tmp->channelList->SortAlpha(); - RADIOallList->orgChannelList = RADIOchannelList; + RADIOallList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp = RADIOallList->addBouquet(g_Locale->getText(LOCALE_CHANNELLIST_HEAD)); + tmp->channelList = new CChannelList(*RADIOchannelList); + tmp->channelList->SortAlpha(); - int bnum; - sat_iterator_t sit; - for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) { - tvi = 0, ri = 0; - CBouquet* tmp1 = TVsatList->addBouquet(sit->second.name.c_str()); - CBouquet* tmp2 = RADIOsatList->addBouquet(sit->second.name.c_str()); + if(TVsatList) delete TVsatList; + TVsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); + if(RADIOsatList) delete RADIOsatList; + RADIOsatList = new CBouquetList(g_Locale->getText(LOCALE_CHANNELLIST_SATS)); - for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++) { - if(it->second.getSatellitePosition() == sit->first) { - if (it->second.getServiceType() == ST_DIGITAL_TELEVISION_SERVICE) { - tmp1->channelList->addChannel(&(it->second)); - tvi++; - } - else if (it->second.getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE) { - tmp2->channelList->addChannel(&(it->second)); - ri++; + sat_iterator_t sit; + for(sit = satellitePositions.begin(); sit != satellitePositions.end(); sit++) { + if(!sit->second.have_channels) + continue; + + tvi = 0, ri = 0; + CBouquet* tmp1 = TVsatList->addBouquet(sit->second.name.c_str()); + CBouquet* tmp2 = RADIOsatList->addBouquet(sit->second.name.c_str()); + + for (tallchans_iterator it = allchans.begin(); it != allchans.end(); it++) { + if(it->second.getSatellitePosition() == sit->first) { + if (it->second.getServiceType() == ST_DIGITAL_TELEVISION_SERVICE) { + tmp1->channelList->addChannel(&(it->second)); + tvi++; + } + else if (it->second.getServiceType() == ST_DIGITAL_RADIO_SOUND_SERVICE) { + tmp2->channelList->addChannel(&(it->second)); + ri++; + } } } + if(tvi) + tmp1->channelList->SortAlpha(); + else + TVsatList->deleteBouquet(tmp1); + if(ri) + tmp2->channelList->SortAlpha(); + else + RADIOsatList->deleteBouquet(tmp2); + if(tvi || ri) + printf("[neutrino] created %s bouquet with %d TV and %d RADIO channels\n", sit->second.name.c_str(), tvi, ri); } - if(tvi) - tmp1->channelList->SortAlpha(); - else - TVsatList->deleteBouquet(tmp1); - if(ri) - tmp2->channelList->SortAlpha(); - else - RADIOsatList->deleteBouquet(tmp2); - if(tvi || ri) - printf("[neutrino] created %s bouquet with %d TV and %d RADIO channels\n", sit->second.name.c_str(), tvi, ri); + TIMER_STOP("[neutrino] sats took"); } bnum = 0; @@ -1794,15 +1797,14 @@ void CNeutrinoApp::channelsInit(bool /*bOnly*/) tmp = TVbouquetList->addBouquet(g_bouquetManager->Bouquets[i]); ZapitChannelList* channels = &(g_bouquetManager->Bouquets[i]->tvChannels); - tmp->channelList->setSize(channels->size()); - for(int j = 0; j < (int) channels->size(); j++) { - tmp->channelList->addChannel((*channels)[j]); - } + tmp->channelList->SetChannelList(channels); bnum++; } } printf("[neutrino] got %d TV bouquets\n", bnum); fflush(stdout); + TIMER_STOP("[neutrino] tv took"); + if(g_settings.make_hd_list) TVfavList->Bouquets.push_back(hdBouquet); @@ -1817,10 +1819,7 @@ void CNeutrinoApp::channelsInit(bool /*bOnly*/) tmp = RADIObouquetList->addBouquet(g_bouquetManager->Bouquets[i]); ZapitChannelList* channels = &(g_bouquetManager->Bouquets[i]->radioChannels); - tmp->channelList->setSize(channels->size()); - for(int j = 0; j < (int) channels->size(); j++) { - tmp->channelList->addChannel((*channels)[j]); - } + tmp->channelList->SetChannelList(channels); bnum++; } } @@ -2930,9 +2929,10 @@ printf("[neutrino] direct record\n"); } } -int CNeutrinoApp::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) +int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) { int res = 0; + neutrino_msg_t msg = _msg; //printf("[neutrino] handleMsg %X data %X\n", msg, data); fflush(stdout); if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { @@ -3015,8 +3015,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) if(bouquetList->Bouquets.size()) { old_num = bouquetList->Bouquets[old_b]->channelList->getActiveChannelNumber(); } - - //if(msg == CRCInput::RC_ok && bouquetList->Bouquets.size()) +_show: if(msg == CRCInput::RC_ok) { if(bouquetList->Bouquets.size() && bouquetList->Bouquets[old_b]->channelList->getSize() > 0) @@ -3051,7 +3050,16 @@ _repeat: SetChannelMode(old_mode); g_channel_list_changed = 0; if(old_b_id < 0) old_b_id = old_b; - g_Zapit->saveBouquets(); + //g_Zapit->saveBouquets(); + /* lets do it in sync */ + reloadhintBox->paint(); + g_bouquetManager->saveBouquets(); + g_bouquetManager->saveUBouquets(); + g_bouquetManager->renumServices(); + channelsInit(true); + bouquetList->activateBouquet(old_b_id, false); + msg = CRCInput::RC_ok; + goto _show; } if(g_settings.mode_clock) diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 61cde8926..bfee0171a 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -17,7 +17,6 @@ #include #include "channel.h" -#include "xmlinterface.h" using namespace std; @@ -62,7 +61,7 @@ class CBouquetManager CZapitBouquet * remainChannels; void makeRemainingChannelsBouquet(void); - void parseBouquetsXml (const xmlNodePtr root, bool ub = false); + void parseBouquetsXml (char * fname, bool ub = false); void writeBouquetHeader (FILE * bouq_fd, uint32_t i, const char * bouquetName); void writeBouquetFooter (FILE * bouq_fd); void writeBouquetChannels (FILE * bouq_fd, uint32_t i, bool bUser = false); diff --git a/src/zapit/include/zapit/client/zapitclient.h b/src/zapit/include/zapit/client/zapitclient.h index c6d49b34f..b6a8d5bda 100644 --- a/src/zapit/include/zapit/client/zapitclient.h +++ b/src/zapit/include/zapit/client/zapitclient.h @@ -467,7 +467,7 @@ class CZapitClient:public CBasicClient void renumChannellist(); /* saves current bouquet configuration to bouquets.xml */ - void saveBouquets(); + void saveBouquets(const bool saveall = false); /****************************************/ /* */ diff --git a/src/zapit/include/zapit/satconfig.h b/src/zapit/include/zapit/satconfig.h index c950c5af3..3514568bc 100644 --- a/src/zapit/include/zapit/satconfig.h +++ b/src/zapit/include/zapit/satconfig.h @@ -13,6 +13,7 @@ typedef struct sat_config { int use_in_scan; int use_usals; std::string name; + int have_channels; t_satellite_position position; } sat_config_t; diff --git a/src/zapit/lib/zapitclient.cpp b/src/zapit/lib/zapitclient.cpp index d9d0caf5e..31c2ee752 100644 --- a/src/zapit/lib/zapitclient.cpp +++ b/src/zapit/lib/zapitclient.cpp @@ -874,9 +874,12 @@ void CZapitClient::renumChannellist() /* saves current bouquet configuration to bouquets.xml*/ -void CZapitClient::saveBouquets() +void CZapitClient::saveBouquets(const bool saveall) { - send(CZapitMessages::CMD_BQ_SAVE_BOUQUETS); + CZapitMessages::commandBoolean msg; + msg.truefalse = saveall; + + send(CZapitMessages::CMD_BQ_SAVE_BOUQUETS, (char*)&msg, sizeof(msg)); CZapitMessages::responseCmd response; CBasicClient::receive_data((char* )&response, sizeof(response)); diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index 10ca95b3d..36f20d6ba 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -353,9 +353,16 @@ void CBouquetManager::sortBouquets(void) sort(Bouquets.begin(), Bouquets.end(), CmpBouquetByChName()); } -void CBouquetManager::parseBouquetsXml(const xmlNodePtr root, bool bUser) +void CBouquetManager::parseBouquetsXml(char * fname, bool bUser) { - xmlNodePtr search=root->xmlChildrenNode; + xmlDocPtr parser; + + parser = parseXmlFile(fname); + if (parser == NULL) + return; + + xmlNodePtr root = xmlDocGetRootElement(parser); + xmlNodePtr search = root->xmlChildrenNode; xmlNodePtr channel_node; if (search) { @@ -414,28 +421,18 @@ DBG("%04x %04x %04x %s\n", transport_stream_id, original_network_id, service_id, } INFO("found %d bouquets", Bouquets.size()); } + xmlFreeDoc(parser); } void CBouquetManager::loadBouquets(bool ignoreBouquetFile) { - xmlDocPtr parser; - TIMER_START(); if (ignoreBouquetFile == false) { - parser = parseXmlFile(BOUQUETS_XML); - if (parser != NULL) { - parseBouquetsXml(xmlDocGetRootElement(parser), false); - xmlFreeDoc(parser); - parser = NULL; - } + parseBouquetsXml((char *) BOUQUETS_XML, false); sortBouquets(); } - parser = parseXmlFile(UBOUQUETS_XML); - if (parser != NULL) { - parseBouquetsXml(xmlDocGetRootElement(parser), true); - xmlFreeDoc(parser); - parser = NULL; - } + + parseBouquetsXml((char *) UBOUQUETS_XML, true); renumServices(); TIMER_STOP("[zapit] bouquet loading took"); } diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index d3b6287ab..c4da72240 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -132,8 +132,15 @@ void ParseChannels(xmlNodePtr node, const t_transport_stream_id transport_stream std::string desc = ""; desc += "Preset"; t_channel_id chid; + int dummy; + int * have_ptr = &dummy; + + sat_iterator_t sit = satellitePositions.find(satellitePosition); + if(sit != satellitePositions.end()) + have_ptr = &sit->second.have_channels; while ((node = xmlGetNextOccurence(node, "S")) != NULL) { + *have_ptr = 1; service_id = xmlGetNumericAttribute(node, "i", 16); name = xmlGetAttribute(node, "n"); service_type = xmlGetNumericAttribute(node, "t", 16); diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index b98119a4d..5b2ffdc0d 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -982,8 +982,8 @@ bool zapit_parse_command(CBasicMessage::Header &rmsg, int connfd) DBG("[zapit] sending EVT_SERVICES_CHANGED\n"); frontend->setTsidOnid(0); zapit(live_channel_id, current_is_nvod); - //eventServer->sendEvent(CZapitClient::EVT_SERVICES_CHANGED, CEventServer::INITID_ZAPIT); - eventServer->sendEvent(CZapitClient::EVT_BOUQUETS_CHANGED, CEventServer::INITID_ZAPIT); + eventServer->sendEvent(CZapitClient::EVT_SERVICES_CHANGED, CEventServer::INITID_ZAPIT); + //eventServer->sendEvent(CZapitClient::EVT_BOUQUETS_CHANGED, CEventServer::INITID_ZAPIT); break; } case CZapitMessages::CMD_SCANSTART: { @@ -1334,10 +1334,14 @@ printf("[zapit] recording mode: %d\n", msgSetRecordMode.activate);fflush(stdout) break; case CZapitMessages::CMD_BQ_SAVE_BOUQUETS: { + CZapitMessages::commandBoolean msgBoolean; + CBasicServer::receive_data(connfd, &msgBoolean, sizeof(msgBoolean)); + CZapitMessages::responseCmd response; response.cmd = CZapitMessages::CMD_READY; CBasicServer::send_data(connfd, &response, sizeof(response)); #if 0 + //if (msgBoolean.truefalse) if(g_list_changed) { eventServer->sendEvent(CZapitClient::EVT_SERVICES_CHANGED, CEventServer::INITID_ZAPIT); } else @@ -1346,7 +1350,8 @@ printf("[zapit] recording mode: %d\n", msgSetRecordMode.activate);fflush(stdout) g_bouquetManager->saveBouquets(); g_bouquetManager->saveUBouquets(); g_bouquetManager->renumServices(); - eventServer->sendEvent(CZapitClient::EVT_SERVICES_CHANGED, CEventServer::INITID_ZAPIT); + //eventServer->sendEvent(CZapitClient::EVT_SERVICES_CHANGED, CEventServer::INITID_ZAPIT); + eventServer->sendEvent(CZapitClient::EVT_BOUQUETS_CHANGED, CEventServer::INITID_ZAPIT); if(g_list_changed) { SaveServices(true); g_list_changed = 0;