30
30
* as that of the covered work.
33
34
#include "config.h"
35
37
#include "configurationmanager.h"
38
39
#include "../manager.h"
39
40
#include "sip/sipvoiplink.h"
41
#include "sip/siptransport.h"
40
42
#include "account.h"
41
44
#include "sip/sipaccount.h"
43
46
const char* ConfigurationManager::SERVER_PATH =
50
53
std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails()
52
55
std::map<std::string, std::string> ip2ipAccountDetails;
53
SIPAccount *sipaccount = static_cast<SIPAccount *>(Manager::instance().getAccount(IP2IP_PROFILE));
56
SIPAccount *sipaccount = Manager::instance().getIP2IPAccount();
56
ERROR("ConfigurationManager: could not find account");
59
ERROR("Could not find IP2IP account");
57
60
return ip2ipAccountDetails;
59
62
return sipaccount->getIp2IpDetails();
61
std::map<std::string, std::string> tlsSettings = getTlsSettings();
64
std::map<std::string, std::string> tlsSettings(getTlsSettings());
62
65
std::copy(tlsSettings.begin(), tlsSettings.end(),
63
66
std::inserter(ip2ipAccountDetails, ip2ipAccountDetails.end()));
79
82
portstr << DEFAULT_SIP_TLS_PORT;
81
84
std::map<std::string, std::string> tlsSettingsDefault;
82
tlsSettingsDefault[TLS_LISTENER_PORT] = portstr.str();
83
tlsSettingsDefault[TLS_CA_LIST_FILE] = "";
84
tlsSettingsDefault[TLS_CERTIFICATE_FILE] = "";
85
tlsSettingsDefault[TLS_PRIVATE_KEY_FILE] = "";
86
tlsSettingsDefault[TLS_PASSWORD] = "";
87
tlsSettingsDefault[TLS_METHOD] = "TLSv1";
88
tlsSettingsDefault[TLS_CIPHERS] = "";
89
tlsSettingsDefault[TLS_SERVER_NAME] = "";
90
tlsSettingsDefault[TLS_VERIFY_SERVER] = "true";
91
tlsSettingsDefault[TLS_VERIFY_CLIENT] = "true";
92
tlsSettingsDefault[TLS_REQUIRE_CLIENT_CERTIFICATE] = "true";
93
tlsSettingsDefault[TLS_NEGOTIATION_TIMEOUT_SEC] = "2";
94
tlsSettingsDefault[TLS_NEGOTIATION_TIMEOUT_MSEC] = "0";
85
tlsSettingsDefault[CONFIG_TLS_LISTENER_PORT] = portstr.str();
86
tlsSettingsDefault[CONFIG_TLS_CA_LIST_FILE] = "";
87
tlsSettingsDefault[CONFIG_TLS_CERTIFICATE_FILE] = "";
88
tlsSettingsDefault[CONFIG_TLS_PRIVATE_KEY_FILE] = "";
89
tlsSettingsDefault[CONFIG_TLS_PASSWORD] = "";
90
tlsSettingsDefault[CONFIG_TLS_METHOD] = "TLSv1";
91
tlsSettingsDefault[CONFIG_TLS_CIPHERS] = "";
92
tlsSettingsDefault[CONFIG_TLS_SERVER_NAME] = "";
93
tlsSettingsDefault[CONFIG_TLS_VERIFY_SERVER] = "true";
94
tlsSettingsDefault[CONFIG_TLS_VERIFY_CLIENT] = "true";
95
tlsSettingsDefault[CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE] = "true";
96
tlsSettingsDefault[CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC] = "2";
97
tlsSettingsDefault[CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC] = "0";
96
99
return tlsSettingsDefault;
111
114
void ConfigurationManager::setTlsSettings(const std::map<std::string, std::string>& details)
113
SIPAccount * sipaccount = (SIPAccount *) Manager::instance().getAccount(IP2IP_PROFILE);
116
SIPAccount * sipaccount = Manager::instance().getIP2IPAccount();
115
118
if (!sipaccount) {
116
DEBUG("ConfigurationManager: Error: No valid account in set TLS settings");
119
DEBUG("No valid account in set TLS settings");
262
265
std::string ConfigurationManager::getCurrentAudioOutputPlugin()
264
DEBUG("ConfigurationManager: Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
267
DEBUG("Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
266
269
return Manager::instance().getCurrentAudioOutputPlugin();
390
393
std::map<std::string, std::string> ConfigurationManager::getHookSettings()
392
return Manager::instance().getHookSettings();
395
return Manager::instance().hookPreference.toMap();
395
398
void ConfigurationManager::setHookSettings(const std::map<std::string,
396
399
std::string>& settings)
398
Manager::instance().setHookSettings(settings);
401
Manager::instance().hookPreference = HookPreference(settings);
401
404
void ConfigurationManager::setAccountsOrder(const std::string& order)
412
415
ConfigurationManager::getAddrFromInterfaceName(const std::string& interface)
414
return SIPVoIPLink::getInterfaceAddrFromName(interface);
417
return SipTransport::getInterfaceAddrFromName(interface);
417
420
std::vector<std::string> ConfigurationManager::getAllIpInterface()
419
return SIPVoIPLink::getAllIpInterface();
422
return SipTransport::getAllIpInterface();
422
425
std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName()
424
return SIPVoIPLink::getAllIpInterfaceByName();
427
return SipTransport::getAllIpInterfaceByName();
427
430
std::map<std::string, std::string> ConfigurationManager::getShortcuts()
439
442
std::vector<std::map<std::string, std::string> > ConfigurationManager::getCredentials(
440
443
const std::string& accountID)
442
Account *account = Manager::instance().getAccount(accountID);
445
SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
443
446
std::vector<std::map<std::string, std::string> > credentialInformation;
445
if (!account or account->getType() != "SIP")
446
449
return credentialInformation;
448
SIPAccount *sipaccount = static_cast<SIPAccount *>(account);
449
return sipaccount->getCredentials();
451
return account->getCredentials();
452
454
void ConfigurationManager::setCredentials(const std::string& accountID,
453
455
const std::vector<std::map<std::string, std::string> >& details)
455
Account *account = Manager::instance().getAccount(accountID);
457
if (account and account->getType() == "SIP") {
458
SIPAccount *sipaccount = static_cast<SIPAccount*>(account);
459
sipaccount->setCredentials(details);
457
SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
459
account->setCredentials(details);