]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Remove GetPeers SiriKit Intent
authorAlessio Nossa <alessio.nossa@gmail.com>
Wed, 5 Apr 2023 11:30:40 +0000 (13:30 +0200)
committerAlessio Nossa <alessio.nossa@gmail.com>
Wed, 5 Apr 2023 11:42:56 +0000 (13:42 +0200)
Signed-off-by: Alessio Nossa <alessio.nossa@gmail.com>
Sources/Shared/Intents.intentdefinition
Sources/WireGuardIntentsExtension/IntentHandler.swift
Sources/WireGuardIntentsExtension/IntentHandling.swift

index 8c8d33b639e2792cbde6c660e93959229571f581..97b2595ec56695abf34683fb8ff7dd18fb82f9af 100644 (file)
        <string>14.2</string>
        <key>INIntents</key>
        <array>
-               <dict>
-                       <key>INIntentCategory</key>
-                       <string>generic</string>
-                       <key>INIntentConfigurable</key>
-                       <true/>
-                       <key>INIntentDescription</key>
-                       <string>Get list of public keys of peers in the selected configuration</string>
-                       <key>INIntentDescriptionID</key>
-                       <string>e4jxYU</string>
-                       <key>INIntentIneligibleForSuggestions</key>
-                       <true/>
-                       <key>INIntentKeyParameter</key>
-                       <string>tunnel</string>
-                       <key>INIntentLastParameterTag</key>
-                       <integer>1</integer>
-                       <key>INIntentManagedParameterCombinations</key>
-                       <dict>
-                               <key>tunnel</key>
-                               <dict>
-                                       <key>INIntentParameterCombinationSupportsBackgroundExecution</key>
-                                       <true/>
-                                       <key>INIntentParameterCombinationTitle</key>
-                                       <string>Get peers of ${tunnel}</string>
-                                       <key>INIntentParameterCombinationTitleID</key>
-                                       <string>5Ewt1o</string>
-                                       <key>INIntentParameterCombinationUpdatesLinked</key>
-                                       <true/>
-                               </dict>
-                       </dict>
-                       <key>INIntentName</key>
-                       <string>GetPeers</string>
-                       <key>INIntentParameters</key>
-                       <array>
-                               <dict>
-                                       <key>INIntentParameterConfigurable</key>
-                                       <true/>
-                                       <key>INIntentParameterDisplayName</key>
-                                       <string>Tunnel</string>
-                                       <key>INIntentParameterDisplayNameID</key>
-                                       <string>tUPuxx</string>
-                                       <key>INIntentParameterDisplayPriority</key>
-                                       <integer>1</integer>
-                                       <key>INIntentParameterMetadata</key>
-                                       <dict>
-                                               <key>INIntentParameterMetadataCapitalization</key>
-                                               <string>Sentences</string>
-                                               <key>INIntentParameterMetadataDefaultValueID</key>
-                                               <string>0AfeHS</string>
-                                       </dict>
-                                       <key>INIntentParameterName</key>
-                                       <string>tunnel</string>
-                                       <key>INIntentParameterPromptDialogs</key>
-                                       <array>
-                                               <dict>
-                                                       <key>INIntentParameterPromptDialogCustom</key>
-                                                       <true/>
-                                                       <key>INIntentParameterPromptDialogType</key>
-                                                       <string>Configuration</string>
-                                               </dict>
-                                               <dict>
-                                                       <key>INIntentParameterPromptDialogCustom</key>
-                                                       <true/>
-                                                       <key>INIntentParameterPromptDialogType</key>
-                                                       <string>Primary</string>
-                                               </dict>
-                                       </array>
-                                       <key>INIntentParameterSupportsDynamicEnumeration</key>
-                                       <true/>
-                                       <key>INIntentParameterTag</key>
-                                       <integer>1</integer>
-                                       <key>INIntentParameterType</key>
-                                       <string>String</string>
-                               </dict>
-                       </array>
-                       <key>INIntentResponse</key>
-                       <dict>
-                               <key>INIntentResponseCodes</key>
-                               <array>
-                                       <dict>
-                                               <key>INIntentResponseCodeName</key>
-                                               <string>success</string>
-                                               <key>INIntentResponseCodeSuccess</key>
-                                               <true/>
-                                       </dict>
-                                       <dict>
-                                               <key>INIntentResponseCodeName</key>
-                                               <string>failure</string>
-                                       </dict>
-                                       <dict>
-                                               <key>INIntentResponseCodeConciseFormatString</key>
-                                               <string>Failed to retrive configuration with the provided name.</string>
-                                               <key>INIntentResponseCodeConciseFormatStringID</key>
-                                               <string>ExhkKO</string>
-                                               <key>INIntentResponseCodeFormatString</key>
-                                               <string>Failed to retrive configuration with the provided name.</string>
-                                               <key>INIntentResponseCodeFormatStringID</key>
-                                               <string>lxnQb0</string>
-                                               <key>INIntentResponseCodeName</key>
-                                               <string>wrongTunnel</string>
-                                       </dict>
-                               </array>
-                               <key>INIntentResponseLastParameterTag</key>
-                               <integer>2</integer>
-                               <key>INIntentResponseOutput</key>
-                               <string>peersPublicKeys</string>
-                               <key>INIntentResponseParameters</key>
-                               <array>
-                                       <dict>
-                                               <key>INIntentResponseParameterDisplayName</key>
-                                               <string>Peers Public Keys</string>
-                                               <key>INIntentResponseParameterDisplayNameID</key>
-                                               <string>zJOQgA</string>
-                                               <key>INIntentResponseParameterDisplayPriority</key>
-                                               <integer>1</integer>
-                                               <key>INIntentResponseParameterName</key>
-                                               <string>peersPublicKeys</string>
-                                               <key>INIntentResponseParameterSupportsMultipleValues</key>
-                                               <true/>
-                                               <key>INIntentResponseParameterTag</key>
-                                               <integer>2</integer>
-                                               <key>INIntentResponseParameterType</key>
-                                               <string>String</string>
-                                       </dict>
-                               </array>
-                       </dict>
-                       <key>INIntentTitle</key>
-                       <string>Get Peers</string>
-                       <key>INIntentTitleID</key>
-                       <string>V1ySW4</string>
-                       <key>INIntentType</key>
-                       <string>Custom</string>
-                       <key>INIntentVerb</key>
-                       <string>Do</string>
-               </dict>
                <dict>
                        <key>INIntentCategory</key>
                        <string>generic</string>
