From 558dbba9c45d6a40831f8438d9a90761e9530b19 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Wed, 6 May 2020 11:45:30 -0400 Subject: [PATCH] accountmodel: add supplemental account config option when creating new accounts Change-Id: Ibb100a51f86b0004533b8352520c3aafb085ea4b --- src/api/newaccountmodel.h | 10 +++++++--- src/newaccountmodel.cpp | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/api/newaccountmodel.h b/src/api/newaccountmodel.h index 133dd016..1e36eaa8 100644 --- a/src/api/newaccountmodel.h +++ b/src/api/newaccountmodel.h @@ -153,11 +153,13 @@ public: * @param username * @param password * @param serverUri + * @param config * @return the account id */ static QString connectToAccountManager(const QString& username, - const QString& password, - const QString& serverUri); + const QString& password, + const QString& serverUri, + const MapStringString& config = MapStringString()); /** * Create a new Ring or SIP account @@ -168,6 +170,7 @@ public: * @param password of the archive (unused for SIP) * @param pin of the archive (unused for SIP) * @param uri of the account (for SIP) + * @param config * @return the created account */ static QString createNewAccount(profile::Type type, @@ -175,7 +178,8 @@ public: const QString& archivePath = "", const QString& password = "", const QString& pin = "", - const QString& uri = ""); + const QString& uri = "", + const MapStringString& config = MapStringString()); /** * Set an account to the first position diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 7702be09..43bb45e3 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -942,7 +942,8 @@ NewAccountModel::createNewAccount(profile::Type type, const QString& archivePath, const QString& password, const QString& pin, - const QString& uri) + const QString& uri, + const MapStringString& config) { MapStringString details = type == profile::Type::SIP? @@ -956,8 +957,12 @@ NewAccountModel::createNewAccount(profile::Type type, details[ConfProperties::ARCHIVE_PASSWORD] = password; details[ConfProperties::ARCHIVE_PIN] = pin; details[ConfProperties::ARCHIVE_PATH] = archivePath; - if (type == profile::Type::SIP) { + if (type == profile::Type::SIP) details[ConfProperties::USERNAME] = uri; + if (!config.isEmpty()) { + for (MapStringString::const_iterator it = config.begin(); it != config.end(); it++) { + details[it.key()] = it.value(); + } } QString accountId = ConfigurationManager::instance().addAccount(details); @@ -967,7 +972,8 @@ NewAccountModel::createNewAccount(profile::Type type, QString NewAccountModel::connectToAccountManager(const QString& username, const QString& password, - const QString& serverUri) + const QString& serverUri, + const MapStringString& config) { MapStringString details = ConfigurationManager::instance().getAccountTemplate("RING"); using namespace DRing::Account; @@ -975,6 +981,11 @@ NewAccountModel::connectToAccountManager(const QString& username, details[ConfProperties::MANAGER_URI] = serverUri; details[ConfProperties::MANAGER_USERNAME] = username; details[ConfProperties::ARCHIVE_PASSWORD] = password; + if (!config.isEmpty()) { + for (MapStringString::const_iterator it = config.begin(); it != config.end(); it++) { + details[it.key()] = it.value(); + } + } QString accountId = ConfigurationManager::instance().addAccount(details); return accountId; -- GitLab