diff options
| author | Michael Biebl <biebl@debian.org> | 2019-12-18 18:29:24 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-12-18 18:29:24 +0100 |
| commit | 28028b26b3371756811e95d894f709f4b1207c00 (patch) | |
| tree | 6fe7316fd743b51042db47601a8ef8814b3134ac /libnm/nm-device-bt.c | |
| parent | e22609983008e1a669196ad64ba3a59ae8c76e0d (diff) | |
New upstream version 1.22.0 upstream/1.22.0
Diffstat (limited to 'libnm/nm-device-bt.c')
| -rw-r--r-- | libnm/nm-device-bt.c | 129 |
1 files changed, 54 insertions, 75 deletions
diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index 47a01f4f..150b5d84 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -1,21 +1,7 @@ +// 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 2007 - 2008 Novell, Inc. - * Copyright 2007 - 2012 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + * Copyright (C) 2007 - 2012 Red Hat, Inc. */ #include "nm-default.h" @@ -28,9 +14,13 @@ #include "nm-object-private.h" #include "nm-enum-types.h" -G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_BT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BT, NMDeviceBtPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_NAME, + PROP_BT_CAPABILITIES, +); typedef struct { char *hw_address; @@ -38,15 +28,21 @@ typedef struct { guint32 bt_capabilities; } NMDeviceBtPrivate; -enum { - PROP_0, - PROP_HW_ADDRESS, - PROP_NAME, - PROP_BT_CAPABILITIES, +struct _NMDeviceBt { + NMDevice parent; + NMDeviceBtPrivate _priv; +}; - LAST_PROP +struct _NMDeviceBtClass { + NMDeviceClass parent; }; +G_DEFINE_TYPE (NMDeviceBt, nm_device_bt, NM_TYPE_DEVICE) + +#define NM_DEVICE_BT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceBt, NM_IS_DEVICE_BT, NMObject, NMDevice) + +/*****************************************************************************/ + /** * nm_device_bt_get_hw_address: * @device: a #NMDeviceBt @@ -61,7 +57,7 @@ nm_device_bt_get_hw_address (NMDeviceBt *device) { g_return_val_if_fail (NM_IS_DEVICE_BT (device), NULL); - return nm_str_not_empty (NM_DEVICE_BT_GET_PRIVATE (device)->hw_address); + return _nml_coerce_property_str_not_empty (NM_DEVICE_BT_GET_PRIVATE (device)->hw_address); } /** @@ -188,24 +184,6 @@ nm_device_bt_init (NMDeviceBt *device) } static void -init_dbus (NMObject *object) -{ - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); - const NMPropertiesInfo property_info[] = { - { NM_DEVICE_BT_HW_ADDRESS, &priv->hw_address }, - { NM_DEVICE_BT_NAME, &priv->name }, - { NM_DEVICE_BT_CAPABILITIES, &priv->bt_capabilities }, - { NULL }, - }; - - NM_OBJECT_CLASS (nm_device_bt_parent_class)->init_dbus (object); - - _nm_object_register_properties (object, - NM_DBUS_INTERFACE_DEVICE_BLUETOOTH, - property_info); -} - -static void finalize (GObject *object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (object); @@ -240,62 +218,63 @@ get_property (GObject *object, } } +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bluetooth = NML_DBUS_META_IFACE_INIT_PROP ( + NM_DBUS_INTERFACE_DEVICE_BLUETOOTH, + nm_device_bt_get_type, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_HIGH, + NML_DBUS_META_IFACE_DBUS_PROPERTIES ( + NML_DBUS_META_PROPERTY_INIT_U ("BtCapabilities", PROP_BT_CAPABILITIES, NMDeviceBt, _priv.bt_capabilities ), + NML_DBUS_META_PROPERTY_INIT_S ("HwAddress", PROP_HW_ADDRESS, NMDeviceBt, _priv.hw_address ), + NML_DBUS_META_PROPERTY_INIT_S ("Name", PROP_NAME, NMDeviceBt, _priv.name ), + ), +); + static void nm_device_bt_class_init (NMDeviceBtClass *bt_class) { GObjectClass *object_class = G_OBJECT_CLASS (bt_class); - NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bt_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bt_class); - g_type_class_add_private (bt_class, sizeof (NMDeviceBtPrivate)); - - /* virtual methods */ - object_class->finalize = finalize; object_class->get_property = get_property; - - nm_object_class->init_dbus = init_dbus; + object_class->finalize = finalize; device_class->connection_compatible = connection_compatible; - device_class->get_setting_type = get_setting_type; - device_class->get_hw_address = get_hw_address; - - /* properties */ + device_class->get_setting_type = get_setting_type; + device_class->get_hw_address = get_hw_address; /** * NMDeviceBt:hw-address: * * The hardware (MAC) address of the device. **/ - g_object_class_install_property - (object_class, PROP_HW_ADDRESS, - g_param_spec_string (NM_DEVICE_BT_HW_ADDRESS, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_HW_ADDRESS] = + g_param_spec_string (NM_DEVICE_BT_HW_ADDRESS, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); /** * NMDeviceBt:name: * * The name of the bluetooth device. **/ - g_object_class_install_property - (object_class, PROP_NAME, - g_param_spec_string (NM_DEVICE_BT_NAME, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_NAME] = + g_param_spec_string (NM_DEVICE_BT_NAME, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); /** * NMDeviceBt:bt-capabilities: * * The device's bluetooth capabilities, a combination of #NMBluetoothCapabilities. **/ - g_object_class_install_property - (object_class, PROP_BT_CAPABILITIES, - g_param_spec_flags (NM_DEVICE_BT_CAPABILITIES, "", "", - NM_TYPE_BLUETOOTH_CAPABILITIES, - NM_BT_CAPABILITY_NONE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - + obj_properties[PROP_BT_CAPABILITIES] = + g_param_spec_flags (NM_DEVICE_BT_CAPABILITIES, "", "", + NM_TYPE_BLUETOOTH_CAPABILITIES, + NM_BT_CAPABILITY_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + _nml_dbus_meta_class_init_with_properties (object_class, &_nml_dbus_meta_iface_nm_device_bluetooth); } |