[network-manager-applet/lr/bad-wep] applet: replace lock icon for WEP networks with an exclaimation mark




commit cb8604e6e8b0a4f31d04f18b416c50b4bedf57ef
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Mar 8 15:38:36 2022 +0100

    applet: replace lock icon for WEP networks with an exclaimation mark
    
    This is supposed to indicate that the network is not secure, analogously
    to what web browsers do for bad certificates.
    
    It's not beautiful, but I guess it's not a huge problem. By now the applet
    is a probably a niche tool.

 Makefile.am                   |   1 +
 icons/22/nm-insecure-warn.png | Bin 0 -> 7437 bytes
 icons/meson.build             |   1 +
 src/ap-menu-item.c            |  38 +++++++++++++++++++++++++++-----------
 4 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ad8407a9..9ce11178 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,6 +65,7 @@ icon22_DATA = \
        icons/22/nm-device-wired-secure.png \
        icons/22/nm-device-wired.png \
        icons/22/nm-device-wwan.png \
+       icons/22/nm-insecure-warn.png \
        icons/22/nm-mb-roam.png \
        icons/22/nm-no-connection.png \
        icons/22/nm-secure-lock.png \
diff --git a/icons/22/nm-insecure-warn.png b/icons/22/nm-insecure-warn.png
new file mode 100644
index 00000000..81ed16c6
Binary files /dev/null and b/icons/22/nm-insecure-warn.png differ
diff --git a/icons/meson.build b/icons/meson.build
index 4341112b..1b101897 100644
--- a/icons/meson.build
+++ b/icons/meson.build
@@ -9,6 +9,7 @@ icons_22 = [
   'nm-device-wired-secure.png',
   'nm-device-wired.png',
   'nm-device-wwan.png',
+  'nm-insecure-warn.png',
   'nm-mb-roam.png',
   'nm-no-connection.png',
   'nm-secure-lock.png',
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 1da010fa..7f439301 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -34,6 +34,7 @@ typedef struct {
        gboolean    has_connections;
        gboolean    is_adhoc;
        gboolean    is_encrypted;
+       gboolean    is_insecure;
 } NMNetworkMenuItemPrivate;
 
 /******************************************************************/
@@ -71,6 +72,10 @@ update_atk_desc (NMNetworkMenuItem *item)
                        g_string_append (desc, ", ");
                        g_string_append (desc, _("secure."));
                }
+               if (priv->is_insecure) {
+                       g_string_append (desc, ", ");
+                       g_string_append (desc, _("insecure."));
+               }
        }
 
        atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (item)), desc->str);
@@ -100,18 +105,24 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
 
        icon = nma_icon_check_and_load (icon_name, applet);
        if (icon) {
-               if (priv->is_encrypted) {
-                       GdkPixbuf *encrypted = nma_icon_check_and_load ("nm-secure-lock", applet);
+               GdkPixbuf *extra_icon;
+
+               if (priv->is_insecure) {
+                       extra_icon = nma_icon_check_and_load ("nm-insecure-warn", applet);
+               } else if (priv->is_encrypted) {
+                       extra_icon = nma_icon_check_and_load ("nm-secure-lock", applet);
+               } else {
+                       extra_icon = NULL;
+               }
 
-                       if (encrypted) {
-                               icon = icon_free = gdk_pixbuf_copy (icon);
+               if (extra_icon) {
+                       icon = icon_free = gdk_pixbuf_copy (icon);
 
-                               gdk_pixbuf_composite (encrypted, icon, 0, 0,
-                                                     gdk_pixbuf_get_width (encrypted),
-                                                     gdk_pixbuf_get_height (encrypted),
-                                                     0, 0, 1.0, 1.0,
-                                                     GDK_INTERP_NEAREST, 255);
-                       }
+                       gdk_pixbuf_composite (extra_icon, icon, 0, 0,
+                                             gdk_pixbuf_get_width (extra_icon),
+                                             gdk_pixbuf_get_height (extra_icon),
+                                             0, 0, 1.0, 1.0,
+                                             GDK_INTERP_NEAREST, 255);
                }
 
                /* Scale to menu size if larger so the menu doesn't look awful */
@@ -279,8 +290,13 @@ nm_network_menu_item_new (NMAccessPoint *ap,
        ap_flags = nm_access_point_get_flags (ap);
        ap_wpa = nm_access_point_get_wpa_flags (ap);
        ap_rsn = nm_access_point_get_rsn_flags (ap);
-       if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY) || ap_wpa || ap_rsn)
+
+       if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY) && !ap_wpa && !ap_rsn) {
+               /* WEP connections. */
+               priv->is_insecure = TRUE;
+       } else if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY) || ap_wpa || ap_rsn) {
                priv->is_encrypted = TRUE;
+       }
 
        /* Don't enable the menu item the device can't even connect to the AP */
        if (   !nm_utils_security_valid (NMU_SEC_NONE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]