configurationmanager.cpp 24.1 KB
Newer Older
1
/*
2
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
3
 *  Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
4
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
5
 *  Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com>
6
 *
7 8
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 3 of the License, or
10
 *  (at your option) any later version.
11
 *
12 13 14 15
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
16
 *
17 18 19
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 22 23 24 25 26 27 28 29 30
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
31
 */
32

33 34
#include <global.h>
#include <configurationmanager.h>
35
#include <sstream>
36
#include "../manager.h"
37
#include "sip/sipvoiplink.h"
38
#include "sip/sipaccount.h"
39

40 41 42 43 44 45 46 47
const char* ConfigurationManager::SERVER_PATH =
		"/org/sflphone/SFLphone/ConfigurationManager";

ConfigurationManager::ConfigurationManager(DBus::Connection& connection) :
	DBus::ObjectAdaptor(connection, SERVER_PATH) {
	shortcutsKeys.push_back("pick_up");
	shortcutsKeys.push_back("hang_up");
	shortcutsKeys.push_back("popup_window");
48 49
	shortcutsKeys.push_back("toggle_pick_up_hang_up");
	shortcutsKeys.push_back("toggle_hold");
50 51 52 53
}

std::map<std::string, std::string> ConfigurationManager::getAccountDetails(
		const std::string& accountID) {
54 55 56

  _debug("ConfigurationManager: get account details %s", accountID.c_str());
    return Manager::instance().getAccountDetails(accountID);
57 58 59 60 61 62
}

std::map<std::string, std::string> ConfigurationManager::getTlsSettingsDefault(
		void) {

	std::map<std::string, std::string> tlsSettingsDefault;
63

64
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
65
                        TLS_LISTENER_PORT, DEFAULT_SIP_TLS_PORT));
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_CA_LIST_FILE, ""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_CERTIFICATE_FILE, ""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_PRIVATE_KEY_FILE, ""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(TLS_PASSWORD,
			""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(TLS_METHOD,
			"TLSv1"));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(TLS_CIPHERS,
			""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_SERVER_NAME, ""));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_VERIFY_SERVER, "true"));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_VERIFY_CLIENT, "true"));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_REQUIRE_CLIENT_CERTIFICATE, "true"));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_NEGOTIATION_TIMEOUT_SEC, "2"));
	tlsSettingsDefault.insert(std::pair<std::string, std::string>(
			TLS_NEGOTIATION_TIMEOUT_MSEC, "0"));

	return tlsSettingsDefault;
}

