From a0c4483bdb9b4334da4d74a22db5d28e8bc8ccef Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 25 Nov 2013 12:06:02 -0600 Subject: [PATCH] api/wifi: add AccessPoints property Helps other bindings. --- introspection/nm-device-wifi.xml | 8 ++++++++ src/devices/nm-device-wifi.c | 22 ++++++++++++++++++++++ src/devices/nm-device-wifi.h | 1 + 3 files changed, 31 insertions(+) diff --git a/introspection/nm-device-wifi.xml b/introspection/nm-device-wifi.xml index dcfa20ccb9..fff74337af 100644 --- a/introspection/nm-device-wifi.xml +++ b/introspection/nm-device-wifi.xml @@ -50,11 +50,19 @@ The bit rate currently used by the wireless device, in kilobits/second (Kb/s). + + + + List of object paths of access point visible to this wireless device. + + + Object path of the access point currently used by the wireless device. + The capabilities of the wireless device. diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index 5415527cfe..995c2f858e 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -58,6 +58,8 @@ #include "nm-settings-connection.h" #include "nm-enum-types.h" #include "wifi-utils.h" +#include "nm-dbus-glib-types.h" + static gboolean impl_device_get_access_points (NMDeviceWifi *device, GPtrArray **aps, @@ -87,6 +89,7 @@ enum { PROP_PERM_HW_ADDRESS, PROP_MODE, PROP_BITRATE, + PROP_ACCESS_POINTS, PROP_ACTIVE_ACCESS_POINT, PROP_CAPABILITIES, PROP_SCANNING, @@ -808,6 +811,7 @@ remove_access_point (NMDeviceWifi *device, priv->ap_list = g_slist_remove (priv->ap_list, ap); g_signal_emit (device, signals[ACCESS_POINT_REMOVED], 0, ap); + g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_ACCESS_POINTS); g_object_unref (ap); } @@ -1865,6 +1869,7 @@ merge_scanned_ap (NMDeviceWifi *self, priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap); nm_ap_export_to_dbus (merge_ap); g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, merge_ap); + g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_ACCESS_POINTS); nm_device_recheck_available_connections (NM_DEVICE (self)); } } @@ -2875,6 +2880,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) g_object_freeze_notify (G_OBJECT (self)); set_current_ap (self, ap, FALSE, FALSE); g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, ap); + g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_ACCESS_POINTS); g_object_thaw_notify (G_OBJECT (self)); nm_device_recheck_available_connections (NM_DEVICE (self)); nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (ap)); @@ -3462,6 +3468,8 @@ get_property (GObject *object, guint prop_id, { NMDeviceWifi *device = NM_DEVICE_WIFI (object); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); + GPtrArray *array; + GSList *iter; switch (prop_id) { case PROP_PERM_HW_ADDRESS: @@ -3476,6 +3484,12 @@ get_property (GObject *object, guint prop_id, case PROP_CAPABILITIES: g_value_set_uint (value, priv->capabilities); break; + case PROP_ACCESS_POINTS: + array = g_ptr_array_sized_new (4); + for (iter = priv->ap_list; iter; iter = g_slist_next (iter)) + g_ptr_array_add (array, g_strdup (nm_ap_get_dbus_path (NM_AP (iter->data)))); + g_value_take_boxed (value, array); + break; case PROP_ACTIVE_ACCESS_POINT: if (priv->current_ap) g_value_set_boxed (value, nm_ap_get_dbus_path (priv->current_ap)); @@ -3571,6 +3585,14 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) 0, G_MAXUINT32, 0, G_PARAM_READABLE)); + g_object_class_install_property + (object_class, PROP_ACCESS_POINTS, + g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS, + "Access points", + "Access points", + DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, + G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_ACTIVE_ACCESS_POINT, g_param_spec_boxed (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, "Active access point", diff --git a/src/devices/nm-device-wifi.h b/src/devices/nm-device-wifi.h index 2403c94530..18d26e463d 100644 --- a/src/devices/nm-device-wifi.h +++ b/src/devices/nm-device-wifi.h @@ -54,6 +54,7 @@ typedef enum { #define NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_WIFI_MODE "mode" #define NM_DEVICE_WIFI_BITRATE "bitrate" +#define NM_DEVICE_WIFI_ACCESS_POINTS "access-points" #define NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT "active-access-point" #define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities" #define NM_DEVICE_WIFI_SCANNING "scanning"