From fc32350b39a795d127d56129c162130e30e5de24 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 7 Mar 2011 10:44:50 +0000 Subject: [PATCH] neutrino: parental PIN unlocks bouquet for 1 hour for 'pre-locked' bouquets, remember that they are unlocked for an hour this speeds up channel switching because no EPG is needed for unlocking git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1272 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a5dabda81f581c099366c36a5dcae35932287ef3 Author: Stefan Seyfried Date: 2011-03-07 (Mon, 07 Mar 2011) ------------------ This commit was generated by Migit --- src/daemonc/remotecontrol.cpp | 28 +++++++++++------------ src/gui/channellist.cpp | 38 +++++++++++++++++++++++++++---- src/zapit/include/zapit/channel.h | 1 + src/zapit/src/channel.cpp | 2 ++ 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index f76289b09..173214c9a 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -125,10 +125,10 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data zap_completion_timeout = 0; g_InfoViewer->chanready = 1; } -#if 0 - if ((!is_video_started) && (g_settings.parentallock_prompt != PARENTALLOCK_PROMPT_NEVER)) - g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false ); -#endif + /* for CHANGETOLOCKED, we don't need to wait for EPG to arrive... */ + if ((!is_video_started) && + (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED)) + g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false); } } else { if ((msg == NeutrinoMessages::EVT_ZAP_COMPLETE) || (msg == NeutrinoMessages::EVT_ZAP_FAILED ) || @@ -167,10 +167,9 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data if ( g_InfoViewer->is_visible ) g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR , 0 ); } -#if 0 - if ((!is_video_started) && (g_settings.parentallock_prompt != PARENTALLOCK_PROMPT_NEVER)) - g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false ); -#endif + if ((!is_video_started) && + (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED)) + g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false); } else if ((msg == NeutrinoMessages::EVT_ZAP_SUB_COMPLETE) || (msg == NeutrinoMessages:: EVT_ZAP_SUB_FAILED )) { @@ -232,13 +231,14 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data time_t end_program= info_CN->current_zeit.startzeit+ info_CN->current_zeit.dauer; current_programm_timer = g_RCInput->addTimer( &end_program ); - - // is_video_started is only false if channel is locked - if (((!is_video_started) && (info_CN->current_fsk == 0)) || ((!is_video_started) && (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED))) - g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false ); - else - g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, info_CN->current_fsk, false ); } + + // is_video_started is only false if channel is locked + if ((!is_video_started) && + (info_CN->current_fsk == 0 || g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED)) + g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false); + else + g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, info_CN->current_fsk, false); } return messages_return::handled; } diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 42d2bab3f..48d79be98 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -948,18 +949,41 @@ int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED && data < 0x100) goto out; + /* if a pre-locked channel is inside the zap time, open it. Hardcoded to one hour for now. */ + if (data >= 0x100 && chanlist[selected]->last_unlocked_time + 3600 > time_monotonic()) + goto out; + /* OK, let's ask for a PIN */ g_RemoteControl->stopvideo(); //printf("stopped video\n"); - startvideo = false; zapProtection = new CZapProtection(g_settings.parentallock_pincode, data); if (zapProtection->check()) { - //printf("checked true\n"); // remember it for the next time - chanlist[selected]->last_unlocked_EPGid= g_RemoteControl->current_EPGid; - startvideo = true; + /* data < 0x100: lock age -> remember EPG ID */ + if (data < 0x100) + chanlist[selected]->last_unlocked_EPGid = g_RemoteControl->current_EPGid; + else + { + /* data >= 0x100: pre locked bouquet -> remember unlock time */ + chanlist[selected]->last_unlocked_time = time_monotonic(); + int bnum = bouquetList->getActiveBouquetNumber(); + if (bnum >= 0) + { + /* unlock the whole bouquet */ + int i; + for (i = 0; i < bouquetList->Bouquets[bnum]->channelList->getSize(); i++) + bouquetList->Bouquets[bnum]->channelList->getChannelFromIndex(i)->last_unlocked_time = chanlist[selected]->last_unlocked_time; + } + } + } + else + { + /* last_unlocked_time == 0 is the magic to tell zapTo() to not record the time. + Without that, zapping to a locked channel twice would open it without the PIN */ + chanlist[selected]->last_unlocked_time = 0; + startvideo = false; } delete zapProtection; zapProtection = NULL; @@ -1089,6 +1113,12 @@ void CChannelList::zapTo(int pos, bool /* forceStoreToLastChannels */) pos = 0; } + /* we record when we switched away from a channel, so that the parental-PIN code can + check for timeout. last_unlocked_time == 0 means: the PIN was not entered + "tuned" is the *old* channel, before zap */ + if (tuned < chanlist.size() && chanlist[tuned]->last_unlocked_time != 0) + chanlist[tuned]->last_unlocked_time = time_monotonic(); + CZapitChannel* chan = chanlist[pos]; printf("**************************** CChannelList::zapTo me %p %s tuned %d new %d %s -> %llx\n", this, name.c_str(), tuned, pos, chan->name.c_str(), chan->channel_id); if ( pos!=(int)tuned ) { diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index 65fd88eda..b94a5b1c6 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -150,6 +150,7 @@ class CZapitChannel /* from neutrino CChannel class */ uint64_t last_unlocked_EPGid; + time_t last_unlocked_time; std::string ttx_language_code; friend class CChannelList; diff --git a/src/zapit/src/channel.cpp b/src/zapit/src/channel.cpp index bfdf6a844..035f315d7 100644 --- a/src/zapit/src/channel.cpp +++ b/src/zapit/src/channel.cpp @@ -43,6 +43,8 @@ CZapitChannel::CZapitChannel(const std::string & p_name, t_service_id p_sid, t_t pmtPid = 0; resetPids(); ttx_language_code = ""; + last_unlocked_EPGid = 0; + last_unlocked_time = 0; //printf("NEW CHANNEL %s %x\n", name.c_str(), (int) this); }