From 65029e0f894e8f56d420b1b0c816c94ddcef5671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 29 Aug 2012 18:01:33 +0200 Subject: [PATCH] settings: update seen-bssids property in 802-11-wireless setting for GetSettings https://bugzilla.gnome.org/show_bug.cgi?id=672501 --- src/settings/nm-settings-connection.c | 40 +++++++++++++++++++++++++++ src/settings/nm-settings-connection.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index c1c55b058c..88ecb977f8 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "nm-settings-connection.h" @@ -1062,7 +1063,9 @@ get_settings_auth_cb (NMSettingsConnection *self, GHashTable *settings; NMConnection *dupl_con; NMSettingConnection *s_con; + NMSettingWireless *s_wifi; guint64 timestamp = 0; + GSList *bssid_list; dupl_con = nm_connection_duplicate (NM_CONNECTION (self)); g_assert (dupl_con); @@ -1079,6 +1082,16 @@ get_settings_auth_cb (NMSettingsConnection *self, g_assert (s_con); g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL); } + /* Seen BSSIDs are not updated in 802-11-wireless 'seen-bssids' property + * from the same reason as timestamp. Thus we put it here to GetSettings() + * return settings too. + */ + bssid_list = nm_settings_connection_get_seen_bssids (self); + s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (dupl_con)); + if (bssid_list && s_wifi) { + g_object_set (s_wifi, NM_SETTING_WIRELESS_SEEN_BSSIDS, bssid_list, NULL); + nm_utils_slist_free (bssid_list, g_free); + } /* Secrets should *never* be returned by the GetSettings method, they * get returned by the GetSecrets method which can be better @@ -1544,6 +1557,33 @@ mac_dup (const struct ether_addr *old) return new; } +/** + * nm_settings_connection_get_seen_bssids: + * @connection: the #NMSettingsConnection + * + * Returns current list of seen BSSIDs for the connection. + * + * Returns: (transfer full) list of seen BSSIDs (in the standard hex-digits-and-colons notation). + * The caller is responsible for freeing the list. + **/ +GSList * +nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection) +{ + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection); + GHashTableIter iter; + char *bssid_str; + GSList *bssid_list = NULL; + + g_return_val_if_fail (connection != NULL, 0); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (connection), NULL); + + g_hash_table_iter_init (&iter, priv->seen_bssids); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &bssid_str)) + bssid_list = g_slist_prepend (bssid_list, g_strdup (bssid_str)); + + return bssid_list; +} + /** * nm_settings_connection_has_seen_bssid: * @connection: the #NMSettingsConnection diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 73ca8192ad..7875afbe2a 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -131,6 +131,8 @@ void nm_settings_connection_update_timestamp (NMSettingsConnection *connection, void nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *connection); +GSList *nm_settings_connection_get_seen_bssids (NMSettingsConnection *connection); + gboolean nm_settings_connection_has_seen_bssid (NMSettingsConnection *connection, const struct ether_addr *bssid);