From aa824e3eb2b9bd8998cb0a3d74c7cdb0a101fab5 Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Tue, 30 Jul 2019 10:56:19 -0400
Subject: [PATCH] lrc: add setAccountEnabled() function to properly change
 account enable state

- the function will call sendRegister that will also saveConfig
  we can just change the enable option in account so that
  reduce the complexity of calling setAccountConfig

Change-Id: Id37093fb174dd45dadf2886063da6779ea7bcc47
---
 src/api/newaccountmodel.h | 8 ++++++++
 src/newaccountmodel.cpp   | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/src/api/newaccountmodel.h b/src/api/newaccountmodel.h
index 65347d50..406e9331 100644
--- a/src/api/newaccountmodel.h
+++ b/src/api/newaccountmodel.h
@@ -76,6 +76,14 @@ public:
      * flag account corresponding to passed id as freeable.
      */
     void flagFreeable(const std::string& accountId) const;
+
+     /**
+     * set account enable/disable, save config and do unregister for account
+     * @param accountId.
+     * @param enabled.
+     */
+    void setAccountEnabled(const std::string& accountID, bool enabled) const;
+
     /**
      * saves account config to .yml
      * @param accountId.
diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp
index 242c507f..3400ef28 100644
--- a/src/newaccountmodel.cpp
+++ b/src/newaccountmodel.cpp
@@ -175,6 +175,12 @@ NewAccountModel::getAccountList() const
     return accountsId;
 }
 
+void
+NewAccountModel::setAccountEnabled(const std::string& accountId, bool enabled) const
+{
+     ConfigurationManager::instance().sendRegister(QString::fromStdString(accountId), enabled);
+}
+
 void
 NewAccountModel::setAccountConfig(const std::string& accountId,
                                   const account::ConfProperties_t& confProperties) const
-- 
GitLab