summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-11-01 10:50:52 +0100
committerAndrej Mihajlov <and@mullvad.net>2022-11-01 10:50:52 +0100
commitffbb2b5f6a7dd26f737e99379f60e8cf839b9517 (patch)
treec985cccfd0f7b36e247a9c83c9ab8cb77969f905
parentb413068b48f416c98b69ac5b075ab81295382c2e (diff)
parentd625ce6f26457d66a15855c84090bb9620170f6b (diff)
downloadmullvadvpn-ffbb2b5f6a7dd26f737e99379f60e8cf839b9517.tar.xz
mullvadvpn-ffbb2b5f6a7dd26f737e99379f60e8cf839b9517.zip
Merge branch 'intents-no-shared'
-rw-r--r--ios/MullvadVPN/AppDelegate.swift6
-rw-r--r--ios/MullvadVPN/IntentHandlers.swift26
2 files changed, 24 insertions, 8 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift
index 8776da06e9..75f41f0fb2 100644
--- a/ios/MullvadVPN/AppDelegate.swift
+++ b/ios/MullvadVPN/AppDelegate.swift
@@ -79,11 +79,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any? {
switch intent {
case is StartVPNIntent:
- return StartVPNIntentHandler()
+ return StartVPNIntentHandler(tunnelManager: .shared)
case is StopVPNIntent:
- return StopVPNIntentHandler()
+ return StopVPNIntentHandler(tunnelManager: .shared)
case is ReconnectVPNIntent:
- return ReconnectVPNIntentHandler()
+ return ReconnectVPNIntentHandler(tunnelManager: .shared)
default:
return nil
}
diff --git a/ios/MullvadVPN/IntentHandlers.swift b/ios/MullvadVPN/IntentHandlers.swift
index 36ad4b3bd6..434f09b8fe 100644
--- a/ios/MullvadVPN/IntentHandlers.swift
+++ b/ios/MullvadVPN/IntentHandlers.swift
@@ -9,8 +9,14 @@
import Foundation
final class StartVPNIntentHandler: NSObject, StartVPNIntentHandling {
+ private let tunnelManager: TunnelManager
+
+ init(tunnelManager: TunnelManager) {
+ self.tunnelManager = tunnelManager
+ }
+
func handle(intent: StartVPNIntent, completion: @escaping (StartVPNIntentResponse) -> Void) {
- TunnelManager.shared.startTunnel { operationCompletion in
+ tunnelManager.startTunnel { operationCompletion in
let code: StartVPNIntentResponseCode = operationCompletion.isSuccess
? .success
: .failure
@@ -22,8 +28,14 @@ final class StartVPNIntentHandler: NSObject, StartVPNIntentHandling {
}
final class StopVPNIntentHandler: NSObject, StopVPNIntentHandling {
+ private let tunnelManager: TunnelManager
+
+ init(tunnelManager: TunnelManager) {
+ self.tunnelManager = tunnelManager
+ }
+
func handle(intent: StopVPNIntent, completion: @escaping (StopVPNIntentResponse) -> Void) {
- TunnelManager.shared.stopTunnel { operationCompletion in
+ tunnelManager.stopTunnel { operationCompletion in
let code: StopVPNIntentResponseCode = operationCompletion.isSuccess
? .success
: .failure
@@ -35,12 +47,16 @@ final class StopVPNIntentHandler: NSObject, StopVPNIntentHandling {
}
final class ReconnectVPNIntentHandler: NSObject, ReconnectVPNIntentHandling {
+ private let tunnelManager: TunnelManager
+
+ init(tunnelManager: TunnelManager) {
+ self.tunnelManager = tunnelManager
+ }
+
func handle(
intent: ReconnectVPNIntent,
completion: @escaping (ReconnectVPNIntentResponse) -> Void
) {
- let tunnelManager = TunnelManager.shared
-
tunnelManager.reconnectTunnel(selectNewRelay: true) { operationCompletion in
let error = operationCompletion.error
@@ -52,7 +68,7 @@ final class ReconnectVPNIntentHandler: NSObject, ReconnectVPNIntentHandling {
}
if shouldStartTunnel {
- tunnelManager.startTunnel { operationCompletion in
+ self.tunnelManager.startTunnel { operationCompletion in
completion(
ReconnectVPNIntentResponse(
code: operationCompletion.isSuccess ? .success : .failure,