aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-03-08 15:24:56 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-18 06:46:55 +0100
commit0ae8d251346ed33778a9bb069699b32c68640aa1 (patch)
tree90fadfdf591e7c76e09226381053f7a58645eef8
parenton-demand: iOS: Update on-demand info shown in tunnel edit view (diff)
downloadwireguard-apple-0ae8d251346ed33778a9bb069699b32c68640aa1.tar.xz
wireguard-apple-0ae8d251346ed33778a9bb069699b32c68640aa1.zip
on-demand: macOS: Tunnel detail: Show SSID info
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/Base.lproj/Localizable.strings1
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift27
2 files changed, 25 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings
index 0ba64b2b..fa271ca9 100644
--- a/WireGuard/WireGuard/Base.lproj/Localizable.strings
+++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings
@@ -312,6 +312,7 @@
"macFieldKey (%@)" = "%@:";
"macFieldOnDemand" = "On-Demand:";
+"macFieldOnDemandSSIDs" = "SSIDs:";
// Mac status display
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
index ec8850a6..1cb9e2ac 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
@@ -9,13 +9,15 @@ class TunnelDetailTableViewController: NSViewController {
case interfaceFieldRow(TunnelViewModel.InterfaceField)
case peerFieldRow(peer: TunnelViewModel.PeerData, field: TunnelViewModel.PeerField)
case onDemandRow
+ case onDemandSSIDRow
case spacerRow
func localizedSectionKeyString() -> String {
switch self {
case .interfaceFieldRow: return tr("tunnelSectionTitleInterface")
case .peerFieldRow: return tr("tunnelSectionTitlePeer")
- case .onDemandRow: return ""
+ case .onDemandRow: return tr("macFieldOnDemand")
+ case .onDemandSSIDRow: return ""
case .spacerRow: return ""
}
}
@@ -25,6 +27,7 @@ class TunnelDetailTableViewController: NSViewController {
case .interfaceFieldRow(let field): return field == .name
case .peerFieldRow(_, let field): return field == .publicKey
case .onDemandRow: return true
+ case .onDemandSSIDRow: return false
case .spacerRow: return false
}
}
@@ -41,6 +44,10 @@ class TunnelDetailTableViewController: NSViewController {
.rxBytes, .txBytes, .lastHandshakeTime
]
+ static let onDemandFields: [ActivateOnDemandViewModel.OnDemandField] = [
+ .onDemand, .ssid
+ ]
+
let tableView: NSTableView = {
let tableView = NSTableView()
tableView.addTableColumn(NSTableColumn(identifier: NSUserInterfaceItemIdentifier("TunnelDetail")))
@@ -76,6 +83,9 @@ class TunnelDetailTableViewController: NSViewController {
updateTableViewModelRows()
}
}
+
+ var onDemandViewModel: ActivateOnDemandViewModel
+
private var tableViewModelRowsBySection = [[(isVisible: Bool, modelRow: TableViewModelRow)]]()
private var tableViewModelRows = [TableViewModelRow]()
@@ -87,6 +97,7 @@ class TunnelDetailTableViewController: NSViewController {
self.tunnelsManager = tunnelsManager
self.tunnel = tunnel
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
+ onDemandViewModel = ActivateOnDemandViewModel(setting: tunnel.activateOnDemandSetting)
super.init(nibName: nil, bundle: nil)
updateTableViewModelRowsBySection()
updateTableViewModelRows()
@@ -177,6 +188,9 @@ class TunnelDetailTableViewController: NSViewController {
var onDemandSection = [(isVisible: Bool, modelRow: TableViewModelRow)]()
onDemandSection.append((isVisible: true, modelRow: .onDemandRow))
+ if onDemandViewModel.isWiFiInterfaceEnabled {
+ onDemandSection.append((isVisible: true, modelRow: .onDemandSSIDRow))
+ }
modelRowsBySection.append(onDemandSection)
tableViewModelRowsBySection = modelRowsBySection
@@ -382,10 +396,16 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
return NSView()
case .onDemandRow:
let cell: KeyValueRow = tableView.dequeueReusableCell()
- cell.key = tr("macFieldOnDemand")
- cell.value = TunnelViewModel.activateOnDemandDetailText(for: tunnel.activateOnDemandSetting)
+ cell.key = modelRow.localizedSectionKeyString()
+ cell.value = onDemandViewModel.localizedInterfaceDescription
cell.isKeyInBold = true
return cell
+ case .onDemandSSIDRow:
+ let cell: KeyValueRow = tableView.dequeueReusableCell()
+ cell.key = tr("macFieldOnDemandSSIDs")
+ cell.value = onDemandViewModel.ssidOption.localizedUIString
+ cell.isKeyInBold = false
+ return cell
}
}
@@ -472,6 +492,7 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
func tunnelSaved(tunnel: TunnelContainer) {
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
+ onDemandViewModel = ActivateOnDemandViewModel(setting: tunnel.activateOnDemandSetting)
updateTableViewModelRowsBySection()
updateTableViewModelRows()
updateStatus()