index a3527ef938adcec6211645c27584516a60258fd9..bc85e2adb75558ef6e1da50d9702f141af3f84ca 100644 (file)
@@ -11,8 +11,7 @@ class IntentHandler: INExtension {
     }
 
     override func handler(for intent: INIntent) -> Any {
-        guard intent is GetPeersIntent ||
-                intent is UpdateConfigurationIntent else {
+        guard intent is UpdateConfigurationIntent else {
             fatalError("Unhandled intent type: \(intent)")
         }
 
index 1de3d46ade8b430b502a71d6a8ae6aea0c86a45c..461c5aa1674ebf32e51d4487aec7b6caf04f3351 100644 (file)
@@ -57,66 +57,6 @@ extension IntentHandling {
             onTunnelsManagerReady = getTunnelsNameBlock
         }
     }
-
-    private func allTunnelPeers(for tunnelName: String, completion: @escaping (Result<[String], IntentError>) -> Void) {
-        let getPeersFromConfigBlock: (TunnelsManager) -> Void = { tunnelsManager in
-            guard let tunnel = tunnelsManager.tunnel(named: tunnelName) else {
-                return completion(.failure(.wrongTunnel))
-            }
-
-            guard let publicKeys = tunnel.tunnelConfiguration?.peers.map({ $0.publicKey.base64Key }) else {
-                return completion(.failure(.unknown))
-            }
-            return completion(.success(publicKeys))
-        }
-
-        if let tunnelsManager = tunnelsManager {
-            getPeersFromConfigBlock(tunnelsManager)
-        } else {
-            if onTunnelsManagerReady != nil {
-                wg_log(.error, message: "Overriding onTunnelsManagerReady action in allTunnelPeers function. This should not happen.")
-            }
-            onTunnelsManagerReady = getPeersFromConfigBlock
-        }
-    }
-}
-
-extension IntentHandling: GetPeersIntentHandling {
-
-    @available(iOSApplicationExtension 14.0, *)
-    func provideTunnelOptionsCollection(for intent: GetPeersIntent, with completion: @escaping (INObjectCollection<NSString>?, Error?) -> Void) {
-
-        self.allTunnelNames { tunnelsNames in
-            let tunnelsNamesObjects = (tunnelsNames ?? []).map { NSString(string: $0) }
-
-            let objectCollection = INObjectCollection(items: tunnelsNamesObjects)
-            completion(objectCollection, nil)
-        }
-    }
-
-    func handle(intent: GetPeersIntent, completion: @escaping (GetPeersIntentResponse) -> Void) {
-        guard let tunnel = intent.tunnel else {
-            return completion(GetPeersIntentResponse(code: .failure, userActivity: nil))
-        }
-
-        self.allTunnelPeers(for: tunnel) { peersResult in
-            switch peersResult {
-            case .success(let peers):
-                let response = GetPeersIntentResponse(code: .success, userActivity: nil)
-                response.peersPublicKeys = peers
-                completion(response)
-
-            case .failure(let error):
-                switch error {
-                case .wrongTunnel:
-                    completion(GetPeersIntentResponse(code: .wrongTunnel, userActivity: nil))
-                default:
-                    completion(GetPeersIntentResponse(code: .failure, userActivity: nil))
-                }
-            }
-        }
-    }
-
 }
 
 extension IntentHandling: UpdateConfigurationIntentHandling {