api/core: add ActiveConnection property to device objects

Enables easier traversal of the object hierarchy; if a client is
watching signals on a device they can easily get back to the
parent NMActiveConnection object to grab connection details or
status.
This commit is contained in:
Dan Williams 2011-05-26 18:27:01 -05:00
parent e56f0ea18f
commit 459e7b9518
4 changed files with 28 additions and 0 deletions

View file

@ -51,6 +51,14 @@
The current state of the device.
</tp:docstring>
</property>
<property name="ActiveConnection" type="o" access="read">
<tp:docstring>
Object path of an ActiveConnection object that "owns" this device during
activation. The ActiveConnection object tracks the life-cycle of a
connection to a specific network and implements the
org.freedesktop.NetworkManager.Connection.Active D-Bus interface.
</tp:docstring>
</property>
<property name="Ip4Config" type="o" access="read">
<tp:docstring>
Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.

View file

@ -164,6 +164,14 @@ nm_device_interface_init (gpointer g_iface)
0, G_MAXUINT32, NM_DEVICE_STATE_UNKNOWN,
G_PARAM_READABLE));
g_object_interface_install_property
(g_iface,
g_param_spec_boxed (NM_DEVICE_INTERFACE_ACTIVE_CONNECTION,
"ActiveConnection",
"ActiveConnection",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_interface_install_property
(g_iface,
g_param_spec_uint (NM_DEVICE_INTERFACE_DEVICE_TYPE,

View file

@ -58,6 +58,7 @@ typedef enum
#define NM_DEVICE_INTERFACE_IP6_CONFIG "ip6-config"
#define NM_DEVICE_INTERFACE_DHCP6_CONFIG "dhcp6-config"
#define NM_DEVICE_INTERFACE_STATE "state"
#define NM_DEVICE_INTERFACE_ACTIVE_CONNECTION "active-connection"
#define NM_DEVICE_INTERFACE_DEVICE_TYPE "device-type" /* ugh */
#define NM_DEVICE_INTERFACE_MANAGED "managed"
#define NM_DEVICE_INTERFACE_FIRMWARE_MISSING "firmware-missing"
@ -79,6 +80,7 @@ typedef enum {
NM_DEVICE_INTERFACE_PROP_IP6_CONFIG,
NM_DEVICE_INTERFACE_PROP_DHCP6_CONFIG,
NM_DEVICE_INTERFACE_PROP_STATE,
NM_DEVICE_INTERFACE_PROP_ACTIVE_CONNECTION,
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
NM_DEVICE_INTERFACE_PROP_MANAGED,
NM_DEVICE_INTERFACE_PROP_FIRMWARE_MISSING,

View file

@ -3463,6 +3463,7 @@ get_property (GObject *object, guint prop_id,
NMDevice *self = NM_DEVICE (object);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDeviceState state;
const char *ac_path = NULL;
state = nm_device_get_state (self);
@ -3518,6 +3519,11 @@ get_property (GObject *object, guint prop_id,
case NM_DEVICE_INTERFACE_PROP_STATE:
g_value_set_uint (value, priv->state);
break;
case NM_DEVICE_INTERFACE_PROP_ACTIVE_CONNECTION:
if (priv->act_request)
ac_path = nm_act_request_get_active_connection_path (priv->act_request);
g_value_set_boxed (value, ac_path ? ac_path : "/");
break;
case NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE:
g_value_set_uint (value, priv->type);
break;
@ -3615,6 +3621,10 @@ nm_device_class_init (NMDeviceClass *klass)
NM_DEVICE_INTERFACE_PROP_STATE,
NM_DEVICE_INTERFACE_STATE);
g_object_class_override_property (object_class,
NM_DEVICE_INTERFACE_PROP_ACTIVE_CONNECTION,
NM_DEVICE_INTERFACE_ACTIVE_CONNECTION);
g_object_class_override_property (object_class,
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
NM_DEVICE_INTERFACE_DEVICE_TYPE);