api: add "Uuid" property to ActiveConnection interface
A convenience so that clients which might key certain operations off which connections are active (checking work mail only when on VPN for example) can more easily get which connections are active. This would allow those apps to store the UUID (which they would already be doing) and not have to create a Connection proxy and then get the connection properties just to retrieve the UUID of the connection. Instead they can now get it from GetAll of the ActiveConnection object, which they would already be doing.
This commit is contained in:
@@ -8,6 +8,12 @@
|
||||
<property name="SpecificObject" type="o" access="read">
|
||||
<tp:docstring>A specific object associated with the active connection.</tp:docstring>
|
||||
</property>
|
||||
<property name="Uuid" type="s" access="read">
|
||||
<tp:docstring>
|
||||
The UUID of the connection, provided as a convenience so that clients
|
||||
do not have to retrieve all connection details.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
<property name="Devices" type="ao" access="read">
|
||||
<tp:docstring>Array of object paths representing devices which are part of this active connection.</tp:docstring>
|
||||
</property>
|
||||
|
@@ -25,6 +25,7 @@ global:
|
||||
nm_active_connection_get_specific_object;
|
||||
nm_active_connection_get_state;
|
||||
nm_active_connection_get_type;
|
||||
nm_active_connection_get_uuid;
|
||||
nm_active_connection_new;
|
||||
nm_client_activate_connection;
|
||||
nm_client_add_and_activate_connection;
|
||||
|
@@ -44,6 +44,7 @@ typedef struct {
|
||||
DBusGProxy *proxy;
|
||||
|
||||
char *connection;
|
||||
char *uuid;
|
||||
char *specific_object;
|
||||
GPtrArray *devices;
|
||||
NMActiveConnectionState state;
|
||||
@@ -54,6 +55,7 @@ typedef struct {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
PROP_UUID,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_DEVICES,
|
||||
PROP_STATE,
|
||||
@@ -64,6 +66,7 @@ enum {
|
||||
};
|
||||
|
||||
#define DBUS_PROP_CONNECTION "Connection"
|
||||
#define DBUS_PROP_UUID "Uuid"
|
||||
#define DBUS_PROP_SPECIFIC_OBJECT "SpecificObject"
|
||||
#define DBUS_PROP_DEVICES "Devices"
|
||||
#define DBUS_PROP_STATE "State"
|
||||
@@ -118,6 +121,33 @@ nm_active_connection_get_connection (NMActiveConnection *connection)
|
||||
return priv->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_active_connection_get_uuid:
|
||||
* @connection: a #NMActiveConnection
|
||||
*
|
||||
* Gets the #NMConnection<!-- -->'s UUID.
|
||||
*
|
||||
* Returns: the UUID of the #NMConnection that backs the #NMActiveConnection.
|
||||
* This is the internal string used by the connection, and must not be modified.
|
||||
**/
|
||||
const char *
|
||||
nm_active_connection_get_uuid (NMActiveConnection *connection)
|
||||
{
|
||||
NMActiveConnectionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
|
||||
|
||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
|
||||
if (!priv->uuid) {
|
||||
priv->uuid = _nm_object_get_string_property (NM_OBJECT (connection),
|
||||
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
|
||||
DBUS_PROP_UUID,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return priv->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_active_connection_get_specific_object:
|
||||
* @connection: a #NMActiveConnection
|
||||
@@ -292,6 +322,7 @@ finalize (GObject *object)
|
||||
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->connection);
|
||||
g_free (priv->uuid);
|
||||
g_free (priv->specific_object);
|
||||
|
||||
G_OBJECT_CLASS (nm_active_connection_parent_class)->finalize (object);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2007 - 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2007 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,7 @@ 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_UUID "uuid"
|
||||
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
|
||||
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
|
||||
#define NM_ACTIVE_CONNECTION_STATE "state"
|
||||
@@ -67,6 +68,7 @@ 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);
|
||||
const char * nm_active_connection_get_uuid (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);
|
||||
|
@@ -84,6 +84,7 @@ typedef struct {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
PROP_UUID,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_DEVICES,
|
||||
PROP_STATE,
|
||||
@@ -531,6 +532,9 @@ get_property (GObject *object, guint prop_id,
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
|
||||
break;
|
||||
case PROP_UUID:
|
||||
g_value_set_string (value, nm_connection_get_uuid (priv->connection));
|
||||
break;
|
||||
case PROP_SPECIFIC_OBJECT:
|
||||
if (priv->specific_object)
|
||||
g_value_set_boxed (value, priv->specific_object);
|
||||
@@ -622,6 +626,7 @@ nm_act_request_class_init (NMActRequestClass *req_class)
|
||||
/* properties */
|
||||
nm_active_connection_install_properties (object_class,
|
||||
PROP_CONNECTION,
|
||||
PROP_UUID,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_DEVICES,
|
||||
PROP_STATE,
|
||||
|
@@ -35,6 +35,7 @@ nm_active_connection_get_next_object_path (void)
|
||||
void
|
||||
nm_active_connection_install_properties (GObjectClass *object_class,
|
||||
guint prop_connection,
|
||||
guint prop_uuid,
|
||||
guint prop_specific_object,
|
||||
guint prop_devices,
|
||||
guint prop_state,
|
||||
@@ -49,6 +50,13 @@ nm_active_connection_install_properties (GObjectClass *object_class,
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class, prop_uuid,
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_UUID,
|
||||
"Connection UUID",
|
||||
"Connection UUID",
|
||||
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",
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "nm-connection.h"
|
||||
|
||||
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
|
||||
#define NM_ACTIVE_CONNECTION_UUID "uuid"
|
||||
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
|
||||
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
|
||||
#define NM_ACTIVE_CONNECTION_STATE "state"
|
||||
@@ -36,6 +37,7 @@ char *nm_active_connection_get_next_object_path (void);
|
||||
|
||||
void nm_active_connection_install_properties (GObjectClass *object_class,
|
||||
guint prop_connection,
|
||||
guint prop_uuid,
|
||||
guint prop_specific_object,
|
||||
guint prop_devices,
|
||||
guint prop_state,
|
||||
|
@@ -44,6 +44,7 @@ typedef struct {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CONNECTION,
|
||||
PROP_UUID,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_DEVICES,
|
||||
PROP_STATE,
|
||||
@@ -143,6 +144,9 @@ get_property (GObject *object, guint prop_id,
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
|
||||
break;
|
||||
case PROP_UUID:
|
||||
g_value_set_boxed (value, nm_connection_get_uuid (priv->connection));
|
||||
break;
|
||||
case PROP_SPECIFIC_OBJECT:
|
||||
g_value_set_boxed (value, priv->ac_path);
|
||||
break;
|
||||
@@ -181,6 +185,7 @@ nm_vpn_connection_base_class_init (NMVpnConnectionBaseClass *vpn_class)
|
||||
/* properties */
|
||||
nm_active_connection_install_properties (object_class,
|
||||
PROP_CONNECTION,
|
||||
PROP_UUID,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_DEVICES,
|
||||
PROP_STATE,
|
||||
|
Reference in New Issue
Block a user