Define custom intents
- Connect - Disable - (Un)Trust current network - (Un)Trust cellular network - Move to location
This commit is contained in:
parent
f01027bca5
commit
2e4d2162ac
|
@ -25,6 +25,10 @@
|
|||
|
||||
import UIKit
|
||||
import TunnelKit
|
||||
import Intents
|
||||
import SwiftyBeaver
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
|
||||
|
@ -153,3 +157,15 @@ extension UISplitViewController {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate {
|
||||
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
|
||||
guard let interaction = userActivity.interaction else {
|
||||
return false
|
||||
}
|
||||
if #available(iOS 12, *) {
|
||||
InteractionsHandler.handleInteraction(interaction)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,16 @@
|
|||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<false/>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>ConnectVPNIntent</string>
|
||||
<string>DisableVPNIntent</string>
|
||||
<string>MoveToLocationIntent</string>
|
||||
<string>TrustCellularNetworkIntent</string>
|
||||
<string>TrustCurrentNetworkIntent</string>
|
||||
<string>UntrustCellularNetworkIntent</string>
|
||||
<string>UntrustCurrentNetworkIntent</string>
|
||||
</array>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
|
|
@ -0,0 +1,585 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>INEnums</key>
|
||||
<array/>
|
||||
<key>INIntentDefinitionModelVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>INIntentDefinitionSystemVersion</key>
|
||||
<string>17G3025</string>
|
||||
<key>INIntentDefinitionToolsBuildVersion</key>
|
||||
<string>10B61</string>
|
||||
<key>INIntentDefinitionToolsVersion</key>
|
||||
<string>10.1</string>
|
||||
<key>INIntents</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>eXXb2z</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>5</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>ConnectVPN</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key>context,profileId</key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string>On-demand VPN service</string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>uMFvJW</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string>Connect to ${profileId}</string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>U6o81V</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentParameterDisplayPriority</key>
|
||||
<integer>1</integer>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>context</string>
|
||||
<key>INIntentParameterSupportsMultipleValues</key>
|
||||
<false/>
|
||||
<key>INIntentParameterTag</key>
|
||||
<integer>5</integer>
|
||||
<key>INIntentParameterType</key>
|
||||
<string>String</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentParameterDisplayPriority</key>
|
||||
<integer>2</integer>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>profileId</string>
|
||||
<key>INIntentParameterSupportsMultipleValues</key>
|
||||
<false/>
|
||||
<key>INIntentParameterTag</key>
|
||||
<integer>4</integer>
|
||||
<key>INIntentParameterType</key>
|
||||
<string>String</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string>Unable to connect</string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>uKU9RD</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string>Successfully connected!</string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>WNbRl5</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Connect to VPN</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>LA99yM</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>BKxs8X</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>TrustCurrentNetwork</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key></key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>AxbXUn</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>POyDPM</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array/>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>x3pVKZ</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>qEDn4J</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Trust current network</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>m2E7SI</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>eQ1yzr</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>DisableVPN</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key></key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>85kxu8</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>IeGsEq</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array/>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>fnSNbT</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>oKHXZ3</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Disable VPN service</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>1ZRTCZ</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>7eoAss</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>UntrustCurrentNetwork</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key></key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>pb3MGt</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>0Wu9nb</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array/>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>r0ZjO4</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>rtaAzk</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Untrust current network</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>rd1T8p</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>9GpJt5</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>TrustCellularNetwork</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key></key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>vIPVA5</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>NWWgCl</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array/>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>nMRaxS</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>gSqy7Y</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Trust cellular network</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>H4taev</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>0jRWn5</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>UntrustCellularNetwork</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key></key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>qRkLSU</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string></string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>ggzKA2</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array/>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>YncGoj</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>BW8KLX</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Untrust cellular network</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>wB1iYX</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Do</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentCategory</key>
|
||||
<string>generic</string>
|
||||
<key>INIntentDescriptionID</key>
|
||||
<string>KjkCfU</string>
|
||||
<key>INIntentLastParameterTag</key>
|
||||
<integer>3</integer>
|
||||
<key>INIntentName</key>
|
||||
<string>MoveToLocation</string>
|
||||
<key>INIntentParameterCombinations</key>
|
||||
<dict>
|
||||
<key>providerId,poolName,poolId</key>
|
||||
<dict>
|
||||
<key>INIntentParameterCombinationIsPrimary</key>
|
||||
<false/>
|
||||
<key>INIntentParameterCombinationSubtitle</key>
|
||||
<string>With ${providerId} provider</string>
|
||||
<key>INIntentParameterCombinationSubtitleID</key>
|
||||
<string>66bZBE</string>
|
||||
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
|
||||
<true/>
|
||||
<key>INIntentParameterCombinationTitle</key>
|
||||
<string>Move to ${poolName}</string>
|
||||
<key>INIntentParameterCombinationTitleID</key>
|
||||
<string>WnTPFg</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>INIntentParameters</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentParameterDisplayPriority</key>
|
||||
<integer>1</integer>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>providerId</string>
|
||||
<key>INIntentParameterSupportsMultipleValues</key>
|
||||
<false/>
|
||||
<key>INIntentParameterTag</key>
|
||||
<integer>2</integer>
|
||||
<key>INIntentParameterType</key>
|
||||
<string>String</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentParameterDisplayPriority</key>
|
||||
<integer>2</integer>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>poolId</string>
|
||||
<key>INIntentParameterSupportsMultipleValues</key>
|
||||
<false/>
|
||||
<key>INIntentParameterTag</key>
|
||||
<integer>3</integer>
|
||||
<key>INIntentParameterType</key>
|
||||
<string>String</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentParameterDisplayPriority</key>
|
||||
<integer>3</integer>
|
||||
<key>INIntentParameterName</key>
|
||||
<string>poolName</string>
|
||||
<key>INIntentParameterSupportsMultipleValues</key>
|
||||
<false/>
|
||||
<key>INIntentParameterTag</key>
|
||||
<integer>1</integer>
|
||||
<key>INIntentParameterType</key>
|
||||
<string>String</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponse</key>
|
||||
<dict>
|
||||
<key>INIntentResponseCodes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>PmWNkC</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>failure</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>INIntentResponseCodeFormatString</key>
|
||||
<string></string>
|
||||
<key>INIntentResponseCodeFormatStringID</key>
|
||||
<string>O6nCLQ</string>
|
||||
<key>INIntentResponseCodeName</key>
|
||||
<string>success</string>
|
||||
<key>INIntentResponseCodeSuccess</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>INIntentResponseLastParameterTag</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentResponseParameters</key>
|
||||
<array/>
|
||||
</dict>
|
||||
<key>INIntentRestrictions</key>
|
||||
<integer>0</integer>
|
||||
<key>INIntentTitle</key>
|
||||
<string>Move to provider location</string>
|
||||
<key>INIntentTitleID</key>
|
||||
<string>qo3Szz</string>
|
||||
<key>INIntentType</key>
|
||||
<string>Custom</string>
|
||||
<key>INIntentUserConfirmationRequired</key>
|
||||
<false/>
|
||||
<key>INIntentVerb</key>
|
||||
<string>Go</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,267 @@
|
|||
//
|
||||
// InteractionsHandler.swift
|
||||
// Passepartout-iOS
|
||||
//
|
||||
// Created by Davide De Rosa on 3/8/19.
|
||||
// Copyright (c) 2018 Davide De Rosa. All rights reserved.
|
||||
//
|
||||
// https://github.com/passepartoutvpn
|
||||
//
|
||||
// This file is part of Passepartout.
|
||||
//
|
||||
// Passepartout is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Passepartout is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Intents
|
||||
import SwiftyBeaver
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
||||
@available(iOS 12, *)
|
||||
class InteractionsHandler {
|
||||
private class Groups {
|
||||
static let vpn = "VPN"
|
||||
|
||||
static let trust = "Trust"
|
||||
}
|
||||
|
||||
static func donateConnectVPN(with profile: ConnectionProfile) {
|
||||
let profileKey = ProfileKey(profile)
|
||||
|
||||
let intent = ConnectVPNIntent()
|
||||
intent.context = profileKey.context.rawValue
|
||||
intent.profileId = profileKey.id
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = profileKey.rawValue
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateDisableVPN() {
|
||||
let intent = DisableVPNIntent()
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = Groups.vpn
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateMoveToLocation(with profile: ProviderConnectionProfile, pool: Pool) {
|
||||
let profileKey = ProfileKey(profile)
|
||||
|
||||
let intent = MoveToLocationIntent()
|
||||
intent.providerId = profile.id
|
||||
intent.poolId = pool.id
|
||||
intent.poolName = pool.name
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = profileKey.rawValue
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateTrustCurrentNetwork() {
|
||||
let intent = TrustCurrentNetworkIntent()
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = Groups.trust
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateUntrustCurrentNetwork() {
|
||||
let intent = UntrustCurrentNetworkIntent()
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = Groups.trust
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateTrustCellularNetwork() {
|
||||
let intent = TrustCellularNetworkIntent()
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = Groups.trust
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
static func donateUntrustCellularNetwork() {
|
||||
let intent = UntrustCellularNetworkIntent()
|
||||
|
||||
let interaction = INInteraction(intent: intent, response: nil)
|
||||
interaction.groupIdentifier = Groups.trust
|
||||
interaction.donateAndLog()
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
static func handleInteraction(_ interaction: INInteraction) {
|
||||
if let custom = interaction.intent as? ConnectVPNIntent {
|
||||
handleConnectVPN(custom, interaction: interaction)
|
||||
} else if let custom = interaction.intent as? DisableVPNIntent {
|
||||
handleDisableVPN(custom, interaction: interaction)
|
||||
} else if let custom = interaction.intent as? MoveToLocationIntent {
|
||||
handleMoveToLocation(custom, interaction: interaction)
|
||||
} else if let _ = interaction.intent as? TrustCurrentNetworkIntent {
|
||||
handleCurrentNetwork(trust: true, interaction: interaction)
|
||||
} else if let _ = interaction.intent as? UntrustCurrentNetworkIntent {
|
||||
handleCurrentNetwork(trust: false, interaction: interaction)
|
||||
} else if let _ = interaction.intent as? TrustCellularNetworkIntent {
|
||||
handleCellularNetwork(trust: true, interaction: interaction)
|
||||
} else if let _ = interaction.intent as? UntrustCellularNetworkIntent {
|
||||
handleCellularNetwork(trust: false, interaction: interaction)
|
||||
}
|
||||
}
|
||||
|
||||
private static func handleConnectVPN(_ intent: ConnectVPNIntent, interaction: INInteraction) {
|
||||
guard let contextValue = intent.context, let context = Context(rawValue: contextValue), let id = intent.profileId else {
|
||||
INInteraction.delete(with: [interaction.identifier], completion: nil)
|
||||
return
|
||||
}
|
||||
let profileKey = ProfileKey(context, id)
|
||||
log.info("Connect to profile \(profileKey)")
|
||||
|
||||
let service = TransientStore.shared.service
|
||||
let vpn = VPN.shared
|
||||
guard !(service.isActiveProfile(profileKey) && (vpn.status == .connected)) else {
|
||||
log.info("Profile is already active and connected")
|
||||
return
|
||||
}
|
||||
|
||||
guard let profile = service.profile(withContext: context, id: id) else {
|
||||
return
|
||||
}
|
||||
service.activateProfile(profile)
|
||||
|
||||
// FIXME: ServiceViewController is not updated
|
||||
|
||||
let configuration: VPNConfiguration
|
||||
do {
|
||||
configuration = try service.vpnConfiguration()
|
||||
} catch let e {
|
||||
log.error("Unable to build VPN configuration: \(e)")
|
||||
return
|
||||
}
|
||||
|
||||
vpn.reconnect(configuration: configuration) { (error) in
|
||||
if let error = error {
|
||||
log.error("Unable to connect to \(profileKey): \(error)")
|
||||
return
|
||||
}
|
||||
log.info("Connecting to \(profileKey)...")
|
||||
}
|
||||
}
|
||||
|
||||
private static func handleDisableVPN(_ intent: DisableVPNIntent, interaction: INInteraction) {
|
||||
VPN.shared.disconnect(completionHandler: nil)
|
||||
}
|
||||
|
||||
private static func handleMoveToLocation(_ intent: MoveToLocationIntent, interaction: INInteraction) {
|
||||
guard let providerId = intent.providerId, let poolId = intent.poolId else {
|
||||
return
|
||||
}
|
||||
let service = TransientStore.shared.service
|
||||
guard let providerProfile = service.profile(withContext: .provider, id: providerId) as? ProviderConnectionProfile else {
|
||||
return
|
||||
}
|
||||
log.info("Move to provider \(providerId) @ [\(poolId)]")
|
||||
|
||||
let vpn = VPN.shared
|
||||
guard !(service.isActiveProfile(providerProfile) && (providerProfile.poolId == poolId) && (vpn.status == .connected)) else {
|
||||
log.info("Profile is already active and connected to \(poolId)")
|
||||
return
|
||||
}
|
||||
|
||||
providerProfile.poolId = poolId
|
||||
service.activateProfile(providerProfile)
|
||||
|
||||
let configuration: VPNConfiguration
|
||||
do {
|
||||
configuration = try service.vpnConfiguration()
|
||||
} catch let e {
|
||||
log.error("Unable to build VPN configuration: \(e)")
|
||||
return
|
||||
}
|
||||
|
||||
vpn.reconnect(configuration: configuration) { (error) in
|
||||
if let error = error {
|
||||
log.error("Unable to connect to \(providerId) @ [\(poolId)]: \(error)")
|
||||
return
|
||||
}
|
||||
log.info("Connecting to \(providerId) @ [\(poolId)]...")
|
||||
}
|
||||
}
|
||||
|
||||
private static func handleCurrentNetwork(trust: Bool, interaction: INInteraction) {
|
||||
guard let currentWifi = Utils.currentWifiNetworkName() else {
|
||||
return
|
||||
}
|
||||
let service = TransientStore.shared.service
|
||||
service.preferences.trustedWifis[currentWifi] = trust
|
||||
TransientStore.shared.serialize(withProfiles: false)
|
||||
|
||||
reconnectVPN(service: service)
|
||||
}
|
||||
|
||||
private static func handleCellularNetwork(trust: Bool, interaction: INInteraction) {
|
||||
guard Utils.hasCellularData() else {
|
||||
return
|
||||
}
|
||||
let service = TransientStore.shared.service
|
||||
service.preferences.trustsMobileNetwork = trust
|
||||
TransientStore.shared.serialize(withProfiles: false)
|
||||
|
||||
reconnectVPN(service: service)
|
||||
}
|
||||
|
||||
private static func reconnectVPN(service: ConnectionService) {
|
||||
let configuration: VPNConfiguration
|
||||
do {
|
||||
configuration = try service.vpnConfiguration()
|
||||
} catch let e {
|
||||
log.error("Unable to build VPN configuration: \(e)")
|
||||
return
|
||||
}
|
||||
|
||||
let vpn = VPN.shared
|
||||
switch vpn.status {
|
||||
case .connected:
|
||||
vpn.reconnect(configuration: configuration, completionHandler: nil)
|
||||
|
||||
default:
|
||||
vpn.install(configuration: configuration, completionHandler: nil)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
static func forgetProfile(withKey profileKey: ProfileKey) {
|
||||
INInteraction.delete(with: profileKey.rawValue) { (error) in
|
||||
if let error = error {
|
||||
log.error("Unable to forget interactions: \(error)")
|
||||
return
|
||||
}
|
||||
log.debug("Removed profile \(profileKey) interactions")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension INInteraction {
|
||||
func donateAndLog() {
|
||||
donate { (error) in
|
||||
if let error = error {
|
||||
log.error("Unable to donate interaction: \(error)")
|
||||
}
|
||||
log.debug("Donated \(self.intent)")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -223,6 +223,9 @@ class OrganizerViewController: UITableViewController, TableModelHost {
|
|||
tableView.endUpdates()
|
||||
|
||||
service.removeProfile(rowProfile)
|
||||
if #available(iOS 12, *) {
|
||||
InteractionsHandler.forgetProfile(withKey: rowProfile)
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmVpnProfileDeletion() {
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
0E4FD7E120D3E4C5002221FF /* MockVPNProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7E020D3E4C5002221FF /* MockVPNProvider.swift */; };
|
||||
0E4FD7EE20D539A0002221FF /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; };
|
||||
0E4FD7F120D58618002221FF /* Macros.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7F020D58618002221FF /* Macros.swift */; };
|
||||
0E50E7C322330E4900D5F76C /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 0E50E7C222330E4900D5F76C /* Intents.intentdefinition */; };
|
||||
0E50E7C6223318A500D5F76C /* InteractionsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E50E7C5223318A500D5F76C /* InteractionsHandler.swift */; };
|
||||
0E57F63C20C83FC5008323CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E57F63B20C83FC5008323CF /* AppDelegate.swift */; };
|
||||
0E57F63E20C83FC5008323CF /* ServiceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E57F63D20C83FC5008323CF /* ServiceViewController.swift */; };
|
||||
0E57F64120C83FC5008323CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0E57F63F20C83FC5008323CF /* Main.storyboard */; };
|
||||
|
@ -152,6 +154,8 @@
|
|||
0E4FD7ED20D539A0002221FF /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
|
||||
0E4FD7F020D58618002221FF /* Macros.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Macros.swift; sourceTree = "<group>"; };
|
||||
0E4FD80420D683A2002221FF /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/NetworkExtension.framework; sourceTree = DEVELOPER_DIR; };
|
||||
0E50E7C222330E4900D5F76C /* Intents.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = Intents.intentdefinition; sourceTree = "<group>"; };
|
||||
0E50E7C5223318A500D5F76C /* InteractionsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractionsHandler.swift; sourceTree = "<group>"; };
|
||||
0E57F63820C83FC5008323CF /* Passepartout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Passepartout.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0E57F63B20C83FC5008323CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
0E57F63D20C83FC5008323CF /* ServiceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -289,6 +293,15 @@
|
|||
path = VPN;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E50E7C422330E5100D5F76C /* Intents */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0E50E7C222330E4900D5F76C /* Intents.intentdefinition */,
|
||||
0E50E7C5223318A500D5F76C /* InteractionsHandler.swift */,
|
||||
);
|
||||
path = Intents;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0E57F62F20C83FC5008323CF = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -319,6 +332,7 @@
|
|||
0E1066CA20E0F85C004F98B7 /* Cells */,
|
||||
0ECEE44C20E1120F00A6BB43 /* Tables */,
|
||||
0EDE8DF120C93ED8004C739C /* Scenes */,
|
||||
0E50E7C422330E5100D5F76C /* Intents */,
|
||||
0EDE8DE220C86A13004C739C /* Passepartout.entitlements */,
|
||||
0E57F63B20C83FC5008323CF /* AppDelegate.swift */,
|
||||
0E57F63F20C83FC5008323CF /* Main.storyboard */,
|
||||
|
@ -826,6 +840,7 @@
|
|||
0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */,
|
||||
0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */,
|
||||
0EBE3AA6213DC1B000BFA2F5 /* ProviderConnectionProfile.swift in Sources */,
|
||||
0E50E7C322330E4900D5F76C /* Intents.intentdefinition in Sources */,
|
||||
0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */,
|
||||
0EBBE8F52182361800106008 /* ConnectionService+Migration.swift in Sources */,
|
||||
0E39BCF3214DA9310035E9DE /* AppConstants.swift in Sources */,
|
||||
|
@ -834,6 +849,7 @@
|
|||
0E79D14121919F5600BB5FB2 /* ProfileKey.swift in Sources */,
|
||||
0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */,
|
||||
0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */,
|
||||
0E50E7C6223318A500D5F76C /* InteractionsHandler.swift in Sources */,
|
||||
0EFD9440215BED8E00529B64 /* LabelViewController.swift in Sources */,
|
||||
0ED31C2C20CF2D6F0027975F /* ProviderPoolViewController.swift in Sources */,
|
||||
0E2B494020FCFF990094784C /* Theme+Titles.swift in Sources */,
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
struct ProfileKey: RawRepresentable, Hashable, Codable {
|
||||
struct ProfileKey: RawRepresentable, Hashable, Codable, CustomStringConvertible {
|
||||
private static let separator: Character = "."
|
||||
|
||||
let context: Context
|
||||
|
@ -63,4 +63,10 @@ struct ProfileKey: RawRepresentable, Hashable, Codable {
|
|||
let idEnd = rawValue.endIndex
|
||||
id = String(rawValue[idStart..<idEnd])
|
||||
}
|
||||
|
||||
// MARK: CustomStringConvertible
|
||||
|
||||
var description: String {
|
||||
return "{context=\(context), id=\(id)}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import SwiftyBeaver
|
|||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
||||
// FIXME: replace completionHandler?(nil) with completionHandler?(some_error)
|
||||
|
||||
class GracefulVPN {
|
||||
private let service: ConnectionService
|
||||
|
||||
|
|
Loading…
Reference in New Issue