diff options
author | Roopesh Chander <roop@roopc.net> | 2019-02-23 14:24:30 +0530 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-18 06:46:55 +0100 |
commit | 3767a1298362caccd9844e9693428e7b1cc4b9f6 (patch) | |
tree | feb202bf8f2c0b322303fae0f952bee3310fe689 /WireGuard/WireGuard/UI/TunnelViewModel.swift | |
parent | macOS: Localize tooltips (diff) | |
download | wireguard-apple-3767a1298362caccd9844e9693428e7b1cc4b9f6.tar.xz wireguard-apple-3767a1298362caccd9844e9693428e7b1cc4b9f6.zip |
on-demand: Simplify OS-specific code for interface type selection
Previously, the enum values themselves were different for iOS and macOS.
With this commit, the enum values are common, and only how they're handled
is specific to iOS and macOS.
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/TunnelViewModel.swift | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index e6b00a1..8a9b007 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -627,21 +627,24 @@ extension TunnelViewModel { switch activateOnDemandOption { case .none: return tr("tunnelOnDemandOptionOff") - case .useOnDemandOverWiFiOnly: + case .wiFiInterfaceOnly: return tr("tunnelOnDemandOptionWiFiOnly") - #if os(iOS) - case .useOnDemandOverWiFiOrCellular: - return tr("tunnelOnDemandOptionWiFiOrCellular") - case .useOnDemandOverCellularOnly: + case .nonWiFiInterfaceOnly: + #if os(iOS) return tr("tunnelOnDemandOptionCellularOnly") - #elseif os(macOS) - case .useOnDemandOverWiFiOrEthernet: - return tr("tunnelOnDemandOptionWiFiOrEthernet") - case .useOnDemandOverEthernetOnly: + #elseif os(macOS) return tr("tunnelOnDemandOptionEthernetOnly") - #else - #error("Unimplemented") - #endif + #else + #error("Unimplemented") + #endif + case .anyInterface: + #if os(iOS) + return tr("tunnelOnDemandOptionWiFiOrCellular") + #elseif os(macOS) + return tr("tunnelOnDemandOptionWiFiOrEthernet") + #else + #error("Unimplemented") + #endif } } @@ -658,13 +661,7 @@ extension TunnelViewModel { } static func defaultActivateOnDemandOption() -> ActivateOnDemandOption { - #if os(iOS) - return .useOnDemandOverWiFiOrCellular - #elseif os(macOS) - return .useOnDemandOverWiFiOrEthernet - #else - #error("Unimplemented") - #endif + return .anyInterface } } |