dbusconfigurationmanager.cpp 18.6 KB
Newer Older
1
/*
2
 *  Copyright (C) 2004-2018 Savoir-faire Linux Inc.
3
 *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *  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.
 */

21 22 23 24
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

25
#include "dbusconfigurationmanager.h"
26
#include "configurationmanager_interface.h"
27
#include "datatransfer_interface.h"
28 29

#include "media/audio/audiolayer.h"
30 31

DBusConfigurationManager::DBusConfigurationManager(DBus::Connection& connection)
Adrien Béraud's avatar
Adrien Béraud committed
32
    : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/ConfigurationManager")
33
{}
34

35 36
auto
DBusConfigurationManager::getAccountDetails(const std::string& accountID) -> decltype(DRing::getAccountDetails(accountID))
37
{
38
    return DRing::getAccountDetails(accountID);
39 40
}

41 42
auto
DBusConfigurationManager::getVolatileAccountDetails(const std::string& accountID) -> decltype(DRing::getVolatileAccountDetails(accountID))
43
{
44
    return DRing::getVolatileAccountDetails(accountID);
45 46
}

47 48
void
DBusConfigurationManager::setAccountDetails(const std::string& accountID, const std::map<std::string, std::string>& details)
49
{
50
    DRing::setAccountDetails(accountID, details);
51 52
}

53 54 55 56 57 58 59
auto
DBusConfigurationManager::testAccountICEInitialization(const std::string& accountID) -> decltype(DRing::testAccountICEInitialization(accountID))
{
    return DRing::testAccountICEInitialization(accountID);
}


60 61 62 63 64 65
void
DBusConfigurationManager::setAccountActive(const std::string& accountID, const bool& active)
{
    DRing::setAccountActive(accountID, active);
}

66
auto
67
DBusConfigurationManager::getAccountTemplate(const std::string& accountType) -> decltype(DRing::getAccountTemplate(accountType))
68
{
69
    return DRing::getAccountTemplate(accountType);
70 71
}

72 73
auto
DBusConfigurationManager::addAccount(const std::map<std::string, std::string>& details) -> decltype(DRing::addAccount(details))
74
{
75
    return DRing::addAccount(details);
76 77
}

78 79 80 81 82 83
auto
DBusConfigurationManager::exportOnRing(const std::string& accountID, const std::string& password) -> decltype(DRing::exportOnRing(accountID, password))
{
    return DRing::exportOnRing(accountID, password);
}

84 85 86 87 88 89
auto
DBusConfigurationManager::revokeDevice(const std::string& accountID, const std::string& password, const std::string& device) -> decltype(DRing::revokeDevice(accountID, password, device))
{
    return DRing::revokeDevice(accountID, password, device);
}

90 91 92 93 94 95
auto
DBusConfigurationManager::getKnownRingDevices(const std::string& accountID) -> decltype(DRing::getKnownRingDevices(accountID))
{
    return DRing::getKnownRingDevices(accountID);
}

96 97 98 99 100 101
auto
DBusConfigurationManager::changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new) -> decltype(DRing::changeAccountPassword(accountID, password_old, password_new))
{
    return DRing::changeAccountPassword(accountID, password_old, password_new);
}

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
auto
DBusConfigurationManager::lookupName(const std::string& account, const std::string& nameserver, const std::string& name) -> decltype(DRing::lookupName(account, nameserver, name))
{
    return DRing::lookupName(account, nameserver, name);
}

auto
DBusConfigurationManager::lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address) -> decltype(DRing::lookupAddress(account, nameserver, address))
{
    return DRing::lookupAddress(account, nameserver, address);
}

auto
DBusConfigurationManager::registerName(const std::string& account, const std::string& password, const std::string& name) -> decltype(DRing::registerName(account, password, name))
{
    return DRing::registerName(account, password, name);
}

120 121
void
DBusConfigurationManager::removeAccount(const std::string& accountID)
122
{
123
    DRing::removeAccount(accountID);
124 125
}

126 127
auto
DBusConfigurationManager::getAccountList() -> decltype(DRing::getAccountList())
128
{
129
    return DRing::getAccountList();
130 131
}

132 133
void
DBusConfigurationManager::sendRegister(const std::string& accountID, const bool& enable)
134
{
135
    DRing::sendRegister(accountID, enable);
136 137
}

138 139
void
DBusConfigurationManager::registerAllAccounts(void)
140
{
141
    DRing::registerAllAccounts();
142 143
}

