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
This commit is contained in:
seife
2011-03-07 10:44:50 +00:00
parent e78a89520d
commit a5dabda81f
4 changed files with 51 additions and 18 deletions

View File

@@ -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;
}

View File

@@ -41,6 +41,7 @@
#include <driver/fontrenderer.h>
#include <driver/screen_max.h>
#include <driver/rcinput.h>
#include <driver/abstime.h>
#include <gui/color.h>
#include <gui/eventlist.h>
@@ -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 ) {

View File

@@ -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;

View File

@@ -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);
}