Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify local TunnelKit's handling of hasBetterPath using NWPathMonitor #338

Merged
merged 2 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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