From ce7cb28d85cb15250fe36ba611e0243931faf4b1 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 25 May 2014 15:22:31 +0200 Subject: [PATCH] zapit/bouquets: count locked bouquets a channels is in, and honor lock in all bouquets Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/abe03ad749cbf3ec478cd1bf3780adee9de48eb5 Author: martii Date: 2014-05-25 (Sun, 25 May 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/daemonc/remotecontrol.cpp | 2 +- src/gui/bedit/bouqueteditor_bouquets.cpp | 20 ++++++++++++++++++++ src/gui/channellist.cpp | 6 +++--- src/zapit/include/zapit/channel.h | 2 +- src/zapit/src/bouquets.cpp | 6 ++++-- src/zapit/src/channel.cpp | 1 + 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index fc1036ccb..5f001b20f 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -147,7 +147,7 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data is_video_started = true; if (channel) { current_channel_name = channel->getName(); - if (channel->bAlwaysLocked != g_settings.parentallock_defaultlocked) + if (!!channel->bAlwaysLocked != g_settings.parentallock_defaultlocked) stopvideo(); } CVFD::getInstance()->showServicename(current_channel_name); // UTF-8 diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 98d9d4949..d14934c22 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -430,6 +430,16 @@ void CBEBouquetWidget::deleteBouquet() if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) return; + if ((*Bouquets)[selected]->bLocked) { + ZapitChannelList *channels = &(*Bouquets)[selected]->tvChannels; + for(unsigned int i = 0; i < channels->size(); i++) + ((*channels)[i])->bAlwaysLocked--; + + channels = &(*Bouquets)[selected]->radioChannels; + for(unsigned int i = 0; i < channels->size(); i++) + ((*channels)[i])->bAlwaysLocked--; + } + g_bouquetManager->deleteBouquet(selected); Bouquets = &g_bouquetManager->Bouquets; if (selected >= Bouquets->size()) @@ -520,6 +530,16 @@ void CBEBouquetWidget::switchLockBouquet() bouquetsChanged = true; (*Bouquets)[selected]->bLocked = !(*Bouquets)[selected]->bLocked; paint(); + + int add = (*Bouquets)[selected]->bLocked ? +1 : -1; + + ZapitChannelList *channels = &(*Bouquets)[selected]->tvChannels; + for(unsigned int i = 0; i < channels->size(); i++) + ((*channels)[i])->bAlwaysLocked += add; + + channels = &(*Bouquets)[selected]->radioChannels; + for(unsigned int i = 0; i < channels->size(); i++) + ((*channels)[i])->bAlwaysLocked += add; } std::string CBEBouquetWidget::inputName(const char * const defaultName, const neutrino_locale_t caption) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index ce77a68d2..04cb89964 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -352,7 +352,7 @@ int CChannelList::doChannelMenu(void) * a channel could be added/removed to/from an unlocked bouquet and so made * accessible. */ if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED && - chanlist[selected]->bAlwaysLocked != g_settings.parentallock_defaultlocked) + !!chanlist[selected]->bAlwaysLocked != g_settings.parentallock_defaultlocked) unlocked = (chanlist[selected]->last_unlocked_time + 3600 > time_monotonic()); snprintf(cnt, sizeof(cnt), "%d", i); @@ -1083,7 +1083,7 @@ int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) chanlist[selected]->last_unlocked_EPGid = g_RemoteControl->current_EPGid; else { - /* data >= 0x100: pre locked bouquet -> remember unlock time */ + /* data >= 0x100: pre-locked bouquet -> remember unlock time */ chanlist[selected]->last_unlocked_time = time_monotonic(); int bnum = bouquetList->getActiveBouquetNumber(); if (bnum >= 0) @@ -1298,7 +1298,7 @@ void CChannelList::zapToChannel(CZapitChannel *channel, bool force) } selected_chid = channel->getChannelID(); - g_RemoteControl->zapTo_ChannelID(selected_chid, channel->getName(), (channel->bAlwaysLocked == g_settings.parentallock_defaultlocked)); + g_RemoteControl->zapTo_ChannelID(selected_chid, channel->getName(), (!!channel->bAlwaysLocked == g_settings.parentallock_defaultlocked)); CNeutrinoApp::getInstance()->channelList->adjustToChannelID(channel->getChannelID()); } if(new_zap_mode != 2 /* not active */) { diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index 3017a8791..2361df501 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -178,7 +178,7 @@ class CZapitChannel } channel_flags_t; casys_map_t camap; - bool bAlwaysLocked; + unsigned int bAlwaysLocked; int number; CChannelEvent currentEvent,nextEvent; diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index d7526423a..e1771d74d 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -110,6 +110,8 @@ void CZapitBouquet::addService(CZapitChannel* newChannel) radioChannels.push_back(newChannel); break; } + if (bLocked) + newChannel->bAlwaysLocked++; } void CZapitBouquet::removeService(CZapitChannel* oldChannel) @@ -128,6 +130,8 @@ void CZapitBouquet::removeService(CZapitChannel* oldChannel) break; } + if (bLocked) + oldChannel->bAlwaysLocked--; (*channels).erase(remove(channels->begin(), channels->end(), oldChannel), channels->end()); } } @@ -406,14 +410,12 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser) if(!bUser) chan->pname = (char *) newBouquet->Name.c_str(); - chan->bAlwaysLocked = newBouquet->bLocked; newBouquet->addService(chan); } else if (bUser) { chan = new CZapitChannel(name2, CREATE_CHANNEL_ID64, 1 /*service_type*/, satellitePosition, freq); CServiceManager::getInstance()->AddChannel(chan); chan->flags = CZapitChannel::NOT_FOUND; - chan->bAlwaysLocked = newBouquet->bLocked; newBouquet->addService(chan); CServiceManager::getInstance()->SetServicesChanged(false); } diff --git a/src/zapit/src/channel.cpp b/src/zapit/src/channel.cpp index 0bdc95695..89c6e21ad 100644 --- a/src/zapit/src/channel.cpp +++ b/src/zapit/src/channel.cpp @@ -69,6 +69,7 @@ void CZapitChannel::Init() polarization = 0; flags = 0; deltype = FE_QPSK; + bAlwaysLocked = 0; } CZapitChannel::~CZapitChannel(void)