Skip to content

Commit

Permalink
Merge pull request #338 from roop/tunnelkit_has_better_path
Browse files Browse the repository at this point in the history
Modify local TunnelKit's handling of hasBetterPath using NWPathMonitor
  • Loading branch information
roop authored Sep 23, 2020
2 parents 3ddf675 + 79277ba commit 3a3f6ac
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 23 deletions.
8 changes: 8 additions & 0 deletions EduVPN-redesign/Controllers/PreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PreferencesViewController: ViewController, ParametrizedViewController {
@IBOutlet weak var showInStatusBarCheckbox: NSButton!
@IBOutlet weak var showInDockCheckbox: NSButton!
@IBOutlet weak var launchAtLoginCheckbox: NSButton!
@IBOutlet weak var assistPathUpgradingCheckbox: NSButton!

func initializeParameters(_ parameters: Parameters) {
guard self.parameters == nil else {
Expand All @@ -46,11 +47,13 @@ class PreferencesViewController: ViewController, ParametrizedViewController {
let isShowInStatusBarEnabled = userDefaults.showInStatusBar
let isShowInDockEnabled = userDefaults.showInDock
let isLaunchAtLoginEnabled = userDefaults.launchAtLogin
let isAssistPathUpgradingEnabled = userDefaults.assistPathUpgradingWithPathMonitor

useTCPOnlyCheckbox.state = isForceTCPEnabled ? .on : .off
showInStatusBarCheckbox.state = isShowInStatusBarEnabled ? .on : .off
showInDockCheckbox.state = isShowInDockEnabled ? .on : .off
launchAtLoginCheckbox.state = isLaunchAtLoginEnabled ? .on : .off
assistPathUpgradingCheckbox.state = isAssistPathUpgradingEnabled ? .on : .off

// If one of "Show in status bar" or "Show in Dock" is off,
// disable editing the other
Expand All @@ -67,6 +70,11 @@ class PreferencesViewController: ViewController, ParametrizedViewController {
UserDefaults.standard.forceTCP = isUseTCPOnlyChecked
}

@IBAction func assistPathUpgradingCheckboxClicked(_ sender: Any) {
let isChecked = (assistPathUpgradingCheckbox.state == .on)
UserDefaults.standard.assistPathUpgradingWithPathMonitor = isChecked
}

@IBAction func viewLogClicked(_ sender: Any) {
let connectionService = parameters.environment.connectionService
guard connectionService.isInitialized else { return }
Expand Down
11 changes: 11 additions & 0 deletions EduVPN-redesign/Helpers/UserDefaults+Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extension UserDefaults {
private static let showInDockKey = "showInDock"
private static let launchAtLoginKey = "launchAtLogin"

private static let assistPathUpgradingWithPathMonitorKey = "assistPathUpgradingWithPathMonitor"

var forceTCP: Bool {
get { // swiftlint:disable:this implicit_getter
return bool(forKey: Self.forceTCPDefaultsKey)
Expand Down Expand Up @@ -53,4 +55,13 @@ extension UserDefaults {
set(newValue, forKey: Self.launchAtLoginKey)
}
}

var assistPathUpgradingWithPathMonitor: Bool {
get { // swiftlint:disable:this implicit_getter
return bool(forKey: Self.assistPathUpgradingWithPathMonitorKey)
}
set {
set(newValue, forKey: Self.assistPathUpgradingWithPathMonitorKey)
}
}
}
Loading

0 comments on commit 3a3f6ac

Please sign in to comment.