From 1ab09e4af90adc965f7b1d4b86397e82a21f2752 Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Thu, 12 Nov 2020 11:03:36 -0500
Subject: [PATCH] settings: use route set in account config to save SIP account
 proxy option

Change-Id: I95b0c80968c51e22662a0c0187adfe07fff1584c
---
 src/accountadapter.cpp                                 |  2 +-
 src/settingsadapter.cpp                                | 10 ++++++++--
 src/settingsadapter.h                                  |  3 ++-
 src/settingsview/components/CurrentAccountSettings.qml |  2 +-
 src/settingsview/components/SIPUserIdentity.qml        |  4 ++--
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp
index d23629a6c..545eff0a7 100644
--- a/src/accountadapter.cpp
+++ b/src/accountadapter.cpp
@@ -160,7 +160,7 @@ AccountAdapter::createSIPAccount(const QVariantMap& settings, QString photoBooth
                               confProps.hostname = settings["hostname"].toString();
                               confProps.username = settings["username"].toString();
                               confProps.password = settings["password"].toString();
-                              confProps.proxyServer = settings["proxy"].toString();
+                              confProps.routeset = settings["proxy"].toString();
                               LRCInstance::accountModel().setAccountConfig(accountId, confProps);
 
                               // set up photobooth avatar to SIP avatar
diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp
index e82f0ff8e..60957fb8b 100644
--- a/src/settingsadapter.cpp
+++ b/src/settingsadapter.cpp
@@ -318,6 +318,12 @@ SettingsAdapter::getAccountConfig_Password()
     return getAccountConfig().password;
 }
 
+QString
+SettingsAdapter::getAccountConfig_RouteSet()
+{
+    return getAccountConfig().routeset;
+}
+
 QString
 SettingsAdapter::getAccountConfig_ProxyServer()
 {
@@ -595,10 +601,10 @@ SettingsAdapter::setAccountConfig_Password(QString input)
 }
 
 void
-SettingsAdapter::setAccountConfig_ProxyServer(QString input)
+SettingsAdapter::setAccountConfig_RouteSet(QString input)
 {
     auto confProps = getAccountConfig();
-    confProps.proxyServer = input;
+    confProps.routeset = input;
     LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
 }
 
diff --git a/src/settingsadapter.h b/src/settingsadapter.h
index db621f598..d1b216d20 100644
--- a/src/settingsadapter.h
+++ b/src/settingsadapter.h
@@ -108,6 +108,7 @@ public:
     Q_INVOKABLE QString getAccountConfig_Hostname();
     Q_INVOKABLE QString getAccountConfig_Password();
 
+    Q_INVOKABLE QString getAccountConfig_RouteSet();
     Q_INVOKABLE QString getAccountConfig_ProxyServer();
     Q_INVOKABLE bool getAccountConfig_ProxyEnabled();
 
@@ -166,7 +167,7 @@ public:
     Q_INVOKABLE void setAccountConfig_Username(QString input);
     Q_INVOKABLE void setAccountConfig_Hostname(QString input);
     Q_INVOKABLE void setAccountConfig_Password(QString input);
-    Q_INVOKABLE void setAccountConfig_ProxyServer(QString input);
+    Q_INVOKABLE void setAccountConfig_RouteSet(QString input);
 
     Q_INVOKABLE void setAutoConnectOnLocalNetwork(bool state);
     Q_INVOKABLE void setCallsUntrusted(bool state);
diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml
index fcfb86a73..cc38e243d 100644
--- a/src/settingsview/components/CurrentAccountSettings.qml
+++ b/src/settingsview/components/CurrentAccountSettings.qml
@@ -228,6 +228,7 @@ Rectangle {
 
             visible: !isSIP && SettingsAdapter.getAccountConfig_Manageruri() === ""
             Layout.alignment: Qt.AlignHCenter
+            Layout.topMargin: JamiTheme.preferredMarginSize
             Layout.preferredWidth: JamiTheme.preferredFieldWidth
             Layout.preferredHeight: JamiTheme.preferredFieldHeight
 
@@ -274,7 +275,6 @@ Rectangle {
             Layout.alignment: Qt.AlignHCenter
             Layout.preferredWidth: JamiTheme.preferredFieldWidth
             Layout.preferredHeight: JamiTheme.preferredFieldHeight
-            Layout.topMargin: isSIP ? JamiTheme.preferredMarginSize : 0
             Layout.leftMargin: JamiTheme.preferredMarginSize
             Layout.rightMargin: JamiTheme.preferredMarginSize
 
diff --git a/src/settingsview/components/SIPUserIdentity.qml b/src/settingsview/components/SIPUserIdentity.qml
index b95e04340..32f6752f3 100644
--- a/src/settingsview/components/SIPUserIdentity.qml
+++ b/src/settingsview/components/SIPUserIdentity.qml
@@ -37,7 +37,7 @@ ColumnLayout {
         usernameSIP.setText(SettingsAdapter.getAccountConfig_Username())
         hostnameSIP.setText(SettingsAdapter.getAccountConfig_Hostname())
         passSIPlineEdit.setText(SettingsAdapter.getAccountConfig_Password())
-        proxySIP.setText(SettingsAdapter.getAccountConfig_ProxyServer())
+        proxySIP.setText(SettingsAdapter.getAccountConfig_RouteSet())
     }
 
     SettingsMaterialLineEdit {
@@ -70,7 +70,7 @@ ColumnLayout {
 
         titleField: qsTr("Proxy")
         itemWidth: root.itemWidth
-        onEditFinished: SettingsAdapter.setAccountConfig_ProxyServer(textField)
+        onEditFinished: SettingsAdapter.setAccountConfig_RouteSet(textField)
     }
 
     SettingsMaterialLineEdit {
-- 
GitLab