Skip to content

Commit

Permalink
Import config from filesystem on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
outspace committed Sep 1, 2023
1 parent cacf74a commit 1b3a32f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
6 changes: 4 additions & 2 deletions client/amnezia_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion client/platforms/ios/QtAppDelegate-C-Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
#include "ui/controllers/importController.h"

void QtAppDelegateInitialize();
void setImportController(ImportController*);

#endif // QTAPPDELEGATECINTERFACE_H
3 changes: 0 additions & 3 deletions client/platforms/ios/QtAppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#import <UIKit/UIKit.h>
#import "QtAppDelegate-C-Interface.h"

#include "ui/controllers/importController.h"

@interface QtAppDelegate : UIResponder <UIApplicationDelegate>
+(QtAppDelegate *)sharedQtAppDelegate;
@property (nonatomic) ImportController* ImportController;
@end
7 changes: 2 additions & 5 deletions client/platforms/ios/QtAppDelegate.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "QtAppDelegate.h"
#import "ios_controller.h"

#include <QFile>

Expand Down Expand Up @@ -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;
Expand All @@ -92,8 +93,4 @@ void QtAppDelegateInitialize()
NSLog(@"Created a new AppDelegate");
}

void setImportController(ImportController* controller) {
[QtAppDelegate sharedQtAppDelegate].ImportController = controller;
}

@end
1 change: 1 addition & 0 deletions client/platforms/ios/ios_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 1b3a32f

Please sign in to comment.