libnm-glib: add :parent property for VLAN devices

This commit is contained in:
Jiří Klimeš
2014-07-21 12:32:10 +02:00
parent 4e105c5012
commit 922a78d120
3 changed files with 43 additions and 1 deletions

View File

@@ -183,6 +183,7 @@ global:
nm_device_vlan_error_quark; nm_device_vlan_error_quark;
nm_device_vlan_get_carrier; nm_device_vlan_get_carrier;
nm_device_vlan_get_hw_address; nm_device_vlan_get_hw_address;
nm_device_vlan_get_parent;
nm_device_vlan_get_type; nm_device_vlan_get_type;
nm_device_vlan_get_vlan_id; nm_device_vlan_get_vlan_id;
nm_device_vlan_new; nm_device_vlan_new;

View File

@@ -42,6 +42,7 @@ typedef struct {
char *hw_address; char *hw_address;
gboolean carrier; gboolean carrier;
NMDevice *parent;
guint vlan_id; guint vlan_id;
} NMDeviceVlanPrivate; } NMDeviceVlanPrivate;
@@ -49,6 +50,7 @@ enum {
PROP_0, PROP_0,
PROP_HW_ADDRESS, PROP_HW_ADDRESS,
PROP_CARRIER, PROP_CARRIER,
PROP_PARENT,
PROP_VLAN_ID, PROP_VLAN_ID,
LAST_PROP LAST_PROP
@@ -131,6 +133,23 @@ nm_device_vlan_get_carrier (NMDeviceVlan *device)
return NM_DEVICE_VLAN_GET_PRIVATE (device)->carrier; return NM_DEVICE_VLAN_GET_PRIVATE (device)->carrier;
} }
/**
* nm_device_vlan_get_parent:
* @device: a #NMDeviceVlan
*
* Returns: the device's parent device
*
* Since: 1.0
**/
NMDevice *
nm_device_vlan_get_parent (NMDeviceVlan *device)
{
g_return_val_if_fail (NM_IS_DEVICE_VLAN (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_VLAN_GET_PRIVATE (device)->parent;
}
/** /**
* nm_device_vlan_get_vlan_id: * nm_device_vlan_get_vlan_id:
* @device: a #NMDeviceVlan * @device: a #NMDeviceVlan
@@ -231,6 +250,7 @@ register_properties (NMDeviceVlan *device)
const NMPropertiesInfo property_info[] = { const NMPropertiesInfo property_info[] = {
{ NM_DEVICE_VLAN_HW_ADDRESS, &priv->hw_address }, { NM_DEVICE_VLAN_HW_ADDRESS, &priv->hw_address },
{ NM_DEVICE_VLAN_CARRIER, &priv->carrier }, { NM_DEVICE_VLAN_CARRIER, &priv->carrier },
{ NM_DEVICE_VLAN_PARENT, &priv->parent, NULL, NM_TYPE_DEVICE },
{ NM_DEVICE_VLAN_VLAN_ID, &priv->vlan_id }, { NM_DEVICE_VLAN_VLAN_ID, &priv->vlan_id },
{ NULL }, { NULL },
}; };
@@ -256,6 +276,7 @@ dispose (GObject *object)
{ {
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
g_clear_object (&priv->parent);
g_clear_object (&priv->proxy); g_clear_object (&priv->proxy);
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object); G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
@@ -288,6 +309,9 @@ get_property (GObject *object,
case PROP_CARRIER: case PROP_CARRIER:
g_value_set_boolean (value, nm_device_vlan_get_carrier (device)); g_value_set_boolean (value, nm_device_vlan_get_carrier (device));
break; break;
case PROP_PARENT:
g_value_set_object (value, nm_device_vlan_get_parent (device));
break;
case PROP_VLAN_ID: case PROP_VLAN_ID:
g_value_set_uint (value, nm_device_vlan_get_vlan_id (device)); g_value_set_uint (value, nm_device_vlan_get_vlan_id (device));
break; break;
@@ -340,6 +364,20 @@ nm_device_vlan_class_init (NMDeviceVlanClass *vlan_class)
G_PARAM_READABLE | G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/**
* NMDeviceVlan:parent:
*
* The devices's parent device.
*
* Since: 1.0
**/
g_object_class_install_property
(object_class, PROP_PARENT,
g_param_spec_object (NM_DEVICE_VLAN_PARENT, "", "",
NM_TYPE_DEVICE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/** /**
* NMDeviceVlan:vlan-id: * NMDeviceVlan:vlan-id:
* *

View File

@@ -15,7 +15,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA. * Boston, MA 02110-1301 USA.
* *
* Copyright 2012 Red Hat, Inc. * Copyright 2012 - 2014 Red Hat, Inc.
*/ */
#ifndef NM_DEVICE_VLAN_H #ifndef NM_DEVICE_VLAN_H
@@ -55,6 +55,7 @@ GQuark nm_device_vlan_error_quark (void);
#define NM_DEVICE_VLAN_HW_ADDRESS "hw-address" #define NM_DEVICE_VLAN_HW_ADDRESS "hw-address"
#define NM_DEVICE_VLAN_CARRIER "carrier" #define NM_DEVICE_VLAN_CARRIER "carrier"
#define NM_DEVICE_VLAN_PARENT "parent"
#define NM_DEVICE_VLAN_VLAN_ID "vlan-id" #define NM_DEVICE_VLAN_VLAN_ID "vlan-id"
typedef struct { typedef struct {
@@ -79,6 +80,8 @@ GObject *nm_device_vlan_new (DBusGConnection *connection, const char *path);
const char * nm_device_vlan_get_hw_address (NMDeviceVlan *device); const char * nm_device_vlan_get_hw_address (NMDeviceVlan *device);
gboolean nm_device_vlan_get_carrier (NMDeviceVlan *device); gboolean nm_device_vlan_get_carrier (NMDeviceVlan *device);
NM_AVAILABLE_IN_1_0
NMDevice * nm_device_vlan_get_parent (NMDeviceVlan *device);
guint nm_device_vlan_get_vlan_id (NMDeviceVlan *device); guint nm_device_vlan_get_vlan_id (NMDeviceVlan *device);
G_END_DECLS G_END_DECLS