From 1756e8b0f2bb5a322f38f5e0e079d27cfcfecd57 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 17:33:46 -0700 Subject: [PATCH] Wire up checkboxes for allowGlobal, allowDefault, allowManaged to set the proper state in zerotier daemon checkboxes are disabled if the network is not currently connected. --- ZeroTier One/NetworkInfoCell.swift | 13 ++++++++----- ZeroTier One/ShowNetworksViewController.swift | 8 ++++++++ ZeroTier One/ShowNetworksViewController.xib | 9 +++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index 427bdc84a..12e719480 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -42,14 +42,10 @@ class NetworkInfoCell: NSTableCellView { } @IBAction func onConnectCheckStateChanged(sender: NSButton) { - NSLog("Checked State Changed") - if(sender.state == NSOnState) { - NSLog("Checked") joinNetwork(networkIdField.stringValue) } else { - NSLog("Unchecked") leaveNetwork(networkIdField.stringValue) } } @@ -60,10 +56,17 @@ class NetworkInfoCell: NSTableCellView { } func joinNetwork(nwid: String) { - ServiceCom.joinNetwork(nwid) + ServiceCom.joinNetwork(nwid, + allowManaged: allowManaged.state == NSOnState, + allowGlobal: allowGlobal.state == NSOnState, + allowDefault: !defaultRouteExists(parent.networkList) && (allowDefault.state == NSOnState)) } func leaveNetwork(nwid: String) { ServiceCom.leaveNetwork(nwid) } + + @IBAction func onAllowStatusChanged(sender: NSButton) { + joinNetwork(networkIdField.stringValue) + } } diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 250cc73a0..e2bdd105c 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -103,9 +103,17 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable if network.connected { cell.connectedCheckbox.state = NSOnState + + cell.allowDefault.enabled = true + cell.allowGlobal.enabled = true + cell.allowManaged.enabled = true } else { cell.connectedCheckbox.state = NSOffState + + cell.allowDefault.enabled = false + cell.allowGlobal.enabled = false + cell.allowManaged.enabled = false } return cell diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 74582eb69..1535c6685 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -168,6 +168,9 @@ + + +