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

@@ -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 ) {