- rc_lock: rework class; switch to singleton; add icon; vfd-support

This commit is contained in:
svenhoefer
2016-01-20 20:00:00 +01:00
parent 7783ee684f
commit 2eb0aed5db
14 changed files with 115 additions and 64 deletions

View File

@@ -1,11 +1,8 @@
/*
Neutrino-GUI - DBoxII-Project
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert
auf der Client-Server Idee, diese GUI ist also von der direkten DBox-
Steuerung getrennt. Diese wird dann von Daemons uebernommen.
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2015 Sven Hoefer (svenhoefer)
License: GPL
@@ -34,41 +31,63 @@
#include <gui/rc_lock.h>
#include <driver/display.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/messagebox.h>
#include <gui/widget/stringinput.h>
const std::string CRCLock::NO_USER_INPUT = "noUserInput";
bool CRCLock::locked = false;
const std::string CRCLock::NO_USER_INPUT = "NO_USER_INPUT";
// -- Menue Handler Interface
// -- Infinite Loop to lock remote control (until release lock key pressed)
// -- 2003-12-01 rasc
CRCLock::CRCLock()
{
locked = false;
lockIcon = NULL;
}
CRCLock::~CRCLock()
{
if (lockIcon)
{
delete lockIcon;
lockIcon = NULL;
}
}
CRCLock* CRCLock::getInstance()
{
static CRCLock* me = NULL;
if (!me)
me = new CRCLock();
return me;
}
int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey)
{
if(locked)
if (locked)
{
printf("CRCLock::%s: already locked; exiting\n", __func__);
return menu_return::RETURN_EXIT_ALL;
}
if (parent)
parent->hide();
bool no_input = (actionKey == NO_USER_INPUT);
if (ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_LOCKMSG,
CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel,
NEUTRINO_ICON_INFO,450,no_input ? 5 : -1,no_input) == CMessageBox::mbrCancel)
std::string key_unlock = CRCInput::getKeyName((neutrino_msg_t) g_settings.key_unlock);
char lock_msg[1024];
snprintf(lock_msg, sizeof(lock_msg)-1, g_Locale->getText(LOCALE_RCLOCK_LOCKMSG), key_unlock.c_str());
if (ShowMsg(LOCALE_RCLOCK_TITLE, lock_msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel,
NEUTRINO_ICON_INFO, 450, no_input ? 5 : -1, no_input) == CMessageBox::mbrCancel)
return menu_return::RETURN_EXIT_ALL;
// -- Lockup Box
locked = true;
lockBox();
lockRC();
locked = false;
ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO,450, no_input ? 5 : -1);
ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack,
NEUTRINO_ICON_INFO, 450, no_input ? 5 : -1);
return menu_return::RETURN_EXIT_ALL;
}
void CRCLock::lockBox()
void CRCLock::lockRC()
{
neutrino_msg_t msg;
neutrino_msg_data_t data;
@@ -76,36 +95,53 @@ void CRCLock::lockBox()
uint64_t timeoutEnd;
// -- Loop until release key pressed
// -- Key sequence: <RED> <DBOX> within 5 secs
while (1) {
// -- Release key sequence: [red] [g_settings.key_unlock] within 5 secs
printf("CRCLock::%s: locking remote control\n", __func__);
while (1)
{
timeoutEnd = CRCInput::calcTimeoutEnd(9999999);
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
if (msg == NeutrinoMessages::UNLOCK_RC)
break;
if (msg == CRCInput::RC_red) {
if (msg == CRCInput::RC_red)
{
timeoutEnd = CRCInput::calcTimeoutEnd(5);
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
//if (msg == CRCInput::RC_setup) break;
if (msg == (neutrino_msg_t) g_settings.key_unlock) break;
if (msg == (neutrino_msg_t) g_settings.key_unlock)
break;
}
if (msg == CRCInput::RC_timeout) continue;
if (msg == CRCInput::RC_timeout)
continue;
// -- Zwen told me: Eating only RC events would be nice
// -- so be it...
if (msg > CRCInput::RC_MaxRC) {
if (msg > CRCInput::RC_MaxRC)
{
CNeutrinoApp::getInstance()->handleMsg(msg, data);
} else {
}
else
{
if (lockIcon == NULL)
{
lockIcon = new CComponentsPicture(
g_settings.screen_StartX + 10,
g_settings.screen_StartY + 10,
NEUTRINO_ICON_RCLOCK);
lockIcon->doPaintBg(false);
}
lockIcon->paint(CC_SAVE_SCREEN_YES);
CVFD::getInstance()->showRCLock();
// Since showRCLock blocks 2secs for each key we eat all
// messages created during this time. Hopefully this ok...
// showRCLock blocks box for 2 seconds,
// so we eat all messages created during this time.
g_RCInput->clearRCMsg();
lockIcon->hide();
}
}
printf("CRCLock::%s: unlocking remote control\n", __func__);
return;
}