summary refs log tree commit diff
path: root/libnm/nm-access-point.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-08-28 01:13:48 +0200
committerMichael Biebl <biebl@debian.org>2015-08-28 01:13:48 +0200
commit81836c2d44802b4cca833d7775dd627e0797a7e2 (patch)
tree91154e6cefc0465306603f51ec0010d9963bbea4 /libnm/nm-access-point.c
parent50a58f0fabd8a34c1b6108a107e08abe3c1ccd24 (diff)
Imported Upstream version 1.0.6 upstream/1.0.6
Diffstat (limited to 'libnm/nm-access-point.c')
-rw-r--r--libnm/nm-access-point.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c
index e20cd997..c071a927 100644
--- a/libnm/nm-access-point.c
+++ b/libnm/nm-access-point.c
@@ -49,6 +49,7 @@ typedef struct {
 	NM80211Mode mode;
 	guint32 max_bitrate;
 	guint8 strength;
+	gint32 last_seen;
 } NMAccessPointPrivate;
 
 enum {
@@ -63,6 +64,7 @@ enum {
 	PROP_MAX_BITRATE,
 	PROP_STRENGTH,
 	PROP_BSSID,
+	PROP_LAST_SEEN,
 
 	LAST_PROP
 };
@@ -221,6 +223,26 @@ nm_access_point_get_strength (NMAccessPoint *ap)
 }
 
 /**
+ * nm_access_point_get_last_seen:
+ * @ap: a #NMAccessPoint
+ *
+ * Returns the timestamp (in CLOCK_BOOTTIME seconds) for the last time the
+ * access point was found in scan results.  A value of -1 means the access
+ * point has not been found in a scan.
+ *
+ * Returns: the last seen time in seconds
+ *
+ * Since: 1.0.6
+ **/
+gint32
+nm_access_point_get_last_seen (NMAccessPoint *ap)
+{
+	g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), -1);
+
+	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
@@ -364,6 +386,7 @@ nm_access_point_filter_connections (NMAccessPoint *ap, const GPtrArray *connecti
 static void
 nm_access_point_init (NMAccessPoint *ap)
 {
+	NM_ACCESS_POINT_GET_PRIVATE (ap)->last_seen = -1;
 }
 
 static void
@@ -418,6 +441,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;
@@ -439,6 +465,7 @@ init_dbus (NMObject *object)
 		{ 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 },
 	};
 
@@ -595,4 +622,20 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
 		                     0, G_MAXUINT8, 0,
 		                     G_PARAM_READABLE |
 		                     G_PARAM_STATIC_STRINGS));
+
+	/**
+	 * NMAccessPoint:last-seen:
+	 *
+	 * The timestamp (in CLOCK_BOOTTIME seconds) for the last time the
+	 * access point was found in scan results.  A value of -1 means the
+	 * access point has not been found in a scan.
+	 *
+	 * Since: 1.0.6
+	 **/
+	g_object_class_install_property
+		(object_class, PROP_LAST_SEEN,
+		 g_param_spec_int (NM_ACCESS_POINT_LAST_SEEN, "", "",
+		                   -1, G_MAXINT, -1,
+		                   G_PARAM_READABLE |
+		                   G_PARAM_STATIC_STRINGS));
 }