std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails(void) {

	std::map<std::string, std::string> ip2ipAccountDetails;

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
	SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(IP2IP_PROFILE);

	if(!sipaccount) {
	  _error("ConfigurationManager: could not find account");
	  return ip2ipAccountDetails;
	}

	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(ACCOUNT_ID, IP2IP_PROFILE));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(SRTP_KEY_EXCHANGE, sipaccount->getSrtpKeyExchange())); 
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(SRTP_ENABLE, sipaccount->getSrtpEnable() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(SRTP_RTP_FALLBACK, sipaccount->getSrtpFallback() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(ZRTP_DISPLAY_SAS, sipaccount->getZrtpDisplaySas() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(ZRTP_HELLO_HASH, sipaccount->getZrtpHelloHash() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(ZRTP_NOT_SUPP_WARNING, sipaccount->getZrtpNotSuppWarning() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(ZRTP_DISPLAY_SAS_ONCE, sipaccount->getZrtpDiaplaySasOnce() ? "true" : "false"));
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(LOCAL_INTERFACE, sipaccount->getLocalInterface()));
	std::stringstream portstr; portstr << sipaccount->getLocalPort();
	ip2ipAccountDetails.insert(std::pair<std::string, std::string>(LOCAL_PORT, portstr.str()));
116 117

	std::map<std::string, std::string> tlsSettings;
Julien Bonjean's avatar
Julien Bonjean committed
118
	tlsSettings = getTlsSettings();
119 120 121 122 123 124 125 126 127 128 129 130
	std::copy(tlsSettings.begin(), tlsSettings.end(), std::inserter(
			ip2ipAccountDetails, ip2ipAccountDetails.end()));

	return ip2ipAccountDetails;

}

void ConfigurationManager::setIp2IpDetails(const std::map<std::string,
		std::string>& details) {
	std::map<std::string, std::string> map_cpy = details;
	std::map<std::string, std::string>::iterator it;

131
	SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(IP2IP_PROFILE);
132

133 134
	if(!sipaccount) {
	  _error("ConfigurationManager: could not find account");
135
	}
136
	  
137

138 139
	it = map_cpy.find(LOCAL_INTERFACE);
	if (it != details.end()) sipaccount->setLocalInterface(it->second);
140

141 142
	it = map_cpy.find(LOCAL_PORT);
	if (it != details.end()) sipaccount->setLocalPort(atoi(it->second.data()));
143

144
	it = map_cpy.find(SRTP_ENABLE);
145
	if (it != details.end()) sipaccount->setSrtpEnable((it->second == "true"));
146

147
	it = map_cpy.find(SRTP_RTP_FALLBACK);
148
	if (it != details.end()) sipaccount->setSrtpFallback((it->second == "true"));
149

150
	it = map_cpy.find(SRTP_KEY_EXCHANGE);
151
	if (it != details.end()) sipaccount->setSrtpKeyExchange(it->second);
152

153
	it = map_cpy.find(ZRTP_DISPLAY_SAS);
154
	if (it != details.end()) sipaccount->setZrtpDisplaySas((it->second == "true"));
155

156
	it = map_cpy.find(ZRTP_NOT_SUPP_WARNING);
157
	if (it != details.end()) sipaccount->setZrtpNotSuppWarning((it->second == "true"));
158

159
	it = map_cpy.find(ZRTP_HELLO_HASH);
160
	if (it != details.end()) sipaccount->setZrtpHelloHash((it->second == "true"));
161

162
	it = map_cpy.find(ZRTP_DISPLAY_SAS_ONCE);
163
	if (it != details.end()) sipaccount->setZrtpDiaplaySasOnce((it->second == "true"));
164

Julien Bonjean's avatar
Julien Bonjean committed
165
	setTlsSettings(details);
166 167 168 169 170 171 172 173 174 175 176

	Manager::instance().saveConfig();

	// Update account details to the client side
	accountsChanged();

	// Reload account settings from config
	Manager::instance().getAccount(IP2IP_PROFILE)->loadConfig();

}

Julien Bonjean's avatar
Julien Bonjean committed
177
std::map<std::string, std::string> ConfigurationManager::getTlsSettings() {
178

179 180
	std::map<std::string, std::string> tlsSettings;

181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
	SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(IP2IP_PROFILE); 

	if(!sipaccount)
	  return tlsSettings;

	std::stringstream portstr; portstr << sipaccount->getTlsListenerPort();
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_LISTENER_PORT, portstr.str()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_ENABLE, sipaccount->getTlsEnable()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_CA_LIST_FILE, sipaccount->getTlsCaListFile()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_CERTIFICATE_FILE, sipaccount->getTlsCertificateFile()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_PRIVATE_KEY_FILE, sipaccount->getTlsPrivateKeyFile()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_PASSWORD, sipaccount->getTlsPassword()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_METHOD, sipaccount->getTlsMethod()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_CIPHERS, sipaccount->getTlsCiphers()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_SERVER_NAME, sipaccount->getTlsServerName()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_VERIFY_SERVER, sipaccount->getTlsVerifyServer() ? "true" : "false"));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_VERIFY_CLIENT, sipaccount->getTlsVerifyClient() ? "true" : "false"));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_REQUIRE_CLIENT_CERTIFICATE, sipaccount->getTlsRequireClientCertificate() ? "true" : "false"));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_NEGOTIATION_TIMEOUT_SEC, sipaccount->getTlsNegotiationTimeoutSec()));
	tlsSettings.insert(std::pair<std::string, std::string>(TLS_NEGOTIATION_TIMEOUT_MSEC, sipaccount->getTlsNegotiationTimeoutMsec()));

