summary refs log tree commit diff
path: root/libnm-glib/nm-device-vlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib/nm-device-vlan.c')
-rw-r--r--libnm-glib/nm-device-vlan.c74
1 files changed, 54 insertions, 20 deletions
diff --git a/libnm-glib/nm-device-vlan.c b/libnm-glib/nm-device-vlan.c
index 2a84b946..26c234bd 100644
--- a/libnm-glib/nm-device-vlan.c
+++ b/libnm-glib/nm-device-vlan.c
@@ -1,7 +1,5 @@
 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /*
- * libnm_glib -- Access network status & information from glib applications
- *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -17,10 +15,11 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright 2012 Red Hat, Inc.
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <string.h>
 #include <netinet/ether.h>
 
@@ -43,6 +42,7 @@ typedef struct {
 
 	char *hw_address;
 	gboolean carrier;
+	NMDevice *parent;
 	guint vlan_id;
 } NMDeviceVlanPrivate;
 
@@ -50,6 +50,7 @@ enum {
 	PROP_0,
 	PROP_HW_ADDRESS,
 	PROP_CARRIER,
+	PROP_PARENT,
 	PROP_VLAN_ID,
 
 	LAST_PROP
@@ -133,6 +134,23 @@ nm_device_vlan_get_carrier (NMDeviceVlan *device)
 }
 
 /**
+ * nm_device_vlan_get_parent:
+ * @device: a #NMDeviceVlan
+ *
+ * Returns: (transfer none): 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:
  * @device: a #NMDeviceVlan
  *
@@ -232,6 +250,7 @@ register_properties (NMDeviceVlan *device)
 	const NMPropertiesInfo property_info[] = {
 		{ NM_DEVICE_VLAN_HW_ADDRESS, &priv->hw_address },
 		{ NM_DEVICE_VLAN_CARRIER,    &priv->carrier },
+		{ NM_DEVICE_VLAN_PARENT,     &priv->parent, NULL, NM_TYPE_DEVICE },
 		{ NM_DEVICE_VLAN_VLAN_ID,    &priv->vlan_id },
 		{ NULL },
 	};
@@ -257,6 +276,7 @@ dispose (GObject *object)
 {
 	NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
 
+	g_clear_object (&priv->parent);
 	g_clear_object (&priv->proxy);
 
 	G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
@@ -289,6 +309,9 @@ get_property (GObject *object,
 	case PROP_CARRIER:
 		g_value_set_boolean (value, nm_device_vlan_get_carrier (device));
 		break;
+	case PROP_PARENT:
+		g_value_set_object (value, nm_device_vlan_get_parent (device));
+		break;
 	case PROP_VLAN_ID:
 		g_value_set_uint (value, nm_device_vlan_get_vlan_id (device));
 		break;
@@ -299,12 +322,12 @@ get_property (GObject *object,
 }
 
 static void
-nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
+nm_device_vlan_class_init (NMDeviceVlanClass *vlan_class)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (eth_class);
-	NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class);
+	GObjectClass *object_class = G_OBJECT_CLASS (vlan_class);
+	NMDeviceClass *device_class = NM_DEVICE_CLASS (vlan_class);
 
-	g_type_class_add_private (eth_class, sizeof (NMDeviceVlanPrivate));
+	g_type_class_add_private (vlan_class, sizeof (NMDeviceVlanPrivate));
 
 	/* virtual methods */
 	object_class->constructed = constructed;
@@ -324,11 +347,10 @@ nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
 	 **/
 	g_object_class_install_property
 		(object_class, PROP_HW_ADDRESS,
-		 g_param_spec_string (NM_DEVICE_VLAN_HW_ADDRESS,
-		                      "Active MAC Address",
-		                      "Currently set hardware MAC address",
+		 g_param_spec_string (NM_DEVICE_VLAN_HW_ADDRESS, "", "",
 		                      NULL,
-		                      G_PARAM_READABLE));
+		                      G_PARAM_READABLE |
+		                      G_PARAM_STATIC_STRINGS));
 
 	/**
 	 * NMDeviceVlan:carrier:
@@ -337,11 +359,24 @@ nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
 	 **/
 	g_object_class_install_property
 		(object_class, PROP_CARRIER,
-		 g_param_spec_boolean (NM_DEVICE_VLAN_CARRIER,
-		                       "Carrier",
-		                       "Carrier",
+		 g_param_spec_boolean (NM_DEVICE_VLAN_CARRIER, "", "",
 		                       FALSE,
-		                       G_PARAM_READABLE));
+		                       G_PARAM_READABLE |
+		                       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:
@@ -350,9 +385,8 @@ nm_device_vlan_class_init (NMDeviceVlanClass *eth_class)
 	 **/
 	g_object_class_install_property
 		(object_class, PROP_VLAN_ID,
-		 g_param_spec_uint (NM_DEVICE_VLAN_VLAN_ID,
-		                    "VLAN ID",
-		                    "VLAN ID",
+		 g_param_spec_uint (NM_DEVICE_VLAN_VLAN_ID, "", "",
 		                    0, 4095, 0,
-		                    G_PARAM_READABLE));
+		                    G_PARAM_READABLE |
+		                    G_PARAM_STATIC_STRINGS));
 }