configurationmanager.cpp 24.5 KB
Newer Older
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
10
 *  (at your option) any later version.
11
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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
 *
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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.
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
31
 */
32

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
33 34
#include <global.h>
#include <configurationmanager.h>
35
#include <sstream>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
36
#include "../manager.h"
37
#include "sip/sipvoiplink.h"
38
#include "sip/sipaccount.h"
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
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 118 119 120 121 122 123 124 125 126 127 128 129 130

	std::map<std::string, std::string> tlsSettings;
	tlsSettings = getTlsSettings(IP2IP_PROFILE);
	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

165 166 167 168 169 170 171 172 173 174 175 176 177 178
	setTlsSettings(IP2IP_PROFILE, details);

	Manager::instance().saveConfig();

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

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

}

std::map<std::string, std::string> ConfigurationManager::getTlsSettings(
		const std::string& section) {
Alexandre Savard's avatar
Alexandre Savard committed
179

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

182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
	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()));

203 204 205 206 207
	return tlsSettings;
}

void ConfigurationManager::setTlsSettings(const std::string& section,
		const std::map<std::string, std::string>& details) {
208

209 210 211
	std::map<std::string, std::string> map_cpy = details;
	std::map<std::string, std::string>::iterator it;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

258
	Manager::instance().saveConfig();
259

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

263 264
}

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

268
        Account *account = Manager::instance().getAccount(accountID);
269

270
	std::map<std::string, std::string> credentialInformation;
271

272 273
	if(account->getType() != "SIP")
	  return credentialInformation;
274

275 276
	SIPAccount *sipaccount = (SIPAccount *)account;
 
277

278
	if(index == 0) {
279 280 281 282 283 284 285
	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));
286 287 288 289 290 291 292 293 294 295 296 297
	}
	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));
	}
298

299
	return credentialInformation;
300 301
}

302 303
int32_t ConfigurationManager::getNumberOfCredential(
		const std::string& accountID) {
304 305 306

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

309 310
void ConfigurationManager::setNumberOfCredential(const std::string& accountID,
		const int32_t& number) {
311
  /*
312 313 314 315
  if (accountID != AccountNULL || !accountID.empty()) {
    SIPAccount *sipaccount = (SIPAccount *)Manager::instance().getAccount(accountID);
    sipaccount->setCredentialCount(number);
  }
316
  */
317
}
318

319 320 321
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);
322 323
}

324 325
void ConfigurationManager::deleteAllCredential(const std::string& accountID) {
	Manager::instance().deleteAllCredential(accountID);
326 327
}

328 329 330
void ConfigurationManager::setAccountDetails(const std::string& accountID,
		const std::map<std::string, std::string>& details) {
	Manager::instance().setAccountDetails(accountID, details);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
331 332
}

333 334 335
void ConfigurationManager::sendRegister(const std::string& accountID,
		const int32_t& expire) {
	Manager::instance().sendRegister(accountID, expire);
336 337
}

338 339 340
std::string ConfigurationManager::addAccount(const std::map<std::string,
		std::string>& details) {
	return Manager::instance().addAccount(details);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
341 342
}

343 344
void ConfigurationManager::removeAccount(const std::string& accoundID) {
	return Manager::instance().removeAccount(accoundID);
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
345 346
}

347 348
std::vector<std::string> ConfigurationManager::getAccountList() {
	return Manager::instance().getAccountList();
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
349 350
}

351
//TODO
352 353 354
std::vector<std::string> ConfigurationManager::getToneLocaleList() {
	std::vector<std::string> ret;
	return ret;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
355 356
}

357
//TODO
358 359 360
std::string ConfigurationManager::getVersion() {
	std::string ret("");
	return ret;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
361 362
}

363
//TODO
364 365 366
std::vector<std::string> ConfigurationManager::getRingtoneList() {
	std::vector<std::string> ret;
	return ret;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
367 368
}

Emmanuel Milou's avatar
Emmanuel Milou committed
369 370
/**
 * Send the list of all codecs loaded to the client through DBus.
371
 * Can stay global, as only the active codecs will be set per accounts
Emmanuel Milou's avatar
Emmanuel Milou committed
372
 */