Adrien Béraud's avatar
Adrien Béraud committed
144 145 146 147 148 149 150 151
auto
DBusConfigurationManager::sendTextMessage(const std::string& accountID, const std::string& to, const std::map<std::string, std::string>& payloads) -> decltype(DRing::sendAccountTextMessage(accountID, to, payloads))
{
    return DRing::sendAccountTextMessage(accountID, to, payloads);
}

auto
DBusConfigurationManager::getMessageStatus(const uint64_t& id) -> decltype(DRing::getMessageStatus(id))
152
{
Adrien Béraud's avatar
Adrien Béraud committed
153
    return DRing::getMessageStatus(id);
154 155
}

156 157
auto
DBusConfigurationManager::getTlsDefaultSettings() -> decltype(DRing::getTlsDefaultSettings())
158
{
159
    return DRing::getTlsDefaultSettings();
160 161
}

162
auto
163
DBusConfigurationManager::getCodecList() -> decltype(DRing::getCodecList())
164
{
165
    return DRing::getCodecList();
166 167
}

168 169
auto
DBusConfigurationManager::getSupportedTlsMethod() -> decltype(DRing::getSupportedTlsMethod())
170
{
171
    return DRing::getSupportedTlsMethod();
172 173
}

174 175
auto
DBusConfigurationManager::getSupportedCiphers(const std::string& accountID) -> decltype(DRing::getSupportedCiphers(accountID))
176
{
177
    return DRing::getSupportedCiphers(accountID);
178 179
}

180
auto
181
DBusConfigurationManager::getCodecDetails(const std::string& accountID, const unsigned& codecId) -> decltype(DRing::getCodecDetails(accountID, codecId))
182
{
183
    return DRing::getCodecDetails(accountID, codecId);
184 185
}

186 187 188 189 190 191 192
auto
DBusConfigurationManager::setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details)
-> decltype(DRing::setCodecDetails(accountID, codecId, details))
{
    return DRing::setCodecDetails(accountID, codecId, details);
}

193
auto
194
DBusConfigurationManager::getActiveCodecList(const std::string& accountID) -> decltype(DRing::getActiveCodecList(accountID))
195
{
196
    return DRing::getActiveCodecList(accountID);
197 198
}

199
void
200
DBusConfigurationManager::setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list)
201
{
202
    DRing::setActiveCodecList(accountID, list);
203 204
}

205 206
auto
DBusConfigurationManager::getAudioPluginList() -> decltype(DRing::getAudioPluginList())
207
{
208
    return DRing::getAudioPluginList();
209 210
}

211 212
void
DBusConfigurationManager::setAudioPlugin(const std::string& audioPlugin)
213
{
214
    DRing::setAudioPlugin(audioPlugin);
215 216
}

217 218
auto
DBusConfigurationManager::getAudioOutputDeviceList() -> decltype(DRing::getAudioOutputDeviceList())
219
{
220
    return DRing::getAudioOutputDeviceList();
221 222
}

223 224
void
DBusConfigurationManager::setAudioOutputDevice(const int32_t& index)
225
{
226
    DRing::setAudioOutputDevice(index);
227 228
}

229 230
void
DBusConfigurationManager::setAudioInputDevice(const int32_t& index)
231
{
232
    DRing::setAudioInputDevice(index);
233 234
}

235 236
void
DBusConfigurationManager::setAudioRingtoneDevice(const int32_t& index)
237
{
238
    DRing::setAudioRingtoneDevice(index);
239 240
}

241 242
auto
DBusConfigurationManager::getAudioInputDeviceList() -> decltype(DRing::getAudioInputDeviceList())
243
{
244
    return DRing::getAudioInputDeviceList();
245 246
}

247 248
auto
DBusConfigurationManager::getCurrentAudioDevicesIndex() -> decltype(DRing::getCurrentAudioDevicesIndex())
249
{
250
    return DRing::getCurrentAudioDevicesIndex();
251 252
}

253 254
auto
DBusConfigurationManager::getAudioInputDeviceIndex(const std::string& name) -> decltype(DRing::getAudioInputDeviceIndex(name))
255
{
256
    return DRing::getAudioInputDeviceIndex(name);
257 258
}

259 260
auto
DBusConfigurationManager::getAudioOutputDeviceIndex(const std::string& name) -> decltype(DRing::getAudioOutputDeviceIndex(name))
261
{
262
    return DRing::getAudioOutputDeviceIndex(name);
263 264
}

265 266
auto
DBusConfigurationManager::getCurrentAudioOutputPlugin() -> decltype(DRing::getCurrentAudioOutputPlugin())
267
{
268
    return DRing::getCurrentAudioOutputPlugin();
269 270
}

