Skip to content

Commit

Permalink
small refactor and typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
linkfrg committed Feb 3, 2025
1 parent 29d3bab commit 650c5e9
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ignis/services/network/access_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, point: NM.AccessPoint, client: NM.Client, device: NM.DeviceWi

self._ssid: str | None = None
self._connect_dialog: WifiConnectDialog | None = None
self._connections: list[NM.Connection] = []
self._connections: list[NM.RemoteConnection] = []

self._state_changed_ids: dict[NM.ActiveConnection, int] = {}

Expand Down Expand Up @@ -213,11 +213,7 @@ def psk(self, value: str) -> None:
wireless_sec.set_property("key-mgmt", "wpa-psk")
wireless_sec.set_secret_flags("psk", NM.SettingSecretFlags.NONE)
conn.add_setting(wireless_sec)
conn.commit_changes_async(
True,
None,
lambda x, res, conn=conn: conn.commit_changes_finish(res),
)
self.__commit_changes_async(conn)

@GObject.Property
def is_connected(self) -> bool:
Expand Down Expand Up @@ -284,11 +280,7 @@ def clear_secrets(self) -> None:
"""
for conn in self._connections:
conn.remove_setting(NM.SettingWirelessSecurity)
conn.commit_changes_async( # type: ignore
True,
None,
lambda x, res, conn=conn: conn.commit_changes_finish(res),
)
self.__commit_changes_async(conn)

def forget(self) -> None:
"""
Expand Down Expand Up @@ -401,6 +393,13 @@ def __invoke_wifi_dialog(self) -> None:
self, on_state_changed=self.__check_new_state
)

def __commit_changes_async(self, conn: NM.RemoteConnection) -> None:
conn.commit_changes_async(
True,
None,
lambda x, res, conn=conn: conn.commit_changes_finish(res),
)


class ActiveAccessPoint(WifiAccessPoint):
"""
Expand Down

0 comments on commit 650c5e9

Please sign in to comment.