202 203 204
	return tlsSettings;
}

Julien Bonjean's avatar
Julien Bonjean committed
205
void ConfigurationManager::setTlsSettings(const std::map<std::string, std::string>& details) {
206

207 208 209
	std::map<std::string, std::string> map_cpy = details;
	std::map<std::string, std::string>::iterator it;

210 211 212 213 214
	SIPAccount * sipaccount = (SIPAccount *)Manager::instance().getAccount(IP2IP_PROFILE);

	if(!sipaccount) {
	  _debug("ConfigurationManager: Error: No valid account in set TLS settings");
	  return;
215
	}
216

217 218
	it = map_cpy.find(TLS_LISTENER_PORT);
	if (it != details.end()) sipaccount->setTlsListenerPort(atoi(it->second.data()));
219

220 221
	it = map_cpy.find(TLS_ENABLE);
	if (it != details.end()) sipaccount->setTlsEnable(it->second);
222

223
	it = map_cpy.find(TLS_CA_LIST_FILE);
224
	if (it != map_cpy.end()) sipaccount->setTlsCaListFile(it->second);
225

226
	it = map_cpy.find(TLS_CERTIFICATE_FILE);
227
	if (it != map_cpy.end()) sipaccount->setTlsCertificateFile(it->second);
228

229
	it = map_cpy.find(TLS_PRIVATE_KEY_FILE);
230
	if (it != map_cpy.end()) sipaccount->setTlsPrivateKeyFile(it->second);
231

232
	it = map_cpy.find(TLS_PASSWORD);
233
	if (it != map_cpy.end()) sipaccount->setTlsPassword(it->second);
234

235
	it = map_cpy.find(TLS_METHOD);
236
	if (it != map_cpy.end()) sipaccount->setTlsMethod(it->second);
237

238
	it = map_cpy.find(TLS_CIPHERS);
239
	if (it != map_cpy.end()) sipaccount->setTlsCiphers(it->second);
240

241
	it = map_cpy.find(TLS_SERVER_NAME);
242
	if (it != map_cpy.end()) sipaccount->setTlsServerName(it->second);
243

244
	it = map_cpy.find(TLS_VERIFY_CLIENT);
245
	if (it != map_cpy.end()) sipaccount->setTlsVerifyClient((it->second == "true") ? true : false);
246

247
	it = map_cpy.find(TLS_REQUIRE_CLIENT_CERTIFICATE);
248
	if (it != map_cpy.end()) sipaccount->setTlsRequireClientCertificate((it->second == "true") ? true : false);
249

250
	it = map_cpy.find(TLS_NEGOTIATION_TIMEOUT_SEC);
251
	if (it != map_cpy.end()) sipaccount->setTlsNegotiationTimeoutSec(it->second);
252

253
	it = map_cpy.find(TLS_NEGOTIATION_TIMEOUT_MSEC);
254
	if (it != map_cpy.end()) sipaccount->setTlsNegotiationTimeoutMsec(it->second);
255

256
	Manager::instance().saveConfig();
257

258 259
	// Update account details to the client side
	accountsChanged();
260

261 262
}

