~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to daemon/src/dbus/configurationmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-19 21:46:37 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120519214637-la8rbrford5kj6m3
Tags: 1.1.0-1
* New upstream release 
  - Fixes "FTBFS with libccrtp-dev/2.0.2 from experimental" (Closes: #663282)
* NEW Maintainer: Debian VoIP Team - Thanks Francois for your work.
  - (Closes: #665789: O: sflphone -- SIP and IAX2 compatible VoIP phone)
* Added Build-Depends: libdbus-c++-bin
* Add gcc47-fixes.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 *  as that of the covered work.
31
31
 */
32
32
 
 
33
#ifdef HAVE_CONFIG_H
33
34
#include "config.h"
 
35
#endif
34
36
 
35
37
#include "configurationmanager.h"
36
38
#include <sstream>
37
 
#include "config.h"
38
39
#include "../manager.h"
39
40
#include "sip/sipvoiplink.h"
 
41
#include "sip/siptransport.h"
40
42
#include "account.h"
 
43
#include "logger.h"
41
44
#include "sip/sipaccount.h"
42
45
 
43
46
const char* ConfigurationManager::SERVER_PATH =
50
53
std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails()
51
54
{
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();
54
57
 
55
58
    if (!sipaccount) {
56
 
        ERROR("ConfigurationManager: could not find account");
 
59
        ERROR("Could not find IP2IP account");
57
60
        return ip2ipAccountDetails;
58
61
    } else
59
62
        return sipaccount->getIp2IpDetails();
60
63
 
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()));
64
67
 
79
82
    portstr << DEFAULT_SIP_TLS_PORT;
80
83
 
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";
95
98
 
96
99
    return tlsSettingsDefault;
97
100
}
100
103
{
101
104
    std::map<std::string, std::string> tlsSettings;
102
105
 
103
 
    SIPAccount *sipaccount = (SIPAccount *) Manager::instance().getAccount(IP2IP_PROFILE);
 
106
    SIPAccount *sipaccount = Manager::instance().getIP2IPAccount();
104
107
 
105
108
    if (!sipaccount)
106
109
        return tlsSettings;
110
113
 
111
114
void ConfigurationManager::setTlsSettings(const std::map<std::string, std::string>& details)
112
115
{
113
 
    SIPAccount * sipaccount = (SIPAccount *) Manager::instance().getAccount(IP2IP_PROFILE);
 
116
    SIPAccount * sipaccount = Manager::instance().getIP2IPAccount();
114
117
 
115
118
    if (!sipaccount) {
116
 
        DEBUG("ConfigurationManager: Error: No valid account in set TLS settings");
 
119
        DEBUG("No valid account in set TLS settings");
117
120
        return;
118
121
    }
119
122
 
261
264
 
262
265
std::string ConfigurationManager::getCurrentAudioOutputPlugin()
263
266
{
264
 
    DEBUG("ConfigurationManager: Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
 
267
    DEBUG("Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
265
268
 
266
269
    return Manager::instance().getCurrentAudioOutputPlugin();
267
270
}
389
392
 
390
393
std::map<std::string, std::string> ConfigurationManager::getHookSettings()
391
394
{
392
 
    return Manager::instance().getHookSettings();
 
395
    return Manager::instance().hookPreference.toMap();
393
396
}
394
397
 
395
398
void ConfigurationManager::setHookSettings(const std::map<std::string,
396
399
        std::string>& settings)
397
400
{
398
 
    Manager::instance().setHookSettings(settings);
 
401
    Manager::instance().hookPreference = HookPreference(settings);
399
402
}
400
403
 
401
404
void ConfigurationManager::setAccountsOrder(const std::string& order)
411
414
std::string
412
415
ConfigurationManager::getAddrFromInterfaceName(const std::string& interface)
413
416
{
414
 
    return SIPVoIPLink::getInterfaceAddrFromName(interface);
 
417
    return SipTransport::getInterfaceAddrFromName(interface);
415
418
}
416
419
 
417
420
std::vector<std::string> ConfigurationManager::getAllIpInterface()
418
421
{
419
 
    return SIPVoIPLink::getAllIpInterface();
 
422
    return SipTransport::getAllIpInterface();
420
423
}
421
424
 
422
425
std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName()
423
426
{
424
 
    return SIPVoIPLink::getAllIpInterfaceByName();
 
427
    return SipTransport::getAllIpInterfaceByName();
425
428
}
426
429
 
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)
441
444
{
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;
444
447
 
445
 
    if (!account or account->getType() != "SIP")
 
448
    if (!account)
446
449
        return credentialInformation;
447
 
 
448
 
    SIPAccount *sipaccount = static_cast<SIPAccount *>(account);
449
 
    return sipaccount->getCredentials();
 
450
    else
 
451
        return account->getCredentials();
450
452
}
451
453
 
452
454
void ConfigurationManager::setCredentials(const std::string& accountID,
453
455
        const std::vector<std::map<std::string, std::string> >& details)
454
456
{
455
 
    Account *account = Manager::instance().getAccount(accountID);
456
 
 
457
 
    if (account and account->getType() == "SIP") {
458
 
        SIPAccount *sipaccount = static_cast<SIPAccount*>(account);
459
 
        sipaccount->setCredentials(details);
460
 
    }
 
457
    SIPAccount *account = dynamic_cast<SIPAccount*>(Manager::instance().getAccount(accountID));
 
458
    if (account)
 
459
        account->setCredentials(details);
461
460
}