diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py
index 13646acfa..13f0b0310 100755
--- a/examples/python/gi/get-active-connections.py
+++ b/examples/python/gi/get-active-connections.py
@@ -21,27 +21,14 @@
# This example lists currently active connections
-main_loop = None
+from gi.repository import GLib, NMClient
-from gi.repository import GLib, NetworkManager, NMClient
-
-def connections_read(settings):
+if __name__ == "__main__":
client = NMClient.Client.new()
acons = client.get_active_connections()
for ac in acons:
- rem_con = settings.get_connection_by_path(ac.get_connection())
- c_type = rem_con.get_setting_connection().get_connection_type()
- print "%s (%s) - %s" % (rem_con.get_id(), ac.get_uuid(), c_type)
+ print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type())
if len(acons) == 0:
print "No active connections"
- main_loop.quit()
-if __name__ == "__main__":
- main_loop = GLib.MainLoop()
- settings = NMClient.RemoteSettings.new(None);
-
- # connections are read asynchronously, so we need to wait for the
- # settings object to tell us that it's read all connections
- settings.connect("connections-read", connections_read)
- main_loop.run()
diff --git a/introspection/nm-active-connection.xml b/introspection/nm-active-connection.xml
index 56a10132a..cbecdfcef 100644
--- a/introspection/nm-active-connection.xml
+++ b/introspection/nm-active-connection.xml
@@ -22,12 +22,24 @@
not change over the lifetime of the ActiveConnection once set.
+
+
+ The ID of the connection, provided as a convenience so that clients
+ do not have to retrieve all connection details.
+
+
The UUID of the connection, provided as a convenience so that clients
do not have to retrieve all connection details.
+
+
+ The type of the connection, provided as a convenience so that clients
+ do not have to retrieve all connection details.
+
+
Array of object paths representing devices which are part of this active
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 8eb17e29e..aa6f913d0 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -20,11 +20,13 @@ global:
nm_access_point_get_wpa_flags;
nm_access_point_new;
nm_active_connection_get_connection;
+ nm_active_connection_get_connection_type;
nm_active_connection_get_default6;
nm_active_connection_get_default;
nm_active_connection_get_devices;
nm_active_connection_get_dhcp4_config;
nm_active_connection_get_dhcp6_config;
+ nm_active_connection_get_id;
nm_active_connection_get_ip4_config;
nm_active_connection_get_ip6_config;
nm_active_connection_get_master;
diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c
index 460a2158a..fc4425f1e 100644
--- a/libnm-glib/nm-active-connection.c
+++ b/libnm-glib/nm-active-connection.c
@@ -53,7 +53,9 @@ typedef struct {
DBusGProxy *proxy;
char *connection;
+ char *id;
char *uuid;
+ char *type;
char *specific_object;
GPtrArray *devices;
NMActiveConnectionState state;
@@ -70,7 +72,9 @@ typedef struct {
enum {
PROP_0,
PROP_CONNECTION,
+ PROP_ID,
PROP_UUID,
+ PROP_TYPE,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
@@ -219,6 +223,26 @@ nm_active_connection_get_connection (NMActiveConnection *connection)
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->connection;
}
+/**
+ * nm_active_connection_get_id:
+ * @connection: a #NMActiveConnection
+ *
+ * Gets the #NMConnection's ID.
+ *
+ * Returns: the ID of the #NMConnection that backs the #NMActiveConnection.
+ * This is the internal string used by the connection, and must not be modified.
+ *
+ * Since: 0.9.10
+ **/
+const char *
+nm_active_connection_get_id (NMActiveConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
+
+ _nm_object_ensure_inited (NM_OBJECT (connection));
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->id;
+}
+
/**
* nm_active_connection_get_uuid:
* @connection: a #NMActiveConnection
@@ -237,6 +261,26 @@ nm_active_connection_get_uuid (NMActiveConnection *connection)
return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->uuid;
}
+/**
+ * nm_active_connection_get_connection_type:
+ * @connection: a #NMActiveConnection
+ *
+ * Gets the #NMConnection's type.
+ *
+ * Returns: the type of the #NMConnection that backs the #NMActiveConnection.
+ * This is the internal string used by the connection, and must not be modified.
+ *
+ * Since: 0.9.10
+ **/
+const char *
+nm_active_connection_get_connection_type (NMActiveConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
+
+ _nm_object_ensure_inited (NM_OBJECT (connection));
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->type;
+}
+
/**
* nm_active_connection_get_specific_object:
* @connection: a #NMActiveConnection
@@ -481,7 +525,9 @@ finalize (GObject *object)
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
g_free (priv->connection);
+ g_free (priv->id);
g_free (priv->uuid);
+ g_free (priv->type);
g_free (priv->specific_object);
g_free (priv->master);
@@ -502,9 +548,15 @@ get_property (GObject *object,
case PROP_CONNECTION:
g_value_set_string (value, nm_active_connection_get_connection (self));
break;
+ case PROP_ID:
+ g_value_set_string (value, nm_active_connection_get_id (self));
+ break;
case PROP_UUID:
g_value_set_string (value, nm_active_connection_get_uuid (self));
break;
+ case PROP_TYPE:
+ g_value_set_string (value, nm_active_connection_get_connection_type (self));
+ break;
case PROP_SPECIFIC_OBJECT:
g_value_set_boxed (value, nm_active_connection_get_specific_object (self));
break;
@@ -550,7 +602,9 @@ register_properties (NMActiveConnection *connection)
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
const NMPropertiesInfo property_info[] = {
{ NM_ACTIVE_CONNECTION_CONNECTION, &priv->connection },
+ { NM_ACTIVE_CONNECTION_ID, &priv->id },
{ NM_ACTIVE_CONNECTION_UUID, &priv->uuid },
+ { NM_ACTIVE_CONNECTION_TYPE, &priv->type },
{ NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, &priv->specific_object },
{ NM_ACTIVE_CONNECTION_DEVICES, &priv->devices, NULL, NM_TYPE_DEVICE },
{ NM_ACTIVE_CONNECTION_STATE, &priv->state },
@@ -611,6 +665,21 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
NULL,
G_PARAM_READABLE));
+ /**
+ * NMActiveConnection:id:
+ *
+ * The active connection's ID
+ *
+ * Since: 0.9.10
+ **/
+ g_object_class_install_property
+ (object_class, PROP_ID,
+ g_param_spec_string (NM_ACTIVE_CONNECTION_ID,
+ "ID",
+ "ID",
+ NULL,
+ G_PARAM_READABLE));
+
/**
* NMActiveConnection:uuid:
*
@@ -624,6 +693,21 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
NULL,
G_PARAM_READABLE));
+ /**
+ * NMActiveConnection:type:
+ *
+ * The active connection's type
+ *
+ * Since: 0.9.10
+ **/
+ g_object_class_install_property
+ (object_class, PROP_TYPE,
+ g_param_spec_string (NM_ACTIVE_CONNECTION_TYPE,
+ "Type",
+ "Type",
+ NULL,
+ G_PARAM_READABLE));
+
/**
* NMActiveConnection:specific-object:
*
diff --git a/libnm-glib/nm-active-connection.h b/libnm-glib/nm-active-connection.h
index 1d3ea99a4..b15e8340c 100644
--- a/libnm-glib/nm-active-connection.h
+++ b/libnm-glib/nm-active-connection.h
@@ -44,7 +44,9 @@ G_BEGIN_DECLS
#define NM_ACTIVE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionClass))
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
+#define NM_ACTIVE_CONNECTION_ID "id"
#define NM_ACTIVE_CONNECTION_UUID "uuid"
+#define NM_ACTIVE_CONNECTION_TYPE "type"
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
@@ -78,7 +80,11 @@ GType nm_active_connection_get_type (void);
GObject *nm_active_connection_new (DBusGConnection *connection, const char *path);
const char * nm_active_connection_get_connection (NMActiveConnection *connection);
+NM_AVAILABLE_IN_0_9_10
+const char * nm_active_connection_get_id (NMActiveConnection *connection);
const char * nm_active_connection_get_uuid (NMActiveConnection *connection);
+NM_AVAILABLE_IN_0_9_10
+const char * nm_active_connection_get_connection_type (NMActiveConnection *connection);
const char * nm_active_connection_get_specific_object (NMActiveConnection *connection);
const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *connection);
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index 09f7c58f6..481de76c2 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -11,6 +11,7 @@ global:
nm_connection_error_get_type;
nm_connection_error_quark;
nm_connection_for_each_setting_value;
+ nm_connection_get_connection_type;
nm_connection_get_id;
nm_connection_get_path;
nm_connection_get_setting;
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 213d715fb..8546d9bcb 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -1243,6 +1243,29 @@ nm_connection_get_id (NMConnection *connection)
return nm_setting_connection_get_id (s_con);
}
+/**
+ * nm_connection_get_connection_type:
+ * @connection: the #NMConnection
+ *
+ * A shortcut to return the type from the connection's #NMSettingConnection.
+ *
+ * Returns: the type from the connection's 'connection' setting
+ *
+ * Since: 0.9.10
+ **/
+const char *
+nm_connection_get_connection_type (NMConnection *connection)
+{
+ NMSettingConnection *s_con;
+
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+
+ s_con = nm_connection_get_setting_connection (connection);
+ g_return_val_if_fail (s_con != NULL, NULL);
+
+ return nm_setting_connection_get_connection_type (s_con);
+}
+
/**
* nm_connection_get_virtual_device_description:
* @connection: an #NMConnection for a virtual device type
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
index c13f45689..4524c8f62 100644
--- a/libnm-util/nm-connection.h
+++ b/libnm-util/nm-connection.h
@@ -197,9 +197,10 @@ GType nm_connection_lookup_setting_type (const char *name);
GType nm_connection_lookup_setting_type_by_quark (GQuark error_quark);
/* Helpers */
-const char * nm_connection_get_uuid (NMConnection *connection);
-
-const char * nm_connection_get_id (NMConnection *connection);
+const char * nm_connection_get_uuid (NMConnection *connection);
+const char * nm_connection_get_id (NMConnection *connection);
+NM_AVAILABLE_IN_0_9_10
+const char * nm_connection_get_connection_type (NMConnection *connection);
NM_AVAILABLE_IN_0_9_10
char * nm_connection_get_virtual_device_description (NMConnection *connection);
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index e8d07dd23..792ec51a1 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2008 - 2012 Red Hat, Inc.
+ * Copyright (C) 2008 - 2014 Red Hat, Inc.
*/
#include
@@ -68,7 +68,9 @@ typedef struct {
enum {
PROP_0,
PROP_CONNECTION,
+ PROP_ID,
PROP_UUID,
+ PROP_TYPE,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
@@ -714,9 +716,15 @@ get_property (GObject *object, guint prop_id,
case PROP_CONNECTION:
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
break;
+ case PROP_ID:
+ g_value_set_string (value, nm_connection_get_id (priv->connection));
+ break;
case PROP_UUID:
g_value_set_string (value, nm_connection_get_uuid (priv->connection));
break;
+ case PROP_TYPE:
+ g_value_set_string (value, nm_connection_get_connection_type (priv->connection));
+ break;
case PROP_SPECIFIC_OBJECT:
g_value_set_boxed (value, priv->specific_object ? priv->specific_object : "/");
break;
@@ -838,6 +846,13 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_ID,
+ g_param_spec_string (NM_ACTIVE_CONNECTION_ID,
+ "Connection ID",
+ "Connection ID",
+ NULL,
+ G_PARAM_READABLE));
+
g_object_class_install_property (object_class, PROP_UUID,
g_param_spec_string (NM_ACTIVE_CONNECTION_UUID,
"Connection UUID",
@@ -845,6 +860,13 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
NULL,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_TYPE,
+ g_param_spec_string (NM_ACTIVE_CONNECTION_TYPE,
+ "Connection Type",
+ "Connection Type",
+ NULL,
+ G_PARAM_READABLE));
+
g_object_class_install_property (object_class, PROP_SPECIFIC_OBJECT,
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
"Specific object",
diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h
index 2a4df9705..fac09e7c0 100644
--- a/src/nm-active-connection.h
+++ b/src/nm-active-connection.h
@@ -35,7 +35,9 @@
/* D-Bus Exported Properties */
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
+#define NM_ACTIVE_CONNECTION_ID "id"
#define NM_ACTIVE_CONNECTION_UUID "uuid"
+#define NM_ACTIVE_CONNECTION_TYPE "type"
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
@@ -94,6 +96,10 @@ void nm_active_connection_set_connection (NMActiveConnection *self,
const char * nm_active_connection_get_name (NMActiveConnection *self);
+const char * nm_active_connection_get_uuid (NMActiveConnection *self);
+
+const char * nm_active_connection_get_connection_type (NMActiveConnection *self);
+
const char * nm_active_connection_get_path (NMActiveConnection *self);
const char * nm_active_connection_get_specific_object (NMActiveConnection *self);