263 264
std::map<std::string, std::string> ConfigurationManager::getCredential(
		const std::string& accountID, const int32_t& index) {
265

266
        Account *account = Manager::instance().getAccount(accountID);
267

268
	std::map<std::string, std::string> credentialInformation;
269

270 271
	if(account->getType() != "SIP")
	  return credentialInformation;
272

273 274
	SIPAccount *sipaccount = (SIPAccount *)account;
 
275

276
	if(index == 0) {
277 278 279 280 281 282 283
	std::string username = sipaccount->getUsername();
	std::string password = sipaccount->getPassword();
        std::string realm = sipaccount->getRealm();

	credentialInformation.insert(std::pair<std::string, std::string>(USERNAME, username));
	credentialInformation.insert(std::pair<std::string, std::string>(PASSWORD, password));
	credentialInformation.insert(std::pair<std::string, std::string>(REALM, realm));
284 285 286 287 288 289 290 291 292 293 294 295
	}
	else {

	  // TODO: implement for extra credentials
	  std::string username = sipaccount->getUsername();
	  std::string password = sipaccount->getPassword();
	  std::string realm = sipaccount->getRealm();

	  credentialInformation.insert(std::pair<std::string, std::string>(USERNAME, username));
	  credentialInformation.insert(std::pair<std::string, std::string>(PASSWORD, password));
	  credentialInformation.insert(std::pair<std::string, std::string>(REALM, realm));
	}
296

297
	return credentialInformation;
298 299
}

300 301
int32_t ConfigurationManager::getNumberOfCredential(
		const std::string& accountID) {
302 303 304

  SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(accountID);
  return sipaccount->getCredentialCount();
305 306
}

307 308 309
void ConfigurationManager::setCredential(const std::string& accountID,
		const int32_t& index, const std::map<std::string, std::string>& details) {
	Manager::instance().setCredential(accountID, index, details);
310 311
}

312 313
void ConfigurationManager::deleteAllCredential(const std::string& accountID) {
	Manager::instance().deleteAllCredential(accountID);
314 315
}

316 317 318
void ConfigurationManager::setAccountDetails(const std::string& accountID,
		const std::map<std::string, std::string>& details) {
	Manager::instance().setAccountDetails(accountID, details);
319 320
}

321 322 323
void ConfigurationManager::sendRegister(const std::string& accountID,
		const int32_t& expire) {
	Manager::instance().sendRegister(accountID, expire);
324 325
}

326 327 328
std::string ConfigurationManager::addAccount(const std::map<std::string,
		std::string>& details) {
	return Manager::instance().addAccount(details);
329 330
}

331 332
void ConfigurationManager::removeAccount(const std::string& accoundID) {
	return Manager::instance().removeAccount(accoundID);
333 334
}

335 336
std::vector<std::string> ConfigurationManager::getAccountList() {
	return Manager::instance().getAccountList();
337 338
}

339
//TODO
340 341 342
std::vector<std::string> ConfigurationManager::getToneLocaleList() {
	std::vector<std::string> ret;
	return ret;
343 344
}

345
//TODO
346 347 348
std::string ConfigurationManager::getVersion() {
	std::string ret("");
	return ret;
349 350
}

351
//TODO
352 353 354
std::vector<std::string> ConfigurationManager::getRingtoneList() {
	std::vector<std::string> ret;
	return ret;
355 356
}

357 358
/**
 * Send the list of all codecs loaded to the client through DBus.
359
 * Can stay global, as only the active codecs will be set per accounts
360
 */
361
std::vector<std::string> ConfigurationManager::getCodecList(void) {
362

363
	std::vector<std::string> list;
364

365
	CodecsMap codecs = Manager::instance().getCodecDescriptorMap().getCodecsMap();
366
	CodecsMap::iterator iter = codecs.begin();
367

368 369
	while (iter != codecs.end()) {
		std::stringstream ss;
370

371 372 373 374
		if (iter->second != NULL) {
			ss << iter->first;
			list.push_back((ss.str()).data());
		}
375

376 377
		iter++;
	}
378

379
	return list;
380 381
}

382 383 384 385 386 387 388 389
std::vector<std::string> ConfigurationManager::getSupportedTlsMethod(void) {
	std::vector<std::string> method;
	method.push_back("Default");
	method.push_back("TLSv1");
	method.push_back("SSLv2");
	method.push_back("SSLv3");
	method.push_back("SSLv23");
	return method;
390 391
}

392 393
std::vector<std::string> ConfigurationManager::getCodecDetails(
		const int32_t& payload) {
394

395 396
	return Manager::instance().getCodecDescriptorMap().getCodecSpecifications(
			payload);
397 398
}

