From 70df98e3595fc7786b02120b766e3aa6c2e263fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 22 Sep 2017 10:12:12 -0400 Subject: [PATCH] account: add the ability to change the account password MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I24dc2287d916a0dc694863351dcf2b7a273870a6 Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com> --- src/account.cpp | 11 +++++++++++ src/account.h | 2 ++ src/qtwrapper/configurationmanager_wrap.h | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/account.cpp b/src/account.cpp index 9fc1fbd3..9a7fb5c0 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1091,6 +1091,12 @@ QString Account::displayName() const return d_ptr->accountDetail(DRing::Account::ConfProperties::DISPLAYNAME); } +bool Account::archiveHasPassword() const +{ + return d_ptr->accountDetail(DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD) == "true"; +} + + QString Account::archivePassword() const { return d_ptr->accountDetail(DRing::Account::ConfProperties::ARCHIVE_PASSWORD); @@ -1106,6 +1112,11 @@ QString Account::archivePath() const return d_ptr->accountDetail(DRing::Account::ConfProperties::ARCHIVE_PATH); } +bool Account::changePassword(const QString& currentPassword, const QString newPassword) const +{ + return ConfigurationManager::instance().changeAccountPassword(id(), currentPassword, newPassword); +} + bool Account::allowIncomingFromUnknown() const { return d_ptr->accountDetail(DRing::Account::ConfProperties::DHT::PUBLIC_IN_CALLS) IS_TRUE; diff --git a/src/account.h b/src/account.h index 02223f1c..ca20cda3 100644 --- a/src/account.h +++ b/src/account.h @@ -448,9 +448,11 @@ class LIB_EXPORT Account : public ItemBase { QString turnServerRealm () const; bool hasProxy () const; QString displayName () const; + bool archiveHasPassword () const; QString archivePassword () const; QString archivePin () const; QString archivePath () const; + bool changePassword (const QString& currentPassword, const QString newPassword) const; RegistrationState registrationState () const; Protocol protocol () const; ContactMethod* contactMethod () const; diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index 5ebbaefe..4e1fd39e 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -480,6 +480,11 @@ public Q_SLOTS: // METHODS 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); -- GitLab