configurationmanager_wrap.h 27.1 KB
Newer Older
Philippe's avatar
Philippe committed
1
/******************************************************************************
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *   Copyright (C) 2014-2017 Savoir-faire Linux                               *
 *   Author : Philippe Groarke <philippe.groarke@savoirfairelinux.com>        *
 *   Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com>        *
 *                                                                            *
 *   This library is free software; you can redistribute it and/or            *
 *   modify it under the terms of the GNU Lesser General Public               *
 *   License as published by the Free Software Foundation; either             *
 *   version 2.1 of the License, or (at your option) any later version.       *
 *                                                                            *
 *   This library 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        *
 *   Lesser General Public License for more details.                          *
 *                                                                            *
 *   You should have received a copy of the Lesser GNU General Public License *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
 *****************************************************************************/
Guillaume Roguez's avatar
Guillaume Roguez committed
19
#pragma once
Philippe's avatar
Philippe committed
20 21 22 23 24

#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
Alexandre Lision's avatar
Alexandre Lision committed
25
#include <QtCore/QTimer>
Philippe's avatar
Philippe committed
26 27 28 29 30 31
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>

#include <future>

32
#include <configurationmanager_interface.h>
Guillaume Roguez's avatar
Guillaume Roguez committed
33
#include <datatransfer_interface.h>
34
#include <account_const.h>
35 36

#include "typedefs.h"
Philippe's avatar
Philippe committed
37 38 39
#include "conversions_wrap.hpp"

/*
40
 * Proxy class for interface org.ring.Ring.ConfigurationManager
Philippe's avatar
Philippe committed
41 42 43 44 45 46
 */
class ConfigurationManagerInterface: public QObject
{
    Q_OBJECT

public:
47
    std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>> confHandlers;
Guillaume Roguez's avatar
Guillaume Roguez committed
48
    std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>> dataXferHandlers;
49 50 51 52 53 54