271 272
auto
DBusConfigurationManager::getNoiseSuppressState() -> decltype(DRing::getNoiseSuppressState())
273
{
274
    return DRing::getNoiseSuppressState();
275 276
}

277 278
void
DBusConfigurationManager::setNoiseSuppressState(const bool& state)
279
{
280
    DRing::setNoiseSuppressState(state);
281 282
}

283 284
auto
DBusConfigurationManager::isAgcEnabled() -> decltype(DRing::isAgcEnabled())
285
{
286
    return DRing::isAgcEnabled();
287 288
}

289 290
void
DBusConfigurationManager::setAgcState(const bool& enabled)
291
{
292
    DRing::setAgcState(enabled);
293 294
}

295 296
void
DBusConfigurationManager::muteDtmf(const bool& mute)
297
{
298
    DRing::muteDtmf(mute);
299 300
}

301 302
auto
DBusConfigurationManager::isDtmfMuted() -> decltype(DRing::isDtmfMuted())
303
{
304
    return DRing::isDtmfMuted();
305 306
}

307 308
auto
DBusConfigurationManager::isCaptureMuted() -> decltype(DRing::isCaptureMuted())
309
{
310
    return DRing::isCaptureMuted();
311 312
}

313 314
void
DBusConfigurationManager::muteCapture(const bool& mute)
315
{
316
    DRing::muteCapture(mute);
317 318
}

319 320
auto
DBusConfigurationManager::isPlaybackMuted() -> decltype(DRing::isPlaybackMuted())
321
{
322
    return DRing::isPlaybackMuted();
323 324
}

325 326
void
DBusConfigurationManager::mutePlayback(const bool& mute)
327
{
328
    DRing::mutePlayback(mute);
329 330
}

331 332 333 334 335 336 337 338 339 340 341 342
auto
DBusConfigurationManager::isRingtoneMuted() -> decltype(DRing::isRingtoneMuted())
{
    return DRing::isRingtoneMuted();
}

void
DBusConfigurationManager::muteRingtone(const bool& mute)
{
    DRing::muteRingtone(mute);
}

343 344
auto
DBusConfigurationManager::getAudioManager() -> decltype(DRing::getAudioManager())
345
{
346
    return DRing::getAudioManager();
347 348
}

349 350
auto
DBusConfigurationManager::setAudioManager(const std::string& api) -> decltype(DRing::setAudioManager(api))
351
{
352
    return DRing::setAudioManager(api);
353 354
}

355 356
std::vector<std::string>
DBusConfigurationManager::getSupportedAudioManagers()
357
{
358 359 360 361 362 363 364 365 366 367 368
    return {
#if HAVE_ALSA
        ALSA_API_STR,
#endif
#if HAVE_PULSE
        PULSEAUDIO_API_STR,
#endif
#if HAVE_JACK
        JACK_API_STR,
#endif
    };
369 370
}

371 372
auto
DBusConfigurationManager::getRecordPath() -> decltype(DRing::getRecordPath())
373
{
374
    return DRing::getRecordPath();
375 376
}

377 378
void
DBusConfigurationManager::setRecordPath(const std::string& recPath)
379
{
380
    DRing::setRecordPath(recPath);
381 382
}

383 384
auto
DBusConfigurationManager::getIsAlwaysRecording() -> decltype(DRing::getIsAlwaysRecording())
385
{
386
    return DRing::getIsAlwaysRecording();
387 388
}

389 390
void
DBusConfigurationManager::setIsAlwaysRecording(const bool& rec)
391
{
392
    DRing::setIsAlwaysRecording(rec);
393 394
}

395 396
void
DBusConfigurationManager::setHistoryLimit(const int32_t& days)
397
{
398
    DRing::setHistoryLimit(days);
399 400
}

401 402
auto
DBusConfigurationManager::getHistoryLimit() -> decltype(DRing::getHistoryLimit())
403
{
404
    return DRing::getHistoryLimit();
405 406
}

407 408
void
DBusConfigurationManager::setAccountsOrder(const std::string& order)
409
{
410
    DRing::setAccountsOrder(order);
411 412
}

413 414
auto
DBusConfigurationManager::getHookSettings() -> decltype(DRing::getHookSettings())
415
{
416
    return DRing::getHookSettings();
417 418
}

419 420
void
DBusConfigurationManager::setHookSettings(const std::map<std::string, std::string>& settings)
421
{
422
    DRing::setHookSettings(settings);
423 424
}

