From 7531305be27c4e6b8039d7bbb33a22f9884338da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 30 Jul 2021 16:07:21 -0400 Subject: [PATCH] account: add support for sendReadReceipt Change-Id: Iba44d7b7618c61db01d37477aee0a73ead094ca8 GitLab: https://git.jami.net/savoirfairelinux/ring-daemon/-/issues/599 --- qml.qrc | 1 + src/constant/JamiStrings.qml | 5 ++ src/settingsadapter.cpp | 15 +++++ src/settingsadapter.h | 2 + .../components/AdvancedChatSettings.qml | 61 +++++++++++++++++++ .../components/AdvancedSettings.qml | 24 +++++--- 6 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 src/settingsview/components/AdvancedChatSettings.qml diff --git a/qml.qrc b/qml.qrc index c6396fa30..8f5835d1d 100644 --- a/qml.qrc +++ b/qml.qrc @@ -65,6 +65,7 @@ <file>src/settingsview/components/AdvancedPublicAddressSettings.qml</file> <file>src/settingsview/components/AdvancedConnectivitySettings.qml</file> <file>src/settingsview/components/AdvancedCallSettings.qml</file> + <file>src/settingsview/components/AdvancedChatSettings.qml</file> <file>src/settingsview/components/SettingMaterialButton.qml</file> <file>src/settingsview/components/ToggleSwitch.qml</file> <file>src/settingsview/components/SettingSpinBox.qml</file> diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index e1ecee629..d94a7ab39 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -75,6 +75,11 @@ Item { property string addCustomRingtone: qsTr("Add a custom ringtone") property string selectNewRingtone: qsTr("Select a new ringtone") + // AdvancedChatSettings + property string chatSettings: qsTr("Chat Settings") + property string enableReadReceipts: qsTr("Enable read receipts") + property string enableReadReceiptsTooltip: qsTr("Send and receive receipts indicating that a message have been displayed") + // AdvancedVoiceMailSettings property string voiceMail: qsTr("Voicemail") property string voiceMailDialCode: qsTr("Voicemail dial code") diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp index bc908bd4e..7ec10f603 100644 --- a/src/settingsadapter.cpp +++ b/src/settingsadapter.cpp @@ -324,6 +324,12 @@ SettingsAdapter::getAccountConfig_DHT_PublicInCalls() return getAccountConfig().DHT.PublicInCalls; } +bool +SettingsAdapter::getAccountConfig_ReadReceipt() +{ + return getAccountConfig().sendReadReceipt; +} + bool SettingsAdapter::getAccountConfig_RendezVous() { @@ -632,6 +638,15 @@ SettingsAdapter::setAutoAnswerCalls(bool state) lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); } +void +SettingsAdapter::setSendReadReceipt(bool state) +{ + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->get_currentAccountId()); + confProps.sendReadReceipt = state; + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); +} + void SettingsAdapter::setEnableRingtone(bool state) { diff --git a/src/settingsadapter.h b/src/settingsadapter.h index 9f0e3fb84..73ea02a76 100644 --- a/src/settingsadapter.h +++ b/src/settingsadapter.h @@ -104,6 +104,7 @@ public: Q_INVOKABLE bool getAccountConfig_PeerDiscovery(); Q_INVOKABLE bool getAccountConfig_DHT_PublicInCalls(); + Q_INVOKABLE bool getAccountConfig_ReadReceipt(); Q_INVOKABLE bool getAccountConfig_RendezVous(); Q_INVOKABLE bool getAccountConfig_AutoAnswer(); @@ -164,6 +165,7 @@ public: Q_INVOKABLE void setCallsUntrusted(bool state); Q_INVOKABLE void setIsRendezVous(bool state); Q_INVOKABLE void setAutoAnswerCalls(bool state); + Q_INVOKABLE void setSendReadReceipt(bool state); Q_INVOKABLE void setEnableRingtone(bool state); Q_INVOKABLE void setEnableProxy(bool state); Q_INVOKABLE void setKeepAliveEnabled(bool state); diff --git a/src/settingsview/components/AdvancedChatSettings.qml b/src/settingsview/components/AdvancedChatSettings.qml new file mode 100644 index 000000000..f403109a1 --- /dev/null +++ b/src/settingsview/components/AdvancedChatSettings.qml @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 by Savoir-faire Linux + * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +import QtQuick 2.14 +import QtQuick.Layouts 1.14 +import QtQuick.Controls 2.14 + +import net.jami.Adapters 1.0 +import net.jami.Constants 1.0 + +import "../../commoncomponents" + +ColumnLayout { + id: root + + property int itemWidth + + function updateSettings() { + checkBoxSendDisplayed.checked = SettingsAdapter.getAccountConfig_ReadReceipt() + } + + ElidedTextLabel { + Layout.fillWidth: true + + eText: JamiStrings.chatSettings + fontSize: JamiTheme.headerFontSize + maxWidth: width + } + + ColumnLayout { + Layout.fillWidth: true + Layout.leftMargin: JamiTheme.preferredMarginSize + + ToggleSwitch { + id: checkBoxSendDisplayed + + tooltipText: JamiStrings.enableReadReceiptsTooltip + labelText: JamiStrings.enableReadReceipts + fontPointSize: JamiTheme.settingsFontSize + + onSwitchToggled: { + SettingsAdapter.setSendReadReceipt(checked) + } + } + } +} diff --git a/src/settingsview/components/AdvancedSettings.qml b/src/settingsview/components/AdvancedSettings.qml index b9cb3c450..f251097af 100644 --- a/src/settingsview/components/AdvancedSettings.qml +++ b/src/settingsview/components/AdvancedSettings.qml @@ -39,6 +39,7 @@ ColumnLayout { function updateAdvancedAccountInfos() { advancedCallSettings.updateCallSettingsInfos() + advancedChatSettings.updateSettings() advancedVoiceMailSettings.updateVoiceMailSettingsInfos() advancedSIPSecuritySettings.updateSecurityAccountInfos() advancedNameServerSettings.updateNameServerInfos() @@ -104,7 +105,16 @@ ColumnLayout { Layout.fillWidth: true - isSIP: root.isSIP + isSIP: LRCInstance.currentAccountType === Profile.Type.SIP + itemWidth: root.itemWidth + } + + AdvancedChatSettings { + id: advancedChatSettings + + Layout.fillWidth: true + + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -113,7 +123,7 @@ ColumnLayout { Layout.fillWidth: true - visible: root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.SIP itemWidth: root.itemWidth } @@ -122,7 +132,7 @@ ColumnLayout { Layout.fillWidth: true - visible: root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.SIP itemWidth: root.itemWidth } @@ -131,7 +141,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -140,7 +150,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -149,7 +159,7 @@ ColumnLayout { Layout.fillWidth: true - visible: !root.isSIP + visible: LRCInstance.currentAccountType === Profile.Type.JAMI itemWidth: root.itemWidth } @@ -159,7 +169,7 @@ ColumnLayout { Layout.fillWidth: true itemWidth: root.itemWidth - isSIP: root.isSIP + isSIP: LRCInstance.currentAccountType === Profile.Type.SIP } AdvancedPublicAddressSettings { -- GitLab