    ConfigurationManagerInterface() {
        setObjectName("ConfigurationManagerInterface");
        using DRing::exportable_callback;
        using DRing::ConfigurationSignal;
        using DRing::AudioSignal;
Guillaume Roguez's avatar
Guillaume Roguez committed
55
        using DRing::DataTransferSignal;
56 57 58 59 60 61 62 63 64 65 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

        setObjectName("ConfigurationManagerInterface");
        confHandlers = {
            exportable_callback<ConfigurationSignal::VolumeChanged>(
                [this] (const std::string &device, double value) {
                    Q_EMIT this->volumeChanged(QString(device.c_str()), value);
                }),
            exportable_callback<ConfigurationSignal::AccountsChanged>(
                [this] () {
                    Q_EMIT this->accountsChanged();
                }),
            exportable_callback<ConfigurationSignal::StunStatusFailed>(
                [this] (const std::string &reason) {
                    Q_EMIT this->stunStatusFailure(QString(reason.c_str()));
                }),
            exportable_callback<ConfigurationSignal::RegistrationStateChanged>(
                [this] (const std::string &accountID, const std::string& registration_state,
                        unsigned detail_code,
                        const std::string& detail_str) {
                    Q_EMIT this->registrationStateChanged(QString(accountID.c_str()),
                                                          QString(registration_state.c_str()),
                                                          detail_code,
                                                          QString(detail_str.c_str()));
                }),
            exportable_callback<ConfigurationSignal::VolatileDetailsChanged>(
                [this] (const std::string &accountID, const std::map<std::string, std::string>& details) {
                    Q_EMIT this->volatileAccountDetailsChanged(QString(accountID.c_str()), convertMap(details));
                }),
            exportable_callback<ConfigurationSignal::Error>(
                [this] (int code) {
                    Q_EMIT this->errorAlert(code);
                }),
            exportable_callback<ConfigurationSignal::CertificateExpired>(
                [this] (const std::string &certId) {
                    Q_EMIT this->certificateExpired(QString(certId.c_str()));
                }),
            exportable_callback<ConfigurationSignal::CertificatePinned>(
                [this] (const std::string &certId) {
                    Q_EMIT this->certificatePinned(QString(certId.c_str()));
                }),
            exportable_callback<ConfigurationSignal::CertificatePathPinned>(
                [this] (const std::string &certPath, const std::vector<std::string>& list) {
                    Q_EMIT this->certificatePathPinned(QString(certPath.c_str()),convertStringList(list));
                }),
            exportable_callback<ConfigurationSignal::CertificateStateChanged>(
                [this] (const std::string &accountID, const std::string &certId, const std::string &state) {
                    QTimer::singleShot(
                        0, [this, accountID, certId, state] {
                            Q_EMIT this->certificateStateChanged(QString(accountID.c_str()), QString(certId.c_str()), QString(state.c_str()));
                        });
                }),
            exportable_callback<DRing::ConfigurationSignal::AccountMessageStatusChanged>(
                [this] (const std::string& accountID, uint64_t id, const std::string& to, int status) {
                    Q_EMIT this->accountMessageStatusChanged(QString(accountID.c_str()), id, QString(to.c_str()), status);
                }),
            exportable_callback<ConfigurationSignal::IncomingTrustRequest>(
                [this] (const std::string &accountId, const std::string &certId, const std::vector<uint8_t> &payload, time_t timestamp) {
                    Q_EMIT this->incomingTrustRequest(QString(accountId.c_str()), QString(certId.c_str()), QByteArray(reinterpret_cast<const char*>(payload.data()), payload.size()), timestamp);
                }),
            exportable_callback<ConfigurationSignal::KnownDevicesChanged>(
                [this] (const std::string &accountId, const std::map<std::string, std::string>& devices) {
                    Q_EMIT this->knownDevicesChanged(QString(accountId.c_str()), convertMap(devices));
                }),
            exportable_callback<ConfigurationSignal::ExportOnRingEnded>(
                [this] (const std::string &accountId, int status, const std::string &pin) {
Alexandre Lision's avatar
Alexandre Lision committed
121
                    Q_EMIT this->exportOnRingEnded(QString(accountId.c_str()), status, QString(pin.c_str()));
122 123 124 125
                }),
            exportable_callback<ConfigurationSignal::NameRegistrationEnded>(
                [this] (const std::string &accountId, int status, const std::string &name) {
                    Q_EMIT this->nameRegistrationEnded(QString(accountId.c_str()), status, QString(name.c_str()));
126

127 128
                }),
            exportable_callback<ConfigurationSignal::RegisteredNameFound>(
129
                [this] (const std::string &accountId, int status, const std::string &address, const std::string &name) {
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
                    Q_EMIT this->registeredNameFound(QString(accountId.c_str()), status, QString(address.c_str()), QString(name.c_str()));
                }),
            exportable_callback<ConfigurationSignal::IncomingAccountMessage>(
                [this] (const std::string& account_id, const std::string& from, const std::map<std::string, std::string>& payloads) {
                    Q_EMIT this->incomingAccountMessage(QString(account_id.c_str()), QString(from.c_str()), convertMap(payloads));
                }),
            exportable_callback<ConfigurationSignal::MediaParametersChanged>(
                [this] (const std::string& account_id) {
                    Q_EMIT this->mediaParametersChanged(QString(account_id.c_str()));
                }),
            exportable_callback<AudioSignal::DeviceEvent>(
                [this] () {
                    Q_EMIT this->audioDeviceEvent();
                }),
            exportable_callback<ConfigurationSignal::MigrationEnded>(
                [this] (const std::string& account_id, const std::string& result) {
                    Q_EMIT this->migrationEnded(QString(account_id.c_str()), QString(result.c_str()));
                }),
            exportable_callback<ConfigurationSignal::ContactAdded>(
                [this] (const std::string& account_id, const std::string& uri, const bool& confirmed) {
                    Q_EMIT this->contactAdded(QString(account_id.c_str()), QString(uri.c_str()), confirmed);
                }),
            exportable_callback<ConfigurationSignal::ContactRemoved>(
                [this] (const std::string& account_id, const std::string& uri, const bool& banned) {
                    Q_EMIT this->contactRemoved(QString(account_id.c_str()), QString(uri.c_str()), banned);
                }),
        };
Guillaume Roguez's avatar
Guillaume Roguez committed
157 158 159 160 161 162 163

        dataXferHandlers = {
            exportable_callback<DataTransferSignal::DataTransferEvent>(
                [this] (const uint64_t& transfer_id, const uint32_t& code) {
                    Q_EMIT this->dataTransferEvent(transfer_id, code);
                }),
        };
164 165 166
    }

    ~ConfigurationManagerInterface() {}
Philippe's avatar
Philippe committed
167 168

public Q_SLOTS: // METHODS
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 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 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
    QString addAccount(MapStringString details) {
        QString temp(DRing::addAccount(convertMap(details)).c_str());
        return temp;
    }

    bool exportOnRing(const QString& accountID, const QString& password) {
        return DRing::exportOnRing(accountID.toStdString(), password.toStdString());
    }

    MapStringString getKnownRingDevices(const QString& accountID) {
        MapStringString temp = convertMap(DRing::getKnownRingDevices(accountID.toStdString()));
        return temp;
    }

    bool lookupName(const QString& accountID, const QString& nameServiceURL, const QString& name) {
        return DRing::lookupName(accountID.toStdString(), nameServiceURL.toStdString(), name.toStdString());
    }

    bool lookupAddress(const QString& accountID, const QString& nameServiceURL, const QString& address) {
        return DRing::lookupAddress(accountID.toStdString(), nameServiceURL.toStdString(), address.toStdString());
    }

    bool registerName(const QString& accountID, const QString& password, const QString& name) {
        return DRing::registerName(accountID.toStdString(), password.toStdString(), name.toStdString());
    }

    MapStringString getAccountDetails(const QString& accountID) {
        MapStringString temp = convertMap(DRing::getAccountDetails(accountID.toStdString()));
        return temp;
    }

    QStringList getAccountList() {
        QStringList temp =
            convertStringList(DRing::getAccountList());
        return temp;
    }

    MapStringString getAccountTemplate(const QString& accountType) {
        MapStringString temp = convertMap(DRing::getAccountTemplate(accountType.toStdString()));
        return temp;
    }

    // TODO: works?
    VectorUInt getActiveCodecList(const QString& accountID) {
        return QVector<unsigned int>::fromStdVector(DRing::getActiveCodecList(accountID.toStdString()));
    }

    QString getAddrFromInterfaceName(const QString& interface) {
        QString temp(DRing::getAddrFromInterfaceName(interface.toStdString()).c_str());
        return temp;
    }

    QStringList getAllIpInterface() {
        QStringList temp = convertStringList(DRing::getAllIpInterface());
        return temp;
    }

    QStringList getAllIpInterfaceByName() {
        QStringList temp = convertStringList(DRing::getAllIpInterfaceByName());
        return temp;
    }

    MapStringString getCodecDetails(const QString& accountID, int payload) {
        MapStringString temp = convertMap(DRing::getCodecDetails(accountID.toStdString().c_str(), payload));
        return temp;
    }

    VectorUInt getCodecList() {
        return QVector<unsigned int>::fromStdVector(DRing::getCodecList());
    }

    VectorMapStringString getContacts(const QString &accountID) {
        VectorMapStringString temp;
        for (const auto& x : DRing::getContacts(accountID.toStdString())) {
            temp.push_back(convertMap(x));
        }
        return temp;
    }

    int getAudioInputDeviceIndex(const QString& devname) {
        return DRing::getAudioInputDeviceIndex(devname.toStdString());
    }

    QStringList getAudioInputDeviceList() {
        QStringList temp = convertStringList(DRing::getAudioInputDeviceList());
        return temp;
    }

    QString getAudioManager() {
        QString temp(DRing::getAudioManager().c_str());
        return temp;
    }

    int getAudioOutputDeviceIndex(const QString& devname) {
        return DRing::getAudioOutputDeviceIndex(devname.toStdString());
    }

    QStringList getAudioOutputDeviceList() {
        QStringList temp = convertStringList(DRing::getAudioOutputDeviceList());
        return temp;
    }

    QStringList getAudioPluginList() {
        QStringList temp = convertStringList(DRing::getAudioPluginList());
        return temp;
    }

    VectorMapStringString getCredentials(const QString& accountID) {
        VectorMapStringString temp;
        for (auto x : DRing::getCredentials(accountID.toStdString())) {
            temp.push_back(convertMap(x));
        }
        return temp;
    }

    QStringList getCurrentAudioDevicesIndex() {
        QStringList temp = convertStringList(DRing::getCurrentAudioDevicesIndex());
        return temp;
    }

    QString getCurrentAudioOutputPlugin() {
        QString temp(DRing::getCurrentAudioOutputPlugin().c_str());
        return temp;
    }

    int getHistoryLimit() {
        return DRing::getHistoryLimit();
    }

    MapStringString getHookSettings() {
        MapStringString temp = convertMap(DRing::getHookSettings());
        return temp;
    }

