- 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

@@ -212,6 +212,7 @@ install_DATA += \
radiotextget.png \ radiotextget.png \
radiotextoff.png \ radiotextoff.png \
radiotextwait.png \ radiotextwait.png \
rclock.png \
rec.png \ rec.png \
rec_event_marker.png \ rec_event_marker.png \
rec_gray.png \ rec_gray.png \

BIN
data/icons/rclock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1991,10 +1991,10 @@ plugintype.game Spiel
plugintype.lua Lua-Plugin plugintype.lua Lua-Plugin
plugintype.script Skript plugintype.script Skript
plugintype.tool Werkzeug plugintype.tool Werkzeug
rclock.lockmsg Die Fernbedienung der CST wird gesperrt.\n Um die Sperre aufzuheben, bitte\n <ROT> und <MENU> auf der Fernbedienung\n drücken. rclock.locked Gesperrt
rclock.menueadd FB sperren rclock.lockmsg Die Fernbedienung wird gesperrt.\nUm die Sperre aufzuheben, bitte\n[rot] gefolgt von [%s]\nauf der Fernbedienung drücken.
rclock.title Fernbedienung sperren rclock.title Fernbedienung sperren
rclock.unlockmsg Fernbedienung reaktiviert... rclock.unlockmsg Fernbedienung reaktiviert
recording.is_running Folgende Aufnahme läuft bereits! Neue Aufnahme starten? recording.is_running Folgende Aufnahme läuft bereits! Neue Aufnahme starten?
recording.start Starte Aufnahme, bitte warten...! recording.start Starte Aufnahme, bitte warten...!
recording.startstop_msg Meldung bei Aufnahme Start/Ende recording.startstop_msg Meldung bei Aufnahme Start/Ende

View File

@@ -1991,10 +1991,10 @@ plugintype.game Game
plugintype.lua Lua plugin plugintype.lua Lua plugin
plugintype.script Script plugintype.script Script
plugintype.tool Tool plugintype.tool Tool
rclock.lockmsg Your box remote control will be locked.\n To unlock it, press <RED> \n and <MENU> on your remote control. rclock.locked Locked
rclock.menueadd Lock RC rclock.lockmsg Remote control will be locked.\nTo unlock, press\n[red] followed by [%s]\non your remote control.
rclock.title Lock Remote Control rclock.title Lock remote control
rclock.unlockmsg Remote control reactivated. rclock.unlockmsg Remote control unlocked
recording.is_running This channel already recording. Start new record? recording.is_running This channel already recording. Start new record?
recording.start Start recording, please wait...! recording.start Start recording, please wait...!
recording.startstop_msg Message when recording is start/stop recording.startstop_msg Message when recording is start/stop

View File

@@ -404,8 +404,18 @@ void CVFD::showTime(bool force)
recstatus = tmp_recstatus; recstatus = tmp_recstatus;
} }
void CVFD::showRCLock(int /*duration*/) void CVFD::showRCLock(int duration)
{ {
if (!has_lcd)
{
sleep(duration);
return;
}
std::string _text = text;
ShowText(g_Locale->getText(LOCALE_RCLOCK_LOCKED));
sleep(duration);
ShowText(_text.c_str());
} }
void CVFD::showVolume(const char vol, const bool force_update) void CVFD::showVolume(const char vol, const bool force_update)

View File

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

View File

@@ -1,7 +1,8 @@
/* /*
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Copyright (C) 2015 Sven Hoefer (svenhoefer)
License: GPL License: GPL
@@ -21,28 +22,30 @@
*/ */
#ifndef _remoteLock_ #ifndef _rc_lock_
#define _remoteLock_ #define _rc_lock_
#include <gui/widget/menue.h> #include <gui/widget/menue.h>
#include <string> #include <string>
//
// -- Implements RemoteControl Locking...
// -- ... usefull, if you want to protect your box against unintented zapping
// -- 2003-12-01 rasc
//
class CRCLock: public CMenuTarget class CRCLock: public CMenuTarget
{ {
private: private:
void lockBox(); bool locked;
CComponentsPicture *lockIcon;
void lockRC();
public: public:
CRCLock();
~CRCLock();
static CRCLock* getInstance();
static const std::string NO_USER_INPUT; static const std::string NO_USER_INPUT;
int isLocked() { return locked; }
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
static bool locked;
}; };
#endif #endif

View File

@@ -224,7 +224,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg)
break; break;
case SNeutrinoSettings::ITEM_REMOTE: case SNeutrinoSettings::ITEM_REMOTE:
keyhelper.get(&key,&icon,feat_key[g_settings.personalize[SNeutrinoSettings::P_FEAT_KEY_RC_LOCK]].key); //CRCInput::RC_nokey); keyhelper.get(&key,&icon,feat_key[g_settings.personalize[SNeutrinoSettings::P_FEAT_KEY_RC_LOCK]].key); //CRCInput::RC_nokey);
menu_item = new CMenuDForwarder(LOCALE_RCLOCK_MENUEADD, true, NULL, new CRCLock, "-1" , key, icon ); menu_item = new CMenuForwarder(LOCALE_RCLOCK_TITLE, true, NULL, CRCLock::getInstance(), "-1" , key, icon );
// FIXME menu_item->setHint("", NONEXISTANT_LOCALE); // FIXME menu_item->setHint("", NONEXISTANT_LOCALE);
break; break;
case SNeutrinoSettings::ITEM_EPG_SUPER: case SNeutrinoSettings::ITEM_EPG_SUPER:

View File