399 400
std::vector<std::string> ConfigurationManager::getActiveCodecList(
		const std::string& accountID) {
401

402
	_debug("Send active codec list for account %s", accountID.c_str ());
403

404
	std::vector<std::string> v;
405 406
	Account *acc;
	CodecOrder active;
407
	unsigned int i = 0;
408 409
	size_t size;

410
	acc = Manager::instance().getAccount(accountID);
411
	if (acc != NULL) {
412
		active = acc->getActiveCodecs();
413
		size = active.size();
414
		while (i < size) {
415 416
			std::stringstream ss;
			ss << active[i];
417
			v.push_back((ss.str()).data());
418 419 420 421
			i++;
		}
	}

422
	return v;
423

424
}
425

426 427
void ConfigurationManager::setActiveCodecList(
		const std::vector<std::string>& list, const std::string& accountID) {
428

Alexandre Savard's avatar
Alexandre Savard committed
429
	_debug ("ConfigurationManager: Active codec list received");
430 431 432 433

	Account *acc;

	// Save the codecs list per account
434
	acc = Manager::instance().getAccount(accountID);
435
	if (acc != NULL) {
436
		acc->setActiveCodecs(list);
437
	}
438 439
}

Alexandre Savard's avatar
Alexandre Savard committed
440

441
std::vector<std::string> ConfigurationManager::getAudioPluginList() {
442

443
	std::vector<std::string> v;
444

445
	v.push_back(PCM_DEFAULT);
446 447
	// v.push_back(PCM_DMIX);
	v.push_back(PCM_DMIX_DSNOOP);
448

449
	return v;
450
}
451

Alexandre Savard's avatar
Alexandre Savard committed
452

453 454
void ConfigurationManager::setInputAudioPlugin(const std::string& audioPlugin) {
	return Manager::instance().setInputAudioPlugin(audioPlugin);
455 456
}

457 458
void ConfigurationManager::setOutputAudioPlugin(const std::string& audioPlugin) {
	return Manager::instance().setOutputAudioPlugin(audioPlugin);
459 460
}

461 462
std::vector<std::string> ConfigurationManager::getAudioOutputDeviceList() {
	return Manager::instance().getAudioOutputDeviceList();
463
}
464

465 466
std::vector<std::string> ConfigurationManager::getAudioInputDeviceList() {
	return Manager::instance().getAudioInputDeviceList();
467
}
468

469 470 471 472
void ConfigurationManager::setAudioOutputDevice(const int32_t& index) {
        return Manager::instance().setAudioDevice(index, SFL_PCM_PLAYBACK);
}

473
void ConfigurationManager::setAudioInputDevice(const int32_t& index) {
474 475 476 477 478
        return Manager::instance().setAudioDevice(index, SFL_PCM_CAPTURE);
}

void ConfigurationManager::setAudioRingtoneDevice(const int32_t& index) {
        return Manager::instance().setAudioDevice(index, SFL_PCM_RINGTONE);
479
}
480

481 482
std::vector<std::string> ConfigurationManager::getCurrentAudioDevicesIndex() {
	return Manager::instance().getCurrentAudioDevicesIndex();
483
}
484

485 486
int32_t ConfigurationManager::getAudioDeviceIndex(const std::string& name) {
	return Manager::instance().getAudioDeviceIndex(name);
487 488
}

489 490
std::string ConfigurationManager::getCurrentAudioOutputPlugin(void) {
	return Manager::instance().getCurrentAudioOutputPlugin();
491 492
}

493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
std::string ConfigurationManager::getEchoCancelState(void) {
        return Manager::instance().getEchoCancelState();
}

void ConfigurationManager::setEchoCancelState(const std::string& state) {
        Manager::instance().setEchoCancelState(state);
}

std::string ConfigurationManager::getNoiseSuppressState(void) {
  return Manager::instance().getNoiseSuppressState();
}

void ConfigurationManager::setNoiseSuppressState(const std::string& state) {
  Manager::instance().setNoiseSuppressState(state);
}