    bool getIsAlwaysRecording() {
        return DRing::getIsAlwaysRecording();
    }

    bool getNoiseSuppressState() {
        return DRing::getNoiseSuppressState();
    }

    QString getRecordPath() {
        QString temp(DRing::getRecordPath().c_str());
        return temp;
    }

    QStringList getSupportedAudioManagers() {
        QStringList temp;
        return temp;
    }

    MapStringString getShortcuts() {
        MapStringString temp = convertMap(DRing::getShortcuts());
        return temp;
    }

    QStringList getSupportedTlsMethod() {
        QStringList temp = convertStringList(DRing::getSupportedTlsMethod());
        return temp;
    }

    MapStringString validateCertificate(const QString& unused, const QString& certificate) {
        MapStringString temp = convertMap(DRing::validateCertificate(unused.toStdString(),
                                                                     certificate.toStdString()));
        return temp;
    }

    MapStringString validateCertificatePath(const QString& unused,
                                            const QString& certificate,
                                            const QString& privateKey,
                                            const QString& privateKeyPass,
                                            const QString& caListPath) {
        MapStringString temp = convertMap(DRing::validateCertificatePath(unused.toStdString(),
                                                                         certificate.toStdString(),
                                                                         privateKey.toStdString(),
                                                                         privateKeyPass.toStdString(),
                                                                         caListPath.toStdString()));
        return temp;
    }

    MapStringString getCertificateDetails(const QString& certificate) {
        MapStringString temp = convertMap(DRing::getCertificateDetails(certificate.toStdString()));
        return temp;
    }

    MapStringString getCertificateDetailsPath(const QString& certificate,
                                              const QString& privateKey,
                                              const QString& privateKeyPass) {
        MapStringString temp = convertMap(DRing::getCertificateDetailsPath(certificate.toStdString(),
                                                                           privateKey.toStdString(),
                                                                           privateKeyPass.toStdString()));
        return temp;
    }

    QStringList getSupportedCiphers(const QString& accountID) {
        QStringList temp = convertStringList(DRing::getSupportedCiphers(accountID.toStdString()));
        return temp;
    }

    MapStringString getTlsDefaultSettings() {
        MapStringString temp = convertMap(DRing::getTlsDefaultSettings());
        return temp;
    }

    double getVolume(const QString& device) {
        return DRing::getVolume(device.toStdString());
    }

    bool isAgcEnabled() {
        return DRing::isAgcEnabled();
    }

    bool isCaptureMuted() {
        return DRing::isCaptureMuted();
    }

    bool isDtmfMuted() {
        return DRing::isDtmfMuted();
    }

    bool isPlaybackMuted() {
        return DRing::isPlaybackMuted();
    }

    void muteCapture(bool mute) {
        DRing::muteCapture(mute);
    }

    void muteDtmf(bool mute) {
        DRing::muteDtmf(mute);
    }

    void mutePlayback(bool mute) {
        DRing::mutePlayback(mute);
    }

    void registerAllAccounts() {
        DRing::registerAllAccounts();
    }

    void removeAccount(const QString& accountID) {
        DRing::removeAccount(accountID.toStdString());
    }

    int  exportAccounts(const QStringList& accountIDs, const QString& filePath, const QString& password) {
        return DRing::exportAccounts(convertStringList(accountIDs), filePath.toStdString(), password.toStdString());
    }

    int importAccounts(const QString& filePath, const QString& password) {
        return DRing::importAccounts(filePath.toStdString(), password.toStdString());
    }

    bool changeAccountPassword(const QString& id, const QString& currentPassword, const QString& newPassword) {
        return DRing::changeAccountPassword(id.toStdString(), currentPassword.toStdString(), newPassword.toStdString());
    }

    void sendRegister(const QString& accountID, bool enable) {
        DRing::sendRegister(accountID.toStdString(), enable);
    }

    void setAccountDetails(const QString& accountID, MapStringString details) {
        DRing::setAccountDetails(accountID.toStdString(),
                                 convertMap(details));
    }

    void setAccountsOrder(const QString& order) {
        DRing::setAccountsOrder(order.toStdString());
    }

    void setActiveCodecList(const QString& accountID, VectorUInt &list) {
        //const std::vector<unsigned int> converted = convertStringList(list);
        DRing::setActiveCodecList(accountID.toStdString(),
                                  list.toStdVector());
    }

