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

Annotation of /smsdaemon/plugins/ShellExecPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20