@@ -86,7 +86,7 @@ static keyvals usermenu_items[] =
{ SNeutrinoSettings::ITEM_INETPLAY, LOCALE_INETRADIO_NAME, usermenu_show }, { SNeutrinoSettings::ITEM_INETPLAY, LOCALE_INETRADIO_NAME, usermenu_show },
{ SNeutrinoSettings::ITEM_MOVIEPLAYER_MB, LOCALE_MOVIEBROWSER_HEAD, usermenu_show }, { SNeutrinoSettings::ITEM_MOVIEPLAYER_MB, LOCALE_MOVIEBROWSER_HEAD, usermenu_show },
{ SNeutrinoSettings::ITEM_TIMERLIST, LOCALE_TIMERLIST_NAME, usermenu_show }, { SNeutrinoSettings::ITEM_TIMERLIST, LOCALE_TIMERLIST_NAME, usermenu_show },
{ SNeutrinoSettings::ITEM_REMOTE, LOCALE_RCLOCK_MENUEADD, usermenu_show }, { SNeutrinoSettings::ITEM_REMOTE, LOCALE_RCLOCK_TITLE, usermenu_show },
{ SNeutrinoSettings::ITEM_FAVORITS, LOCALE_FAVORITES_MENUEADD, usermenu_show }, { SNeutrinoSettings::ITEM_FAVORITS, LOCALE_FAVORITES_MENUEADD, usermenu_show },
{ SNeutrinoSettings::ITEM_TECHINFO, LOCALE_EPGMENU_STREAMINFO, usermenu_show }, { SNeutrinoSettings::ITEM_TECHINFO, LOCALE_EPGMENU_STREAMINFO, usermenu_show },
{ SNeutrinoSettings::ITEM_PLUGIN_TYPES, LOCALE_USERMENU_ITEM_PLUGIN_TYPES, usermenu_show }, { SNeutrinoSettings::ITEM_PLUGIN_TYPES, LOCALE_USERMENU_ITEM_PLUGIN_TYPES, usermenu_show },

View File

@@ -158,6 +158,7 @@
#define NEUTRINO_ICON_NETWORK "network" #define NEUTRINO_ICON_NETWORK "network"
#define NEUTRINO_ICON_LCD "lcd" #define NEUTRINO_ICON_LCD "lcd"
#define NEUTRINO_ICON_VOLUME "volume" #define NEUTRINO_ICON_VOLUME "volume"
#define NEUTRINO_ICON_RCLOCK "rclock"
#define NEUTRINO_ICON_RESOLUTION_1920 "res_1920" #define NEUTRINO_ICON_RESOLUTION_1920 "res_1920"
#define NEUTRINO_ICON_RESOLUTION_1080 "res_1080" #define NEUTRINO_ICON_RESOLUTION_1080 "res_1080"
#define NEUTRINO_ICON_RESOLUTION_1440 "res_1440" #define NEUTRINO_ICON_RESOLUTION_1440 "res_1440"

View File

@@ -3237,8 +3237,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
} }
else if (msg == NeutrinoMessages::LOCK_RC) else if (msg == NeutrinoMessages::LOCK_RC)
{ {
CRCLock rcLock; CRCLock::getInstance()->exec(NULL, CRCLock::NO_USER_INPUT);
rcLock.exec(NULL,CRCLock::NO_USER_INPUT);
return messages_return::handled; return messages_return::handled;
} }
else if( msg == NeutrinoMessages::CHANGEMODE ) { else if( msg == NeutrinoMessages::CHANGEMODE ) {

View File

@@ -498,14 +498,15 @@ void CControlAPI::RCCGI(CyhookHandler *hh)
{ {
if (!(hh->ParamList.empty())) if (!(hh->ParamList.empty()))
{ {
bool locked = CRCLock::getInstance()->isLocked();
if (hh->ParamList["1"] == "lock"){ // lock remote control if (hh->ParamList["1"] == "lock"){ // lock remote control
if(!CRCLock::locked) if (!locked)
NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::LOCK_RC, CEventServer::INITID_HTTPD); NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::LOCK_RC, CEventServer::INITID_HTTPD);
} }
else if (hh->ParamList["1"] == "unlock"){// unlock remote control else if (hh->ParamList["1"] == "unlock"){// unlock remote control
if(CRCLock::locked) if (locked)
NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::UNLOCK_RC, CEventServer::INITID_HTTPD); NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::UNLOCK_RC, CEventServer::INITID_HTTPD);
} }
else{ else{
hh->SendError(); hh->SendError();

View File

@@ -2018,8 +2018,8 @@ typedef enum
LOCALE_PLUGINTYPE_LUA, LOCALE_PLUGINTYPE_LUA,
LOCALE_PLUGINTYPE_SCRIPT, LOCALE_PLUGINTYPE_SCRIPT,
LOCALE_PLUGINTYPE_TOOL, LOCALE_PLUGINTYPE_TOOL,
LOCALE_RCLOCK_LOCKED,
LOCALE_RCLOCK_LOCKMSG, LOCALE_RCLOCK_LOCKMSG,
LOCALE_RCLOCK_MENUEADD,
LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_TITLE,
LOCALE_RCLOCK_UNLOCKMSG, LOCALE_RCLOCK_UNLOCKMSG,
LOCALE_RECORDING_IS_RUNNING, LOCALE_RECORDING_IS_RUNNING,

View File

@@ -2018,8 +2018,8 @@ const char * locale_real_names[] =
"plugintype.lua", "plugintype.lua",
"plugintype.script", "plugintype.script",
"plugintype.tool", "plugintype.tool",
"rclock.locked",
"rclock.lockmsg", "rclock.lockmsg",
"rclock.menueadd",
"rclock.title", "rclock.title",
"rclock.unlockmsg", "rclock.unlockmsg",
"recording.is_running", "recording.is_running",