425
auto
426
DBusConfigurationManager::validateCertificate(const std::string& accountId, const std::string& certificate) -> decltype(DRing::validateCertificate(accountId, certificate))
427
{
428
   return DRing::validateCertificate(accountId, certificate);
429 430
}

431
auto
432
DBusConfigurationManager::validateCertificatePath(const std::string& accountId, const std::string& certificate, const std::string& privateKey, const std::string& privateKeyPass, const std::string& caList) -> decltype(DRing::validateCertificatePath(accountId, certificate, privateKey, privateKeyPass, caList))
433
{
434
   return DRing::validateCertificatePath(accountId, certificate, privateKey, privateKeyPass, caList);
435 436
}

437 438
auto
DBusConfigurationManager::getCertificateDetails(const std::string& certificate) -> decltype(DRing::getCertificateDetails(certificate))
439
{
440
    return DRing::getCertificateDetails(certificate);
441 442
}

443
auto
444
DBusConfigurationManager::getCertificateDetailsPath(const std::string& certificate, const std::string& privateKey, const std::string& privateKeyPass) -> decltype(DRing::getCertificateDetailsPath(certificate, privateKey, privateKeyPass))
445
{
446
    return DRing::getCertificateDetailsPath(certificate, privateKey, privateKeyPass);
447 448
}

449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
auto
DBusConfigurationManager::getPinnedCertificates() -> decltype(DRing::getPinnedCertificates())
{
    return DRing::getPinnedCertificates();
}

auto
DBusConfigurationManager::pinCertificate(const std::vector<uint8_t>& certificate, const bool& local) -> decltype(DRing::pinCertificate(certificate, local))
{
    return DRing::pinCertificate(certificate, local);
}

void
DBusConfigurationManager::pinCertificatePath(const std::string& certPath)
{
    return DRing::pinCertificatePath(certPath);
}

auto
DBusConfigurationManager::unpinCertificate(const std::string& certId) -> decltype(DRing::unpinCertificate(certId))
{
    return DRing::unpinCertificate(certId);
}

auto
DBusConfigurationManager::unpinCertificatePath(const std::string& p) -> decltype(DRing::unpinCertificatePath(p))
{
    return DRing::unpinCertificatePath(p);
}

auto
DBusConfigurationManager::pinRemoteCertificate(const std::string& accountId, const std::string& certId) -> decltype(DRing::pinRemoteCertificate(accountId, certId))
{
    return DRing::pinRemoteCertificate(accountId, certId);
}

auto
DBusConfigurationManager::setCertificateStatus(const std::string& accountId, const std::string& certId, const std::string& status) -> decltype(DRing::setCertificateStatus(accountId, certId, status))
{
    return DRing::setCertificateStatus(accountId, certId, status);
}

auto
DBusConfigurationManager::getCertificatesByStatus(const std::string& accountId, const std::string& status) -> decltype(DRing::getCertificatesByStatus(accountId, status))
{
    return DRing::getCertificatesByStatus(accountId, status);
}

auto
DBusConfigurationManager::getTrustRequests(const std::string& accountId) -> decltype(DRing::getTrustRequests(accountId))
{
    return DRing::getTrustRequests(accountId);
}

auto
DBusConfigurationManager::acceptTrustRequest(const std::string& accountId, const std::string& from) -> decltype(DRing::acceptTrustRequest(accountId, from))
{
    return DRing::acceptTrustRequest(accountId, from);
}

auto
DBusConfigurationManager::discardTrustRequest(const std::string& accountId, const std::string& from) -> decltype(DRing::discardTrustRequest(accountId, from))
{
    return DRing::discardTrustRequest(accountId, from);
}

void
516
DBusConfigurationManager::sendTrustRequest(const std::string& accountId, const std::string& to, const std::vector<uint8_t>& payload)
517
{
518
    DRing::sendTrustRequest(accountId, to, payload);
519 520
}

521 522 523 524 525 526 527
void
DBusConfigurationManager::addContact(const std::string& accountId, const std::string& uri)
{
    DRing::addContact(accountId, uri);
}

void
528
DBusConfigurationManager::removeContact(const std::string& accountId, const std::string& uri, const bool& ban)
529
{
530
    DRing::removeContact(accountId, uri, ban);
531 532
}

533 534 535 536 537 538
auto
DBusConfigurationManager::getContactDetails(const std::string& accountId, const std::string& uri) -> decltype(DRing::getContactDetails(accountId, uri))
{
    return DRing::getContactDetails(accountId, uri);
}

