neutrino: refactor the PROGRAMLOCKSTATUS code

Rewrite the NeutrinoMessages::EVT_PROGRAMLOCKSTATUS handling code to
be more readable and understandable. Should be functionally equivalent.

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1230 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
seife
2011-02-27 21:19:35 +00:00
parent b1e7ea7d55
commit 696e168de7

View File

@@ -874,53 +874,64 @@ bool CChannelList::showInfo(int pos, int epgpos)
int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
{
if ( msg == NeutrinoMessages::EVT_PROGRAMLOCKSTATUS) {
bool startvideo = true;
if (msg != NeutrinoMessages::EVT_PROGRAMLOCKSTATUS) // right now the only message handled here.
return messages_return::unhandled;
//printf("===> program-lock-status: %d zp: %d\n", data, zapProtection != NULL);
if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_NEVER)
goto out;
// 0x100 als FSK-Status zeigt an, dass (noch) kein EPG zu einem Kanal der NICHT angezeigt
// werden sollte (vorgesperrt) da ist
// oder das bouquet des Kanals ist vorgesperrt
//printf("program-lock-status: %d\n", data);
if ((g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_ONSIGNAL) || (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED))
{
if ( zapProtection != NULL )
if (zapProtection != NULL) {
zapProtection->fsk = data;
else {
startvideo = false;
goto out;
}
// require password if either
// CHANGETOLOCK mode and channel/bouquet is pre locked (0x100)
// ONSIGNAL mode and fsk(data) is beyond configured value
// if programm has already been unlocked, dont require pin
#if 1
if ((data >= (neutrino_msg_data_t)g_settings.parentallock_lockage) &&
((chanlist[selected]->last_unlocked_EPGid != g_RemoteControl->current_EPGid) || (g_RemoteControl->current_EPGid == 0)) &&
((g_settings.parentallock_prompt != PARENTALLOCK_PROMPT_CHANGETOLOCKED) || (data >= 0x100)))
{
// if program has already been unlocked, dont require pin
if (data < (neutrino_msg_data_t)g_settings.parentallock_lockage)
goto out;
/* already unlocked */
if (chanlist[selected]->last_unlocked_EPGid == g_RemoteControl->current_EPGid && g_RemoteControl->current_EPGid != 0)
goto out;
/* PARENTALLOCK_PROMPT_CHANGETOLOCKED: only pre-locked channels, don't care for fsk sent in SI */
if (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED && data < 0x100)
goto out;
/* OK, let's ask for a PIN */
g_RemoteControl->stopvideo();
zapProtection = new CZapProtection( g_settings.parentallock_pincode, data );
//printf("stopped video\n");
startvideo = false;
zapProtection = new CZapProtection(g_settings.parentallock_pincode, data);
if ( zapProtection->check() )
if (zapProtection->check())
{
g_RemoteControl->startvideo();
//printf("checked true\n");
// remember it for the next time
chanlist[selected]->last_unlocked_EPGid= g_RemoteControl->current_EPGid;
startvideo = true;
}
delete zapProtection;
zapProtection = NULL;
}
else
g_RemoteControl->startvideo();
#endif
}
}
else
out:
if (startvideo)
g_RemoteControl->startvideo();
return messages_return::handled;
}
else
return messages_return::unhandled;
}
/* bToo default to true */
/* TODO make this member of CNeutrinoApp, because this only called from "whole" list ? */
bool CChannelList::adjustToChannelID(const t_channel_id channel_id, bool bToo)