From c143aa1d34946aaf0e7ceb264c6f609c1dbaadc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 29 Aug 2019 16:42:33 -0400 Subject: [PATCH] accounts: add connectToAccountManager Change-Id: Ife4f027a7ea4413de09dbde53543af22dc53a847 --- src/api/newaccountmodel.h | 11 +++++++++++ src/newaccountmodel.cpp | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/api/newaccountmodel.h b/src/api/newaccountmodel.h index d178782e..2f1c6675 100644 --- a/src/api/newaccountmodel.h +++ b/src/api/newaccountmodel.h @@ -150,6 +150,17 @@ public: */ bool registerName(const std::string& accountId, const std::string& password, const std::string& username); + /** + * Connect to JAMS to retrieve the account + * @param username + * @param password + * @param serverUri + * @return the account id + */ + static std::string connectToAccountManager(const std::string& username, + const std::string& password, + const std::string& serverUri); + /** * Create a new Ring or SIP account * @param type determine if the new account will be a Ring account or a SIP one diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 04208dbc..babe1287 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -858,6 +858,25 @@ NewAccountModel::createNewAccount(profile::Type type, if (type == profile::Type::SIP) { details[ConfProperties::USERNAME] = uri.c_str(); } + + QString accountId = ConfigurationManager::instance().addAccount(details); + return accountId.toStdString(); +} + + + +std::string +NewAccountModel::connectToAccountManager(const std::string& username, + const std::string& password, + const std::string& serverUri) +{ + MapStringString details = ConfigurationManager::instance().getAccountTemplate("RING"); + using namespace DRing::Account; + details[ConfProperties::TYPE] = "RING"; + details[ConfProperties::USERNAME] = username.c_str(); + details[ConfProperties::ARCHIVE_PASSWORD] = password.c_str(); + details[ConfProperties::MANAGER_URI] = serverUri.c_str(); + QString accountId = ConfigurationManager::instance().addAccount(details); return accountId.toStdString(); } -- GitLab