neutrino.cpp: add adjustToChannelID();

add flags for accurate saving of things changed in channel list;
always add favorites bouquet to favorite bouquet list;
cleanup showChannelList()
This commit is contained in:
[CST] Focus
2014-10-10 15:18:33 +04:00
parent 722d226dbe
commit bdeb3b50de
3 changed files with 133 additions and 64 deletions

View File

@@ -171,7 +171,7 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
needs_nvods = (msg == NeutrinoMessages:: EVT_ZAP_ISNVOD); needs_nvods = (msg == NeutrinoMessages:: EVT_ZAP_ISNVOD);
//g_Sectionsd->setServiceChanged( current_channel_id, true ); //g_Sectionsd->setServiceChanged( current_channel_id, true );
CNeutrinoApp::getInstance()->channelList->adjustToChannelID(current_channel_id); CNeutrinoApp::getInstance()->adjustToChannelID(current_channel_id);
if ( g_InfoViewer->is_visible ) if ( g_InfoViewer->is_visible )
g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR , 0 ); g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR , 0 );
} }

View File

@@ -222,7 +222,10 @@ CNeutrinoApp::CNeutrinoApp()
lockStandbyCall = false; lockStandbyCall = false;
current_muted = 0; current_muted = 0;
recordingstatus = 0; recordingstatus = 0;
g_channel_list_changed = false; channels_changed = false;
favorites_changed = false;
bouquets_changed = false;
channels_init = false;
channellist_visible = false; channellist_visible = false;
} }
@@ -1457,7 +1460,7 @@ void CNeutrinoApp::channelsInit(bool bOnly)
for (i = 0; i < g_bouquetManager->Bouquets.size(); i++) { for (i = 0; i < g_bouquetManager->Bouquets.size(); i++) {
CZapitBouquet *b = g_bouquetManager->Bouquets[i]; CZapitBouquet *b = g_bouquetManager->Bouquets[i];
if (!b->bHidden) { if (!b->bHidden) {
if (b->getTvChannels(zapitList) /* || b->bUser */) { if (b->getTvChannels(zapitList)|| b->bFav) {
if(b->bUser) if(b->bUser)
tmp = TVfavList->addBouquet(b); tmp = TVfavList->addBouquet(b);
else else
@@ -1466,7 +1469,7 @@ void CNeutrinoApp::channelsInit(bool bOnly)
tmp->channelList->SetChannelList(&zapitList); tmp->channelList->SetChannelList(&zapitList);
tvi++; tvi++;
} }
if (b->getRadioChannels(zapitList) /* || b->bUser */) { if (b->getRadioChannels(zapitList)|| b->bFav) {
if(b->bUser) if(b->bUser)
tmp = RADIOfavList->addBouquet(b); tmp = RADIOfavList->addBouquet(b);
else else
@@ -1504,34 +1507,30 @@ void CNeutrinoApp::SetChannelMode(int newmode)
switch(newmode) { switch(newmode) {
case LIST_MODE_FAV: case LIST_MODE_FAV:
if(mode == mode_radio) { if(mode == mode_radio)
bouquetList = RADIOfavList; bouquetList = RADIOfavList;
} else { else
bouquetList = TVfavList; bouquetList = TVfavList;
}
break; break;
case LIST_MODE_SAT: case LIST_MODE_SAT:
if(mode == mode_radio) { if(mode == mode_radio)
bouquetList = RADIOsatList; bouquetList = RADIOsatList;
} else { else
bouquetList = TVsatList; bouquetList = TVsatList;
}
break; break;
case LIST_MODE_ALL: case LIST_MODE_ALL:
if(mode == mode_radio) { if(mode == mode_radio)
bouquetList = RADIOallList; bouquetList = RADIOallList;
} else { else
bouquetList = TVallList; bouquetList = TVallList;
}
break; break;
default: default:
newmode = LIST_MODE_PROV; newmode = LIST_MODE_PROV;
case LIST_MODE_PROV: case LIST_MODE_PROV:
if(mode == mode_radio) { if(mode == mode_radio)
bouquetList = RADIObouquetList; bouquetList = RADIObouquetList;
} else { else
bouquetList = TVbouquetList; bouquetList = TVbouquetList;
}
break; break;
} }
INFO("newmode %d sort old %d new %d", newmode, sortmode[newmode], g_settings.channellist_sort_mode); INFO("newmode %d sort old %d new %d", newmode, sortmode[newmode], g_settings.channellist_sort_mode);
@@ -1548,7 +1547,7 @@ void CNeutrinoApp::SetChannelMode(int newmode)
if(g_settings.channellist_sort_mode == CChannelList::SORT_CH_NUMBER) if(g_settings.channellist_sort_mode == CChannelList::SORT_CH_NUMBER)
bouquetList->Bouquets[i]->channelList->SortChNumber(); bouquetList->Bouquets[i]->channelList->SortChNumber();
} }
channelList->adjustToChannelID(CZapit::getInstance()->GetCurrentChannelID()); adjustToChannelID(CZapit::getInstance()->GetCurrentChannelID());
} }
lastChannelMode = newmode; lastChannelMode = newmode;
} }
@@ -2061,6 +2060,12 @@ void CNeutrinoApp::numericZap(int msg)
StopSubtitles(); StopSubtitles();
int res = channelList->numericZap( msg ); int res = channelList->numericZap( msg );
StartSubtitles(res < 0); StartSubtitles(res < 0);
if (res >= 0 && CRCInput::isNumeric(msg)) {
if (g_settings.channellist_numeric_adjust && first_mode_found >= 0) {
SetChannelMode(first_mode_found);
channelList->getLastChannels().set_mode(channelList->getActiveChannel_ChannelID());
}
}
} }
void CNeutrinoApp::showInfo() void CNeutrinoApp::showInfo()
@@ -2275,6 +2280,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
} }
else if (CRCInput::isNumeric(msg)) { else if (CRCInput::isNumeric(msg)) {
numericZap( msg ); numericZap( msg );
} }
/* FIXME ??? */ /* FIXME ??? */
else if (CRCInput::isNumeric(msg) && g_RemoteControl->director_mode ) { else if (CRCInput::isNumeric(msg) && g_RemoteControl->director_mode ) {
@@ -2366,22 +2372,16 @@ int CNeutrinoApp::showChannelList(const neutrino_msg_t _msg, bool from_menu)
StopSubtitles(); StopSubtitles();
_show: //_show:
int nNewChannel = -1; int nNewChannel = -1;
int old_b = bouquetList->getActiveBouquetNumber(); int old_b = bouquetList->getActiveBouquetNumber();
t_channel_id old_id = 0; t_channel_id old_id = 0;
if(!bouquetList->Bouquets.empty()) if(!bouquetList->Bouquets.empty())
old_id = bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->getActiveChannel_ChannelID(); old_id = bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->getActiveChannel_ChannelID();
//int old_mode = g_settings.channel_mode;
int old_mode = GetChannelMode();
printf("************************* ZAP START: bouquetList %p size %d old_b %d\n", bouquetList, (int)bouquetList->Bouquets.size(), old_b);fflush(stdout);
#if 0 int old_mode = GetChannelMode();
int old_num = 0; printf("CNeutrinoApp::showChannelList: bouquetList %p size %d old_b %d\n", bouquetList, (int)bouquetList->Bouquets.size(), old_b);fflush(stdout);
if(!bouquetList->Bouquets.empty()) {
old_num = bouquetList->Bouquets[old_b]->channelList->getSelected();
}
#endif
//_show: //_show:
if(msg == CRCInput::RC_ok) if(msg == CRCInput::RC_ok)
{ {
@@ -2401,51 +2401,52 @@ _show:
nNewChannel = bouquetList->exec(true); nNewChannel = bouquetList->exec(true);
} }
_repeat: _repeat:
printf("************************* ZAP RES: nNewChannel %d\n", nNewChannel);fflush(stdout); printf("CNeutrinoApp::showChannelList: nNewChannel %d\n", nNewChannel);fflush(stdout);
//CVFD::getInstance ()->showServicename(channelList->getActiveChannelName()); //CVFD::getInstance ()->showServicename(channelList->getActiveChannelName());
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
if(nNewChannel == -1) { // restore orig. bouquet and selected channel on cancel if(nNewChannel == CHANLIST_CANCEL) { // restore orig. bouquet and selected channel on cancel
/* FIXME if mode was changed while browsing, /* FIXME if mode was changed while browsing,
* other modes selected bouquet not restored */ * other modes selected bouquet not restored */
SetChannelMode(old_mode); SetChannelMode(old_mode);
bouquetList->activateBouquet(old_b, false); bouquetList->activateBouquet(old_b, false);
#if 0
if(!bouquetList->Bouquets.empty()) if(!bouquetList->Bouquets.empty())
bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->setSelected(old_num); bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->adjustToChannelID(old_id);
#endif
if(!bouquetList->Bouquets.empty()) {
bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->adjustToChannelID(old_id, false);
}
StartSubtitles(mode == mode_tv); StartSubtitles(mode == mode_tv);
} }
else if(nNewChannel == -3) { // list mode changed else if(nNewChannel == CHANLIST_CHANGE_MODE) { // list mode changed
printf("************************* ZAP NEW MODE: bouquetList %p size %d\n", bouquetList, (int)bouquetList->Bouquets.size());fflush(stdout); printf("CNeutrinoApp::showChannelList: newmode: bouquetList %p size %d\n", bouquetList, (int)bouquetList->Bouquets.size());fflush(stdout);
nNewChannel = bouquetList->exec(true); nNewChannel = bouquetList->exec(true);
goto _repeat; goto _repeat;
} }
//else if(nNewChannel == -4) if (channels_changed || favorites_changed || bouquets_changed || channels_init) {
if(g_channel_list_changed) neutrino_locale_t loc = channels_init ? LOCALE_SERVICEMENU_RELOAD_HINT : LOCALE_BOUQUETEDITOR_SAVINGCHANGES;
{ CHintBox* hintBox= new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(loc));
/* don't change bouquet after adding a channel to favorites */ hintBox->paint();
if (nNewChannel != -5)
SetChannelMode(old_mode); if (favorites_changed)
g_channel_list_changed = false; g_bouquetManager->saveUBouquets();
if(old_b_id < 0) old_b_id = old_b;
//g_Zapit->saveBouquets(); if (channels_changed)
/* lets do it in sync */ CServiceManager::getInstance()->SaveServices(true);
CHintBox chb(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SERVICEMENU_RELOAD_HINT));
chb.paint(); if (bouquets_changed)
CServiceManager::getInstance()->SaveServices(true, true); g_bouquetManager->saveBouquets();
g_bouquetManager->saveBouquets();
g_bouquetManager->saveUBouquets(); if (channels_init) {
g_bouquetManager->renumServices(); g_bouquetManager->renumServices();
channelsInit(/*true*/); channelsInit(/*true*/);
chb.hide(); }
favorites_changed = false;
channels_changed = false;
bouquets_changed = false;
channels_init = false;
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? adjustToChannelID(live_channel_id);//FIXME what if deleted ?
bouquetList->activateBouquet(old_b_id, false); delete hintBox;
msg = CRCInput::RC_ok;
goto _show;
} }
channellist_visible = false; channellist_visible = false;
@@ -2769,7 +2770,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
printf("NeutrinoMessages::EVT_SERVICESCHANGED\n");fflush(stdout); printf("NeutrinoMessages::EVT_SERVICESCHANGED\n");fflush(stdout);
channelsInit(); channelsInit();
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? adjustToChannelID(live_channel_id);//FIXME what if deleted ?
if(old_b_id >= 0) { if(old_b_id >= 0) {
bouquetList->activateBouquet(old_b_id, false); bouquetList->activateBouquet(old_b_id, false);
old_b_id = -1; old_b_id = -1;
@@ -2780,7 +2781,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
printf("NeutrinoMessages::EVT_BOUQUETSCHANGED\n");fflush(stdout); printf("NeutrinoMessages::EVT_BOUQUETSCHANGED\n");fflush(stdout);
channelsInit(); channelsInit();
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? adjustToChannelID(live_channel_id);//FIXME what if deleted ?
return messages_return::handled; return messages_return::handled;
} }
else if( msg == NeutrinoMessages::EVT_RECORDMODE ) { else if( msg == NeutrinoMessages::EVT_RECORDMODE ) {
@@ -4169,7 +4170,7 @@ void CNeutrinoApp::SDT_ReloadChannels()
//g_Zapit->reinitChannels(); //g_Zapit->reinitChannels();
channelsInit(); channelsInit();
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
channelList->adjustToChannelID(live_channel_id);//FIXME what if deleted ? adjustToChannelID(live_channel_id);//FIXME what if deleted ?
if(old_b_id >= 0) { if(old_b_id >= 0) {
bouquetList->activateBouquet(old_b_id, false); bouquetList->activateBouquet(old_b_id, false);
old_b_id = -1; old_b_id = -1;
@@ -4331,3 +4332,63 @@ void CNeutrinoApp::CheckFastScan(bool standby, bool reload)
} }
} }
} }
bool CNeutrinoApp::adjustToChannelID(const t_channel_id channel_id)
{
int old_mode = lastChannelMode;
int new_mode = old_mode;
bool has_channel = false;
first_mode_found = -1;
if (!channelList->adjustToChannelID(channel_id))
return false;
channelList->getLastChannels().store (channel_id);
if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv
|| CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) {
has_channel = TVfavList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_FAV;
if(!has_channel && old_mode == LIST_MODE_FAV)
new_mode = LIST_MODE_PROV;
has_channel = TVbouquetList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_PROV;
if(!has_channel && old_mode == LIST_MODE_PROV)
new_mode = LIST_MODE_SAT;
has_channel = TVsatList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_SAT;
if(!has_channel && old_mode == LIST_MODE_SAT)
new_mode = LIST_MODE_ALL;
has_channel = TVallList->adjustToChannelID(channel_id);
}
else if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_radio) {
has_channel = RADIOfavList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_FAV;
if(!has_channel && old_mode == LIST_MODE_FAV)
new_mode = LIST_MODE_PROV;
has_channel = RADIObouquetList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_PROV;
if(!has_channel && old_mode == LIST_MODE_PROV)
new_mode = LIST_MODE_SAT;
has_channel = RADIOsatList->adjustToChannelID(channel_id);
if (has_channel && first_mode_found < 0)
first_mode_found = LIST_MODE_SAT;
if(!has_channel && old_mode == LIST_MODE_SAT)
new_mode = LIST_MODE_ALL;
has_channel = RADIOallList->adjustToChannelID(channel_id);
}
if(old_mode != new_mode)
CNeutrinoApp::getInstance()->SetChannelMode(new_mode);
return true;
}

