From 1b3a32f83f2cc7f64ff487c7e19d017871dd07f9 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Fri, 1 Sep 2023 14:49:10 +0300 Subject: [PATCH] Import config from filesystem on iOS --- client/amnezia_application.cpp | 6 ++++-- client/platforms/ios/QtAppDelegate-C-Interface.h | 1 - client/platforms/ios/QtAppDelegate.h | 3 --- client/platforms/ios/QtAppDelegate.mm | 7 ++----- client/platforms/ios/ios_controller.h | 1 + 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index d42d4cf99..64adb1d1e 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -21,7 +21,6 @@ #include "protocols/qml_register_protocols.h" #if defined(Q_OS_IOS) - #include "platforms/ios/QtAppDelegate-C-Interface.h" #include "platforms/ios/ios_controller.h" #endif @@ -112,7 +111,10 @@ void AmneziaApplication::init() #ifdef Q_OS_IOS IosController::Instance()->initialize(); - setImportController(m_importController.get()); + connect(IosController::Instance(), &IosController::importConfigFromOutside, m_importController.get(), + &ImportController::extractConfigFromData); + connect(IosController::Instance(), &IosController::importConfigFromOutside, m_pageController.get(), + &PageController::goToPageViewConfig); #endif m_notificationHandler.reset(NotificationHandler::create(nullptr)); diff --git a/client/platforms/ios/QtAppDelegate-C-Interface.h b/client/platforms/ios/QtAppDelegate-C-Interface.h index dd37dd2a3..39adbb923 100644 --- a/client/platforms/ios/QtAppDelegate-C-Interface.h +++ b/client/platforms/ios/QtAppDelegate-C-Interface.h @@ -4,6 +4,5 @@ #include "ui/controllers/importController.h" void QtAppDelegateInitialize(); -void setImportController(ImportController*); #endif // QTAPPDELEGATECINTERFACE_H diff --git a/client/platforms/ios/QtAppDelegate.h b/client/platforms/ios/QtAppDelegate.h index a32f1b646..cd8bae274 100644 --- a/client/platforms/ios/QtAppDelegate.h +++ b/client/platforms/ios/QtAppDelegate.h @@ -1,9 +1,6 @@ #import -#import "QtAppDelegate-C-Interface.h" #include "ui/controllers/importController.h" @interface QtAppDelegate : UIResponder -+(QtAppDelegate *)sharedQtAppDelegate; -@property (nonatomic) ImportController* ImportController; @end diff --git a/client/platforms/ios/QtAppDelegate.mm b/client/platforms/ios/QtAppDelegate.mm index 432fc1726..7528f2fff 100644 --- a/client/platforms/ios/QtAppDelegate.mm +++ b/client/platforms/ios/QtAppDelegate.mm @@ -1,4 +1,5 @@ #import "QtAppDelegate.h" +#import "ios_controller.h" #include @@ -79,7 +80,7 @@ - (BOOL)application:(UIApplication *)app bool isOpenFile = file.open(QIODevice::ReadOnly); QByteArray data = file.readAll(); - [QtAppDelegate sharedQtAppDelegate].ImportController->extractConfigFromData(QString(data)); + IosController::Instance()->importConfigFromOutside(QString(data)); return YES; } return NO; @@ -92,8 +93,4 @@ void QtAppDelegateInitialize() NSLog(@"Created a new AppDelegate"); } -void setImportController(ImportController* controller) { - [QtAppDelegate sharedQtAppDelegate].ImportController = controller; -} - @end diff --git a/client/platforms/ios/ios_controller.h b/client/platforms/ios/ios_controller.h index 4d1122b29..d6a12529e 100644 --- a/client/platforms/ios/ios_controller.h +++ b/client/platforms/ios/ios_controller.h @@ -49,6 +49,7 @@ class IosController : public QObject signals: void connectionStateChanged(Vpn::ConnectionState state); void bytesChanged(quint64 receivedBytes, quint64 sentBytes); + void importConfigFromOutside(const QString); protected slots: