pzapit: add -lockrc/-unlockrc options; port from martii

I've pulled it from Duckbox-Developers/neutrino-mp-cst-next
and modified it to work


Origin commit data
------------------
Commit: 0330515abc
Author: GetAway <get-away@t-online.de>
Date: 2016-12-11 (Sun, 11 Dec 2016)
This commit is contained in:
GetAway
2016-12-11 16:53:32 +01:00
committed by vanhofen
parent 0086404fb3
commit f199989c9a
9 changed files with 79 additions and 11 deletions

View File

@@ -278,21 +278,36 @@ CRCInput::~CRCInput()
* stopInput - stop reading rcin for plugins
*
**************************************************************************/
void CRCInput::stopInput()
void CRCInput::stopInput(const bool ext)
{
if (isLocked())
return;
input_stopped = true;
close();
if (ext)
postMsg(NeutrinoMessages::LOCK_RC_EXTERN, 0);
}
bool CRCInput::isLocked(void)
{
return input_stopped;
}
/**************************************************************************
* restartInput - restart reading rcin after calling plugins
*
**************************************************************************/
void CRCInput::restartInput()
void CRCInput::restartInput(const bool ext)
{
if (!isLocked())
return;
close();
open();
input_stopped = false;
if (ext)
postMsg(NeutrinoMessages::UNLOCK_RC_EXTERN, 0);
}
#if 0
//never used

View File

@@ -278,8 +278,9 @@ class CRCInput
{
return fd_rc[0];
}
void stopInput();
void restartInput();
void stopInput(const bool ext = false);
void restartInput(const bool ext = false);
bool isLocked(void);
uint64_t repeat_block;
uint64_t repeat_block_generic;

View File

@@ -3394,6 +3394,11 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
CRCLock::getInstance()->exec(NULL, CRCLock::NO_USER_INPUT);
return messages_return::handled;
}
else if (msg == NeutrinoMessages::LOCK_RC_EXTERN || msg == NeutrinoMessages::UNLOCK_RC_EXTERN)
{
printf("CNeutrinoApp::handleMsg: RC is %s now\n", msg == NeutrinoMessages::LOCK_RC_EXTERN ? "LOCKED" : "UNLOCKED");
return messages_return::handled;
}
else if( msg == NeutrinoMessages::CHANGEMODE ) {
printf("CNeutrinoApp::handleMsg: CHANGEMODE to %d rezap %d\n", data & mode_mask, (data & norezap) != norezap);
if((data & mode_mask)== mode_radio) {

View File

@@ -71,10 +71,13 @@ struct NeutrinoMessages {
REMIND = CRCInput::RC_Messages + 18,
LOCK_RC = CRCInput::RC_Messages + 19,
UNLOCK_RC = CRCInput::RC_Messages + 20,
REBOOT = CRCInput::RC_Messages + 21,
RELOAD_SETUP = CRCInput::RC_Messages + 22,
SHOW_MAINMENU = CRCInput::RC_Messages + 23,
LEAVE_ALL = CRCInput::RC_Messages + 24,
LOCK_RC_EXTERN = CRCInput::RC_Messages + 21,
UNLOCK_RC_EXTERN = CRCInput::RC_Messages + 22,
REBOOT = CRCInput::RC_Messages + 23,
RELOAD_SETUP = CRCInput::RC_Messages + 24,
SHOW_MAINMENU = CRCInput::RC_Messages + 25,
LEAVE_ALL = CRCInput::RC_Messages + 26,
EVT_VOLCHANGED = CRCInput::RC_Events + 1,
EVT_MUTECHANGED = CRCInput::RC_Events + 2,

View File

@@ -150,9 +150,8 @@ class CZapitMessages
CMD_GET_MODE43 = 109,
CMD_SET_MODE43 = 110,
CMD_STOP_PIP = 111,
CMD_ZAPTO_EPG = 112
CMD_ZAPTO_EPG = 112,
CMD_LOCKRC = 113
};
struct commandBoolean

View File

@@ -375,6 +375,9 @@ class CZapitClient:public CBasicClient
/* get dvb transmission type */
delivery_system_t getDeliverySystem(void);
/* Lock remote control */
void lockRc(const bool mute);
void zaptoNvodSubService(const int num);
/* send diseqc 1.2 motor command */

View File

@@ -611,6 +611,19 @@ void CZapitClient::getVolume(unsigned int *left, unsigned int *right)
close_connection();
}
void CZapitClient::lockRc(const bool b)
{
CZapitMessages::commandBoolean msg;
//VALGRIND_PARANOIA;
msg.truefalse = b;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
send(CZapitMessages::CMD_LOCKRC, (char*)&msg, sizeof(msg));
close_connection();
}
#if 0
//never used
delivery_system_t CZapitClient::getDeliverySystem(void)

View File

@@ -70,6 +70,8 @@ int usage (const char * basename)
std::cout << "switch to pal mode: " << basename << " --pal" << std::endl;
std::cout << "switch to hd 720p mode: " << basename << " --720p" << std::endl;
std::cout << "send diseqc 1.2 motor command: " << basename << " -m <cmdtype> <addr> <cmd> <number of parameters> <parameter 1> <parameter 2>" << std::endl;
std::cout << "lock remote control: " << basename << " -lockrc" << std::endl;
std::cout << "unlock remote control: " << basename << " -unlockrc" << std::endl;
return -1;
}
@@ -92,6 +94,7 @@ int main (int argc, char** argv)
int nvod = -1;
int arat = -1;
int m43 = -1;
int lockrc = -1;
const char * channelName = NULL;
bool playback = false;
@@ -351,6 +354,16 @@ int main (int argc, char** argv)
continue;
}
}
else if (!strncmp(argv[i], "-lockrc", 7))
{
lockrc = 1;
continue;
}
else if (!strncmp(argv[i], "-unlockrc", 9))
{
lockrc = 0;
continue;
}
else if (i < argc - 1)
{
if ((sscanf(argv[i], "%d", &bouquet) > 0) && (sscanf(argv[++i], "%u", &channel) > 0))
@@ -418,6 +431,11 @@ int main (int argc, char** argv)
zapit.setVolume(volume, volume);
return 0;
}
if (lockrc != -1)
{
zapit.lockRc(lockrc);
return 0;
}
if (rezap)
{
zapit.Rezap();

View File

@@ -1862,6 +1862,17 @@ bool CZapit::ParseCommand(CBasicMessage::Header &rmsg, int connfd)
break;
}
case CZapitMessages::CMD_LOCKRC: {
CZapitMessages::commandBoolean msgBoolean;
CBasicServer::receive_data(connfd, &msgBoolean, sizeof(msgBoolean));
extern CRCInput *g_RCInput;
if (msgBoolean.truefalse)
g_RCInput->stopInput(true);
else
g_RCInput->restartInput(true);
break;
}
case CZapitMessages::CMD_SET_VOLUME: {
CZapitMessages::commandVolume msgVolume;
CBasicServer::receive_data(connfd, &msgVolume, sizeof(msgVolume));