Skip to content

Commit d05a169

Browse files
committed
Removed UpdateConfigurationIntent SiriKit Intent
Signed-off-by: Alessio Nossa <[email protected]>
1 parent bee5d34 commit d05a169

File tree

6 files changed

+3
-418
lines changed

6 files changed

+3
-418
lines changed

Diff for: Sources/Shared/Intents.intentdefinition

+1-212
Original file line numberDiff line numberDiff line change
@@ -15,218 +15,7 @@
1515
<key>INIntentDefinitionToolsVersion</key>
1616
<string>14.2</string>
1717
<key>INIntents</key>
18-
<array>
19-
<dict>
20-
<key>INIntentCategory</key>
21-
<string>generic</string>
22-
<key>INIntentConfigurable</key>
23-
<true/>
24-
<key>INIntentDescription</key>
25-
<string>Update peers configuration. Configuration must be provided with the same format as the following example. The fields you can update are: "Endpoint".
26-
The fields and the peers you omit will not be modified.
27-
28-
Example
29-
{ "Peer1 Public Key (Base64)": { "Endpoint": "1.2.3.4:4321" },
30-
"Peer2 Public Key (Base64)": {"Endpoint": "10.11.12.13:6789"} }</string>
31-
<key>INIntentDescriptionID</key>
32-
<string>uTimVO</string>
33-
<key>INIntentIneligibleForSuggestions</key>
34-
<true/>
35-
<key>INIntentInput</key>
36-
<string>configuration</string>
37-
<key>INIntentLastParameterTag</key>
38-
<integer>5</integer>
39-
<key>INIntentManagedParameterCombinations</key>
40-
<dict>
41-
<key>tunnel,configuration,completionUrl</key>
42-
<dict>
43-
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
44-
<true/>
45-
<key>INIntentParameterCombinationTitle</key>
46-
<string>Update ${tunnel} configuration</string>
47-
<key>INIntentParameterCombinationTitleID</key>
48-
<string>2ASDIM</string>
49-
<key>INIntentParameterCombinationUpdatesLinked</key>
50-
<true/>
51-
</dict>
52-
</dict>
53-
<key>INIntentName</key>
54-
<string>UpdateConfiguration</string>
55-
<key>INIntentParameters</key>
56-
<array>
57-
<dict>
58-
<key>INIntentParameterConfigurable</key>
59-
<true/>
60-
<key>INIntentParameterDisplayName</key>
61-
<string>Tunnel</string>
62-
<key>INIntentParameterDisplayNameID</key>
63-
<string>TjOtzk</string>
64-
<key>INIntentParameterDisplayPriority</key>
65-
<integer>1</integer>
66-
<key>INIntentParameterMetadata</key>
67-
<dict>
68-
<key>INIntentParameterMetadataCapitalization</key>
69-
<string>Sentences</string>
70-
<key>INIntentParameterMetadataDefaultValueID</key>
71-
<string>h56bAD</string>
72-
</dict>
73-
<key>INIntentParameterName</key>
74-
<string>tunnel</string>
75-
<key>INIntentParameterPromptDialogs</key>
76-
<array>
77-
<dict>
78-
<key>INIntentParameterPromptDialogCustom</key>
79-
<true/>
80-
<key>INIntentParameterPromptDialogType</key>
81-
<string>Configuration</string>
82-
</dict>
83-
<dict>
84-
<key>INIntentParameterPromptDialogCustom</key>
85-
<true/>
86-
<key>INIntentParameterPromptDialogType</key>
87-
<string>Primary</string>
88-
</dict>
89-
</array>
90-
<key>INIntentParameterSupportsDynamicEnumeration</key>
91-
<true/>
92-
<key>INIntentParameterTag</key>
93-
<integer>1</integer>
94-
<key>INIntentParameterType</key>
95-
<string>String</string>
96-
</dict>
97-
<dict>
98-
<key>INIntentParameterConfigurable</key>
99-
<true/>
100-
<key>INIntentParameterDisplayName</key>
101-
<string>Configuration</string>
102-
<key>INIntentParameterDisplayNameID</key>
103-
<string>3SLMhb</string>
104-
<key>INIntentParameterDisplayPriority</key>
105-
<integer>2</integer>
106-
<key>INIntentParameterMetadata</key>
107-
<dict>
108-
<key>INIntentParameterMetadataCapitalization</key>
109-
<string>None</string>
110-
<key>INIntentParameterMetadataDefaultValue</key>
111-
<string>{"Peer Public Key": {"Endpoint":"1.2.3.4:5678"} }</string>
112-
<key>INIntentParameterMetadataDefaultValueID</key>
113-
<string>1J2FBa</string>
114-
<key>INIntentParameterMetadataDisableAutocorrect</key>
115-
<true/>
116-
<key>INIntentParameterMetadataDisableSmartDashes</key>
117-
<true/>
118-
<key>INIntentParameterMetadataDisableSmartQuotes</key>
119-
<true/>
120-
<key>INIntentParameterMetadataMultiline</key>
121-
<true/>
122-
</dict>
123-
<key>INIntentParameterName</key>
124-
<string>configuration</string>
125-
<key>INIntentParameterPromptDialogs</key>
126-
<array>
127-
<dict>
128-
<key>INIntentParameterPromptDialogCustom</key>
129-
<true/>
130-
<key>INIntentParameterPromptDialogType</key>
131-
<string>Configuration</string>
132-
</dict>
133-
<dict>
134-
<key>INIntentParameterPromptDialogCustom</key>
135-
<true/>
136-
<key>INIntentParameterPromptDialogType</key>
137-
<string>Primary</string>
138-
</dict>
139-
</array>
140-
<key>INIntentParameterTag</key>
141-
<integer>2</integer>
142-
<key>INIntentParameterType</key>
143-
<string>String</string>
144-
</dict>
145-
<dict>
146-
<key>INIntentParameterConfigurable</key>
147-
<true/>
148-
<key>INIntentParameterDisplayName</key>
149-
<string>Open URL when done</string>
150-
<key>INIntentParameterDisplayNameID</key>
151-
<string>dwpgmC</string>
152-
<key>INIntentParameterDisplayPriority</key>
153-
<integer>3</integer>
154-
<key>INIntentParameterMetadata</key>
155-
<dict>
156-
<key>INIntentParameterMetadataCapitalization</key>
157-
<string>None</string>
158-
<key>INIntentParameterMetadataDefaultValue</key>
159-
<string>shortcuts://</string>
160-
<key>INIntentParameterMetadataDefaultValueID</key>
161-
<string>cyr6LU</string>
162-
<key>INIntentParameterMetadataDisableAutocorrect</key>
163-
<true/>
164-
<key>INIntentParameterMetadataDisableSmartDashes</key>
165-
<true/>
166-
<key>INIntentParameterMetadataDisableSmartQuotes</key>
167-
<true/>
168-
</dict>
169-
<key>INIntentParameterName</key>
170-
<string>completionUrl</string>
171-
<key>INIntentParameterPromptDialogs</key>
172-
<array>
173-
<dict>
174-
<key>INIntentParameterPromptDialogCustom</key>
175-
<true/>
176-
<key>INIntentParameterPromptDialogType</key>
177-
<string>Configuration</string>
178-
</dict>
179-
<dict>
180-
<key>INIntentParameterPromptDialogCustom</key>
181-
<true/>
182-
<key>INIntentParameterPromptDialogType</key>
183-
<string>Primary</string>
184-
</dict>
185-
</array>
186-
<key>INIntentParameterTag</key>
187-
<integer>5</integer>
188-
<key>INIntentParameterType</key>
189-
<string>String</string>
190-
</dict>
191-
</array>
192-
<key>INIntentResponse</key>
193-
<dict>
194-
<key>INIntentResponseCodes</key>
195-
<array>
196-
<dict>
197-
<key>INIntentResponseCodeName</key>
198-
<string>success</string>
199-
<key>INIntentResponseCodeSuccess</key>
200-
<true/>
201-
</dict>
202-
<dict>
203-
<key>INIntentResponseCodeName</key>
204-
<string>failure</string>
205-
</dict>
206-
<dict>
207-
<key>INIntentResponseCodeConciseFormatString</key>
208-
<string>The configuration update provided is not in the right format. Make sure you pass configuration as described in Action description.</string>
209-
<key>INIntentResponseCodeConciseFormatStringID</key>
210-
<string>xB99X4</string>
211-
<key>INIntentResponseCodeFormatString</key>
212-
<string>The configuration update provided is not in the right format. Make sure you pass configuration as described in Action description.</string>
213-
<key>INIntentResponseCodeFormatStringID</key>
214-
<string>UljpyD</string>
215-
<key>INIntentResponseCodeName</key>
216-
<string>wrongConfiguration</string>
217-
</dict>
218-
</array>
219-
</dict>
220-
<key>INIntentTitle</key>
221-
<string>Update Configuration</string>
222-
<key>INIntentTitleID</key>
223-
<string>iYtEWT</string>
224-
<key>INIntentType</key>
225-
<string>Custom</string>
226-
<key>INIntentVerb</key>
227-
<string>Do</string>
228-
</dict>
229-
</array>
18+
<array/>
23019
<key>INTypes</key>
23120
<array/>
23221
</dict>

Diff for: Sources/WireGuardApp/UI/iOS/AppDelegate.swift

-82
Original file line numberDiff line numberDiff line change
@@ -115,88 +115,6 @@ extension AppDelegate {
115115
extension AppDelegate {
116116

117117
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
118-
119-
guard let interaction = userActivity.interaction else {
120-
return false
121-
}
122-
123-
if interaction.intent is UpdateConfigurationIntent {
124-
if let tunnelsManager = tunnelsManager {
125-
self.handleupdateConfigurationIntent(interaction: interaction, tunnelsManager: tunnelsManager)
126-
} else {
127-
var token: NSObjectProtocol?
128-
token = NotificationCenter.default.addObserver(forName: AppDelegate.tunnelsManagerReadyNotificationName, object: nil, queue: .main) { [weak self] _ in
129-
guard let tunnelsManager = self?.tunnelsManager else { return }
130-
131-
self?.handleupdateConfigurationIntent(interaction: interaction, tunnelsManager: tunnelsManager)
132-
NotificationCenter.default.removeObserver(token!)
133-
}
134-
}
135-
136-
return true
137-
}
138-
139118
return false
140119
}
141-
142-
func handleupdateConfigurationIntent(interaction: INInteraction, tunnelsManager: TunnelsManager) {
143-
144-
guard let updateConfigurationIntent = interaction.intent as? UpdateConfigurationIntent,
145-
let configurationUpdates = interaction.intentResponse?.userActivity?.userInfo else {
146-
return
147-
}
148-
149-
guard let tunnelName = updateConfigurationIntent.tunnel,
150-
let configurations = configurationUpdates["Configuration"] as? [String: [String: String]] else {
151-
wg_log(.error, message: "Failed to get informations to update the configuration")
152-
return
153-
}
154-
155-
guard let tunnel = tunnelsManager.tunnel(named: tunnelName),
156-
let tunnelConfiguration = tunnel.tunnelConfiguration else {
157-
wg_log(.error, message: "Failed to get tunnel configuration with name \(tunnelName)")
158-
ErrorPresenter.showErrorAlert(title: "Tunnel not found",
159-
message: "Tunnel with name '\(tunnelName)' is not present.",
160-
from: self.mainVC)
161-
return
162-
}
163-
164-
var peers = tunnelConfiguration.peers
165-
166-
for (peerPubKey, valuesToUpdate) in configurations {
167-
guard let peerIndex = peers.firstIndex(where: { $0.publicKey.base64Key == peerPubKey }) else {
168-
wg_log(.debug, message: "Failed to find peer \(peerPubKey) in tunnel with name \(tunnelName)")
169-
ErrorPresenter.showErrorAlert(title: "Peer not found",
170-
message: "Peer '\(peerPubKey)' is not present in '\(tunnelName)' tunnel.",
171-
from: self.mainVC)
172-
continue
173-
}
174-
175-
if let endpointString = valuesToUpdate["Endpoint"] {
176-
if let newEntpoint = Endpoint(from: endpointString) {
177-
peers[peerIndex].endpoint = newEntpoint
178-
} else {
179-
wg_log(.debug, message: "Failed to convert \(endpointString) to Endpoint")
180-
}
181-
}
182-
}
183-
184-
let newConfiguration = TunnelConfiguration(name: tunnel.name, interface: tunnelConfiguration.interface, peers: peers)
185-
186-
tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: newConfiguration, onDemandOption: tunnel.onDemandOption) { error in
187-
guard error == nil else {
188-
wg_log(.error, message: error!.localizedDescription)
189-
ErrorPresenter.showErrorAlert(error: error!, from: self.mainVC)
190-
return
191-
}
192-
193-
if let completionUrlString = updateConfigurationIntent.completionUrl,
194-
!completionUrlString.isEmpty,
195-
let completionUrl = URL(string: completionUrlString) {
196-
UIApplication.shared.open(completionUrl, options: [:], completionHandler: nil)
197-
}
198-
199-
wg_log(.debug, message: "Updated configuration of tunnel \(tunnelName)")
200-
}
201-
}
202120
}

Diff for: Sources/WireGuardApp/UI/iOS/Info.plist

+1-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@
8383
<key>NSFaceIDUsageDescription</key>
8484
<string>Localized</string>
8585
<key>NSUserActivityTypes</key>
86-
<array>
87-
<string>UpdateConfigurationIntent</string>
88-
</array>
86+
<array/>
8987
<key>UILaunchStoryboardName</key>
9088
<string>LaunchScreen</string>
9189
<key>UIRequiredDeviceCapabilities</key>

Diff for: Sources/WireGuardIntentsExtension/IntentHandler.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ class IntentHandler: INExtension {
1111
}
1212

1313
override func handler(for intent: INIntent) -> Any {
14-
guard intent is UpdateConfigurationIntent else {
15-
fatalError("Unhandled intent type: \(intent)")
16-
}
17-
18-
return IntentHandling()
14+
fatalError("Unhandled intent type: \(intent)")
1915
}
2016

2117
}

0 commit comments

Comments
 (0)