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

Fixed issue #243 and improved Auto Join #256

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion HeliPort/Appearance/StatusMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,11 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
}
case .turnWiFiOn:
power_on()
NetworkManager.scanSavedNetworks()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the Wi-Fi is turned on, it will attempt to auto-join.

case .turnWiFiOff:
if status == ITL80211_S_RUN {
disassociateSSID(disconnectItem)
}
Comment on lines +440 to +442
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When connected, it will disconnect from the current network before turning off the Wi-Fi, thus preventing it from connecting to a network with auto-join disabled when Wi-Fi is turned on (if the previously connected network has auto-join disabled).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes made to .turnWiFiOn and .turnWiFiOff, it behaves the same as Apple's implementation, at least in more recent versions of macOS, as I'm not sure if the same happens in earlier versions.

power_off()
case .joinNetworks:
let joinPop = WiFiConfigWindow()
Expand Down Expand Up @@ -608,7 +612,6 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
options: .regularExpression,
range: nil)
DispatchQueue.global().async {
CredentialsManager.instance.setAutoJoin(ssid, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong, I did recall this is what Apple's implementation used to do back in the days - manually disconnecting a network will opt-out from auto-join, although this is not what the latest macOS versions are doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. Apple’s implementation used to work this way: manually disconnecting from a network would remove it from auto-join. However, more recent versions of macOS no longer follow this behavior; Apple made this change to improve user experience by reducing the need to manually reconfigure network preferences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer to keep this behavior of automatically disabling autojoin when the user disconnects? I think this behavior is not very interesting and many users may not like this behavior. If you prefer to keep this behavior, I think it would be better to add an option in the preferences to activate and deactivate this behavior.

dis_associate_ssid(ssid)
Log.debug("Disconnected from \(ssid)")
}
Expand Down
1 change: 0 additions & 1 deletion HeliPort/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ final class NetworkManager {
if let savedNetworkAuth = CredentialsManager.instance.get(networkInfo) {
networkInfo.auth = savedNetworkAuth
Log.debug("Connecting to network \(networkInfo.ssid) with saved password")
CredentialsManager.instance.setAutoJoin(networkInfo.ssid, true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not certain if this is what Apple’s implementation used to do back in the days (feels unlikely and doesn't match with the current implementation). This is the root cause of #243.

getAuthInfoCallback(networkInfo.auth, false)
return
}
Expand Down