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

Annotation of /smsdaemon/plugins/SpamPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (hide annotations) (download)
Thu Jun 12 12:43:29 2008 UTC (15 years, 11 months ago) by torben
File size: 1023 byte(s)
Make GsmModem use the pdu way.

Added allowMultipart parameter to IGsmModem::SendSms()



1 torben 28 #include "SpamPlugin.h"
2     #include "GsmModem.h"
3    
4     #include "util.h"
5     #include "common.h"
6     #include <sstream>
7    
8    
9     using namespace std;
10    
11    
12     SpamPlugin::SpamPlugin()
13     : Plugin("spam", "Sends a number of messages to a given phone nr")
14     {
15     }
16    
17     const string USAGE = "Usage: spam <recipient> <nr> message";
18    
19 torben 44 void SpamPlugin::Execute(IGsmModem& modem, SMS& sms)
20 torben 28 {
21     string cmd = GetSmsData(sms);
22    
23    
24     if (cmd == "")
25     {
26 torben 63 modem.SendSms(sms.sender, USAGE, false);
27 torben 28 return;
28     }
29    
30     vector<string> parts = Util::str_split(cmd," ");
31    
32    
33     if (parts.size() < 2 )
34     {
35 torben 63 modem.SendSms(sms.sender, USAGE, false);
36 torben 28 return;
37     }
38    
39     string nr = parts[0];
40     unsigned int count = atoi(parts[1].c_str());
41     if (count > 25)
42     count = 25;
43    
44     ostringstream os;
45     os << "Spamming " << nr << " " << count << " times.";
46     Common::instance()->logMessage(os.str());
47    
48     string message;
49     for (unsigned i=2; i<parts.size(); ++i)
50     {
51     if (message.length() > 0)
52     message += " ";
53     message += parts[i];
54     }
55    
56     for (unsigned i=0; i<count; ++i)
57     {
58 torben 63 modem.SendSms(nr,message, false);
59 torben 28 }
60     }

  ViewVC Help
Powered by ViewVC 1.1.20