509 510 511
std::vector<std::string> ConfigurationManager::getPlaybackDeviceList() {
	std::vector<std::string> ret;
	return ret;
512 513
}

514 515 516
std::vector<std::string> ConfigurationManager::getRecordDeviceList() {
	std::vector<std::string> ret;
	return ret;
517 518

}
519

520
bool ConfigurationManager::isMd5CredentialHashing(void) {
521
	return Manager::instance().preferences.getMd5Hash();
522 523
}

524
void ConfigurationManager::setMd5CredentialHashing(const bool& enabled) {
525
        Manager::instance().preferences.setMd5Hash(enabled);
526 527
}

528 529
int32_t ConfigurationManager::isIax2Enabled(void) {
	return Manager::instance().isIax2Enabled();
530
}
531

532 533
void ConfigurationManager::ringtoneEnabled(const std::string& accountID) {
	Manager::instance().ringtoneEnabled(accountID);
534 535
}

536 537
int32_t ConfigurationManager::isRingtoneEnabled(const std::string& accountID) {
        return Manager::instance().isRingtoneEnabled(accountID);
538
}
539

540 541
std::string ConfigurationManager::getRingtoneChoice(const std::string& accountID) {
       return Manager::instance().getRingtoneChoice(accountID);
542 543
}

544 545
void ConfigurationManager::setRingtoneChoice(const std::string& accountID, const std::string& tone) {
       Manager::instance().setRingtoneChoice(accountID, tone);
546 547
}

548 549
std::string ConfigurationManager::getRecordPath(void) {
	return Manager::instance().getRecordPath();
550 551
}

552 553
void ConfigurationManager::setRecordPath(const std::string& recPath) {
	Manager::instance().setRecordPath(recPath);
554 555
}

556
/*
557 558
int32_t ConfigurationManager::getDialpad(void) {
	return Manager::instance().getDialpad();
559 560
}

561 562
void ConfigurationManager::setDialpad(const bool& display) {
	Manager::instance().setDialpad(display);
563 564
}

565 566
int32_t ConfigurationManager::getSearchbar(void) {
	return Manager::instance().getSearchbar();
567 568
}

569 570
void ConfigurationManager::setSearchbar(void) {
	Manager::instance().setSearchbar();
571 572
}

573 574
int32_t ConfigurationManager::getVolumeControls(void) {
	return Manager::instance().getVolumeControls();
575 576
}

577 578
void ConfigurationManager::setVolumeControls(const bool& display) {
	Manager::instance().setVolumeControls(display);
579
}
580
*/
581

582 583
int32_t ConfigurationManager::getHistoryLimit(void) {
	return Manager::instance().getHistoryLimit();
584 585
}

586 587
void ConfigurationManager::setHistoryLimit(const int32_t& days) {
	Manager::instance().setHistoryLimit(days);
588 589
}

590
/*
591 592
void ConfigurationManager::setHistoryEnabled(void) {
	Manager::instance().setHistoryEnabled();
593
}
594

595 596
std::string ConfigurationManager::getHistoryEnabled(void) {
	return Manager::instance().getHistoryEnabled();
597 598
}

599 600
void ConfigurationManager::startHidden(void) {
	Manager::instance().startHidden();
601 602
}

603 604
int32_t ConfigurationManager::isStartHidden(void) {
	return Manager::instance().isStartHidden();
605 606
}

607 608
void ConfigurationManager::switchPopupMode(void) {
	Manager::instance().switchPopupMode();
609 610
}

611 612
int32_t ConfigurationManager::popupMode(void) {
	return Manager::instance().popupMode();
613 614
}

615 616
void ConfigurationManager::setNotify(void) {
	Manager::instance().setNotify();
617
}
618

619 620
int32_t ConfigurationManager::getNotify(void) {
	return Manager::instance().getNotify();
621
}
622
*/
623

624 625
void ConfigurationManager::setAudioManager(const int32_t& api) {
	Manager::instance().setAudioManager(api);
626 627
}

