3 |
|
|
4 |
#include "util.h" |
#include "util.h" |
5 |
|
|
6 |
ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand) |
ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters) |
7 |
: Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), |
: Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), |
8 |
_exeCommand(exeCommand) |
_exeCommand(exeCommand), |
9 |
|
_allowParameters(allowParameters) |
10 |
{ |
{ |
11 |
} |
} |
12 |
|
|
13 |
void ShellExecPlugin::Execute(GsmModem& modem, SMS& sms) |
void ShellExecPlugin::Execute(IGsmModem& modem, SMS& sms) |
14 |
{ |
{ |
15 |
std::string parameters = GetSmsData(sms); |
std::string command = _exeCommand; |
|
parameters = Util::str_replace(parameters,";"); |
|
16 |
|
|
17 |
std::string command = _exeCommand + " " + parameters; |
if (_allowParameters) |
18 |
|
{ |
19 |
|
std::string parameters = GetSmsData(sms); |
20 |
|
|
21 |
|
parameters = Util::str_replace(parameters, "||"); |
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 |
|
|
27 |
|
command += " "; |
28 |
|
command += parameters; |
29 |
|
} |
30 |
int retval = ::system( command.c_str() ); |
int retval = ::system( command.c_str() ); |
31 |
|
|
32 |
std::string message; |
std::string message; |
35 |
else |
else |
36 |
message = "OK"; |
message = "OK"; |
37 |
|
|
38 |
modem.SendSms(sms.sender, message ); |
modem.SendSms(sms.sender, message, false ); |
39 |
} |
} |