The EventHandler is now not dependent on Logic
This commit is contained in:
parent
6cc0ee1191
commit
ee5003a599
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
\verbatim
|
||||
SvxLink - A Multi Purpose Voice Services System for Ham Radio Use
|
||||
Copyright (C) 2003-2015 Tobias Blomberg / SM0SVX
|
||||
Copyright (C) 2003-2019 Tobias Blomberg / SM0SVX
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -55,7 +55,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
****************************************************************************/
|
||||
|
||||
#include "EventHandler.h"
|
||||
#include "Logic.h"
|
||||
#include "Module.h"
|
||||
|
||||
|
||||
|
|
@ -119,20 +118,20 @@ using namespace Async;
|
|||
****************************************************************************/
|
||||
|
||||
|
||||
EventHandler::EventHandler(const string& event_script, Logic *logic)
|
||||
: event_script(event_script), logic(logic), interp(0)
|
||||
EventHandler::EventHandler(const string& event_script, const string& logic_name)
|
||||
: event_script(event_script), logic_name(logic_name), interp(0)
|
||||
{
|
||||
interp = Tcl_CreateInterp();
|
||||
if (interp == 0)
|
||||
{
|
||||
cerr << "*** ERROR: Could not create TCL interpreter for logic "
|
||||
<< logic->name() << "\n";
|
||||
<< logic_name << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Tcl_Init(interp) != TCL_OK)
|
||||
{
|
||||
cerr << event_script << " in logic " << logic->name() << ": "
|
||||
cerr << event_script << " in logic " << logic_name << ": "
|
||||
<< Tcl_GetStringResult(interp) << endl;
|
||||
Tcl_DeleteInterp(interp);
|
||||
interp = 0;
|
||||
|
|
@ -179,7 +178,7 @@ bool EventHandler::initialize(void)
|
|||
|
||||
if (Tcl_EvalFile(interp, event_script.c_str()) != TCL_OK)
|
||||
{
|
||||
cerr << event_script << " in logic " << logic->name() << ": "
|
||||
cerr << event_script << " in logic " << logic_name << ": "
|
||||
<< Tcl_GetStringResult(interp) << endl;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -200,7 +199,7 @@ void EventHandler::setVariable(const string& name, const string& value)
|
|||
if (Tcl_SetVar(interp, name.c_str(), value.c_str(), TCL_LEAVE_ERR_MSG)
|
||||
== NULL)
|
||||
{
|
||||
cerr << event_script << " in logic " << logic->name() << ": "
|
||||
cerr << event_script << " in logic " << logic_name << ": "
|
||||
<< Tcl_GetStringResult(interp) << endl;
|
||||
}
|
||||
Tcl_Release(interp);
|
||||
|
|
@ -219,7 +218,7 @@ bool EventHandler::processEvent(const string& event)
|
|||
if (Tcl_Eval(interp, (event + ";").c_str()) != TCL_OK)
|
||||
{
|
||||
cerr << "*** ERROR: Unable to handle event: " << event
|
||||
<< " in logic " << logic->name() << " ("
|
||||
<< " in logic " << logic_name << " ("
|
||||
<< Tcl_GetStringResult(interp) << ")" << endl;
|
||||
success = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
\verbatim
|
||||
SvxLink - A Multi Purpose Voice Services System for Ham Radio Use
|
||||
Copyright (C) 2003-2015 Tobias Blomberg / SM0SVX
|
||||
Copyright (C) 2003-2019 Tobias Blomberg / SM0SVX
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -62,7 +62,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
class Logic;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -116,8 +115,8 @@ class EventHandler : public sigc::trackable
|
|||
/**
|
||||
* @brief Constuctor
|
||||
*/
|
||||
EventHandler(const std::string& event_script, Logic *logic);
|
||||
|
||||
EventHandler(const std::string& event_script, const std::string& logic_name);
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
|
|
@ -219,12 +218,12 @@ class EventHandler : public sigc::trackable
|
|||
sigc::signal<void, const std::string&, int> injectDtmf;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
std::string event_script;
|
||||
Logic *logic;
|
||||
Tcl_Interp *interp;
|
||||
|
||||
std::string event_script;
|
||||
std::string logic_name;
|
||||
Tcl_Interp * interp;
|
||||
|
||||
static int playFileHandler(ClientData cdata, Tcl_Interp *irp,
|
||||
int argc, const char *argv[]);
|
||||
static int playSilenceHandler(ClientData cdata, Tcl_Interp *irp,
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ bool Logic::initialize(void)
|
|||
tx_audio_mixer->addSource(msg_pacer);
|
||||
prev_tx_src = 0;
|
||||
|
||||
event_handler = new EventHandler(event_handler_str, this);
|
||||
event_handler = new EventHandler(event_handler_str, name());
|
||||
event_handler->playFile.connect(mem_fun(*this, &Logic::playFile));
|
||||
event_handler->playSilence.connect(mem_fun(*this, &Logic::playSilence));
|
||||
event_handler->playTone.connect(mem_fun(*this, &Logic::playTone));
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LIBECHOLIB=1.3.3
|
|||
LIBASYNC=1.5.99.2
|
||||
|
||||
# SvxLink versions
|
||||
SVXLINK=1.6.99.14
|
||||
SVXLINK=1.6.99.15
|
||||
MODULE_HELP=1.0.0
|
||||
MODULE_PARROT=1.1.1
|
||||
MODULE_ECHOLINK=1.4.99.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue