summaryrefslogtreecommitdiff
path: root/libnm-glib
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-02-12 13:11:42 -0500
committerDan Winship <danw@gnome.org>2013-02-14 09:31:33 -0500
commit43f259ee1f982a937426307f60b57aecd7601455 (patch)
tree0d903e659ff35a176b1c97e0613d75b6df01454f /libnm-glib
parent24cda2bc367d9fafa847a82493a1adb9f3e53e47 (diff)
downloadNetworkManager-43f259ee1f982a937426307f60b57aecd7601455.tar.gz
libnm-glib: add NMDevice:available-connections
NMDevice has a D-Bus "AvailableConnections" property, but we weren't exposing it on NMDevice. Fix that. https://bugzilla.gnome.org/show_bug.cgi?id=693669
Diffstat (limited to 'libnm-glib')
-rw-r--r--libnm-glib/libnm-glib.ver1
-rw-r--r--libnm-glib/nm-device.c50
-rw-r--r--libnm-glib/nm-device.h2
3 files changed, 53 insertions, 0 deletions
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 9fb956afc5..571bc7d25c 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -100,6 +100,7 @@ global:
nm_device_filter_connections;
nm_device_get_active_connection;
nm_device_get_autoconnect;
+ nm_device_get_available_connections;
nm_device_get_capabilities;
nm_device_get_device_type;
nm_device_get_dhcp4_config;
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index 22e2844cfc..227b92623a 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -41,6 +41,8 @@
#include "nm-device-private.h"
#include "nm-object-private.h"
#include "nm-object-cache.h"
+#include "nm-remote-connection.h"
+#include "nm-types.h"
#include "nm-glib-marshal.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
@@ -84,6 +86,7 @@ typedef struct {
NMDeviceStateReason reason;
NMActiveConnection *active_connection;
+ GPtrArray *available_connections;
GUdevClient *client;
char *product;
@@ -112,6 +115,7 @@ enum {
PROP_IP_INTERFACE,
PROP_DEVICE_TYPE,
PROP_ACTIVE_CONNECTION,
+ PROP_AVAILABLE_CONNECTIONS,
LAST_PROP
};
@@ -173,6 +177,7 @@ register_properties (NMDevice *device)
{ NM_DEVICE_STATE, &priv->state },
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
{ NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
+ { NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION },
/* Properties that exist in D-Bus but that we don't track */
{ "ip4-address", NULL },
@@ -332,6 +337,15 @@ dispose (GObject *object)
g_clear_object (&priv->client);
g_clear_object (&priv->active_connection);
+ if (priv->available_connections) {
+ int i;
+
+ for (i = 0; i < priv->available_connections->len; i++)
+ g_object_unref (priv->available_connections->pdata[i]);
+ g_ptr_array_free (priv->available_connections, TRUE);
+ priv->available_connections = NULL;
+ }
+
G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
}
@@ -423,6 +437,9 @@ get_property (GObject *object,
case PROP_ACTIVE_CONNECTION:
g_value_set_object (value, nm_device_get_active_connection (device));
break;
+ case PROP_AVAILABLE_CONNECTIONS:
+ g_value_set_boxed (value, nm_device_get_available_connections (device));
+ break;
case PROP_PRODUCT:
g_value_set_string (value, nm_device_get_product (device));
break;
@@ -718,6 +735,19 @@ nm_device_class_init (NMDeviceClass *device_class)
G_PARAM_READABLE));
/**
+ * NMDevice:available-connections:
+ *
+ * The available connections (#NMRemoteConnection) of the device
+ **/
+ g_object_class_install_property
+ (object_class, PROP_AVAILABLE_CONNECTIONS,
+ g_param_spec_boxed (NM_DEVICE_AVAILABLE_CONNECTIONS,
+ "AvailableConnections",
+ "Available Connections",
+ NM_TYPE_OBJECT_ARRAY,
+ G_PARAM_READABLE));
+
+ /**
* NMDevice:vendor:
*
* The vendor string of the device.
@@ -1256,6 +1286,26 @@ nm_device_get_active_connection (NMDevice *device)
return NM_DEVICE_GET_PRIVATE (device)->active_connection;
}
+/**
+ * nm_device_get_available_connections:
+ * @device: a #NMDevice
+ *
+ * Gets the #NMRemoteConnections currently known to the daemon that could
+ * be activated on @device.
+ *
+ * Returns: (element-type NMClient.RemoteConnection): the #GPtrArray
+ * containing #NMRemoteConnections. This is the internal copy used by
+ * the connection, and must not be modified.
+ **/
+const GPtrArray *
+nm_device_get_available_connections (NMDevice *device)
+{
+ g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
+
+ _nm_object_ensure_inited (NM_OBJECT (device));
+ return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections);
+}
+
/* From hostap, Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> */
static int hex2num (char c)
diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h
index 1726862fd3..c49675bccf 100644
--- a/libnm-glib/nm-device.h
+++ b/libnm-glib/nm-device.h
@@ -63,6 +63,7 @@ G_BEGIN_DECLS
#define NM_DEVICE_STATE "state"
#define NM_DEVICE_STATE_REASON "state-reason"
#define NM_DEVICE_ACTIVE_CONNECTION "active-connection"
+#define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections"
#define NM_DEVICE_VENDOR "vendor"
#define NM_DEVICE_PRODUCT "product"
@@ -115,6 +116,7 @@ NMDHCP6Config * nm_device_get_dhcp6_config (NMDevice *device);
NMDeviceState nm_device_get_state (NMDevice *device);
NMDeviceState nm_device_get_state_reason (NMDevice *device, NMDeviceStateReason *reason);
NMActiveConnection * nm_device_get_active_connection(NMDevice *device);
+const GPtrArray * nm_device_get_available_connections(NMDevice *device);
const char * nm_device_get_product (NMDevice *device);
const char * nm_device_get_vendor (NMDevice *device);