dbusconfigurationmanager.cpp 10.4 KB
Newer Older
1
/*
Adrien Béraud's avatar
Adrien Béraud committed
2
 *  Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *  Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com>
 *
 *  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
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  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.
 *
 *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *  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.
 */
#include <iostream>
31
#include "dring.h"
32 33 34 35

#include "dbusconfigurationmanager.h"

DBusConfigurationManager::DBusConfigurationManager(DBus::Connection& connection)
Adrien Béraud's avatar
Adrien Béraud committed
36
    : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/ConfigurationManager")
37 38 39 40 41
{
}

std::map<std::string, std::string> DBusConfigurationManager::getAccountDetails(const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
42
    return ring_config_get_account_details(accountID);
43 44
}

45 46
std::map<std::string, std::string> DBusConfigurationManager::getVolatileAccountDetails(const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
47
    return ring_config_get_volatile_account_details(accountID);
48 49
}

50 51
void DBusConfigurationManager::setAccountDetails(const std::string& accountID, const std::map< std::string, std::string >& details)
{
Adrien Béraud's avatar
Adrien Béraud committed
52
    ring_config_set_account_details(accountID, details);
53 54 55 56
}

std::map<std::string, std::string> DBusConfigurationManager::getAccountTemplate()
{
Adrien Béraud's avatar
Adrien Béraud committed
57
    return ring_config_get_account_template();
58 59 60 61
}

std::string DBusConfigurationManager::addAccount(const std::map< std::string, std::string >& details)
{
Adrien Béraud's avatar
Adrien Béraud committed
62
    return ring_config_add_account(details);
63 64 65 66
}

void DBusConfigurationManager::removeAccount(const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
67
    ring_config_remove_account(accountID);
68 69 70 71
}

std::vector< std::string > DBusConfigurationManager::getAccountList()
{
Adrien Béraud's avatar
Adrien Béraud committed
72
    return ring_config_get_account_list();
73 74 75 76
}

void DBusConfigurationManager::sendRegister(const std::string& accountID, const bool& enable)
{
Adrien Béraud's avatar
Adrien Béraud committed
77
    ring_config_send_register(accountID, enable);
78 79 80 81
}

void DBusConfigurationManager::registerAllAccounts(void)
{
Adrien Béraud's avatar
Adrien Béraud committed
82
    ring_config_register_all_accounts();
83 84 85 86
}

std::map< std::string, std::string > DBusConfigurationManager::getTlsSettingsDefault()
{
Adrien Béraud's avatar
Adrien Béraud committed
87
    return ring_config_get_tls_default_settings();
88 89 90 91
}

std::vector< int32_t > DBusConfigurationManager::getAudioCodecList()
{
Adrien Béraud's avatar
Adrien Béraud committed
92
    return ring_config_get_audio_codec_list();
93 94 95 96
}

std::vector< std::string > DBusConfigurationManager::getSupportedTlsMethod()
{
Adrien Béraud's avatar
Adrien Béraud committed
97
    return ring_config_get_supported_tls_method();
98 99
}

100 101 102 103 104
std::vector< std::string > DBusConfigurationManager::getSupportedCiphers(const std::string& accountID)
{
    return ring_config_get_supported_ciphers(accountID);
}

105 106
std::vector< std::string > DBusConfigurationManager::getAudioCodecDetails(const int32_t& payload)
{
Adrien Béraud's avatar
Adrien Béraud committed
107
    return ring_config_get_audio_codec_details(payload);
108 109 110 111
}

std::vector< int32_t > DBusConfigurationManager::getActiveAudioCodecList(const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
112
    return ring_config_get_active_audio_codec_list(accountID);
113 114 115 116
}

void DBusConfigurationManager::setActiveAudioCodecList(const std::vector< std::string >& list, const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
117
    ring_config_set_active_audio_codec_list(list, accountID);
118 119 120 121
}

std::vector< std::string > DBusConfigurationManager::getAudioPluginList()
{
Adrien Béraud's avatar
Adrien Béraud committed
122
    return ring_config_get_audio_plugin_list();
123 124 125 126
}

void DBusConfigurationManager::setAudioPlugin(const std::string& audioPlugin)
{
Adrien Béraud's avatar
Adrien Béraud committed
127
    ring_config_set_audio_plugin(audioPlugin);
128 129 130 131
}

std::vector< std::string > DBusConfigurationManager::getAudioOutputDeviceList()
{
Adrien Béraud's avatar
Adrien Béraud committed
132
    return ring_config_get_audio_output_device_list();
133 134 135 136
}

void DBusConfigurationManager::setAudioOutputDevice(const int32_t& index)
{
Adrien Béraud's avatar
Adrien Béraud committed
137
    ring_config_set_audio_output_device(index);
138 139 140 141
}

void DBusConfigurationManager::setAudioInputDevice(const int32_t& index)
{
Adrien Béraud's avatar
Adrien Béraud committed
142
    ring_config_set_audio_input_device(index);
143 144 145 146
}

