From 593ecc991040da71d0c28db7c978eca916081ad7 Mon Sep 17 00:00:00 2001
From: Matheo Joseph <matheo.joseph@savoirfairelinux.com>
Date: Mon, 12 Jun 2023 10:23:42 -0400
Subject: [PATCH] whitelabeling: add uicustom info in account property

GitLab: #1097

Change-Id: I1f7db2b14c437d033264ff58457d8067e4ff6c05
---
 daemon                         | 2 +-
 src/app/currentaccount.cpp     | 3 +++
 src/app/currentaccount.h       | 3 +++
 src/libclient/accountmodel.cpp | 9 +++++++++
 src/libclient/api/account.h    | 2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/daemon b/daemon
index 417447a16..d191e2e26 160000
--- a/daemon
+++ b/daemon
@@ -1 +1 @@
-Subproject commit 417447a167c52512e8c81250cc08bb5b24c6b667
+Subproject commit d191e2e262a26c5c17bc0ea2ecea08fe6f42142c
diff --git a/src/app/currentaccount.cpp b/src/app/currentaccount.cpp
index 00090325d..5b1b54b1a 100644
--- a/src/app/currentaccount.cpp
+++ b/src/app/currentaccount.cpp
@@ -222,6 +222,9 @@ CurrentAccount::updateData()
         set_autoTransferSizeThreshold(settingsManager_->getValue(Settings::Key::AcceptTransferBelow)
                                           .toInt(),
                                       true);
+
+        // UI Customization settings
+        set_uiCustomization(accConfig.uiCustomization, true);
     } catch (...) {
         qWarning() << "Can't update current account info data for" << id_;
     }
diff --git a/src/app/currentaccount.h b/src/app/currentaccount.h
index a20d959c2..f73a4240a 100644
--- a/src/app/currentaccount.h
+++ b/src/app/currentaccount.h
@@ -191,6 +191,9 @@ class CurrentAccount final : public QObject
     QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(bool, autoTransferFromTrusted, AutoAcceptFiles)
     QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(int, autoTransferSizeThreshold, AcceptTransferBelow)
 
+    // UI Customization settings
+    QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QJsonObject, uiCustomization)
+
 public:
     explicit CurrentAccount(LRCInstance* lrcInstance,
                             AppSettingsManager* settingsManager,
diff --git a/src/libclient/accountmodel.cpp b/src/libclient/accountmodel.cpp
index 1669a49a9..c484e6d56 100644
--- a/src/libclient/accountmodel.cpp
+++ b/src/libclient/accountmodel.cpp
@@ -49,6 +49,7 @@
 #include <QtGui/QPixmap>
 #include <QtGui/QImage>
 #include <QtCore/QBuffer>
+#include <QJsonDocument>
 
 #include <atomic>
 
@@ -928,6 +929,11 @@ account::Info::fromDetails(const MapStringString& details)
     // Jams
     confProperties.managerUri = details[ConfProperties::MANAGER_URI];
     confProperties.managerUsername = details[ConfProperties::MANAGER_USERNAME];
+    // uiCustomization
+    QJsonDocument doc = QJsonDocument::fromJson(details[ConfProperties::UI_CUSTOMIZATION].toUtf8());
+    if (!doc.isNull() && doc.isObject()) {
+        confProperties.uiCustomization = doc.object();
+    }
 }
 
 MapStringString
@@ -1033,6 +1039,9 @@ account::ConfProperties_t::toDetails() const
     // Manager
     details[ConfProperties::MANAGER_URI] = this->managerUri;
     details[ConfProperties::MANAGER_USERNAME] = this->managerUsername;
+    // UI Customization
+    QJsonDocument doc(this->uiCustomization);
+    details[ConfProperties::UI_CUSTOMIZATION] = doc.toJson(QJsonDocument::Compact);
 
     return details;
 }
diff --git a/src/libclient/api/account.h b/src/libclient/api/account.h
index 58701dd3e..c57491bd9 100644
--- a/src/libclient/api/account.h
+++ b/src/libclient/api/account.h
@@ -25,6 +25,7 @@
 #include <memory>
 
 #include <QString>
+#include <QJsonObject>
 
 namespace lrc {
 
@@ -118,6 +119,7 @@ struct ConfProperties_t
     QString defaultModerators;
     bool localModeratorsEnabled;
     VectorMapStringString credentials;
+    QJsonObject uiCustomization;
     struct Audio_t
     {
         int audioPortMax;
-- 
GitLab