1 |
#include "ShellExecPlugin.h" |
#include "ShellExecPlugin.h" |
2 |
#include "GsmModem.h" |
#include "IGsmModem.h" |
3 |
|
#include "Sms.h" |
4 |
|
|
5 |
#include "util.h" |
#include "util.h" |
6 |
|
|
7 |
ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand) |
ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters) |
8 |
: Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), |
: Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), |
9 |
_exeCommand(exeCommand) |
_exeCommand(exeCommand), |
10 |
|
_allowParameters(allowParameters) |
11 |
{ |
{ |
12 |
} |
} |
13 |
|
|
14 |
void ShellExecPlugin::Execute(GsmModem& modem, SMS& sms) |
void ShellExecPlugin::Execute(IGsmModem& modem, SMS& sms) |
15 |
{ |
{ |
16 |
std::string parameters = GetSmsData(sms); |
std::string command = _exeCommand; |
|
Util::str_clean(¶meters,";"); |
|
17 |
|
|
18 |
std::string command = _exeCommand + " " + parameters; |
if (_allowParameters) |
19 |
int retval = ::system( command.c_str() ); |
{ |
20 |
|
std::string parameters = GetSmsData(sms); |
21 |
|
|
22 |
|
parameters = Util::str_replace(parameters, "||"); |
23 |
|
parameters = Util::str_replace(parameters, "&&"); |
24 |
|
parameters = Util::str_replace(parameters, ";"); |
25 |
|
parameters = Util::str_replace(parameters, "'"); |
26 |
|
parameters = Util::str_replace(parameters, "\""); |
27 |
|
|
28 |
|
command += " "; |
29 |
|
command += parameters; |
30 |
|
} |
31 |
|
int retval = Util::my_system( command.c_str() ); |
32 |
|
|
33 |
std::string message; |
std::string message; |
34 |
if (retval == -1) |
if (retval == -1) |
36 |
else |
else |
37 |
message = "OK"; |
message = "OK"; |
38 |
|
|
39 |
modem.SendSms(sms.sender, message ); |
modem.SendSms(sms.sender, message, false ); |
40 |
} |
} |