[gnome-control-center/wip/benzea/wifi-panel: 5/9] wifi: Show encryption status for unavailable connections



commit 9f722c066f2d0dbe021b720d90e6b756e365b6c2
Author: Benjamin Berg <bberg redhat com>
Date:   Sat Dec 15 17:41:52 2018 +0100

    wifi: Show encryption status for unavailable connections

 panels/network/cc-wifi-connection-row.c | 42 +++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/panels/network/cc-wifi-connection-row.c b/panels/network/cc-wifi-connection-row.c
index b2926c829..beaee7180 100644
--- a/panels/network/cc-wifi-connection-row.c
+++ b/panels/network/cc-wifi-connection-row.c
@@ -92,6 +92,34 @@ get_access_point_security (NMAccessPoint *ap)
   return type;
 }
 
+static NMAccessPointSecurity
+get_connection_security (NMConnection *con)
+{
+  NMSettingWirelessSecurity *sws;
+  const gchar *key_mgmt;
+
+  sws = nm_connection_get_setting_wireless_security (con);
+  g_debug ("getting security from %p", sws);
+  if (!sws)
+    return NM_AP_SEC_NONE;
+
+  key_mgmt = nm_setting_wireless_security_get_key_mgmt (sws);
+  g_debug ("key management is %s", key_mgmt);
+
+  if (!key_mgmt)
+    return NM_AP_SEC_NONE;
+  else if (g_str_equal (key_mgmt, "none"))
+    return NM_AP_SEC_WEP;
+  else if (g_str_equal (key_mgmt, "ieee8021x"))
+    return NM_AP_SEC_WEP;
+  else if (g_str_equal (key_mgmt, "wpa-eap"))
+    return NM_AP_SEC_WPA2;
+  else if (strncmp (key_mgmt, "wpa-", 4) == 0)
+    return NM_AP_SEC_WPA;
+  else
+    return NM_AP_SEC_UNKNOWN;
+}
+
 static void
 update_ui (CcWifiConnectionRow *self)
 {
@@ -99,8 +127,8 @@ update_ui (CcWifiConnectionRow *self)
   g_autofree gchar *title = NULL;
   gboolean active;
   gboolean connecting;
-  NMAccessPointSecurity security;
-  guint8 strength;
+  NMAccessPointSecurity security = NM_AP_SEC_UNKNOWN;
+  guint8 strength = 0;
   NMDeviceState state;
   NMAccessPoint *active_ap;
 
@@ -168,10 +196,16 @@ update_ui (CcWifiConnectionRow *self)
     {
       active = FALSE;
       connecting = FALSE;
-      security = NM_AP_SEC_UNKNOWN;
-      strength = 0;
     }
 
+  if (self->connection)
+    security = get_connection_security (self->connection);
+
+  if (self->ap != NULL)
+    {
+      security = get_access_point_security (best_ap);
+      strength = nm_access_point_get_strength (best_ap);
+    }
 
 
   if (connecting)


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