    void setAgcState(bool enabled) {
        DRing::setAgcState(enabled);
    }

    void setAudioInputDevice(int index) {
        DRing::setAudioInputDevice(index);
    }

    bool setAudioManager(const QString& api) {
        return DRing::setAudioManager(api.toStdString());
    }

    void setAudioOutputDevice(int index) {
        DRing::setAudioOutputDevice(index);
    }

    void setAudioPlugin(const QString& audioPlugin) {
        DRing::setAudioPlugin(audioPlugin.toStdString());
    }

    void setAudioRingtoneDevice(int index) {
        DRing::setAudioRingtoneDevice(index);
    }

    void setCredentials(const QString& accountID, VectorMapStringString credentialInformation) {
        std::vector<std::map<std::string, std::string> > temp;
        for (auto x : credentialInformation) {
            temp.push_back(convertMap(x));
        }
        DRing::setCredentials(accountID.toStdString(), temp);
    }

    void setHistoryLimit(int days) {
        DRing::setHistoryLimit(days);
    }

    void setHookSettings(MapStringString settings) {
        DRing::setHookSettings(convertMap(settings));
    }

    void setIsAlwaysRecording(bool enabled) {
        DRing::setIsAlwaysRecording(enabled);
    }

    void setNoiseSuppressState(bool state) {
        DRing::setNoiseSuppressState(state);
    }

    void setRecordPath(const QString& rec) {
        DRing::setRecordPath(rec.toStdString());
    }

    void setShortcuts(MapStringString shortcutsMap) {
        DRing::setShortcuts(convertMap(shortcutsMap));
    }

    void setVolume(const QString& device, double value) {
        DRing::setVolume(device.toStdString(), value);
    }

    MapStringString getVolatileAccountDetails(const QString& accountID) {
        MapStringString temp = convertMap(DRing::getVolatileAccountDetails(accountID.toStdString()));
        return temp;
    }

    QStringList getPinnedCertificates() {
        QStringList temp = convertStringList(DRing::getPinnedCertificates());
        return temp;
    }

    QStringList pinCertificate(const QByteArray& content, bool local) {
        std::vector<unsigned char> raw(content.begin(), content.end());
        return convertStringList(DRing::pinCertificate(raw,local));
    }

    bool unpinCertificate(const QString& certId) {
        return DRing::unpinCertificate(certId.toStdString());
    }

    void pinCertificatePath(const QString& certPath) {
        DRing::pinCertificatePath(certPath.toStdString());
    }

    uint unpinCertificatePath(const QString& certPath) {
        return DRing::unpinCertificatePath(certPath.toStdString());
    }

    bool pinRemoteCertificate(const QString& accountId, const QString& certPath) {
        return DRing::pinRemoteCertificate(accountId.toStdString(), certPath.toStdString());
    }

    bool setCertificateStatus(const QString& accountId, const QString& certPath, const QString& status) {
        return DRing::setCertificateStatus(accountId.toStdString(), certPath.toStdString(), status.toStdString());
    }

    QStringList getCertificatesByStatus(const QString& accountId, const QString& status) {
        return convertStringList(DRing::getCertificatesByStatus(accountId.toStdString(), status.toStdString()));
    }

    VectorMapStringString getTrustRequests(const QString& accountId) {
        return convertVecMap(DRing::getTrustRequests(accountId.toStdString()));
    }

    bool acceptTrustRequest(const QString& accountId, const QString& from) {
        return DRing::acceptTrustRequest(accountId.toStdString(), from.toStdString());
    }

    bool discardTrustRequest(const QString& accountId, const QString& from) {
        return DRing::discardTrustRequest(accountId.toStdString(), from.toStdString());
    }

    void sendTrustRequest(const QString& accountId, const QString& from, const QByteArray& payload) {
        std::vector<unsigned char> raw(payload.begin(), payload.end());
        DRing::sendTrustRequest(accountId.toStdString(), from.toStdString(), raw);
    }

    void removeContact(const QString &accountId, const QString &uri, bool ban) {
        DRing::removeContact(accountId.toStdString(), uri.toStdString(), ban);
    }

    void addContact(const QString &accountId, const QString &uri) {
        DRing::addContact(accountId.toStdString(), uri.toStdString());
    }