539 540 541 542 543 544
auto
DBusConfigurationManager::getContacts(const std::string& accountId) -> decltype(DRing::getContacts(accountId))
{
    return DRing::getContacts(accountId);
}

545 546
auto
DBusConfigurationManager::getCredentials(const std::string& accountID) -> decltype(DRing::getCredentials(accountID))
547
{
548
    return DRing::getCredentials(accountID);
549 550
}

551 552
void
DBusConfigurationManager::setCredentials(const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details)
553
{
554
    DRing::setCredentials(accountID, details);
555 556
}

557 558
auto
DBusConfigurationManager::getAddrFromInterfaceName(const std::string& interface) -> decltype(DRing::getAddrFromInterfaceName(interface))
559
{
560
    return DRing::getAddrFromInterfaceName(interface);
561 562
}

563 564
auto
DBusConfigurationManager::getAllIpInterface() -> decltype(DRing::getAllIpInterface())
565
{
566
    return DRing::getAllIpInterface();
567 568
}

569 570
auto
DBusConfigurationManager::getAllIpInterfaceByName() -> decltype(DRing::getAllIpInterfaceByName())
571
{
572
    return DRing::getAllIpInterfaceByName();
573 574
}

575 576
auto
DBusConfigurationManager::getShortcuts() -> decltype(DRing::getShortcuts())
577
{
578
    return DRing::getShortcuts();
579 580
}

581 582
void
DBusConfigurationManager::setShortcuts(const std::map<std::string, std::string> &shortcutsMap)
583
{
584
    DRing::setShortcuts(shortcutsMap);
585 586
}

587 588
void
DBusConfigurationManager::setVolume(const std::string& device, const double& value)
589
{
590
    DRing::setVolume(device, value);
591 592
}

593 594
auto
DBusConfigurationManager::getVolume(const std::string& device) -> decltype(DRing::getVolume(device))
595
{
596
    return DRing::getVolume(device);
597
}
598 599 600 601 602 603 604 605 606 607 608 609

auto
DBusConfigurationManager::exportAccounts(const std::vector<std::string>& accountIDs, const std::string& filepath, const std::string& password) -> decltype(DRing::exportAccounts(accountIDs, filepath, password))
{
    return DRing::exportAccounts(accountIDs, filepath, password);
}

auto
DBusConfigurationManager::importAccounts(const std::string& archivePath, const std::string& password) -> decltype(DRing::importAccounts(archivePath, password))
{
    return DRing::importAccounts(archivePath, password);
}
610 611 612 613 614 615

void
DBusConfigurationManager::connectivityChanged()
{
    DRing::connectivityChanged();
}
616 617 618 619 620 621 622 623

auto
DBusConfigurationManager::sendFile(const std::string& account_id, const std::string& peer_uri,
                                   const std::string& file_path, const std::string& display_name) -> decltype(DRing::sendFile(account_id, peer_uri, file_path, display_name))
{
    return DRing::sendFile(account_id, peer_uri, file_path, display_name);
}

624
DBus::Struct<bool, uint32_t, uint64_t, uint64_t, std::string, std::string, std::string, std::string>
625 626
DBusConfigurationManager::dataTransferInfo(const DRing::DataTransferId& id)
{
627
    DBus::Struct<bool, uint32_t, uint64_t, uint64_t, std::string, std::string, std::string, std::string> out;
628 629 630 631 632 633 634
    auto info = DRing::dataTransferInfo(id);
    out._1 = info.isOutgoing;
    out._2 = uint32_t(info.lastEvent);
    out._3 = info.totalSize;
    out._4 = info.bytesProgress;
    out._5 = info.displayName;
    out._6 = info.path;
635 636
    out._7 = info.accountId;
    out._8 = info.peer;
637 638
    return out;
}
639 640

uint64_t
641
DBusConfigurationManager::dataTransferBytesProgress(const uint64_t& id)
642
{
643
    return DRing::dataTransferBytesProgress(id);
644
}
645 646 647 648

auto
DBusConfigurationManager::dataTransferList() -> decltype(DRing::dataTransferList())
{
649 650 651 652 653 654 655 656 657 658 659 660 661
    return DRing::dataTransferList();
}

void
DBusConfigurationManager::acceptFileTransfer(const uint64_t& id, const std::string& file_path, const uint64_t& offset)
{
    DRing::acceptFileTransfer(id, file_path, offset);
}

void
DBusConfigurationManager::cancelDataTransfer(const uint64_t& id)
{
    DRing::cancelDataTransfer(id);
662
}