Skip to content
Open
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
12 changes: 10 additions & 2 deletions BlocksScreen/lib/network/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NetworkManager(QObject):
error_occurred = pyqtSignal(str, str)
reconnect_complete = pyqtSignal()
hotspot_config_updated = pyqtSignal(str, str, str)
network_password_loaded = pyqtSignal(str, str)

def __init__(self, parent: QObject | None = None) -> None:
"""Create the worker, wire all signals"""
Expand All @@ -57,7 +58,7 @@ def __init__(self, parent: QObject | None = None) -> None:
self._shutting_down: bool = False
self._worker_ready: bool = False

self._pending_futures: set["asyncio.Future"] = set()
self._pending_futures: set[asyncio.Future] = set()

self._worker = NetworkManagerWorker()

Expand All @@ -72,6 +73,7 @@ def __init__(self, parent: QObject | None = None) -> None:
self._worker.error_occurred.connect(self.error_occurred)
self._worker.hotspot_info_ready.connect(self._on_hotspot_info_ready)
self._worker.reconnect_complete.connect(self.reconnect_complete)
self._worker.network_password_loaded.connect(self.network_password_loaded)
self._worker.initialized.connect(self._on_worker_initialized)

# Keepalive timer: safety net for any missed D-Bus signals.
Expand Down Expand Up @@ -170,9 +172,11 @@ def _on_networks_scanned(self, networks: list) -> None:

@pyqtSlot(list)
def _on_saved_networks_loaded(self, networks: list) -> None:
"""Cache saved profiles, rebuild lowercase lookup map, and re-emit."""
"""Cache saved profiles, rebuild lowercase lookup map, and re-emit if changed."""
if self._shutting_down:
return
if networks == self._cached_saved:
return
self._cached_saved = networks
self._saved_network_map = {n.ssid.lower(): n for n in networks}
self.saved_networks_loaded.emit(networks)
Expand Down Expand Up @@ -249,6 +253,10 @@ def update_network( # nosec B107
"""Update the password and/or autoconnect priority for a saved profile."""
self._schedule(self._worker._async_update_network(ssid, password, priority))

def get_network_password(self, ssid: str) -> None:
"""Ask NM for a saved profile's psk; answered by network_password_loaded."""
self._schedule(self._worker._async_get_network_password(ssid))

def set_wifi_enabled(self, enabled: bool) -> None:
"""Enable or disable the Wi-Fi radio."""
self._schedule(self._worker._async_set_wifi_enabled(enabled))
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/network/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SavedNetwork:
signal_strength: int = 0
timestamp: int = 0 # Unix time of last successful activation
is_dhcp: bool = True # True = auto (DHCP), False = manual (static IP)
ip_address: str = ""
ip_address: str = "" # static IPv4 config, all empty while on DHCP
netmask: str = ""
gateway: str = ""
dns_servers: tuple[str, ...] = ()
Expand Down
Loading
Loading