    uint64_t sendTextMessage(const QString& accountId, const QString& to, const QMap<QString,QString>& payloads) {
        return DRing::sendAccountTextMessage(accountId.toStdString(), to.toStdString(), convertMap(payloads));
    }

    bool setCodecDetails(const QString& accountId, unsigned int codecId, const MapStringString& details) {
        return DRing::setCodecDetails(accountId.toStdString(), codecId, convertMap(details));
    }

    int getMessageStatus(uint64_t id) {
        return DRing::getMessageStatus(id);
    }

    void connectivityChanged() {
        DRing::connectivityChanged();
    }

    MapStringString getContactDetails(const QString &accountID, const QString &uri) {
        return convertMap(DRing::getContactDetails(accountID.toStdString(), uri.toStdString()));
    }
588

Guillaume Roguez's avatar
Guillaume Roguez committed
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
    VectorULongLong dataTransferList() {
        return convertVectorULongLong(DRing::dataTransferList());
    }

    uint64_t sendFile(const QString& account_id, const QString& peer_uri, const QString& file_path, const QString& display_name) {
        return DRing::sendFile(account_id.toStdString(), peer_uri.toStdString(), file_path.toStdString(), display_name.toStdString());
    }

    DataTransferInfo dataTransferInfo(uint64_t transfer_id) {
        auto dring_info = DRing::dataTransferInfo(transfer_id);
        DataTransferInfo lrc_info;
        lrc_info.isOutgoing = dring_info.isOutgoing;
        lrc_info.lastEvent = uint(dring_info.lastEvent);
        lrc_info.totalSize = dring_info.totalSize;
        lrc_info.bytesProgress = dring_info.bytesProgress;
        lrc_info.displayName = QString::fromStdString(dring_info.displayName);
        lrc_info.path = QString::fromStdString(dring_info.path);
        return lrc_info;
    }

609 610
    uint64_t dataTransferBytesProgress(uint64_t transfer_id) {
        return DRing::dataTransferBytesProgress(transfer_id);
Guillaume Roguez's avatar
Guillaume Roguez committed
611 612 613 614 615 616 617 618 619 620
    }

    void acceptFileTransfer(uint64_t transfer_id, const QString& file_path, uint64_t offset) {
        DRing::acceptFileTransfer(transfer_id, file_path.toStdString(), offset);
    }

    void cancelDataTransfer(uint64_t transfer_id) {
        DRing::cancelDataTransfer(transfer_id);
    }

Philippe's avatar
Philippe committed
621
Q_SIGNALS: // SIGNALS
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
    void volumeChanged(const QString& device, double value);
    void accountsChanged();
    void historyChanged();
    void stunStatusFailure(const QString& reason);
    void registrationStateChanged(const QString& accountID, const QString& registration_state, unsigned detail_code, const QString& detail_str);
    void stunStatusSuccess(const QString& message);
    void errorAlert(int code);
    void volatileAccountDetailsChanged(const QString& accountID, MapStringString details);
    void certificatePinned(const QString& certId);
    void certificatePathPinned(const QString& path, const QStringList& certIds);
    void certificateExpired(const QString& certId);
    void certificateStateChanged(const QString& accountId, const QString& certId, const QString& status);
    void incomingTrustRequest(const QString& accountId, const QString& from, const QByteArray& payload, qulonglong timeStamp);
    void knownDevicesChanged(const QString& accountId, const MapStringString& devices);
    void exportOnRingEnded(const QString& accountId, int status, const QString& pin);
    void incomingAccountMessage(const QString& accountId, const QString& from, const MapStringString& payloads);
    void mediaParametersChanged(const QString& accountId);
    void audioDeviceEvent();
    void accountMessageStatusChanged(const QString& accountId, const uint64_t id, const QString& to, int status);
    void nameRegistrationEnded(const QString& accountId, int status, const QString& name);
    void registeredNameFound(const QString& accountId, int status, const QString& address, const QString& name);
    void migrationEnded(const QString &accountID, const QString &result);
    void contactAdded(const QString &accountID, const QString &uri, bool banned);
    void contactRemoved(const QString &accountID, const QString &uri, bool banned);
Guillaume Roguez's avatar
Guillaume Roguez committed
646
    void dataTransferEvent(qulonglong transfer_id, uint code);
Philippe's avatar
Philippe committed
647 648
};

649 650 651
namespace org { namespace ring { namespace Ring {
typedef ::ConfigurationManagerInterface ConfigurationManager;
}}}