diff --git a/qml.qrc b/qml.qrc
index c33ffabb..233a6e2f 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -33,6 +33,7 @@
src/commoncomponents/SpinningAnimation.qml
src/settingsview/SettingsView.qml
src/settingsview/components/ChatviewSettings.qml
+ src/settingsview/components/FileTransferSettings.qml
src/settingsview/components/SettingsMenu.qml
src/settingsview/components/SettingsHeader.qml
src/settingsview/components/SystemSettings.qml
diff --git a/src/appsettingsmanager.h b/src/appsettingsmanager.h
index d3b08111..6ff083ff 100644
--- a/src/appsettingsmanager.h
+++ b/src/appsettingsmanager.h
@@ -36,6 +36,9 @@ const QString defaultDownloadPath = QStandardPaths::writableLocation(
X(DownloadPath, defaultDownloadPath) \
X(EnableNotifications, true) \
X(EnableTypingIndicator, true) \
+ X(AllowFromUntrusted, false) \
+ X(AcceptTransferBelow, 20) \
+ X(AutoAcceptFiles, true) \
X(DisplayHyperlinkPreviews, true) \
X(EnableDarkTheme, false) \
X(AutoUpdate, true) \
diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml
index b6223327..dfc4c83d 100644
--- a/src/constant/JamiStrings.qml
+++ b/src/constant/JamiStrings.qml
@@ -321,6 +321,13 @@ Item {
property string enableTypingIndicator: qsTr("Enable typing indicators")
property string displayHyperlinkPreviews: qsTr("Display hyperlink previews in the chatview")
+ // File transfer settings
+ property string fileTransfer: qsTr("File transfer")
+ property string allowFromUntrusted: qsTr("Allow incoming files from unknown contacts")
+ property string autoAcceptFiles: qsTr("Automatically accept incoming files")
+ property string acceptTransferBelow: qsTr("Accept transfer limit")
+ property string acceptTransferTooltip: qsTr("in MB, 0 = unlimited")
+
// Updates
property string betaInstall: qsTr("Install beta version")
property string checkForUpdates: qsTr("Check for updates now")
diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp
index 2e07c911..26d8200c 100644
--- a/src/mainapplication.cpp
+++ b/src/mainapplication.cpp
@@ -263,7 +263,15 @@ MainApplication::init()
}
auto downloadPath = settingsManager_->getValue(Settings::Key::DownloadPath);
+ auto allowTransferFromUntrusted = settingsManager_->getValue(Settings::Key::AllowFromUntrusted)
+ .toBool();
+ auto allowTransferFromTrusted = settingsManager_->getValue(Settings::Key::AutoAcceptFiles)
+ .toBool();
+ auto acceptTransferBelow = settingsManager_->getValue(Settings::Key::AcceptTransferBelow).toInt();
lrcInstance_->accountModel().downloadDirectory = downloadPath.toString() + "/";
+ lrcInstance_->accountModel().autoTransferFromUntrusted = allowTransferFromUntrusted;
+ lrcInstance_->accountModel().autoTransferFromTrusted = allowTransferFromTrusted;
+ lrcInstance_->accountModel().autoTransferSizeThreshold = acceptTransferBelow;
initQmlLayer();
initSystray();
diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp
index 1702aaee..3c60c243 100644
--- a/src/settingsadapter.cpp
+++ b/src/settingsadapter.cpp
@@ -897,6 +897,27 @@ SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value)
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
+void
+SettingsAdapter::autoAcceptFiles(bool value)
+{
+ lrcInstance_->accountModel().autoTransferFromTrusted = value;
+ setAppValue(Settings::Key::AutoAcceptFiles, value);
+}
+
+void
+SettingsAdapter::allowFromUntrusted(bool value)
+{
+ lrcInstance_->accountModel().autoTransferFromUntrusted = value;
+ setAppValue(Settings::Key::AllowFromUntrusted, value);
+}
+
+void
+SettingsAdapter::acceptTransferBelow(int value)
+{
+ lrcInstance_->accountModel().autoTransferSizeThreshold = value;
+ setAppValue(Settings::Key::AcceptTransferBelow, value);
+}
+
void
SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value)
{
diff --git a/src/settingsadapter.h b/src/settingsadapter.h
index cc06b307..7b5d9efc 100644
--- a/src/settingsadapter.h
+++ b/src/settingsadapter.h
@@ -202,6 +202,10 @@ public:
Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value);
Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(int value);
+ Q_INVOKABLE void autoAcceptFiles(bool value);
+ Q_INVOKABLE void allowFromUntrusted(bool value);
+ Q_INVOKABLE void acceptTransferBelow(int value);
+
Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int& index);
Q_INVOKABLE void setDeviceName(QString text);
diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml
index 75e783ac..1c11c5ea 100644
--- a/src/settingsview/SettingsView.qml
+++ b/src/settingsview/SettingsView.qml
@@ -61,6 +61,7 @@ Rectangle {
pageIdCurrentAccountSettings.updateAccountInfoDisplayed()
break
case SettingsView.General:
+ generalSettings.updateValues()
AccountAdapter.stopPreviewing()
selectedMenu = sel
break
diff --git a/src/settingsview/components/FileTransferSettings.qml b/src/settingsview/components/FileTransferSettings.qml
new file mode 100644
index 00000000..894e28b5
--- /dev/null
+++ b/src/settingsview/components/FileTransferSettings.qml
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 by Savoir-faire Linux
+ * Author: Sébastien Blin
+ *
+ * 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 .
+ */
+
+import QtQuick 2.14
+import QtQuick.Controls 2.14
+import QtQuick.Layouts 1.14
+
+import net.jami.Adapters 1.0
+import net.jami.Enums 1.0
+import net.jami.Constants 1.0
+
+ColumnLayout {
+ id:root
+
+ property int itemWidth
+
+ function updateValues() {
+ acceptTransferBelowSpinBox.setValue(SettingsAdapter.getAppValue(Settings.AcceptTransferBelow))
+ allowFromUntrustedCheckbox.checked = SettingsAdapter.getAppValue(Settings.AllowFromUntrusted)
+ autoAcceptFilesCheckbox.checked = SettingsAdapter.getAppValue(Settings.AutoAcceptFiles)
+ }
+
+ Label {
+ Layout.fillWidth: true
+
+ text: JamiStrings.fileTransfer
+ font.pointSize: JamiTheme.headerFontSize
+ font.kerning: true
+ color: JamiTheme.textColor
+
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ ToggleSwitch {
+ id: allowFromUntrustedCheckbox
+ Layout.fillWidth: true
+ Layout.leftMargin: JamiTheme.preferredMarginSize
+
+ checked: SettingsAdapter.getAppValue(Settings.AllowFromUntrusted)
+
+ labelText: JamiStrings.allowFromUntrusted
+ fontPointSize: JamiTheme.settingsFontSize
+
+ tooltipText: JamiStrings.allowFromUntrusted
+
+ onSwitchToggled: SettingsAdapter.allowFromUntrusted(checked)
+ }
+
+ ToggleSwitch {
+ id: autoAcceptFilesCheckbox
+ Layout.fillWidth: true
+ Layout.leftMargin: JamiTheme.preferredMarginSize
+
+ checked: SettingsAdapter.getAppValue(Settings.AutoAcceptFiles)
+
+ labelText: JamiStrings.autoAcceptFiles
+ fontPointSize: JamiTheme.settingsFontSize
+
+ tooltipText: JamiStrings.autoAcceptFiles
+
+ onSwitchToggled: SettingsAdapter.autoAcceptFiles(checked)
+ }
+
+ SettingSpinBox {
+ id: acceptTransferBelowSpinBox
+ Layout.fillWidth: true
+ Layout.leftMargin: JamiTheme.preferredMarginSize
+
+ title: JamiStrings.acceptTransferBelow
+ tooltipText: JamiStrings.acceptTransferTooltip
+ itemWidth: root.itemWidth
+ bottomValue: 0
+ topValue: 99999999
+ step: 1
+
+ onNewValue: SettingsAdapter.acceptTransferBelow(valueField)
+ }
+}
diff --git a/src/settingsview/components/GeneralSettingsPage.qml b/src/settingsview/components/GeneralSettingsPage.qml
index b14be389..de6328b7 100644
--- a/src/settingsview/components/GeneralSettingsPage.qml
+++ b/src/settingsview/components/GeneralSettingsPage.qml
@@ -39,6 +39,10 @@ Rectangle {
color: JamiTheme.secondaryBackgroundColor
+ function updateValues() {
+ fileTransferSettings.updateValues()
+ }
+
ColumnLayout {
id: generalSettingsColumnLayout
@@ -66,6 +70,17 @@ Rectangle {
itemWidth: preferredColumnWidth
}
+ // file transfer setting panel
+ FileTransferSettings {
+ id: fileTransferSettings
+ Layout.fillWidth: true
+ Layout.topMargin: JamiTheme.preferredMarginSize
+ Layout.leftMargin: JamiTheme.preferredMarginSize
+ Layout.rightMargin: JamiTheme.preferredMarginSize
+
+ itemWidth: preferredColumnWidth
+ }
+
// call recording setting panel
RecordingSettings {
Layout.fillWidth: true
diff --git a/src/settingsview/components/SettingSpinBox.qml b/src/settingsview/components/SettingSpinBox.qml
index 58d4d67c..e749e728 100644
--- a/src/settingsview/components/SettingSpinBox.qml
+++ b/src/settingsview/components/SettingSpinBox.qml
@@ -39,6 +39,7 @@ RowLayout {
property int topValue
property int step
property int valueField
+ property string tooltipText: ""
signal newValue
@@ -87,5 +88,10 @@ RowLayout {
border.color: enabled? root.borderColor : "transparent"
color: JamiTheme.editBackgroundColor
}
+
+ hoverEnabled: true
+ ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
+ ToolTip.visible: hovered && (root.tooltipText.length > 0)
+ ToolTip.text: root.tooltipText
}
}