diff options
author | Dan Winship <danw@gnome.org> | 2012-10-17 16:10:03 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-10-19 12:09:27 -0400 |
commit | ad74379c2c08284ced76505a85d802bf120ec92f (patch) | |
tree | df1c75b5180b70099881e20e108c8a6a93405901 /libnm-glib | |
parent | 439fefd295d4d913179f83ad464422a4458a7f89 (diff) | |
download | NetworkManager-ad74379c2c08284ced76505a85d802bf120ec92f.tar.gz |
core, libnm-glib: expose "slaves" property on NMDeviceBond
https://bugzilla.gnome.org/show_bug.cgi?id=686367
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/libnm-glib.ver | 1 | ||||
-rw-r--r-- | libnm-glib/nm-device-bond.c | 47 | ||||
-rw-r--r-- | libnm-glib/nm-device-bond.h | 6 |
3 files changed, 51 insertions, 3 deletions
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index 4bcbfb0d84..b063ffac9e 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -67,6 +67,7 @@ global: nm_device_bond_error_quark; nm_device_bond_get_carrier; nm_device_bond_get_hw_address; + nm_device_bond_get_slaves; nm_device_bond_get_type; nm_device_bond_new; nm_device_bt_error_get_type; diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c index d5e33e5032..d215fc47f8 100644 --- a/libnm-glib/nm-device-bond.c +++ b/libnm-glib/nm-device-bond.c @@ -33,6 +33,7 @@ #include "nm-device-bond.h" #include "nm-device-private.h" #include "nm-object-private.h" +#include "nm-types.h" G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) @@ -43,18 +44,21 @@ typedef struct { char *hw_address; gboolean carrier; + GPtrArray *slaves; } NMDeviceBondPrivate; enum { PROP_0, PROP_HW_ADDRESS, PROP_CARRIER, + PROP_SLAVES, LAST_PROP }; #define DBUS_PROP_HW_ADDRESS "HwAddress" #define DBUS_PROP_CARRIER "Carrier" +#define DBUS_PROP_SLAVES "Slaves" /** * nm_device_bond_error_quark: @@ -133,6 +137,25 @@ nm_device_bond_get_carrier (NMDeviceBond *device) return NM_DEVICE_BOND_GET_PRIVATE (device)->carrier; } +/** + * nm_device_bond_get_slaves: + * @device: a #NMDeviceBond + * + * Gets the devices currently slaved to @device. + * + * Returns: (element-type NMClient.Device): the #GPtrArray containing + * #NMDevice<!-- -->s that are slaves of @device. This is the internal + * copy used by the device, and must not be modified. + **/ +const GPtrArray * +nm_device_bond_get_slaves (NMDeviceBond *device) +{ + g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE); + + _nm_object_ensure_inited (NM_OBJECT (device)); + return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves); +} + static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { @@ -167,7 +190,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro return FALSE; } - /* FIXME: check slaves? But we can't... */ + /* FIXME: check slaves? */ return TRUE; } @@ -187,6 +210,7 @@ register_properties (NMDeviceBond *device) const NMPropertiesInfo property_info[] = { { NM_DEVICE_BOND_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_BOND_CARRIER, &priv->carrier }, + { NM_DEVICE_BOND_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE }, { NULL }, }; @@ -219,6 +243,12 @@ dispose (GObject *object) g_clear_object (&priv->proxy); + if (priv->slaves) { + g_ptr_array_foreach (priv->slaves, (GFunc) g_object_unref, NULL); + g_ptr_array_free (priv->slaves, TRUE); + priv->slaves = NULL; + } + G_OBJECT_CLASS (nm_device_bond_parent_class)->dispose (object); } @@ -249,6 +279,9 @@ get_property (GObject *object, case PROP_CARRIER: g_value_set_boolean (value, nm_device_bond_get_carrier (device)); break; + case PROP_SLAVES: + g_value_set_boxed (value, nm_device_bond_get_slaves (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -298,4 +331,16 @@ nm_device_bond_class_init (NMDeviceBondClass *eth_class) FALSE, G_PARAM_READABLE)); + /** + * NMDeviceBond:slaves: + * + * The devices (#NMDevice) slaved to the bond device. + **/ + g_object_class_install_property + (object_class, PROP_SLAVES, + g_param_spec_boxed (NM_DEVICE_BOND_SLAVES, + "Slaves", + "Slaves", + NM_TYPE_OBJECT_ARRAY, + G_PARAM_READABLE)); } diff --git a/libnm-glib/nm-device-bond.h b/libnm-glib/nm-device-bond.h index 61ff38267d..a495689a9c 100644 --- a/libnm-glib/nm-device-bond.h +++ b/libnm-glib/nm-device-bond.h @@ -53,6 +53,7 @@ GQuark nm_device_bond_error_quark (void); #define NM_DEVICE_BOND_HW_ADDRESS "hw-address" #define NM_DEVICE_BOND_CARRIER "carrier" +#define NM_DEVICE_BOND_SLAVES "slaves" typedef struct { NMDevice parent; @@ -74,8 +75,9 @@ GType nm_device_bond_get_type (void); GObject *nm_device_bond_new (DBusGConnection *connection, const char *path); -const char * nm_device_bond_get_hw_address (NMDeviceBond *device); -gboolean nm_device_bond_get_carrier (NMDeviceBond *device); +const char *nm_device_bond_get_hw_address (NMDeviceBond *device); +gboolean nm_device_bond_get_carrier (NMDeviceBond *device); +const GPtrArray *nm_device_bond_get_slaves (NMDeviceBond *device); G_END_DECLS |