From 6b3f09aa5df59549a7ed2ddace9b7abc68d35715 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Wed, 6 Mar 2024 17:34:09 -0500 Subject: [PATCH] device: use status attribute for link_encrypted --- lib/logitech_receiver/notifications.py | 2 +- lib/logitech_receiver/status.py | 5 +++-- lib/solaar/ui/pair_window.py | 2 +- lib/solaar/ui/window.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py index bf2d3ba3..7aa79d50 100644 --- a/lib/logitech_receiver/notifications.py +++ b/lib/logitech_receiver/notifications.py @@ -265,7 +265,7 @@ def _process_hidpp10_notification(device, status, n): link_established, bool(flags & 0x80), ) - status[_K.LINK_ENCRYPTED] = link_encrypted + status.link_encrypted = link_encrypted status.changed(active=link_established) return True diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py index d90260fe..87d7391f 100644 --- a/lib/logitech_receiver/status.py +++ b/lib/logitech_receiver/status.py @@ -32,7 +32,7 @@ _hidpp10 = hidpp10.Hidpp10() ALERT = NamedInts(NONE=0x00, NOTIFICATION=0x01, SHOW_WINDOW=0x02, ATTENTION=0x04, ALL=0xFF) -KEYS = NamedInts(LINK_ENCRYPTED=5, NOTIFICATION_FLAGS=6, ERROR=7) +KEYS = NamedInts(NOTIFICATION_FLAGS=6, ERROR=7) def attach_to(device, changed_callback): @@ -87,7 +87,7 @@ class ReceiverStatus(dict): class DeviceStatus(dict): """Holds the 'runtime' status of a peripheral - Currently _active, battery -- dict entries are being moved to attributs + Currently _active, battery, link_encrypted -- dict entries are being moved to attributs Updates mostly come from incoming notification events from the device itself. """ @@ -98,6 +98,7 @@ class DeviceStatus(dict): self._changed_callback = changed_callback self._active = None # is the device active? self.battery = None + self.link_encrypted = None def to_string(self): return self.battery.to_str() if self.battery is not None else "" diff --git a/lib/solaar/ui/pair_window.py b/lib/solaar/ui/pair_window.py index 9dfd5a07..aae92cb3 100644 --- a/lib/solaar/ui/pair_window.py +++ b/lib/solaar/ui/pair_window.py @@ -232,7 +232,7 @@ def _pairing_succeeded(assistant, receiver, device): def _check_encrypted(dev): if assistant.is_drawable(): - if device.status.get(_K.LINK_ENCRYPTED) is False: + if device.status.link_encrypted is False: hbox.pack_start(Gtk.Image.new_from_icon_name("security-low", Gtk.IconSize.MENU), False, False, 0) hbox.pack_start(Gtk.Label(_("The wireless link is not encrypted") + "!"), False, False, 0) hbox.show_all() diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py index 4a984c1b..9c491906 100644 --- a/lib/solaar/ui/window.py +++ b/lib/solaar/ui/window.py @@ -727,12 +727,12 @@ def _update_device_panel(device, panel, buttons, full=False): panel._battery._text.set_markup(text) panel._battery.set_tooltip_text(tooltip_text) - if device.status.get(_K.LINK_ENCRYPTED) is None: + if device.status.link_encrypted is None: panel._secure.set_visible(False) elif is_online: panel._secure.set_visible(True) panel._secure._icon.set_visible(True) - if device.status.get(_K.LINK_ENCRYPTED) is True: + if device.status.link_encrypted is True: panel._secure._text.set_text(_("encrypted")) panel._secure._icon.set_from_icon_name("security-high", _INFO_ICON_SIZE) panel._secure.set_tooltip_text(_("The wireless link between this device and its receiver is encrypted."))