mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-23 06:42:23 +00:00
1756e8b0f2
checkboxes are disabled if the network is not currently connected.
73 lines
2.1 KiB
Swift
73 lines
2.1 KiB
Swift
//
|
|
// NetworkInfoCell.swift
|
|
// ZeroTier One
|
|
//
|
|
// Created by Grant Limberg on 5/24/16.
|
|
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
class NetworkInfoCell: NSTableCellView {
|
|
|
|
weak var parent: ShowNetworksViewController!
|
|
|
|
@IBOutlet var networkIdField: NSTextField!
|
|
@IBOutlet var networkNameField: NSTextField!
|
|
|
|
@IBOutlet var statusField: NSTextField!
|
|
@IBOutlet var typeField: NSTextField!
|
|
@IBOutlet var macField: NSTextField!
|
|
@IBOutlet var mtuField: NSTextField!
|
|
@IBOutlet var broadcastField: NSTextField!
|
|
@IBOutlet var bridgingField: NSTextField!
|
|
@IBOutlet var deviceField: NSTextField!
|
|
@IBOutlet var addressesField: NSTextField!
|
|
|
|
@IBOutlet var allowManaged: NSButton!
|
|
@IBOutlet var allowGlobal: NSButton!
|
|
@IBOutlet var allowDefault: NSButton!
|
|
|
|
@IBOutlet var connectedCheckbox: NSButton!
|
|
@IBOutlet var deleteButton: NSButton!
|
|
|
|
override func awakeFromNib() {
|
|
super.awakeFromNib()
|
|
|
|
}
|
|
override func drawRect(dirtyRect: NSRect) {
|
|
super.drawRect(dirtyRect)
|
|
|
|
// Drawing code here.
|
|
}
|
|
|
|
@IBAction func onConnectCheckStateChanged(sender: NSButton) {
|
|
if(sender.state == NSOnState) {
|
|
joinNetwork(networkIdField.stringValue)
|
|
}
|
|
else {
|
|
leaveNetwork(networkIdField.stringValue)
|
|
}
|
|
}
|
|
|
|
@IBAction func deleteNetwork(sender: NSButton) {
|
|
leaveNetwork(networkIdField.stringValue)
|
|
parent.deleteNetworkFromList(networkIdField.stringValue)
|
|
}
|
|
|
|
func joinNetwork(nwid: String) {
|
|
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)
|
|
}
|
|
}
|