summary refs log tree commit diff
path: root/libnm/nm-device-ovs-bridge.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm/nm-device-ovs-bridge.c')
-rw-r--r--libnm/nm-device-ovs-bridge.c105
1 files changed, 47 insertions, 58 deletions
diff --git a/libnm/nm-device-ovs-bridge.c b/libnm/nm-device-ovs-bridge.c
index 4671c8a9..4b946fca 100644
--- a/libnm/nm-device-ovs-bridge.c
+++ b/libnm/nm-device-ovs-bridge.c
@@ -1,20 +1,6 @@
+// SPDX-License-Identifier: LGPL-2.1+
 /*
- * 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
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA.
- *
- * Copyright 2017,2018 Red Hat, Inc.
+ * Copyright (C) 2017, 2018 Red Hat, Inc.
  */
 
 #include "nm-default.h"
@@ -27,19 +13,19 @@
 #include "nm-setting-connection.h"
 #include "nm-core-internal.h"
 
-enum {
-	PROP_0,
+/*****************************************************************************/
+
+NM_GOBJECT_PROPERTIES_DEFINE_BASE (
 	PROP_SLAVES,
+);
 
-	LAST_PROP
-};
+typedef struct {
+	NMLDBusPropertyAO slaves;
+} NMDeviceOvsBridgePrivate;
 
-/**
- * NMDeviceOvsBridge:
- */
 struct _NMDeviceOvsBridge {
 	NMDevice parent;
-	GPtrArray *slaves;
+	NMDeviceOvsBridgePrivate _priv;
 };
 
 struct _NMDeviceOvsBridgeClass {
@@ -48,6 +34,8 @@ struct _NMDeviceOvsBridgeClass {
 
 G_DEFINE_TYPE (NMDeviceOvsBridge, nm_device_ovs_bridge, NM_TYPE_DEVICE)
 
+#define NM_DEVICE_OVS_BRIDGE_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceOvsBridge, NM_IS_DEVICE_OVS_BRIDGE, NMObject, NMDevice)
+
 /*****************************************************************************/
 
 /**
@@ -67,7 +55,7 @@ nm_device_ovs_bridge_get_slaves (NMDeviceOvsBridge *device)
 {
 	g_return_val_if_fail (NM_IS_DEVICE_OVS_BRIDGE (device), FALSE);
 
-	return device->slaves;
+	return nml_dbus_property_ao_get_objs_as_ptrarray (&NM_DEVICE_OVS_BRIDGE_GET_PRIVATE (device)->slaves);
 }
 
 static const char *
@@ -109,22 +97,6 @@ get_setting_type (NMDevice *device)
 /*****************************************************************************/
 
 static void
-init_dbus (NMObject *object)
-{
-	NMDeviceOvsBridge *device = NM_DEVICE_OVS_BRIDGE (object);
-	const NMPropertiesInfo property_info[] = {
-		{ NM_DEVICE_OVS_BRIDGE_SLAVES, &device->slaves, NULL, NM_TYPE_DEVICE },
-		{ NULL },
-	};
-
-	NM_OBJECT_CLASS (nm_device_ovs_bridge_parent_class)->init_dbus (object);
-
-	_nm_object_register_properties (object,
-	                                NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE,
-	                                property_info);
-}
-
-static void
 get_property (GObject *object,
               guint prop_id,
               GValue *value,
@@ -142,34 +114,51 @@ get_property (GObject *object,
 	}
 }
 
+/*****************************************************************************/
+
 static void
 nm_device_ovs_bridge_init (NMDeviceOvsBridge *device)
 {
 }
 
-static void
-dispose (GObject *object)
-{
-	NMDeviceOvsBridge *device = NM_DEVICE_OVS_BRIDGE (object);
-
-	g_clear_pointer (&device->slaves, g_ptr_array_unref);
-
-	G_OBJECT_CLASS (nm_device_ovs_bridge_parent_class)->dispose (object);
-}
+const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = NML_DBUS_META_IFACE_INIT_PROP (
+	NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE,
+	nm_device_ovs_bridge_get_type,
+	NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH,
+	NML_DBUS_META_IFACE_DBUS_PROPERTIES (
+		NML_DBUS_META_PROPERTY_INIT_AO_PROP ("Slaves", PROP_SLAVES, NMDeviceOvsBridge, _priv.slaves, nm_device_get_type ),
+	),
+);
 
 static void
-nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *ovs_bridge_class)
+nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS (ovs_bridge_class);
-	NMObjectClass *nm_object_class = NM_OBJECT_CLASS (ovs_bridge_class);
-	NMDeviceClass *device_class = NM_DEVICE_CLASS (ovs_bridge_class);
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass);
+	NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
 
 	object_class->get_property = get_property;
-	object_class->dispose = dispose;
 
-	nm_object_class->init_dbus = init_dbus;
+	_NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT (nm_object_class, NMDeviceOvsBridge);
+
+	_NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1 (nm_object_class, NMDeviceOvsBridgePrivate, slaves);
 
-	device_class->get_type_description = get_type_description;
+	device_class->get_type_description  = get_type_description;
 	device_class->connection_compatible = connection_compatible;
-	device_class->get_setting_type = get_setting_type;
+	device_class->get_setting_type      = get_setting_type;
+
+	/**
+	 * NMDeviceOvsBridge:slaves: (type GPtrArray(NMDevice))
+	 *
+	 * Gets the ports currently enslaved to the device.
+	 *
+	 * Since: 1.22
+	 */
+	obj_properties[PROP_SLAVES] =
+	    g_param_spec_boxed (NM_DEVICE_OVS_BRIDGE_SLAVES, "", "",
+	                        G_TYPE_PTR_ARRAY,
+	                        G_PARAM_READABLE |
+	                        G_PARAM_STATIC_STRINGS);
+
+	_nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_ovsbridge);
 }