/[projects]/smsdaemon/plugins/ShellExecPlugin.cpp
ViewVC logotype

Contents of /smsdaemon/plugins/ShellExecPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90 - (show annotations) (download)
Mon Jun 16 10:21:02 2008 UTC (15 years, 11 months ago) by torben
File size: 990 byte(s)
Move IGsmModem to its own header file.

1 #include "ShellExecPlugin.h"
2 #include "IGsmModem.h"
3 #include "Sms.h"
4
5 #include "util.h"
6
7 ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters)
8 : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ),
9 _exeCommand(exeCommand),
10 _allowParameters(allowParameters)
11 {
12 }
13
14 void ShellExecPlugin::Execute(IGsmModem& modem, SMS& sms)
15 {
16 std::string command = _exeCommand;
17
18 if (_allowParameters)
19 {
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;
34 if (retval == -1)
35 message = "Error";
36 else
37 message = "OK";
38
39 modem.SendSms(sms.sender, message, false );
40 }

  ViewVC Help
Powered by ViewVC 1.1.20