373
std::vector<std::string> ConfigurationManager::getCodecList(void) {
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
374

375
	std::vector<std::string> list;
Emmanuel Milou's avatar
Emmanuel Milou committed
376

377
	CodecsMap codecs = Manager::instance().getCodecDescriptorMap().getCodecsMap();
378
	CodecsMap::iterator iter = codecs.begin();
Emmanuel Milou's avatar
Emmanuel Milou committed
379

380 381
	while (iter != codecs.end()) {
		std::stringstream ss;
Emmanuel Milou's avatar
Emmanuel Milou committed
382

383 384 385 386
		if (iter->second != NULL) {
			ss << iter->first;
			list.push_back((ss.str()).data());
		}
Emmanuel Milou's avatar
Emmanuel Milou committed
387

388 389
		iter++;
	}
Emmanuel Milou's avatar
Emmanuel Milou committed
390

391
	return list;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
392 393
}

394 395 396 397 398 399 400 401
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;
402 403
}

404 405
std::vector<std::string> ConfigurationManager::getCodecDetails(
		const int32_t& payload) {
406

407 408
	return Manager::instance().getCodecDescriptorMap().getCodecSpecifications(
			payload);
409 410
}

411 412
std::vector<std::string> ConfigurationManager::getActiveCodecList(
		const std::string& accountID) {
Emmanuel Milou's avatar
Emmanuel Milou committed
413

414
	_debug("Send active codec list for account %s", accountID.c_str ());
Emmanuel Milou's avatar
Emmanuel Milou committed
415

416
	std::vector<std::string> v;
Emmanuel Milou's avatar
Emmanuel Milou committed
417 418
	Account *acc;
	CodecOrder active;
419
	unsigned int i = 0;
Emmanuel Milou's avatar
Emmanuel Milou committed
420 421
	size_t size;

422
	acc = Manager::instance().getAccount(accountID);
Emmanuel Milou's avatar
Emmanuel Milou committed
423
	if (acc != NULL) {
424
		active = acc->getActiveCodecs();
Emmanuel Milou's avatar
Emmanuel Milou committed
425
		size = active.size();
426
		while (i < size) {
Emmanuel Milou's avatar
Emmanuel Milou committed
427 428
			std::stringstream ss;
			ss << active[i];
429
			v.push_back((ss.str()).data());
Emmanuel Milou's avatar
Emmanuel Milou committed
430 431 432 433
			i++;
		}
	}

434
	return v;
435

436
}
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
437

438 439
void ConfigurationManager::setActiveCodecList(
		const std::vector<std::string>& list, const std::string& accountID) {
440

Alexandre Savard's avatar
Alexandre Savard committed
441
	_debug ("ConfigurationManager: Active codec list received");
442 443 444 445

	Account *acc;

	// Save the codecs list per account
446
	acc = Manager::instance().getAccount(accountID);
447
	if (acc != NULL) {
448
		acc->setActiveCodecs(list);
449
	}
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
450 451
}

Alexandre Savard's avatar
Alexandre Savard committed
452

453
std::vector<std::string> ConfigurationManager::getAudioPluginList() {
454

455
	std::vector<std::string> v;
456

457
	v.push_back(PCM_DEFAULT);
458 459
	// v.push_back(PCM_DMIX);
	v.push_back(PCM_DMIX_DSNOOP);
460

461
	return v;
462
}
463

Alexandre Savard's avatar
Alexandre Savard committed
464

465 466
void ConfigurationManager::setInputAudioPlugin(const std::string& audioPlugin) {
	return Manager::instance().setInputAudioPlugin(audioPlugin);
467 468
}

469 470
void ConfigurationManager::setOutputAudioPlugin(const std::string& audioPlugin) {
	return Manager::instance().setOutputAudioPlugin(audioPlugin);
471 472
}

473 474
std::vector<std::string> ConfigurationManager::getAudioOutputDeviceList() {
	return Manager::instance().getAudioOutputDeviceList();
475
}
476

477 478
std::vector<std::string> ConfigurationManager::getAudioInputDeviceList() {
	return Manager::instance().getAudioInputDeviceList();
479
}
480

481 482 483 484
void ConfigurationManager::setAudioOutputDevice(const int32_t& index) {
        return Manager::instance().setAudioDevice(index, SFL_PCM_PLAYBACK);
}

485
void ConfigurationManager::setAudioInputDevice(const int32_t& index) {
486 487 488 489 490
        return Manager::instance().setAudioDevice(index, SFL_PCM_CAPTURE);
}

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

