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

Contents of /smsdaemon/ProxyTransceiver.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 217 - (show annotations) (download)
Tue Dec 23 14:20:43 2008 UTC (15 years, 4 months ago) by torben
File size: 1395 byte(s)
Solved ToDo item:
'- Create a filtering method:
-  Incoming: which phonenumbers are allowed to invoke which plugins
-  Incoming could be solved with a PluginProxy() which intercepts the ExecutePlugin calls (only 
PluginManager needs to know about this one)'

Move the Access related items to AccessManager.*


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

  ViewVC Help
Powered by ViewVC 1.1.20