/[projects]/smsdaemon/ProxyTransceiver.cpp
ViewVC logotype

Annotation of /smsdaemon/ProxyTransceiver.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 216 - (hide annotations) (download)
Tue Dec 23 12:09:08 2008 UTC (15 years, 4 months ago) by torben
File size: 1373 byte(s)
Added config option of privileged and blacklisted phone numbers, and applied the blacklist to
Proxy Transceiver.

Am still missing the equivalent for incomming messages (ProxyPlugin)

1 torben 211 #include "ProxyTransceiver.h"
2     #include "ConfigFile.h"
3     #include "Common.h"
4     #include "Logger.h"
5    
6     ProxyTransceiver::ProxyTransceiver(ISmsTransceiver& realtransceiver)
7     : _transceiver(realtransceiver), _hasCC(false)
8     {
9     Common* cmn = Common::instance();
10 torben 212 _countrycode = cmn->GetConfigfile()->GetValue("smsdaemon","countrycode","").StringValue();
11 torben 211 if (_countrycode != "")
12     {
13     try
14     {
15     if (ConfigHelper::StringToInt(_countrycode) != 0)
16     {
17     _hasCC = true;
18     }
19     }
20 torben 212 catch (...)
21 torben 211 {
22     Logger::logMessage( "Invalid country code:" + _countrycode);
23 torben 212 }
24 torben 211 }
25 torben 212 if (_hasCC)
26     Logger::logMessage( "Enforcing country code: " + _countrycode);
27     else
28     Logger::logMessage( "No countrycode enforced");
29 torben 211 }
30    
31    
32     void ProxyTransceiver::SendSms(std::string to, std::string message, bool allowMultipart)
33     {
34     unsigned maxLength = allowMultipart ? 900 : 160;
35    
36     if (message.size() > maxLength)
37     message = message.substr(0,maxLength);
38    
39     if (to.at(0) == '+') //no leading + signs
40     to.erase(0);
41    
42     if (_hasCC)
43     {
44     if (to.substr(0,_countrycode.size()) != _countrycode)
45     to.insert(0, _countrycode);
46     }
47 torben 216
48     if ( Common::instance()->IsBlacklisted(to))
49     {
50     Logger::logMessage( "Will not send message to blacklisted phone: " + to);
51     return;
52     }
53 torben 211
54     _transceiver.SendSms(to,message,allowMultipart);
55     }
56    
57     std::vector<SMS> ProxyTransceiver::ReadSms(bool readAll)
58     {
59     return _transceiver.ReadSms(readAll);
60     }

  ViewVC Help
Powered by ViewVC 1.1.20