From 195a3ab170eb23e749cf1edf7f257d6867371c97 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Fri, 1 Sep 2023 17:29:48 +0300 Subject: [PATCH] Save files for iOS --- client/fileUtilites.cpp | 5 +++-- client/platforms/ios/QtAppDelegate-C-Interface.h | 2 -- client/platforms/ios/QtAppDelegate.h | 2 -- client/ui/qml/Components/ShareConnectionDrawer.qml | 8 +++++++- client/ui/qml/Pages2/PageSettingsLogging.qml | 8 +++++++- client/ui/qml/Pages2/PageSettingsSplitTunneling.qml | 6 +++++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/client/fileUtilites.cpp b/client/fileUtilites.cpp index 9cbc5a105..301344a77 100644 --- a/client/fileUtilites.cpp +++ b/client/fileUtilites.cpp @@ -24,7 +24,8 @@ void FileUtilites::saveFile(QString fileName, const QString &data) #endif #ifdef Q_OS_IOS - QFile file(fileName); + QUrl fileUrl = QDir::tempPath() + "/" + fileName; + QFile file(fileUrl.toString()); #else QUrl fileUrl = QUrl(fileName); QFile file(fileUrl.toLocalFile()); @@ -37,7 +38,7 @@ void FileUtilites::saveFile(QString fileName, const QString &data) #ifdef Q_OS_IOS QStringList filesToSend; - filesToSend.append(fileName); + filesToSend.append(fileUrl.toString()); MobileUtils::shareText(filesToSend); return; #else diff --git a/client/platforms/ios/QtAppDelegate-C-Interface.h b/client/platforms/ios/QtAppDelegate-C-Interface.h index 39adbb923..dd358097a 100644 --- a/client/platforms/ios/QtAppDelegate-C-Interface.h +++ b/client/platforms/ios/QtAppDelegate-C-Interface.h @@ -1,8 +1,6 @@ #ifndef QTAPPDELEGATECINTERFACE_H #define QTAPPDELEGATECINTERFACE_H -#include "ui/controllers/importController.h" - void QtAppDelegateInitialize(); #endif // QTAPPDELEGATECINTERFACE_H diff --git a/client/platforms/ios/QtAppDelegate.h b/client/platforms/ios/QtAppDelegate.h index cd8bae274..5148c2ca9 100644 --- a/client/platforms/ios/QtAppDelegate.h +++ b/client/platforms/ios/QtAppDelegate.h @@ -1,6 +1,4 @@ #import -#include "ui/controllers/importController.h" - @interface QtAppDelegate : UIResponder @end diff --git a/client/ui/qml/Components/ShareConnectionDrawer.qml b/client/ui/qml/Components/ShareConnectionDrawer.qml index 41dd2ab2d..8f4498a94 100644 --- a/client/ui/qml/Components/ShareConnectionDrawer.qml +++ b/client/ui/qml/Components/ShareConnectionDrawer.qml @@ -69,7 +69,13 @@ DrawerType { text: qsTr("Share") imageSource: "qrc:/images/controls/share-2.svg" - onClicked: fileDialog.open() + onClicked: { + if (Qt.platform.os === "ios") { + ExportController.saveFile("amnezia_config.vpn") + } else { + fileDialog.open() + } + } FileDialog { id: fileDialog diff --git a/client/ui/qml/Pages2/PageSettingsLogging.qml b/client/ui/qml/Pages2/PageSettingsLogging.qml index cfe7d7c99..0e4e486ec 100644 --- a/client/ui/qml/Pages2/PageSettingsLogging.qml +++ b/client/ui/qml/Pages2/PageSettingsLogging.qml @@ -100,7 +100,13 @@ PageType { image: "qrc:/images/controls/save.svg" - onClicked: fileDialog.open() + onClicked: { + if (Qt.platform.os === "ios") { + SettingsController.exportLogsFile("AmneziaVPN.log") + } else { + fileDialog.open() + } + } FileDialog { id: fileDialog diff --git a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml index e074b4ce1..898ce17ba 100644 --- a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml +++ b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml @@ -302,7 +302,11 @@ PageType { text: qsTr("Save site list") clickedFunction: function() { - saveFileDialog.open() + if (Qt.platform.os === "ios") { + ExportController.saveFile("amezia_tunnel.json") + } else { + saveFileDialog.open() + } } FileDialog {