void DBusConfigurationManager::setAudioRingtoneDevice(const int32_t& index)
{
Adrien Béraud's avatar
Adrien Béraud committed
147
    ring_config_set_audio_ringtone_device(index);
148 149 150 151
}

std::vector< std::string > DBusConfigurationManager::getAudioInputDeviceList()
{
Adrien Béraud's avatar
Adrien Béraud committed
152
    return ring_config_get_audio_input_device_list();
153 154 155 156
}

std::vector< std::string > DBusConfigurationManager::getCurrentAudioDevicesIndex()
{
Adrien Béraud's avatar
Adrien Béraud committed
157
    return ring_config_get_current_audio_devices_index();
158 159 160 161
}

int32_t DBusConfigurationManager::getAudioInputDeviceIndex(const std::string& name)
{
Adrien Béraud's avatar
Adrien Béraud committed
162
    return ring_config_get_audio_input_device_index(name);
163 164 165 166
}

int32_t DBusConfigurationManager::getAudioOutputDeviceIndex(const std::string& name)
{
Adrien Béraud's avatar
Adrien Béraud committed
167
    return ring_config_get_audio_output_device_index(name);
168 169 170 171
}

std::string DBusConfigurationManager::getCurrentAudioOutputPlugin()
{
Adrien Béraud's avatar
Adrien Béraud committed
172
    return ring_config_get_current_audio_output_plugin();
173 174 175 176
}

bool DBusConfigurationManager::getNoiseSuppressState()
{
Adrien Béraud's avatar
Adrien Béraud committed
177
    return ring_config_get_noise_suppress_state();
178 179 180 181
}

void DBusConfigurationManager::setNoiseSuppressState(const bool& state)
{
Adrien Béraud's avatar
Adrien Béraud committed
182
    ring_config_set_noise_suppress_state(state);
183 184 185 186
}

bool DBusConfigurationManager::isAgcEnabled()
{
Adrien Béraud's avatar
Adrien Béraud committed
187
    return ring_config_is_agc_enabled();
188 189 190 191
}

void DBusConfigurationManager::setAgcState(const bool& enabled)
{
Adrien Béraud's avatar
Adrien Béraud committed
192
    ring_config_enable_agc(enabled);
193 194 195 196
}

void DBusConfigurationManager::muteDtmf(const bool& mute)
{
Adrien Béraud's avatar
Adrien Béraud committed
197
    ring_config_mute_dtmf(mute);
198 199 200 201
}

bool DBusConfigurationManager::isDtmfMuted()
{
Adrien Béraud's avatar
Adrien Béraud committed
202
    return ring_config_is_dtmf_muted();
203 204 205 206
}

bool DBusConfigurationManager::isCaptureMuted()
{
Adrien Béraud's avatar
Adrien Béraud committed
207
    return ring_config_is_capture_muted();
208 209 210 211
}

void DBusConfigurationManager::muteCapture(const bool& mute)
{
Adrien Béraud's avatar
Adrien Béraud committed
212
    ring_config_mute_capture(mute);
213 214 215 216
}

bool DBusConfigurationManager::isPlaybackMuted()
{
Adrien Béraud's avatar
Adrien Béraud committed
217
    return ring_config_is_playback_muted();
218 219 220 221
}

void DBusConfigurationManager::mutePlayback(const bool& mute)
{
Adrien Béraud's avatar
Adrien Béraud committed
222
    ring_config_mute_playback(mute);
223 224 225 226
}

std::map<std::string, std::string> DBusConfigurationManager::getRingtoneList()
{
Adrien Béraud's avatar
Adrien Béraud committed
227
    return ring_config_get_ringtone_list();
228 229 230 231
}

std::string DBusConfigurationManager::getAudioManager()
{
Adrien Béraud's avatar
Adrien Béraud committed
232
    return ring_config_get_audio_manager();
233 234 235 236
}

bool DBusConfigurationManager::setAudioManager(const std::string& api)
{
Adrien Béraud's avatar
Adrien Béraud committed
237
    return ring_config_set_audio_manager(api);
238 239 240 241
}

std::vector<std::string> DBusConfigurationManager::getSupportedAudioManagers()
{
Adrien Béraud's avatar
Adrien Béraud committed
242
    return ring_config_get_supported_audio_managers();
243 244 245 246
}

int32_t DBusConfigurationManager::isIax2Enabled()
{
Adrien Béraud's avatar
Adrien Béraud committed
247
    return ring_config_is_iax2_enabled();
248 249 250 251
}

std::string DBusConfigurationManager::getRecordPath()
{
Adrien Béraud's avatar
Adrien Béraud committed
252
    return ring_config_get_record_path();
253 254 255 256
}

void DBusConfigurationManager::setRecordPath(const std::string& recPath)
{
Adrien Béraud's avatar
Adrien Béraud committed
257
    ring_config_set_record_path(recPath);
258 259 260 261
}

bool DBusConfigurationManager::getIsAlwaysRecording()
{
Adrien Béraud's avatar
Adrien Béraud committed
262
    return ring_config_is_always_recording();
263 264 265 266
}

