13 |
#include "TaskManager.h" |
#include "TaskManager.h" |
14 |
#include "PluginManager.h" |
#include "PluginManager.h" |
15 |
#include "ConfigFile.h" |
#include "ConfigFile.h" |
16 |
|
#include "Util.h" |
17 |
|
#include "Logger.h" |
18 |
|
|
19 |
using namespace std; |
using namespace std; |
20 |
|
|
141 |
|
|
142 |
return out.str(); |
return out.str(); |
143 |
} |
} |
144 |
|
|
145 |
|
void Common::LoadWorker(std::set<std::string>& set, std::string config) |
146 |
|
{ |
147 |
|
set.clear(); |
148 |
|
|
149 |
|
std::vector<std::string> items = Util::str_split( |
150 |
|
_configFile->GetValue("smsdaemon",config,""), |
151 |
|
","); |
152 |
|
|
153 |
|
std::ostringstream log; |
154 |
|
log << "Loaded list '" << config << "': "; |
155 |
|
for (unsigned i=0; i<items.size(); i++) |
156 |
|
{ |
157 |
|
set.insert( Util::str_trim(items[i]) ); |
158 |
|
log << items[i] << " "; |
159 |
|
} |
160 |
|
Logger::logMessage(log.str()); |
161 |
|
} |
162 |
|
|
163 |
|
void Common::LoadLists() |
164 |
|
{ |
165 |
|
LoadWorker(_blacklist, "blacklist"); |
166 |
|
LoadWorker(_privileged, "privileged"); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
bool Common::IsBlacklisted(const std::string& phone) |
171 |
|
{ |
172 |
|
std::set<std::string>::iterator it = _blacklist.find(phone); |
173 |
|
return ( it != _blacklist.end() ); |
174 |
|
} |
175 |
|
|
176 |
|
bool Common::IsPrivileged(const std::string& phone) |
177 |
|
{ |
178 |
|
std::set<std::string>::iterator it = _privileged.find(phone); |
179 |
|
return ( it != _privileged.end() ); |
180 |
|
} |