On Thu, 2014-09-04 at 22:04 -0400, Mathieu Trudel-Lapierre wrote: > Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapie...@canonical.com> > --- > introspection/nm-access-point.xml | 3 +++ > libnm-glib/libnm-glib.ver | 1 + > libnm-glib/nm-access-point.c | 35 +++++++++++++++++++++++++++++++++++ > libnm-glib/nm-access-point.h | 2 ++ > src/devices/wifi/nm-wifi-ap.c | 23 ++++++++++++++++++++++- > src/devices/wifi/nm-wifi-ap.h | 1 + > 6 files changed, 64 insertions(+), 1 deletion(-) > > diff --git a/introspection/nm-access-point.xml > b/introspection/nm-access-point.xml > index 21f238f..a2ab2f4 100644 > --- a/introspection/nm-access-point.xml > +++ b/introspection/nm-access-point.xml > @@ -30,6 +30,9 @@ > <property name="Strength" type="y" access="read"> > <tp:docstring>The current signal quality of the access point, in > percent.</tp:docstring> > </property> > + <property name="LastSeen" type="i" access="read"> > + <tp:docstring>The current signal quality of the access point, in > percent.</tp:docstring> > + </property>
Any particular reason to make it int instead of unsigned? Would LastSeen ever be negative? Dan > <signal name="PropertiesChanged"> > <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> > diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver > index c0f1bba..20722e8 100644 > --- a/libnm-glib/libnm-glib.ver > +++ b/libnm-glib/libnm-glib.ver > @@ -11,6 +11,7 @@ global: > nm_access_point_get_flags; > nm_access_point_get_frequency; > nm_access_point_get_hw_address; > + nm_access_point_get_last_seen; > nm_access_point_get_max_bitrate; > nm_access_point_get_mode; > nm_access_point_get_rsn_flags; > diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c > index b462a6b..b971190 100644 > --- a/libnm-glib/nm-access-point.c > +++ b/libnm-glib/nm-access-point.c > @@ -52,6 +52,7 @@ typedef struct { > NM80211Mode mode; > guint32 max_bitrate; > guint8 strength; > + gint32 last_seen; > } NMAccessPointPrivate; > > enum { > @@ -66,6 +67,7 @@ enum { > PROP_MAX_BITRATE, > PROP_STRENGTH, > PROP_BSSID, > + PROP_LAST_SEEN, > > LAST_PROP > }; > @@ -265,6 +267,23 @@ nm_access_point_get_strength (NMAccessPoint *ap) > } > > /** > + * nm_access_point_get_last_seen: > + * @ap: a #NMAccessPoint > + * > + * Gets the last seen timestamp for the access point. > + * > + * Returns: the last seen time in seconds > + **/ > +gint32 > +nm_access_point_get_last_seen (NMAccessPoint *ap) > +{ > + g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0); > + > + _nm_object_ensure_inited (NM_OBJECT (ap)); > + return NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen; > +} > + > +/** > * nm_access_point_connection_valid: > * @ap: an #NMAccessPoint to validate @connection against > * @connection: an #NMConnection to validate against @ap > @@ -481,6 +500,9 @@ get_property (GObject *object, > case PROP_STRENGTH: > g_value_set_uchar (value, nm_access_point_get_strength (ap)); > break; > + case PROP_LAST_SEEN: > + g_value_set_int (value, nm_access_point_get_last_seen (ap)); > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -511,6 +533,7 @@ register_properties (NMAccessPoint *ap) > { NM_ACCESS_POINT_MODE, &priv->mode }, > { NM_ACCESS_POINT_MAX_BITRATE, &priv->max_bitrate }, > { NM_ACCESS_POINT_STRENGTH, &priv->strength }, > + { NM_ACCESS_POINT_LAST_SEEN, &priv->last_seen }, > { NULL }, > }; > > @@ -670,4 +693,16 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) > 0, G_MAXUINT8, 0, > G_PARAM_READABLE | > G_PARAM_STATIC_STRINGS)); > + > + /** > + * NMAccessPoint:last-seen: > + * > + * The last seen timestamp of the access point. > + **/ > + g_object_class_install_property > + (object_class, PROP_LAST_SEEN, > + g_param_spec_int (NM_ACCESS_POINT_LAST_SEEN, "", "", > + 0, G_MAXINT32, 0, > + G_PARAM_READABLE | > + G_PARAM_STATIC_STRINGS)); > } > diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h > index d3150f8..d8efad1 100644 > --- a/libnm-glib/nm-access-point.h > +++ b/libnm-glib/nm-access-point.h > @@ -46,6 +46,7 @@ G_BEGIN_DECLS > #define NM_ACCESS_POINT_MODE "mode" > #define NM_ACCESS_POINT_MAX_BITRATE "max-bitrate" > #define NM_ACCESS_POINT_STRENGTH "strength" > +#define NM_ACCESS_POINT_LAST_SEEN "last-seen" > > /* DEPRECATED */ > #define NM_ACCESS_POINT_HW_ADDRESS "hw-address" > @@ -80,6 +81,7 @@ guint32 nm_access_point_get_frequency > (NMAccessPoint *ap); > NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); > guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); > guint8 nm_access_point_get_strength (NMAccessPoint *ap); > +gint32 nm_access_point_get_last_seen (NMAccessPoint *ap); > > GSList * nm_access_point_filter_connections (NMAccessPoint *ap, > const GSList > *connections); > diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c > index 0c25221..362ef58 100644 > --- a/src/devices/wifi/nm-wifi-ap.c > +++ b/src/devices/wifi/nm-wifi-ap.c > @@ -76,6 +76,7 @@ enum { > PROP_MODE, > PROP_MAX_BITRATE, > PROP_STRENGTH, > + PROP_LAST_SEEN, > LAST_PROP > }; > > @@ -89,6 +90,7 @@ nm_ap_init (NMAccessPoint *ap) > priv->flags = NM_802_11_AP_FLAGS_NONE; > priv->wpa_flags = NM_802_11_AP_SEC_NONE; > priv->rsn_flags = NM_802_11_AP_SEC_NONE; > + priv->last_seen = 0; > priv->broadcast = TRUE; > } > > @@ -144,6 +146,9 @@ set_property (GObject *object, guint prop_id, > break; > case PROP_HW_ADDRESS: > break; > + case PROP_LAST_SEEN: > + nm_ap_set_last_seen (ap, g_value_get_int (value)); > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -192,6 +197,9 @@ get_property (GObject *object, guint prop_id, > case PROP_STRENGTH: > g_value_set_schar (value, priv->strength); > break; > + case PROP_LAST_SEEN: > + g_value_set_int (value, priv->last_seen); > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -291,6 +299,13 @@ nm_ap_class_init (NMAccessPointClass *ap_class) > G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | > G_PARAM_STATIC_STRINGS)); > > + g_object_class_install_property > + (object_class, PROP_LAST_SEEN, > + g_param_spec_int (NM_AP_LAST_SEEN, "", "", > + 0, G_MAXINT32, 0, > + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | > + G_PARAM_STATIC_STRINGS)); > + > nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), > G_TYPE_FROM_CLASS (ap_class), > > &dbus_glib_nm_access_point_object_info); > @@ -1090,9 +1105,15 @@ nm_ap_get_last_seen (const NMAccessPoint *ap) > void > nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen) > { > + NMAccessPointPrivate *priv; > g_return_if_fail (NM_IS_AP (ap)); > > - NM_AP_GET_PRIVATE (ap)->last_seen = last_seen; > + priv = NM_AP_GET_PRIVATE (ap); > + > + if (priv->last_seen != last_seen) { > + priv->last_seen = last_seen; > + g_object_notify (G_OBJECT (ap), NM_AP_LAST_SEEN); > + } > } > > gboolean > diff --git a/src/devices/wifi/nm-wifi-ap.h b/src/devices/wifi/nm-wifi-ap.h > index 0abb28f..d09d357 100644 > --- a/src/devices/wifi/nm-wifi-ap.h > +++ b/src/devices/wifi/nm-wifi-ap.h > @@ -43,6 +43,7 @@ > #define NM_AP_MODE "mode" > #define NM_AP_MAX_BITRATE "max-bitrate" > #define NM_AP_STRENGTH "strength" > +#define NM_AP_LAST_SEEN "last-seen" > > typedef struct { > GObject parent; _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list