628 629
int32_t ConfigurationManager::getAudioManager(void) {
	return Manager::instance().getAudioManager();
630 631
}

632 633
void ConfigurationManager::setMailNotify(void) {
	Manager::instance().setMailNotify();
634 635
}

636 637
int32_t ConfigurationManager::getMailNotify(void) {
	return Manager::instance().getMailNotify();
638
}
639

640 641 642
std::map<std::string, int32_t> ConfigurationManager::getAddressbookSettings(
		void) {
	return Manager::instance().getAddressbookSettings();
643 644
}

645 646 647
void ConfigurationManager::setAddressbookSettings(const std::map<std::string,
		int32_t>& settings) {
	Manager::instance().setAddressbookSettings(settings);
648
}
649

650 651
std::vector<std::string> ConfigurationManager::getAddressbookList(void) {
	return Manager::instance().getAddressbookList();
652 653
}

654 655 656
void ConfigurationManager::setAddressbookList(
		const std::vector<std::string>& list) {
	Manager::instance().setAddressbookList(list);
657 658
}

659 660
std::map<std::string, std::string> ConfigurationManager::getHookSettings(void) {
	return Manager::instance().getHookSettings();
661 662
}

663 664 665
void ConfigurationManager::setHookSettings(const std::map<std::string,
		std::string>& settings) {
	Manager::instance().setHookSettings(settings);
666
}
667

668 669
void ConfigurationManager::setAccountsOrder(const std::string& order) {
	Manager::instance().setAccountsOrder(order);
670 671
}

672 673
std::map<std::string, std::string> ConfigurationManager::getHistory(void) {
	return Manager::instance().send_history_to_client();
674 675
}

676 677 678
void ConfigurationManager::setHistory(
		const std::map<std::string, std::string>& entries) {
	Manager::instance().receive_history_from_client(entries);
679
}
680

681 682
std::string ConfigurationManager::getAddrFromInterfaceName(
		const std::string& interface) {
683

684 685
	std::string address = SIPVoIPLink::instance("")->getInterfaceAddrFromName(
			interface);
686

687
	return address;
688 689
}

690
std::vector<std::string> ConfigurationManager::getAllIpInterface(void) {
691

692 693 694
	std::vector<std::string> vector;
	SIPVoIPLink * sipLink = NULL;
	sipLink = SIPVoIPLink::instance("");
695

696 697 698
	if (sipLink != NULL) {
		vector = sipLink->getAllIpInterface();
	}
699

700
	return vector;
701
}
702

703 704 705 706
std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName(void) {
	std::vector<std::string> vector;
	SIPVoIPLink * sipLink = NULL;
	sipLink = SIPVoIPLink::instance("");
707

708 709 710
	if (sipLink != NULL) {
		vector = sipLink->getAllIpInterfaceByName();
	}
711

712
	return vector;
713
}
714 715


716
std::map<std::string, std::string> ConfigurationManager::getShortcuts() {
717

718
	return Manager::instance().shortcutPreferences.getShortcuts();
719 720
}

721
void ConfigurationManager::setShortcuts(
722
		const std::map<std::string, std::string>& shortcutsMap) {
723

Alexandre Savard's avatar
Alexandre Savard committed
724 725
        std::map<std::string, std::string> map_cpy = shortcutsMap;
  /*
726 727
	std::map<std::string, std::string> map_cpy = shortcutsMap;
	std::map<std::string, std::string>::iterator it;
728

Alexandre Savard's avatar
Alexandre Savard committed
729
	for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
730 731 732
		std::string key = shortcutsKeys.at(i);
		it = map_cpy.find(key);
		if (it != shortcutsMap.end()) {
Alexandre Savard's avatar
Alexandre Savard committed
733
		         
734 735 736
			Manager::instance().setConfig("Shortcuts", key, it->second);
		}
	}
Alexandre Savard's avatar
Alexandre Savard committed
737 738
  */
        Manager::instance().shortcutPreferences.setShortcuts(map_cpy);
739 740 741

	Manager::instance().saveConfig();
}
742