493 494
std::vector<std::string> ConfigurationManager::getCurrentAudioDevicesIndex() {
	return Manager::instance().getCurrentAudioDevicesIndex();
495
}
496

497 498
int32_t ConfigurationManager::getAudioDeviceIndex(const std::string& name) {
	return Manager::instance().getAudioDeviceIndex(name);
499 500
}

501 502
std::string ConfigurationManager::getCurrentAudioOutputPlugin(void) {
	return Manager::instance().getCurrentAudioOutputPlugin();
503 504
}

505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
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);
}

521 522 523
std::vector<std::string> ConfigurationManager::getPlaybackDeviceList() {
	std::vector<std::string> ret;
	return ret;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
524 525
}

526 527 528
std::vector<std::string> ConfigurationManager::getRecordDeviceList() {
	std::vector<std::string> ret;
	return ret;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
529 530

}
Emmanuel Milou's avatar
Emmanuel Milou committed
531

532
bool ConfigurationManager::isMd5CredentialHashing(void) {
533
	return Manager::instance().preferences.getMd5Hash();
534 535
}

536
void ConfigurationManager::setMd5CredentialHashing(const bool& enabled) {
537
        Manager::instance().preferences.setMd5Hash(enabled);
538 539
}

540 541
int32_t ConfigurationManager::isIax2Enabled(void) {
	return Manager::instance().isIax2Enabled();
Emmanuel Milou's avatar
Emmanuel Milou committed
542
}
543

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

548 549
int32_t ConfigurationManager::isRingtoneEnabled(const std::string& accountID) {
        return Manager::instance().isRingtoneEnabled(accountID);
550
}
551

552 553
std::string ConfigurationManager::getRingtoneChoice(const std::string& accountID) {
       return Manager::instance().getRingtoneChoice(accountID);
554 555
}

556 557
void ConfigurationManager::setRingtoneChoice(const std::string& accountID, const std::string& tone) {
       Manager::instance().setRingtoneChoice(accountID, tone);
558 559
}

560 561
std::string ConfigurationManager::getRecordPath(void) {
	return Manager::instance().getRecordPath();
562 563
}

564 565
void ConfigurationManager::setRecordPath(const std::string& recPath) {
	Manager::instance().setRecordPath(recPath);
566 567
}

568
/*
569 570
int32_t ConfigurationManager::getDialpad(void) {
	return Manager::instance().getDialpad();
Emmanuel Milou's avatar
Emmanuel Milou committed
571 572
}

573 574
void ConfigurationManager::setDialpad(const bool& display) {
	Manager::instance().setDialpad(display);
Emmanuel Milou's avatar
Emmanuel Milou committed
575 576
}

577 578
int32_t ConfigurationManager::getSearchbar(void) {
	return Manager::instance().getSearchbar();
579 580
}

581 582
void ConfigurationManager::setSearchbar(void) {
	Manager::instance().setSearchbar();
583 584
}

585 586
int32_t ConfigurationManager::getVolumeControls(void) {
	return Manager::instance().getVolumeControls();
587 588
}

589 590
void ConfigurationManager::setVolumeControls(const bool& display) {
	Manager::instance().setVolumeControls(display);
591
}
592
*/
593

594 595
int32_t ConfigurationManager::getHistoryLimit(void) {
	return Manager::instance().getHistoryLimit();
596 597
}

598 599
void ConfigurationManager::setHistoryLimit(const int32_t& days) {
	Manager::instance().setHistoryLimit(days);
600 601
}

602
/*
603 604
void ConfigurationManager::setHistoryEnabled(void) {
	Manager::instance().setHistoryEnabled();
605
}
606

607 608
std::string ConfigurationManager::getHistoryEnabled(void) {
	return Manager::instance().getHistoryEnabled();
609 610
}

611 612
void ConfigurationManager::startHidden(void) {
	Manager::instance().startHidden();
Emmanuel Milou's avatar
Emmanuel Milou committed
613 614
}

615 616
int32_t ConfigurationManager::isStartHidden(void) {
	return Manager::instance().isStartHidden();
Emmanuel Milou's avatar
Emmanuel Milou committed
617 618
}

619 620
void ConfigurationManager::switchPopupMode(void) {
	Manager::instance().switchPopupMode();
621 622
}

623 624
int32_t ConfigurationManager::popupMode(void) {
	return Manager::instance().popupMode();
625 626
}

627 628
void ConfigurationManager::setNotify(void) {
	Manager::instance().setNotify();
629
}
630

631 632
int32_t ConfigurationManager::getNotify(void) {
	return Manager::instance().getNotify();
633
}
634
*/
Emmanuel Milou's avatar
Emmanuel Milou committed
635