View File

@@ -98,12 +98,16 @@ private:
bool skipSleepTimer; bool skipSleepTimer;
bool lockStandbyCall; bool lockStandbyCall;
bool pbBlinkChange; bool pbBlinkChange;
bool g_channel_list_changed; bool channels_changed;
bool favorites_changed;
bool bouquets_changed;
bool channels_init;
bool timer_wakeup; bool timer_wakeup;
int tvsort[LIST_MODE_LAST]; int tvsort[LIST_MODE_LAST];
int radiosort[LIST_MODE_LAST]; int radiosort[LIST_MODE_LAST];
bool channellist_visible; bool channellist_visible;
int first_mode_found;
void SDT_ReloadChannels(); void SDT_ReloadChannels();
void setupNetwork( bool force= false ); void setupNetwork( bool force= false );
@@ -199,7 +203,10 @@ public:
return lastChannelMode; return lastChannelMode;
}; };
void SetChannelMode(int mode); void SetChannelMode(int mode);
void MarkChannelListChanged(void) { g_channel_list_changed = true; }; void MarkChannelsChanged(void) { channels_changed = true; };
void MarkFavoritesChanged(void) { favorites_changed = true; };
void MarkBouquetsChanged(void) { bouquets_changed = true; };
void MarkChannelsInit(void) { channels_init = true; };
void quickZap(int msg); void quickZap(int msg);
void numericZap(int msg); void numericZap(int msg);
void StopSubtitles(); void StopSubtitles();
@@ -220,6 +227,7 @@ public:
void standbyToStandby(void); void standbyToStandby(void);
void lockPlayBack(bool blank = true); void lockPlayBack(bool blank = true);
void stopPlayBack(bool lock = false); void stopPlayBack(bool lock = false);
bool adjustToChannelID(const t_channel_id channel_id);
}; };
#endif #endif