diff --git a/Sources/Shared/Intents.intentdefinition b/Sources/Shared/Intents.intentdefinition
index 6f2d38c..74bbf1f 100644
--- a/Sources/Shared/Intents.intentdefinition
+++ b/Sources/Shared/Intents.intentdefinition
@@ -96,11 +96,11 @@
INIntentDefinitionNamespace
6NREiY
INIntentDefinitionSystemVersion
- 21C52
+ 21G419
INIntentDefinitionToolsBuildVersion
- 13C100
+ 14C18
INIntentDefinitionToolsVersion
- 13.2.1
+ 14.2
INIntents
@@ -447,271 +447,6 @@ Example
INIntentVerb
Do
-
- INIntentCategory
- toggle
- INIntentConfigurable
-
- INIntentDescription
- Enables or disables a tunnel.
-
-The action will not return an error if there are problems during the activation, it just launches the procedure.
- INIntentDescriptionID
- T7NEBw
- INIntentEligibleForWidgets
-
- INIntentLastParameterTag
- 4
- INIntentManagedParameterCombinations
-
- state,tunnel,operation
-
- INIntentParameterCombinationSupportsBackgroundExecution
-
- INIntentParameterCombinationTitle
- ${operation} ${tunnel} tunnel ${state}
- INIntentParameterCombinationTitleID
- juDVvv
- INIntentParameterCombinationUpdatesLinked
-
-
- tunnel,operation
-
- INIntentParameterCombinationSupportsBackgroundExecution
-
- INIntentParameterCombinationTitle
- ${operation} ${tunnel} tunnel
- INIntentParameterCombinationTitleID
- kMEAI0
-
-
- INIntentName
- SetTunnelStatus
- INIntentParameterCombinations
-
- state,tunnel,operation
-
- INIntentParameterCombinationIsLinked
-
- INIntentParameterCombinationSupportsBackgroundExecution
-
- INIntentParameterCombinationTitle
- ${operation} ${tunnel} tunnel ${state}
- INIntentParameterCombinationTitleID
- SjQ7Ur
-
-
- INIntentParameters
-
-
- INIntentParameterConfigurable
-
- INIntentParameterDisplayName
- Tunnel
- INIntentParameterDisplayNameID
- mbhQcc
- INIntentParameterDisplayPriority
- 1
- INIntentParameterMetadata
-
- INIntentParameterMetadataCapitalization
- Sentences
- INIntentParameterMetadataDefaultValueID
- iBD5fT
-
- INIntentParameterName
- tunnel
- INIntentParameterPromptDialogs
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogType
- Configuration
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogType
- Primary
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogFormatString
- There are ${count} options matching ‘${tunnel}’.
- INIntentParameterPromptDialogFormatStringID
- 73NvEc
- INIntentParameterPromptDialogType
- DisambiguationIntroduction
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogFormatString
- Just to confirm, you wanted ‘${tunnel}’?
- INIntentParameterPromptDialogFormatStringID
- 63TirR
- INIntentParameterPromptDialogType
- Confirmation
-
-
- INIntentParameterSupportsDynamicEnumeration
-
- INIntentParameterTag
- 2
- INIntentParameterType
- String
-
-
- INIntentParameterConfigurable
-
- INIntentParameterDisplayName
- Operation
- INIntentParameterDisplayNameID
- U9YFTG
- INIntentParameterDisplayPriority
- 2
- INIntentParameterEnumType
- Operation
- INIntentParameterEnumTypeNamespace
- 6NREiY
- INIntentParameterMetadata
-
- INIntentParameterMetadataDefaultValue
- turn
-
- INIntentParameterName
- operation
- INIntentParameterPromptDialogs
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogType
- Configuration
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogType
- Primary
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogFormatString
- There are ${count} options matching ‘${operation}’.
- INIntentParameterPromptDialogFormatStringID
- SALmBF
- INIntentParameterPromptDialogType
- DisambiguationIntroduction
-
-
- INIntentParameterPromptDialogCustom
-
- INIntentParameterPromptDialogFormatString
- Just to confirm, you wanted ‘${operation}’?
- INIntentParameterPromptDialogFormatStringID
- vB13mD
- INIntentParameterPromptDialogType
- Confirmation
-
-
- INIntentParameterTag
- 4
- INIntentParameterType
- Integer
-
-
- INIntentParameterConfigurable
-
- INIntentParameterDisplayName
- State
- INIntentParameterDisplayNameID
- sLIh6r
- INIntentParameterDisplayPriority
- 3
- INIntentParameterEnumType
- State
- INIntentParameterEnumTypeNamespace
- 6NREiY
- INIntentParameterMetadata
-
- INIntentParameterMetadataDefaultValue
- on
-
- INIntentParameterName
- state
- INIntentParameterRelationship
-
- INIntentParameterRelationshipParentName
- operation
- INIntentParameterRelationshipPredicateName
- EnumHasExactValue
- INIntentParameterRelationshipPredicateValue
- turn
-
- INIntentParameterTag
- 1
- INIntentParameterType
- Integer
-
-
- INIntentResponse
-
- INIntentResponseCodes
-
-
- INIntentResponseCodeName
- success
- INIntentResponseCodeSuccess
-
-
-
- INIntentResponseCodeName
- failure
-
-
- INIntentResponseLastParameterTag
- 1
- INIntentResponseParameters
-
-
- INIntentResponseParameterConfigurable
-
- INIntentResponseParameterCustomDisambiguation
-
- INIntentResponseParameterDisplayName
- State
- INIntentResponseParameterDisplayNameID
- TXqy56
- INIntentResponseParameterDisplayPriority
- 1
- INIntentResponseParameterEnumType
- State
- INIntentResponseParameterEnumTypeNamespace
- 6NREiY
- INIntentResponseParameterName
- state
- INIntentResponseParameterSupportsResolution
-
- INIntentResponseParameterTag
- 1
- INIntentResponseParameterType
- Integer
-
-
-
- INIntentTitle
- Set Tunnel Status
- INIntentTitleID
- HULmDn
- INIntentType
- Custom
- INIntentVerb
- Toggle
-
INTypes
diff --git a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift
index fbf29c4..7751e54 100644
--- a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift
+++ b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift
@@ -5,10 +5,6 @@ import Foundation
import NetworkExtension
import os.log
-#if os(iOS)
-import Intents
-#endif
-
protocol TunnelsManagerListDelegate: AnyObject {
func tunnelAdded(at index: Int)
func tunnelModified(at index: Int)
@@ -311,12 +307,6 @@ class TunnelsManager {
}
#elseif os(iOS)
(tunnelProviderManager.protocolConfiguration as? NETunnelProviderProtocol)?.destroyConfigurationReference()
-
- INInteraction.delete(with: "com.wireguard.intents.tunnel.\(tunnel.name)") { error in
- if let error = error {
- wg_log(.error, message: "Error deleting donated interactions for tunnel \(tunnel.name): \(error.localizedDescription)")
- }
- }
#else
#error("Unimplemented")
#endif
diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift
index 74a8149..6aab559 100644
--- a/Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift
+++ b/Sources/WireGuardApp/UI/iOS/ViewController/MainViewController.swift
@@ -2,7 +2,6 @@
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit
-import Intents
class MainViewController: UISplitViewController {
@@ -97,25 +96,10 @@ extension MainViewController {
if let tunnel = tunnelsManager.tunnel(named: tunnelName) {
tunnelsListVC.showTunnelDetail(for: tunnel, animated: false)
if shouldToggleStatus {
-
- let intent = SetTunnelStatusIntent()
- intent.tunnel = tunnel.name
- intent.operation = .turn
-
if tunnel.status == .inactive {
tunnelsManager.startActivation(of: tunnel)
- intent.state = .on
} else if tunnel.status == .active {
tunnelsManager.startDeactivation(of: tunnel)
- intent.state = .off
- }
-
- let interaction = INInteraction(intent: intent, response: nil)
- interaction.groupIdentifier = "com.wireguard.intents.tunnel.\(tunnel.name)"
- interaction.donate { error in
- if let error = error {
- wg_log(.error, message: "Error donating interaction for SetTunnelStatusIntent: \(error.localizedDescription)")
- }
}
}
}
diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift
index 0361d44..2c185d9 100644
--- a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift
+++ b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift
@@ -388,18 +388,6 @@ extension TunnelDetailTableViewController {
cell.onSwitchToggled = { [weak self] isOn in
guard let self = self else { return }
- let intent = SetTunnelStatusIntent()
- intent.tunnel = self.tunnel.name
- intent.operation = .turn
- intent.state = isOn ? .on : .off
- let interaction = INInteraction(intent: intent, response: nil)
- interaction.groupIdentifier = "com.wireguard.intents.tunnel.\(self.tunnel.name)"
- interaction.donate { error in
- if let error = error {
- wg_log(.error, message: "Error donating interaction for SetTunnelStatusIntent: \(error.localizedDescription)")
- }
- }
-
if self.tunnel.hasOnDemandRules {
self.tunnelsManager.setOnDemandEnabled(isOn, on: self.tunnel) { error in
if error == nil && !isOn {
diff --git a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
index c5132a2..85e64ce 100644
--- a/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
+++ b/Sources/WireGuardApp/UI/iOS/ViewController/TunnelsListTableViewController.swift
@@ -4,7 +4,6 @@
import UIKit
import MobileCoreServices
import UserNotifications
-import Intents
class TunnelsListTableViewController: UIViewController {
@@ -318,19 +317,6 @@ extension TunnelsListTableViewController: UITableViewDataSource {
cell.tunnel = tunnel
cell.onSwitchToggled = { [weak self] isOn in
guard let self = self, let tunnelsManager = self.tunnelsManager else { return }
-
- let intent = SetTunnelStatusIntent()
- intent.tunnel = tunnel.name
- intent.operation = .turn
- intent.state = isOn ? .on : .off
- let interaction = INInteraction(intent: intent, response: nil)
- interaction.groupIdentifier = "com.wireguard.intents.tunnel.\(tunnel.name)"
- interaction.donate { error in
- if let error = error {
- wg_log(.error, message: "Error donating interaction for SetTunnelStatusIntent: \(error.localizedDescription)")
- }
- }
-
if tunnel.hasOnDemandRules {
tunnelsManager.setOnDemandEnabled(isOn, on: tunnel) { error in
if error == nil && !isOn {
diff --git a/Sources/WireGuardIntentsExtension/IntentHandler.swift b/Sources/WireGuardIntentsExtension/IntentHandler.swift
index 6f19951..a3527ef 100644
--- a/Sources/WireGuardIntentsExtension/IntentHandler.swift
+++ b/Sources/WireGuardIntentsExtension/IntentHandler.swift
@@ -12,8 +12,7 @@ class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any {
guard intent is GetPeersIntent ||
- intent is UpdateConfigurationIntent ||
- intent is SetTunnelStatusIntent else {
+ intent is UpdateConfigurationIntent else {
fatalError("Unhandled intent type: \(intent)")
}
diff --git a/Sources/WireGuardIntentsExtension/IntentHandling.swift b/Sources/WireGuardIntentsExtension/IntentHandling.swift
index 78004e0..1de3d46 100644
--- a/Sources/WireGuardIntentsExtension/IntentHandling.swift
+++ b/Sources/WireGuardIntentsExtension/IntentHandling.swift
@@ -15,8 +15,6 @@ class IntentHandling: NSObject {
var onTunnelsManagerReady: ((TunnelsManager) -> Void)?
- var onTunnelStatusActivationReturn: ((Bool) -> Void)?
-
override init() {
super.init()
@@ -29,8 +27,6 @@ class IntentHandling: NSObject {
case .success(let tunnelsManager):
self.tunnelsManager = tunnelsManager
- self.tunnelsManager?.activationDelegate = self
-
self.onTunnelsManagerReady?(tunnelsManager)
self.onTunnelsManagerReady = nil
}
@@ -174,129 +170,3 @@ extension IntentHandling: UpdateConfigurationIntentHandling {
}
}
-
-extension IntentHandling: SetTunnelStatusIntentHandling {
-
- @available(iOSApplicationExtension 14.0, *)
- func provideTunnelOptionsCollection(for intent: SetTunnelStatusIntent, with completion: @escaping (INObjectCollection?, Error?) -> Void) {
-
- self.allTunnelNames { tunnelsNames in
- let tunnelsNamesObjects = (tunnelsNames ?? []).map { NSString(string: $0) }
-
- let objectCollection = INObjectCollection(items: tunnelsNamesObjects)
- completion(objectCollection, nil)
- }
- }
-
- func handle(intent: SetTunnelStatusIntent, completion: @escaping (SetTunnelStatusIntentResponse) -> Void) {
- guard let tunnelName = intent.tunnel else {
- return completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- }
-
- let setTunnelStatusResultBlock: (Bool) -> Void = { result in
- if result {
- completion(SetTunnelStatusIntentResponse(code: .success, userActivity: nil))
- } else {
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- }
- }
-
- let updateStatusBlock: (TunnelsManager) -> Void = { tunnelsManager in
- guard let tunnel = tunnelsManager.tunnel(named: tunnelName) else {
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- return
- }
-
- let operation = intent.operation
- let isOn: Bool
-
- if operation == .toggle {
- switch tunnel.status {
- case .inactive:
- isOn = true
- case .active:
- isOn = false
- default:
- wg_log(.error, message: "SetTunnelStatusIntent action cannot be executed due to the current state of \(tunnelName) tunnel: \(tunnel.status)")
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- return
- }
-
- } else if operation == .turn {
- if (tunnel.status == .inactive) || (tunnel.status == .active) {
- isOn = (intent.state == .on)
-
- if (isOn && tunnel.status == .active) || (!isOn && tunnel.status == .inactive) {
- wg_log(.debug, message: "Tunnel \(tunnelName) is already \(isOn ? "active" : "inactive")")
- completion(SetTunnelStatusIntentResponse(code: .success, userActivity: nil))
- return
- }
- } else {
- wg_log(.error, message: "SetTunnelStatusIntent action cannot be executed due to the current state of \(tunnelName) tunnel: \(tunnel.status)")
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- return
- }
-
- } else {
- wg_log(.error, message: "Invalid 'operation' option in action")
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- return
- }
-
- if tunnel.hasOnDemandRules {
- tunnelsManager.setOnDemandEnabled(isOn, on: tunnel) { error in
- guard error == nil else {
- wg_log(.error, message: "Error setting OnDemand status: \(error!.localizedDescription).")
- completion(SetTunnelStatusIntentResponse(code: .failure, userActivity: nil))
- return
- }
-
- if !isOn {
- tunnelsManager.startDeactivation(of: tunnel)
- }
-
- completion(SetTunnelStatusIntentResponse(code: .success, userActivity: nil))
- }
- } else {
- if isOn {
- self.onTunnelStatusActivationReturn = setTunnelStatusResultBlock
- tunnelsManager.startActivation(of: tunnel)
- } else {
- tunnelsManager.startDeactivation(of: tunnel)
- completion(SetTunnelStatusIntentResponse(code: .success, userActivity: nil))
- }
- }
- }
-
- if let tunnelsManager = tunnelsManager {
- updateStatusBlock(tunnelsManager)
- } else {
- if onTunnelsManagerReady != nil {
- wg_log(.error, message: "Overriding onTunnelsManagerReady action in allTunnelPeers function. This should not happen.")
- }
- onTunnelsManagerReady = updateStatusBlock
- }
- }
-
-}
-
-extension IntentHandling: TunnelsManagerActivationDelegate {
- func tunnelActivationAttemptFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationAttemptError) {
- wg_log(.error, message: "Tunnel Activation Attempt Failed with error: \(error.localizedDescription)")
- self.onTunnelStatusActivationReturn?(false)
- }
-
- func tunnelActivationAttemptSucceeded(tunnel: TunnelContainer) {
- // Nothing to do, we wait tunnelActivationSucceeded to be sure all activation logic has been executed
- }
-
- func tunnelActivationFailed(tunnel: TunnelContainer, error: TunnelsManagerActivationError) {
- wg_log(.error, message: "Tunnel Activation Failed with error: \(error.localizedDescription)")
- self.onTunnelStatusActivationReturn?(false)
- }
-
- func tunnelActivationSucceeded(tunnel: TunnelContainer) {
- self.onTunnelStatusActivationReturn?(true)
- }
-
-}