void DBusConfigurationManager::setIsAlwaysRecording(const bool& rec)
{
Adrien Béraud's avatar
Adrien Béraud committed
267
    ring_config_set_always_recording(rec);
268 269 270 271
}

void DBusConfigurationManager::setHistoryLimit(const int32_t& days)
{
Adrien Béraud's avatar
Adrien Béraud committed
272
    ring_config_set_history_limit(days);
273 274 275 276
}

int32_t DBusConfigurationManager::getHistoryLimit()
{
Adrien Béraud's avatar
Adrien Béraud committed
277
    return ring_config_get_history_limit();
278 279 280 281
}

void DBusConfigurationManager::clearHistory()
{
Adrien Béraud's avatar
Adrien Béraud committed
282
    ring_config_clear_history();
283 284 285 286
}

void DBusConfigurationManager::setAccountsOrder(const std::string& order)
{
Adrien Béraud's avatar
Adrien Béraud committed
287
    ring_config_set_accounts_order(order);
288 289 290 291
}

std::map<std::string, std::string> DBusConfigurationManager::getHookSettings()
{
Adrien Béraud's avatar
Adrien Béraud committed
292
    return ring_config_get_hook_settings();
293 294 295 296
}

void DBusConfigurationManager::setHookSettings(const std::map<std::string, std::string>& settings)
{
Adrien Béraud's avatar
Adrien Béraud committed
297
    ring_config_set_hook_settings(settings);
298 299 300 301
}

std::vector<std::map<std::string, std::string> > DBusConfigurationManager::getHistory()
{
Adrien Béraud's avatar
Adrien Béraud committed
302
    return ring_config_get_history();
303 304 305 306
}

std::map<std::string, std::string> DBusConfigurationManager::getTlsSettings()
{
Adrien Béraud's avatar
Adrien Béraud committed
307
    return ring_config_get_tls_settings();
308 309
}

310 311
std::map<std::string, std::string> DBusConfigurationManager::validateCertificate(const std::string& accountId, const std::string& certificate, const std::string& privateKey)
{
Adrien Béraud's avatar
Adrien Béraud committed
312
   return ring_config_validate_certificate(accountId, certificate, privateKey);
313 314 315 316
}

std::map<std::string, std::string> DBusConfigurationManager::getCertificateDetails(const std::string& certificate)
{
Adrien Béraud's avatar
Adrien Béraud committed
317
    return ring_config_get_certificate_details(certificate);
318 319
}

320 321
void DBusConfigurationManager::setTlsSettings(const std::map< std::string, std::string >& details)
{
Adrien Béraud's avatar
Adrien Béraud committed
322
    ring_config_set_tls_settings(details);
323 324 325 326
}

std::map< std::string, std::string > DBusConfigurationManager::getIp2IpDetails()
{
Adrien Béraud's avatar
Adrien Béraud committed
327
    return ring_config_get_ip2ip_details();
328 329 330 331
}

std::vector< std::map< std::string, std::string > > DBusConfigurationManager::getCredentials(const std::string& accountID)
{
Adrien Béraud's avatar
Adrien Béraud committed
332
    return ring_config_get_credentials(accountID);
333 334 335 336
}

void DBusConfigurationManager::setCredentials(const std::string& accountID, const std::vector< std::map< std::string, std::string > >& details)
{
Adrien Béraud's avatar
Adrien Béraud committed
337
    ring_config_set_credentials(accountID, details);
338 339 340 341
}

std::string DBusConfigurationManager::getAddrFromInterfaceName(const std::string& interface)
{
Adrien Béraud's avatar
Adrien Béraud committed
342
    return ring_config_get_addr_from_interface_name(interface);
343 344 345 346
}

std::vector<std::string> DBusConfigurationManager::getAllIpInterface()
{
Adrien Béraud's avatar
Adrien Béraud committed
347
    return ring_config_get_all_ip_interface();
348 349 350 351
}

std::vector<std::string> DBusConfigurationManager::getAllIpInterfaceByName()
{
Adrien Béraud's avatar
Adrien Béraud committed
352
    return ring_config_get_all_ip_interface_by_name();
353 354 355 356
}

std::map<std::string, std::string> DBusConfigurationManager::getShortcuts()
{
Adrien Béraud's avatar
Adrien Béraud committed
357
    return ring_config_get_shortcuts();
358 359 360 361
}

void DBusConfigurationManager::setShortcuts(const std::map<std::string, std::string> &shortcutsMap)
{
Adrien Béraud's avatar
Adrien Béraud committed
362
    ring_config_set_shortcuts(shortcutsMap);
363 364 365 366
}

void DBusConfigurationManager::setVolume(const std::string& device, const double& value)
{
Adrien Béraud's avatar
Adrien Béraud committed
367
    ring_config_set_volume(device, value);
368 369 370 371
}

double DBusConfigurationManager::getVolume(const std::string& device)
{
Adrien Béraud's avatar
Adrien Béraud committed
372
    return ring_config_get_volume(device);
373
}