636 637
void ConfigurationManager::setAudioManager(const int32_t& api) {
	Manager::instance().setAudioManager(api);
638 639
}

640 641
int32_t ConfigurationManager::getAudioManager(void) {
	return Manager::instance().getAudioManager();
642 643
}

644 645
void ConfigurationManager::setMailNotify(void) {
	Manager::instance().setMailNotify();
646 647
}

648 649
int32_t ConfigurationManager::getMailNotify(void) {
	return Manager::instance().getMailNotify();
650
}
651

652 653 654
std::map<std::string, int32_t> ConfigurationManager::getAddressbookSettings(
		void) {
	return Manager::instance().getAddressbookSettings();
Emmanuel Milou's avatar
Emmanuel Milou committed
655 656
}

657 658 659
void ConfigurationManager::setAddressbookSettings(const std::map<std::string,
		int32_t>& settings) {
	Manager::instance().setAddressbookSettings(settings);
Emmanuel Milou's avatar
Emmanuel Milou committed
660
}
661

662 663
std::vector<std::string> ConfigurationManager::getAddressbookList(void) {
	return Manager::instance().getAddressbookList();
664 665
}

666 667 668
void ConfigurationManager::setAddressbookList(
		const std::vector<std::string>& list) {
	Manager::instance().setAddressbookList(list);
669 670
}

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

675 676 677
void ConfigurationManager::setHookSettings(const std::map<std::string,
		std::string>& settings) {
	Manager::instance().setHookSettings(settings);
678
}
679

680 681
void ConfigurationManager::setAccountsOrder(const std::string& order) {
	Manager::instance().setAccountsOrder(order);
682 683
}

684 685
std::map<std::string, std::string> ConfigurationManager::getHistory(void) {
	return Manager::instance().send_history_to_client();
686 687
}

688 689 690
void ConfigurationManager::setHistory(
		const std::map<std::string, std::string>& entries) {
	Manager::instance().receive_history_from_client(entries);
691
}
692

693 694
std::string ConfigurationManager::getAddrFromInterfaceName(
		const std::string& interface) {
695

696 697
	std::string address = SIPVoIPLink::instance("")->getInterfaceAddrFromName(
			interface);
698

699
	return address;
700 701
}

702
std::vector<std::string> ConfigurationManager::getAllIpInterface(void) {
703

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

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

712
	return vector;
713
}
714

715 716 717 718
std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName(void) {
	std::vector<std::string> vector;
	SIPVoIPLink * sipLink = NULL;
	sipLink = SIPVoIPLink::instance("");
719

720 721 722
	if (sipLink != NULL) {
		vector = sipLink->getAllIpInterfaceByName();
	}
723

724
	return vector;
725
}
726 727


728
std::map<std::string, std::string> ConfigurationManager::getShortcuts() {
729

730
	return Manager::instance().shortcutPreferences.getShortcuts();
731 732
}

733
void ConfigurationManager::setShortcuts(
734
		const std::map<std::string, std::string>& shortcutsMap) {
735

Alexandre Savard's avatar
Alexandre Savard committed
736 737
        std::map<std::string, std::string> map_cpy = shortcutsMap;
  /*
738 739
	std::map<std::string, std::string> map_cpy = shortcutsMap;
	std::map<std::string, std::string>::iterator it;
740

Alexandre Savard's avatar
Alexandre Savard committed
741
	for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
742 743 744
		std::string key = shortcutsKeys.at(i);
		it = map_cpy.find(key);
		if (it != shortcutsMap.end()) {
Alexandre Savard's avatar
Alexandre Savard committed
745
		         
746 747 748
			Manager::instance().setConfig("Shortcuts", key, it->second);
		}
	}
Alexandre Savard's avatar
Alexandre Savard committed
749 750
  */
        Manager::instance().shortcutPreferences.setShortcuts(map_cpy);
751 752 753

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