From 57aa5e2a9df99eb6e6286ae0726cf9f40c5992e6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Oct 2019 08:12:01 +0200 Subject: [PATCH] libnm: hide GObject structs from public API and embed private data These types are all subclasses of NMObject. These instances are commonly created by NMClient itself. It makes no sense that a user would instantiate the type. Much less does it make sense to subclass them. Hide the object and class structures from public API. This is an API and ABI break, but of something that is very likely unused. This is mainly done to embed the private structure in the object itself. This has benefits for performance and debugability. But most importantly, we can obtain a static offset where to access the private data. That means, we can use the information to access the data pointer generically, as we will need later. This is not done for the internal types NMManager, NMRemoteSettings, and NMDnsManager. These types will be dropped later. --- NEWS | 3 + libnm/nm-access-point.c | 47 ++++++++------ libnm/nm-access-point.h | 11 +--- libnm/nm-active-connection.c | 58 +++++++++-------- libnm/nm-active-connection.h | 11 +--- libnm/nm-checkpoint.c | 16 +++-- libnm/nm-device-6lowpan.c | 32 +++++----- libnm/nm-device-6lowpan.h | 5 ++ libnm/nm-device-adsl.c | 30 ++++++--- libnm/nm-device-adsl.h | 11 +--- libnm/nm-device-bond.c | 29 ++++++--- libnm/nm-device-bond.h | 11 +--- libnm/nm-device-bridge.c | 29 ++++++--- libnm/nm-device-bridge.h | 11 +--- libnm/nm-device-bt.c | 29 ++++++--- libnm/nm-device-bt.h | 11 +--- libnm/nm-device-dummy.c | 23 ++++--- libnm/nm-device-dummy.h | 11 +--- libnm/nm-device-ethernet.c | 33 ++++++---- libnm/nm-device-ethernet.h | 11 +--- libnm/nm-device-generic.c | 27 +++++--- libnm/nm-device-generic.h | 11 +--- libnm/nm-device-infiniband.c | 27 +++++--- libnm/nm-device-infiniband.h | 11 +--- libnm/nm-device-ip-tunnel.c | 47 ++++++++------ libnm/nm-device-ip-tunnel.h | 11 +--- libnm/nm-device-macsec.c | 51 +++++++++------ libnm/nm-device-macsec.h | 11 +--- libnm/nm-device-macvlan.c | 33 ++++++---- libnm/nm-device-macvlan.h | 11 +--- libnm/nm-device-modem.c | 33 ++++++---- libnm/nm-device-modem.h | 11 +--- libnm/nm-device-olpc-mesh.c | 29 ++++++--- libnm/nm-device-olpc-mesh.h | 11 +--- libnm/nm-device-ovs-bridge.c | 21 ++++--- libnm/nm-device-ovs-bridge.h | 3 + libnm/nm-device-ovs-interface.c | 5 +- libnm/nm-device-ovs-interface.h | 3 + libnm/nm-device-ovs-port.c | 22 ++++--- libnm/nm-device-ovs-port.h | 3 + libnm/nm-device-ppp.c | 4 +- libnm/nm-device-ppp.h | 3 + libnm/nm-device-team.c | 31 ++++++--- libnm/nm-device-team.h | 11 +--- libnm/nm-device-tun.c | 37 +++++++---- libnm/nm-device-tun.h | 11 +--- libnm/nm-device-vlan.c | 31 ++++++--- libnm/nm-device-vlan.h | 11 +--- libnm/nm-device-vxlan.c | 59 ++++++++++------- libnm/nm-device-vxlan.h | 11 +--- libnm/nm-device-wifi-p2p.c | 5 -- libnm/nm-device-wifi-p2p.h | 5 ++ libnm/nm-device-wifi.c | 56 +++++++++++------ libnm/nm-device-wifi.h | 15 +---- libnm/nm-device-wimax.c | 59 ++++++++++------- libnm/nm-device-wimax.h | 15 +---- libnm/nm-device-wireguard.c | 23 +++---- libnm/nm-device-wireguard.h | 3 + libnm/nm-device-wpan.c | 20 +++--- libnm/nm-device-wpan.h | 5 ++ libnm/nm-device.c | 108 +++++++++++++++++--------------- libnm/nm-device.h | 27 +------- libnm/nm-dhcp-config.c | 26 +++++--- libnm/nm-dhcp-config.h | 11 +--- libnm/nm-dhcp4-config.c | 12 +++- libnm/nm-dhcp4-config.h | 10 +-- libnm/nm-dhcp6-config.c | 12 +++- libnm/nm-dhcp6-config.h | 10 +-- libnm/nm-ip-config.c | 42 ++++++++----- libnm/nm-ip-config.h | 11 +--- libnm/nm-ip4-config.c | 12 +++- libnm/nm-ip4-config.h | 9 +-- libnm/nm-ip6-config.c | 12 +++- libnm/nm-ip6-config.h | 9 +-- libnm/nm-libnm-utils.h | 96 ++++++++++++++++++++++++++-- libnm/nm-object.c | 68 ++++++++++++-------- libnm/nm-object.h | 21 +------ libnm/nm-remote-connection.c | 49 +++++++++------ libnm/nm-remote-connection.h | 11 +--- libnm/nm-vpn-connection.c | 38 ++++++----- libnm/nm-vpn-connection.h | 26 +------- libnm/nm-wifi-p2p-peer.c | 3 - libnm/nm-wifi-p2p-peer.h | 3 + libnm/nm-wimax-nsp.c | 29 ++++++--- libnm/nm-wimax-nsp.h | 11 +--- 85 files changed, 1021 insertions(+), 863 deletions(-) diff --git a/NEWS b/NEWS index c839e18e9..bb185c87d 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! setup, you may need to configure "ipv4.may-fail=no" or "ipv6.may-fail=no", which delays reaching "connected" state for the address family accordingly. * Various bug fixes and improvements. +* libnm: hide NMObject and NMClient typedefs from header files. This prevents + the user from subclassing these types and is an ABI change (in case somebody + was doing so). ============================================= NetworkManager-1.20 diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 1ca50a6d1..39ed2ac21 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -17,22 +17,7 @@ #include "nm-dbus-interface.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT) - -#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NMAccessPointPrivate)) - -typedef struct { - NM80211ApFlags flags; - NM80211ApSecurityFlags wpa_flags; - NM80211ApSecurityFlags rsn_flags; - GBytes *ssid; - guint32 frequency; - char *bssid; - NM80211Mode mode; - guint32 max_bitrate; - guint8 strength; - int last_seen; -} NMAccessPointPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_FLAGS, @@ -48,6 +33,34 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_LAST_SEEN, ); +typedef struct { + NM80211ApFlags flags; + NM80211ApSecurityFlags wpa_flags; + NM80211ApSecurityFlags rsn_flags; + GBytes *ssid; + guint32 frequency; + char *bssid; + NM80211Mode mode; + guint32 max_bitrate; + guint8 strength; + int last_seen; +} NMAccessPointPrivate; + +struct _NMAccessPoint { + NMObject parent; + NMAccessPointPrivate _priv; +}; + +struct _NMAccessPointClass { + NMObjectClass parent; +}; + +G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT) + +#define NM_ACCESS_POINT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMAccessPoint, NM_IS_ACCESS_POINT, NMObject) + +/*****************************************************************************/ + /** * nm_access_point_get_flags: * @ap: a #NMAccessPoint @@ -469,8 +482,6 @@ nm_access_point_class_init (NMAccessPointClass *ap_class) GObjectClass *object_class = G_OBJECT_CLASS (ap_class); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (ap_class); - g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-access-point.h b/libnm/nm-access-point.h index 58b9cfc68..5f7c31502 100644 --- a/libnm/nm-access-point.h +++ b/libnm/nm-access-point.h @@ -39,16 +39,7 @@ G_BEGIN_DECLS /** * NMAccessPoint: */ -struct _NMAccessPoint { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMAccessPointClass; +typedef struct _NMAccessPointClass NMAccessPointClass; GType nm_access_point_get_type (void); diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 94e02d9df..c52c2cf54 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -23,29 +23,7 @@ #include "introspection/org.freedesktop.NetworkManager.Connection.Active.h" -G_DEFINE_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT); - -#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate)) - -typedef struct { - NMRemoteConnection *connection; - char *id; - char *uuid; - char *type; - char *specific_object_path; - GPtrArray *devices; - NMActiveConnectionState state; - guint state_flags; - gboolean is_default; - NMIPConfig *ip4_config; - NMDhcpConfig *dhcp4_config; - gboolean is_default6; - NMIPConfig *ip6_config; - NMDhcpConfig *dhcp6_config; - gboolean is_vpn; - NMDevice *master; - NMActiveConnectionStateReason reason; -} NMActiveConnectionPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection, PROP_CONNECTION, @@ -74,6 +52,32 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +typedef struct _NMActiveConnectionPrivate { + NMRemoteConnection *connection; + char *id; + char *uuid; + char *type; + char *specific_object_path; + GPtrArray *devices; + NMActiveConnectionState state; + guint state_flags; + gboolean is_default; + NMIPConfig *ip4_config; + NMDhcpConfig *dhcp4_config; + gboolean is_default6; + NMIPConfig *ip6_config; + NMDhcpConfig *dhcp6_config; + gboolean is_vpn; + NMDevice *master; + NMActiveConnectionStateReason reason; +} NMActiveConnectionPrivate; + +G_DEFINE_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_OBJECT); + +#define NM_ACTIVE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMActiveConnection, NM_IS_ACTIVE_CONNECTION, NMObject) + +/*****************************************************************************/ + /** * nm_active_connection_get_connection: * @connection: a #NMActiveConnection @@ -373,9 +377,13 @@ nm_active_connection_get_master (NMActiveConnection *connection) } static void -nm_active_connection_init (NMActiveConnection *connection) +nm_active_connection_init (NMActiveConnection *self) { - NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection); + NMActiveConnectionPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_ACTIVE_CONNECTION, NMActiveConnectionPrivate); + + self->_priv = priv; priv->devices = g_ptr_array_new (); } diff --git a/libnm/nm-active-connection.h b/libnm/nm-active-connection.h index fb4e12b5b..15f70ca34 100644 --- a/libnm/nm-active-connection.h +++ b/libnm/nm-active-connection.h @@ -42,16 +42,7 @@ G_BEGIN_DECLS /** * NMActiveConnection: */ -struct _NMActiveConnection { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /*< private >*/ - gpointer padding[8]; -} NMActiveConnectionClass; +typedef struct _NMActiveConnectionClass NMActiveConnectionClass; GType nm_active_connection_get_type (void); diff --git a/libnm/nm-checkpoint.c b/libnm/nm-checkpoint.c index 8f9a54e7f..d029d6db8 100644 --- a/libnm/nm-checkpoint.c +++ b/libnm/nm-checkpoint.c @@ -11,6 +11,14 @@ #include "nm-device.h" #include "nm-object-private.h" +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_DEVICES, + PROP_CREATED, + PROP_ROLLBACK_TIMEOUT, +); + typedef struct { GPtrArray *devices; gint64 created; @@ -28,13 +36,9 @@ struct _NMCheckpointClass { G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_OBJECT) -#define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMCheckpoint, NM_IS_CHECKPOINT) +#define NM_CHECKPOINT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMCheckpoint, NM_IS_CHECKPOINT, NMObject) -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_DEVICES, - PROP_CREATED, - PROP_ROLLBACK_TIMEOUT, -); +/*****************************************************************************/ /** * nm_checkpoint_get_devices: diff --git a/libnm/nm-device-6lowpan.c b/libnm/nm-device-6lowpan.c index b67fad141..25f393297 100644 --- a/libnm/nm-device-6lowpan.c +++ b/libnm/nm-device-6lowpan.c @@ -6,35 +6,35 @@ #include "nm-default.h" #include "nm-device-6lowpan.h" + #include "nm-object-private.h" +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PARENT, + PROP_HW_ADDRESS, +); + typedef struct { NMDevice *parent; char *hw_address; } NMDevice6LowpanPrivate; -/** - * NMDevice6Lowpan: - */ struct _NMDevice6Lowpan { - NMDevice parent; + NMDevice parent; + NMDevice6LowpanPrivate _priv; }; -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDevice6LowpanClass; +struct _NMDevice6LowpanClass { + NMDeviceClass parent; +}; G_DEFINE_TYPE (NMDevice6Lowpan, nm_device_6lowpan, NM_TYPE_DEVICE) -#define NM_DEVICE_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanPrivate)) +#define NM_DEVICE_6LOWPAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDevice6Lowpan, NM_IS_DEVICE_6LOWPAN, NMObject, NMDevice) -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PARENT, - PROP_HW_ADDRESS, -); +/*****************************************************************************/ /** * nm_device_6lowpan_get_parent: @@ -140,8 +140,6 @@ nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDevice6LowpanPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-6lowpan.h b/libnm/nm-device-6lowpan.h index 96712dcf6..eba4886e3 100644 --- a/libnm/nm-device-6lowpan.h +++ b/libnm/nm-device-6lowpan.h @@ -24,6 +24,11 @@ G_BEGIN_DECLS #define NM_DEVICE_6LOWPAN_PARENT "parent" #define NM_DEVICE_6LOWPAN_HW_ADDRESS "hw-address" +/** + * NMDevice6Lowpan: + */ +typedef struct _NMDevice6LowpanClass NMDevice6LowpanClass; + NM_AVAILABLE_IN_1_14 GType nm_device_6lowpan_get_type (void); diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index 8fe10d52c..08174d406 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -12,19 +12,31 @@ #include "nm-setting-adsl.h" #include "nm-setting-connection.h" -G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) - -#define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate)) - -typedef struct { - gboolean carrier; - -} NMDeviceAdslPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_CARRIER, ); +typedef struct { + gboolean carrier; +} NMDeviceAdslPrivate; + +struct _NMDeviceAdsl { + NMDevice parent; + NMDeviceAdslPrivate _priv; +}; + +struct _NMDeviceAdslClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) + +#define NM_DEVICE_ADSL_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceAdsl, NM_IS_DEVICE_ADSL, NMObject, NMDevice) + +/*****************************************************************************/ + /** * nm_device_adsl_get_carrier: * @device: a #NMDeviceAdsl @@ -110,8 +122,6 @@ nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (adsl_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (adsl_class); - g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate)); - object_class->get_property = get_property; nm_object_class->init_dbus = init_dbus; diff --git a/libnm/nm-device-adsl.h b/libnm/nm-device-adsl.h index 5fb510fc3..9315cae1c 100644 --- a/libnm/nm-device-adsl.h +++ b/libnm/nm-device-adsl.h @@ -26,16 +26,7 @@ G_BEGIN_DECLS /** * NMDeviceAdsl: */ -struct _NMDeviceAdsl { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceAdslClass; +typedef struct _NMDeviceAdslClass NMDeviceAdslClass; GType nm_device_adsl_get_type (void); diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 0ef32aab5..b62d829b5 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -13,9 +13,13 @@ #include "nm-object-private.h" #include "nm-core-internal.h" -G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, + PROP_SLAVES, +); typedef struct { char *hw_address; @@ -23,11 +27,20 @@ typedef struct { GPtrArray *slaves; } NMDeviceBondPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, - PROP_SLAVES, -); +struct _NMDeviceBond { + NMDevice parent; + NMDeviceBondPrivate _priv; +}; + +struct _NMDeviceBondClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) + +#define NM_DEVICE_BOND_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceBond, NM_IS_DEVICE_BOND, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_bond_get_hw_address: @@ -188,8 +201,6 @@ nm_device_bond_class_init (NMDeviceBondClass *bond_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bond_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bond_class); - g_type_class_add_private (bond_class, sizeof (NMDeviceBondPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; diff --git a/libnm/nm-device-bond.h b/libnm/nm-device-bond.h index 737c1b71b..a65f88f91 100644 --- a/libnm/nm-device-bond.h +++ b/libnm/nm-device-bond.h @@ -28,16 +28,7 @@ G_BEGIN_DECLS /** * NMDeviceBond: */ -struct _NMDeviceBond { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceBondClass; +typedef struct _NMDeviceBondClass NMDeviceBondClass; GType nm_device_bond_get_type (void); diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index c41af835c..c4fc6e557 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -13,9 +13,13 @@ #include "nm-object-private.h" #include "nm-core-internal.h" -G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgePrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, + PROP_SLAVES, +); typedef struct { char *hw_address; @@ -23,11 +27,20 @@ typedef struct { GPtrArray *slaves; } NMDeviceBridgePrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, - PROP_SLAVES, -); +struct _NMDeviceBridge { + NMDevice parent; + NMDeviceBridgePrivate _priv; +}; + +struct _NMDeviceBridgeClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE) + +#define NM_DEVICE_BRIDGE_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceBridge, NM_IS_DEVICE_BRIDGE, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_bridge_get_hw_address: @@ -193,8 +206,6 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bridge_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bridge_class); - g_type_class_add_private (bridge_class, sizeof (NMDeviceBridgePrivate)); - object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; diff --git a/libnm/nm-device-bridge.h b/libnm/nm-device-bridge.h index 6da6d145d..339f44dd3 100644 --- a/libnm/nm-device-bridge.h +++ b/libnm/nm-device-bridge.h @@ -28,16 +28,7 @@ G_BEGIN_DECLS /** * NMDeviceBridge: */ -struct _NMDeviceBridge { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceBridgeClass; +typedef struct _NMDeviceBridgeClass NMDeviceBridgeClass; GType nm_device_bridge_get_type (void); diff --git a/libnm/nm-device-bt.c b/libnm/nm-device-bt.c index f44b86c4f..e3d9d4559 100644 --- a/libnm/nm-device-bt.c +++ b/libnm/nm-device-bt.c @@ -14,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; @@ -24,11 +28,20 @@ typedef struct { guint32 bt_capabilities; } NMDeviceBtPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_NAME, - PROP_BT_CAPABILITIES, -); +struct _NMDeviceBt { + NMDevice parent; + NMDeviceBtPrivate _priv; +}; + +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: @@ -230,8 +243,6 @@ nm_device_bt_class_init (NMDeviceBtClass *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)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-bt.h b/libnm/nm-device-bt.h index 742a4348a..2633c2dc9 100644 --- a/libnm/nm-device-bt.h +++ b/libnm/nm-device-bt.h @@ -29,16 +29,7 @@ G_BEGIN_DECLS /** * NMDeviceBt: */ -struct _NMDeviceBt { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceBtClass; +typedef struct _NMDeviceBtClass NMDeviceBtClass; GType nm_device_bt_get_type (void); diff --git a/libnm/nm-device-dummy.c b/libnm/nm-device-dummy.c index e1577cbfb..7a56d53b9 100644 --- a/libnm/nm-device-dummy.c +++ b/libnm/nm-device-dummy.c @@ -11,17 +11,28 @@ #include "nm-setting-dummy.h" #include "nm-setting-connection.h" -G_DEFINE_TYPE (NMDeviceDummy, nm_device_dummy, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_DUMMY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_DUMMY, NMDeviceDummyPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, +); typedef struct { char *hw_address; } NMDeviceDummyPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, -); +struct _NMDeviceDummy { + NMDevice parent; + NMDeviceDummyPrivate _priv; +}; + +struct _NMDeviceDummyClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceDummy, nm_device_dummy, NM_TYPE_DEVICE) + +#define NM_DEVICE_DUMMY_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceDummy, NM_IS_DEVICE_DUMMY, NMObject, NMDevice) /*****************************************************************************/ @@ -138,8 +149,6 @@ nm_device_dummy_class_init (NMDeviceDummyClass *dummy_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (dummy_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (dummy_class); - g_type_class_add_private (dummy_class, sizeof (NMDeviceDummyPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; diff --git a/libnm/nm-device-dummy.h b/libnm/nm-device-dummy.h index 00c902282..4b33490c0 100644 --- a/libnm/nm-device-dummy.h +++ b/libnm/nm-device-dummy.h @@ -26,16 +26,7 @@ G_BEGIN_DECLS /** * NMDeviceDummy: */ -struct _NMDeviceDummy { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceDummyClass; +typedef struct _NMDeviceDummyClass NMDeviceDummyClass; GType nm_device_dummy_get_type (void); NM_AVAILABLE_IN_1_10 diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index 72b3559a7..28d3a1076 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -14,9 +14,15 @@ #include "nm-utils.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_PERM_HW_ADDRESS, + PROP_SPEED, + PROP_CARRIER, + PROP_S390_SUBCHANNELS, +); typedef struct { char *hw_address; @@ -26,13 +32,20 @@ typedef struct { char **s390_subchannels; } NMDeviceEthernetPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_PERM_HW_ADDRESS, - PROP_SPEED, - PROP_CARRIER, - PROP_S390_SUBCHANNELS, -); +struct _NMDeviceEthernet { + NMDevice parent; + NMDeviceEthernetPrivate _priv; +}; + +struct _NMDeviceEthernetClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE) + +#define NM_DEVICE_ETHERNET_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceEthernet, NM_IS_DEVICE_ETHERNET, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_ethernet_get_hw_address: @@ -333,8 +346,6 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (eth_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); - g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-ethernet.h b/libnm/nm-device-ethernet.h index 6fcf3454b..28b95dc2d 100644 --- a/libnm/nm-device-ethernet.h +++ b/libnm/nm-device-ethernet.h @@ -31,16 +31,7 @@ G_BEGIN_DECLS /** * NMDeviceEthernet: */ -struct _NMDeviceEthernet { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceEthernetClass; +typedef struct _NMDeviceEthernetClass NMDeviceEthernetClass; GType nm_device_ethernet_get_type (void); diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 5a2c6d6fe..cdc92351a 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -11,19 +11,32 @@ #include "nm-setting-generic.h" #include "nm-setting-connection.h" -G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_GENERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_GENERIC, NMDeviceGenericPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_TYPE_DESCRIPTION, +); typedef struct { char *hw_address; char *type_description; } NMDeviceGenericPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_TYPE_DESCRIPTION, -); +struct _NMDeviceGeneric { + NMDevice parent; + NMDeviceGenericPrivate _priv; +}; + +struct _NMDeviceGenericClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) + +#define NM_DEVICE_GENERIC_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceGeneric, NM_IS_DEVICE_GENERIC, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_generic_get_hw_address: @@ -152,8 +165,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (klass, sizeof (NMDeviceGenericPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-generic.h b/libnm/nm-device-generic.h index 5836a9d03..aa52023a0 100644 --- a/libnm/nm-device-generic.h +++ b/libnm/nm-device-generic.h @@ -27,16 +27,7 @@ G_BEGIN_DECLS /** * NMDeviceGeneric: */ -struct _NMDeviceGeneric { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceGenericClass; +typedef struct _NMDeviceGenericClass NMDeviceGenericClass; GType nm_device_generic_get_type (void); diff --git a/libnm/nm-device-infiniband.c b/libnm/nm-device-infiniband.c index a297b870f..5c750e7ac 100644 --- a/libnm/nm-device-infiniband.c +++ b/libnm/nm-device-infiniband.c @@ -12,19 +12,32 @@ #include "nm-utils.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, +); typedef struct { char *hw_address; gboolean carrier; } NMDeviceInfinibandPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, -); +struct _NMDeviceInfiniband { + NMDevice parent; + NMDeviceInfinibandPrivate _priv; +}; + +struct _NMDeviceInfinibandClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE) + +#define NM_DEVICE_INFINIBAND_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceInfiniband, NM_IS_DEVICE_INFINIBAND, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_infiniband_get_hw_address: @@ -168,8 +181,6 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *ib_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (ib_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (ib_class); - g_type_class_add_private (ib_class, sizeof (NMDeviceInfinibandPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-infiniband.h b/libnm/nm-device-infiniband.h index eac933b0d..06a2c2572 100644 --- a/libnm/nm-device-infiniband.h +++ b/libnm/nm-device-infiniband.h @@ -27,16 +27,7 @@ G_BEGIN_DECLS /** * NMDeviceInfiniband: */ -struct _NMDeviceInfiniband { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceInfinibandClass; +typedef struct _NMDeviceInfinibandClass NMDeviceInfinibandClass; GType nm_device_infiniband_get_type (void); diff --git a/libnm/nm-device-ip-tunnel.c b/libnm/nm-device-ip-tunnel.c index 3dc5fe3ec..2f38071ac 100644 --- a/libnm/nm-device-ip-tunnel.c +++ b/libnm/nm-device-ip-tunnel.c @@ -13,9 +13,22 @@ #include "nm-object-private.h" #include "nm-core-internal.h" -G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_IP_TUNNEL, NMDeviceIPTunnelPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_MODE, + PROP_PARENT, + PROP_LOCAL, + PROP_REMOTE, + PROP_TTL, + PROP_TOS, + PROP_PATH_MTU_DISCOVERY, + PROP_INPUT_KEY, + PROP_OUTPUT_KEY, + PROP_ENCAPSULATION_LIMIT, + PROP_FLOW_LABEL, + PROP_FLAGS, +); typedef struct { NMIPTunnelMode mode; @@ -32,20 +45,20 @@ typedef struct { guint32 flags; } NMDeviceIPTunnelPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_MODE, - PROP_PARENT, - PROP_LOCAL, - PROP_REMOTE, - PROP_TTL, - PROP_TOS, - PROP_PATH_MTU_DISCOVERY, - PROP_INPUT_KEY, - PROP_OUTPUT_KEY, - PROP_ENCAPSULATION_LIMIT, - PROP_FLOW_LABEL, - PROP_FLAGS, -); +struct _NMDeviceIPTunnel { + NMDevice parent; + NMDeviceIPTunnelPrivate _priv; +}; + +struct _NMDeviceIPTunnelClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceIPTunnel, nm_device_ip_tunnel, NM_TYPE_DEVICE) + +#define NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceIPTunnel, NM_IS_DEVICE_IP_TUNNEL, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_ip_tunnel_get_mode: @@ -367,8 +380,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *bond_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (bond_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (bond_class); - g_type_class_add_private (bond_class, sizeof (NMDeviceIPTunnelPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-ip-tunnel.h b/libnm/nm-device-ip-tunnel.h index 42f654615..08c208609 100644 --- a/libnm/nm-device-ip-tunnel.h +++ b/libnm/nm-device-ip-tunnel.h @@ -38,16 +38,7 @@ G_BEGIN_DECLS /** * NMDeviceIPTunnel: */ -struct _NMDeviceIPTunnel { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceIPTunnelClass; +typedef struct _NMDeviceIPTunnelClass NMDeviceIPTunnelClass; NM_AVAILABLE_IN_1_2 GType nm_device_ip_tunnel_get_type (void); diff --git a/libnm/nm-device-macsec.c b/libnm/nm-device-macsec.c index 84d2a687b..59923a8c6 100644 --- a/libnm/nm-device-macsec.c +++ b/libnm/nm-device-macsec.c @@ -11,9 +11,24 @@ #include "nm-object-private.h" #include "nm-utils.h" -G_DEFINE_TYPE (NMDeviceMacsec, nm_device_macsec, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_MACSEC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MACSEC, NMDeviceMacsecPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PARENT, + PROP_HW_ADDRESS, + PROP_SCI, + PROP_CIPHER_SUITE, + PROP_ICV_LENGTH, + PROP_WINDOW, + PROP_ENCODING_SA, + PROP_ENCRYPT, + PROP_PROTECT, + PROP_INCLUDE_SCI, + PROP_ES, + PROP_SCB, + PROP_REPLAY_PROTECT, + PROP_VALIDATION, +); typedef struct { NMDevice *parent; @@ -32,22 +47,20 @@ typedef struct { char *validation; } NMDeviceMacsecPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PARENT, - PROP_HW_ADDRESS, - PROP_SCI, - PROP_CIPHER_SUITE, - PROP_ICV_LENGTH, - PROP_WINDOW, - PROP_ENCODING_SA, - PROP_ENCRYPT, - PROP_PROTECT, - PROP_INCLUDE_SCI, - PROP_ES, - PROP_SCB, - PROP_REPLAY_PROTECT, - PROP_VALIDATION, -); +struct _NMDeviceMacsec { + NMDevice parent; + NMDeviceMacsecPrivate _priv; +}; + +struct _NMDeviceMacsecClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceMacsec, nm_device_macsec, NM_TYPE_DEVICE) + +#define NM_DEVICE_MACSEC_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceMacsec, NM_IS_DEVICE_MACSEC, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_macsec_get_parent: @@ -423,8 +436,6 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *macsec_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (macsec_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (macsec_class); - g_type_class_add_private (macsec_class, sizeof (NMDeviceMacsecPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-macsec.h b/libnm/nm-device-macsec.h index edccde1d7..acf6269b2 100644 --- a/libnm/nm-device-macsec.h +++ b/libnm/nm-device-macsec.h @@ -39,16 +39,7 @@ G_BEGIN_DECLS /** * NMDeviceMacsec: */ -struct _NMDeviceMacsec { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceMacsecClass; +typedef struct _NMDeviceMacsecClass NMDeviceMacsecClass; NM_AVAILABLE_IN_1_6 GType nm_device_macsec_get_type (void); diff --git a/libnm/nm-device-macvlan.c b/libnm/nm-device-macvlan.c index 967e380be..4a53af07b 100644 --- a/libnm/nm-device-macvlan.c +++ b/libnm/nm-device-macvlan.c @@ -13,9 +13,15 @@ #include "nm-device-macvlan.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PARENT, + PROP_MODE, + PROP_NO_PROMISC, + PROP_TAP, + PROP_HW_ADDRESS, +); typedef struct { NMDevice *parent; @@ -25,13 +31,20 @@ typedef struct { char *hw_address; } NMDeviceMacvlanPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PARENT, - PROP_MODE, - PROP_NO_PROMISC, - PROP_TAP, - PROP_HW_ADDRESS, -); +struct _NMDeviceMacvlan { + NMDevice parent; + NMDeviceMacvlanPrivate _priv; +}; + +struct _NMDeviceMacvlanClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_MACVLAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceMacvlan, NM_IS_DEVICE_MACVLAN, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_macvlan_get_parent: @@ -235,8 +248,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *gre_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (gre_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (gre_class); - g_type_class_add_private (gre_class, sizeof (NMDeviceMacvlanPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-macvlan.h b/libnm/nm-device-macvlan.h index 16e9a77e2..c991f8bd8 100644 --- a/libnm/nm-device-macvlan.h +++ b/libnm/nm-device-macvlan.h @@ -30,16 +30,7 @@ G_BEGIN_DECLS /** * NMDeviceMacvlan: */ -struct _NMDeviceMacvlan { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceMacvlanClass; +typedef struct _NMDeviceMacvlanClass NMDeviceMacvlanClass; NM_AVAILABLE_IN_1_2 GType nm_device_macvlan_get_type (void); diff --git a/libnm/nm-device-modem.c b/libnm/nm-device-modem.c index 10262878d..a56eeb4ad 100644 --- a/libnm/nm-device-modem.c +++ b/libnm/nm-device-modem.c @@ -14,9 +14,15 @@ #include "nm-object-private.h" #include "nm-enum-types.h" -G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MODEM, NMDeviceModemPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_MODEM_CAPABILITIES, + PROP_CURRENT_CAPABILITIES, + PROP_DEVICE_ID, + PROP_OPERATOR_CODE, + PROP_APN, +); typedef struct { NMDeviceModemCapabilities caps; @@ -26,13 +32,20 @@ typedef struct { char *apn; } NMDeviceModemPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_MODEM_CAPABILITIES, - PROP_CURRENT_CAPABILITIES, - PROP_DEVICE_ID, - PROP_OPERATOR_CODE, - PROP_APN, -); +struct _NMDeviceModem { + NMDevice parent; + NMDeviceModemPrivate _priv; +}; + +struct _NMDeviceModemClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE) + +#define NM_DEVICE_MODEM_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceModem, NM_IS_DEVICE_MODEM, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_modem_get_modem_capabilities: @@ -271,8 +284,6 @@ nm_device_modem_class_init (NMDeviceModemClass *modem_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (modem_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (modem_class); - g_type_class_add_private (modem_class, sizeof (NMDeviceModemPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-modem.h b/libnm/nm-device-modem.h index dee6895f8..48eed0e80 100644 --- a/libnm/nm-device-modem.h +++ b/libnm/nm-device-modem.h @@ -31,16 +31,7 @@ G_BEGIN_DECLS /** * NMDeviceModem: */ -struct _NMDeviceModem { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceModemClass; +typedef struct _NMDeviceModemClass NMDeviceModemClass; GType nm_device_modem_get_type (void); diff --git a/libnm/nm-device-olpc-mesh.c b/libnm/nm-device-olpc-mesh.c index c5f1b998a..367580bbb 100644 --- a/libnm/nm-device-olpc-mesh.c +++ b/libnm/nm-device-olpc-mesh.c @@ -12,9 +12,13 @@ #include "nm-object-private.h" #include "nm-device-wifi.h" -G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_COMPANION, + PROP_ACTIVE_CHANNEL, +); typedef struct { char *hw_address; @@ -22,11 +26,20 @@ typedef struct { guint32 active_channel; } NMDeviceOlpcMeshPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_COMPANION, - PROP_ACTIVE_CHANNEL, -); +struct _NMDeviceOlpcMesh { + NMDevice parent; + NMDeviceOlpcMeshPrivate _priv; +}; + +struct _NMDeviceOlpcMeshClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) + +#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceOlpcMesh, NM_IS_DEVICE_OLPC_MESH, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_olpc_mesh_get_hw_address: @@ -180,8 +193,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *olpc_mesh_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (olpc_mesh_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (olpc_mesh_class); - g_type_class_add_private (olpc_mesh_class, sizeof (NMDeviceOlpcMeshPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; diff --git a/libnm/nm-device-olpc-mesh.h b/libnm/nm-device-olpc-mesh.h index d2a10d787..2794e6eea 100644 --- a/libnm/nm-device-olpc-mesh.h +++ b/libnm/nm-device-olpc-mesh.h @@ -28,16 +28,7 @@ G_BEGIN_DECLS /** * NMDeviceOlpcMesh: */ -struct _NMDeviceOlpcMesh { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceOlpcMeshClass; +typedef struct _NMDeviceOlpcMeshClass NMDeviceOlpcMeshClass; GType nm_device_olpc_mesh_get_type (void); diff --git a/libnm/nm-device-ovs-bridge.c b/libnm/nm-device-ovs-bridge.c index 40364f0e9..b37743f36 100644 --- a/libnm/nm-device-ovs-bridge.c +++ b/libnm/nm-device-ovs-bridge.c @@ -13,16 +13,19 @@ #include "nm-setting-connection.h" #include "nm-core-internal.h" +/*****************************************************************************/ + NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_SLAVES, ); -/** - * NMDeviceOvsBridge: - */ +typedef struct { + GPtrArray *slaves; +} NMDeviceOvsBridgePrivate; + struct _NMDeviceOvsBridge { NMDevice parent; - GPtrArray *slaves; + NMDeviceOvsBridgePrivate _priv; }; struct _NMDeviceOvsBridgeClass { @@ -31,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) + /*****************************************************************************/ /** @@ -50,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 NM_DEVICE_OVS_BRIDGE_GET_PRIVATE (device)->slaves; } static const char * @@ -96,7 +101,7 @@ 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 }, + { NM_DEVICE_OVS_BRIDGE_SLAVES, &device->_priv.slaves, NULL, NM_TYPE_DEVICE }, { NULL }, }; @@ -133,9 +138,9 @@ nm_device_ovs_bridge_init (NMDeviceOvsBridge *device) static void dispose (GObject *object) { - NMDeviceOvsBridge *device = NM_DEVICE_OVS_BRIDGE (object); + NMDeviceOvsBridgePrivate *priv = NM_DEVICE_OVS_BRIDGE_GET_PRIVATE (object); - g_clear_pointer (&device->slaves, g_ptr_array_unref); + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_ovs_bridge_parent_class)->dispose (object); } diff --git a/libnm/nm-device-ovs-bridge.h b/libnm/nm-device-ovs-bridge.h index fbbcc177f..78aa352c9 100644 --- a/libnm/nm-device-ovs-bridge.h +++ b/libnm/nm-device-ovs-bridge.h @@ -23,6 +23,9 @@ G_BEGIN_DECLS #define NM_DEVICE_OVS_BRIDGE_SLAVES "slaves" +/** + * NMDeviceOvsBridge: + */ typedef struct _NMDeviceOvsBridgeClass NMDeviceOvsBridgeClass; NM_AVAILABLE_IN_1_10 diff --git a/libnm/nm-device-ovs-interface.c b/libnm/nm-device-ovs-interface.c index c592315c0..c205dd5e7 100644 --- a/libnm/nm-device-ovs-interface.c +++ b/libnm/nm-device-ovs-interface.c @@ -12,9 +12,8 @@ #include "nm-setting-ovs-port.h" #include "nm-setting-connection.h" -/** - * NMDeviceOvsInterface: - */ +/*****************************************************************************/ + struct _NMDeviceOvsInterface { NMDevice parent; }; diff --git a/libnm/nm-device-ovs-interface.h b/libnm/nm-device-ovs-interface.h index d38252bd0..d9c81a33f 100644 --- a/libnm/nm-device-ovs-interface.h +++ b/libnm/nm-device-ovs-interface.h @@ -21,6 +21,9 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_OVS_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OVS_INTERFACE)) #define NM_DEVICE_OVS_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OVS_INTERFACE, NMDeviceOvsInterfaceClass)) +/** + * NMDeviceOvsInterface: + */ typedef struct _NMDeviceOvsInterfaceClass NMDeviceOvsInterfaceClass; NM_AVAILABLE_IN_1_10 diff --git a/libnm/nm-device-ovs-port.c b/libnm/nm-device-ovs-port.c index c3a8bf537..ab39ff710 100644 --- a/libnm/nm-device-ovs-port.c +++ b/libnm/nm-device-ovs-port.c @@ -13,16 +13,19 @@ #include "nm-setting-connection.h" #include "nm-core-internal.h" +/*****************************************************************************/ + NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_SLAVES, ); -/** - * NMDeviceOvsPort: - */ +typedef struct { + GPtrArray *slaves; +} NMDeviceOvsPortPrivate; + struct _NMDeviceOvsPort { NMDevice parent; - GPtrArray *slaves; + NMDeviceOvsPortPrivate _priv; }; struct _NMDeviceOvsPortClass { @@ -31,6 +34,8 @@ struct _NMDeviceOvsPortClass { G_DEFINE_TYPE (NMDeviceOvsPort, nm_device_ovs_port, NM_TYPE_DEVICE) +#define NM_DEVICE_OVS_PORT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceOvsPort, NM_IS_DEVICE_OVS_PORT, NMObject, NMDevice) + /*****************************************************************************/ /** @@ -50,7 +55,7 @@ nm_device_ovs_port_get_slaves (NMDeviceOvsPort *device) { g_return_val_if_fail (NM_IS_DEVICE_OVS_PORT (device), FALSE); - return device->slaves; + return NM_DEVICE_OVS_PORT_GET_PRIVATE (device)->slaves; } static const char * @@ -95,8 +100,9 @@ static void init_dbus (NMObject *object) { NMDeviceOvsPort *device = NM_DEVICE_OVS_PORT (object); + NMDeviceOvsPortPrivate *priv = NM_DEVICE_OVS_PORT_GET_PRIVATE (device); const NMPropertiesInfo property_info[] = { - { NM_DEVICE_OVS_PORT_SLAVES, &device->slaves, NULL, NM_TYPE_DEVICE }, + { NM_DEVICE_OVS_PORT_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE }, { NULL }, }; @@ -133,9 +139,9 @@ nm_device_ovs_port_init (NMDeviceOvsPort *device) static void dispose (GObject *object) { - NMDeviceOvsPort *device = NM_DEVICE_OVS_PORT (object); + NMDeviceOvsPortPrivate *priv = NM_DEVICE_OVS_PORT_GET_PRIVATE (object); - g_clear_pointer (&device->slaves, g_ptr_array_unref); + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_ovs_port_parent_class)->dispose (object); } diff --git a/libnm/nm-device-ovs-port.h b/libnm/nm-device-ovs-port.h index 2e6175883..9982104ec 100644 --- a/libnm/nm-device-ovs-port.h +++ b/libnm/nm-device-ovs-port.h @@ -23,6 +23,9 @@ G_BEGIN_DECLS #define NM_DEVICE_OVS_PORT_SLAVES "slaves" +/** + * NMDeviceOvsPort: + */ typedef struct _NMDeviceOvsPortClass NMDeviceOvsPortClass; NM_AVAILABLE_IN_1_10 diff --git a/libnm/nm-device-ppp.c b/libnm/nm-device-ppp.c index c8336c0f4..a4ec67231 100644 --- a/libnm/nm-device-ppp.c +++ b/libnm/nm-device-ppp.c @@ -8,6 +8,8 @@ #include "nm-device-ppp.h" #include "nm-device.h" +/*****************************************************************************/ + struct _NMDevicePpp { NMDevice parent; }; @@ -18,7 +20,7 @@ struct _NMDevicePppClass { G_DEFINE_TYPE (NMDevicePpp, nm_device_ppp, NM_TYPE_DEVICE) -#define NM_DEVICE_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_PPP, NMDevicePppPrivate)) +/*****************************************************************************/ static void nm_device_ppp_init (NMDevicePpp *device) diff --git a/libnm/nm-device-ppp.h b/libnm/nm-device-ppp.h index 3e09ce18f..4a71de478 100644 --- a/libnm/nm-device-ppp.h +++ b/libnm/nm-device-ppp.h @@ -19,6 +19,9 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_PPP)) #define NM_DEVICE_PPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_PPP, NMDevicePppClass)) +/** + * NMDevicePpp: + */ typedef struct _NMDevicePppClass NMDevicePppClass; GType nm_device_ppp_get_type (void); diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index e50b3e1de..49c3aad2d 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -13,9 +13,14 @@ #include "nm-object-private.h" #include "nm-core-internal.h" -G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TEAM, NMDeviceTeamPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, + PROP_SLAVES, + PROP_CONFIG, +); typedef struct { char *hw_address; @@ -24,12 +29,20 @@ typedef struct { char *config; } NMDeviceTeamPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, - PROP_SLAVES, - PROP_CONFIG, -); +struct _NMDeviceTeam { + NMDevice parent; + NMDeviceTeamPrivate _priv; +}; + +struct _NMDeviceTeamClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) + +#define NM_DEVICE_TEAM_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceTeam, NM_IS_DEVICE_TEAM, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_team_get_hw_address: @@ -214,8 +227,6 @@ nm_device_team_class_init (NMDeviceTeamClass *team_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (team_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (team_class); - g_type_class_add_private (team_class, sizeof (NMDeviceTeamPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; diff --git a/libnm/nm-device-team.h b/libnm/nm-device-team.h index 0040fd5ea..8bc0d2cd3 100644 --- a/libnm/nm-device-team.h +++ b/libnm/nm-device-team.h @@ -29,16 +29,7 @@ G_BEGIN_DECLS /** * NMDeviceTeam: */ -struct _NMDeviceTeam { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceTeamClass; +typedef struct _NMDeviceTeamClass NMDeviceTeamClass; GType nm_device_team_get_type (void); diff --git a/libnm/nm-device-tun.c b/libnm/nm-device-tun.c index a9a1cdf3b..e3b36d767 100644 --- a/libnm/nm-device-tun.c +++ b/libnm/nm-device-tun.c @@ -14,9 +14,17 @@ #include "nm-utils.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_TUN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_TUN, NMDeviceTunPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_MODE, + PROP_OWNER, + PROP_GROUP, + PROP_NO_PI, + PROP_VNET_HDR, + PROP_MULTI_QUEUE, +); typedef struct { char *hw_address; @@ -28,15 +36,20 @@ typedef struct { gboolean multi_queue; } NMDeviceTunPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_MODE, - PROP_OWNER, - PROP_GROUP, - PROP_NO_PI, - PROP_VNET_HDR, - PROP_MULTI_QUEUE, -); +struct _NMDeviceTun { + NMDevice parent; + NMDeviceTunPrivate _priv; +}; + +struct _NMDeviceTunClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceTun, nm_device_tun, NM_TYPE_DEVICE) + +#define NM_DEVICE_TUN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceTun, NM_IS_DEVICE_TUN, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_tun_get_hw_address: @@ -298,8 +311,6 @@ nm_device_tun_class_init (NMDeviceTunClass *gre_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (gre_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (gre_class); - g_type_class_add_private (gre_class, sizeof (NMDeviceTunPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-tun.h b/libnm/nm-device-tun.h index 2dd2b27f9..bcb2cbb34 100644 --- a/libnm/nm-device-tun.h +++ b/libnm/nm-device-tun.h @@ -32,16 +32,7 @@ G_BEGIN_DECLS /** * NMDeviceTun: */ -struct _NMDeviceTun { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceTunClass; +typedef struct _NMDeviceTunClass NMDeviceTunClass; NM_AVAILABLE_IN_1_2 GType nm_device_tun_get_type (void); diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index c2da173c1..323d5b30e 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -13,9 +13,14 @@ #include "nm-utils.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, + PROP_PARENT, + PROP_VLAN_ID, +); typedef struct { char *hw_address; @@ -24,12 +29,20 @@ typedef struct { guint vlan_id; } NMDeviceVlanPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, - PROP_PARENT, - PROP_VLAN_ID, -); +struct _NMDeviceVlan { + NMDevice parent; + NMDeviceVlanPrivate _priv; +}; + +struct _NMDeviceVlanClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_VLAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceVlan, NM_IS_DEVICE_VLAN, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_vlan_get_hw_address: @@ -217,8 +230,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *vlan_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (vlan_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (vlan_class); - g_type_class_add_private (vlan_class, sizeof (NMDeviceVlanPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-vlan.h b/libnm/nm-device-vlan.h index c94d52503..7a412cb02 100644 --- a/libnm/nm-device-vlan.h +++ b/libnm/nm-device-vlan.h @@ -29,16 +29,7 @@ G_BEGIN_DECLS /** * NMDeviceVlan: */ -struct _NMDeviceVlan { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceVlanClass; +typedef struct _NMDeviceVlanClass NMDeviceVlanClass; GType nm_device_vlan_get_type (void); diff --git a/libnm/nm-device-vxlan.c b/libnm/nm-device-vxlan.c index 10b5ac71d..006d3a12c 100644 --- a/libnm/nm-device-vxlan.c +++ b/libnm/nm-device-vxlan.c @@ -12,9 +12,28 @@ #include "nm-utils.h" #include "nm-object-private.h" -G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_VXLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VXLAN, NMDeviceVxlanPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_CARRIER, + PROP_PARENT, + PROP_ID, + PROP_GROUP, + PROP_LOCAL, + PROP_TOS, + PROP_TTL, + PROP_LIMIT, + PROP_LEARNING, + PROP_AGEING, + PROP_DST_PORT, + PROP_SRC_PORT_MIN, + PROP_SRC_PORT_MAX, + PROP_PROXY, + PROP_RSC, + PROP_L2MISS, + PROP_L3MISS, +); typedef struct { NMDevice *parent; @@ -37,26 +56,20 @@ typedef struct { gboolean l3miss; } NMDeviceVxlanPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_CARRIER, - PROP_PARENT, - PROP_ID, - PROP_GROUP, - PROP_LOCAL, - PROP_TOS, - PROP_TTL, - PROP_LIMIT, - PROP_LEARNING, - PROP_AGEING, - PROP_DST_PORT, - PROP_SRC_PORT_MIN, - PROP_SRC_PORT_MAX, - PROP_PROXY, - PROP_RSC, - PROP_L2MISS, - PROP_L3MISS, -); +struct _NMDeviceVxlan { + NMDevice parent; + NMDeviceVxlanPrivate _priv; +}; + +struct _NMDeviceVxlanClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceVxlan, nm_device_vxlan, NM_TYPE_DEVICE) + +#define NM_DEVICE_VXLAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceVxlan, NM_IS_DEVICE_VXLAN, NMObject, NMDevice) + +/*****************************************************************************/ /** * nm_device_vxlan_get_hw_address: @@ -518,8 +531,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *vxlan_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (vxlan_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (vxlan_class); - g_type_class_add_private (vxlan_class, sizeof (NMDeviceVxlanPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-vxlan.h b/libnm/nm-device-vxlan.h index 4528c54fe..fef2365f2 100644 --- a/libnm/nm-device-vxlan.h +++ b/libnm/nm-device-vxlan.h @@ -43,16 +43,7 @@ G_BEGIN_DECLS /** * NMDeviceVxlan: */ -struct _NMDeviceVxlan { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMDeviceVxlanClass; +typedef struct _NMDeviceVxlanClass NMDeviceVxlanClass; NM_AVAILABLE_IN_1_2 GType nm_device_vxlan_get_type (void); diff --git a/libnm/nm-device-wifi-p2p.c b/libnm/nm-device-wifi-p2p.c index 0aaf3ecc2..c4fc142c5 100644 --- a/libnm/nm-device-wifi-p2p.c +++ b/libnm/nm-device-wifi-p2p.c @@ -42,11 +42,6 @@ typedef struct { GPtrArray *peers; } NMDeviceWifiP2PPrivate; -/** - * NMDeviceWifiP2P: - * - * Since: 1.16 - */ struct _NMDeviceWifiP2P { NMDevice parent; NMDeviceWifiP2PPrivate _priv; diff --git a/libnm/nm-device-wifi-p2p.h b/libnm/nm-device-wifi-p2p.h index 37b23616d..83127575a 100644 --- a/libnm/nm-device-wifi-p2p.h +++ b/libnm/nm-device-wifi-p2p.h @@ -25,6 +25,11 @@ G_BEGIN_DECLS #define NM_DEVICE_WIFI_P2P_PEERS "peers" #define NM_DEVICE_WIFI_P2P_WFDIES "wfdies" +/** + * NMDeviceWifiP2P: + * + * Since: 1.16 + */ typedef struct _NMDeviceWifiP2PClass NMDeviceWifiP2PClass; NM_AVAILABLE_IN_1_16 diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 0436afc6c..d35825606 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -20,12 +20,18 @@ #include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h" -G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE) +/*****************************************************************************/ -#define NM_DEVICE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIFI, NMDeviceWifiPrivate)) - -void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled); -static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_HW_ADDRESS, + PROP_PERM_HW_ADDRESS, + PROP_MODE, + PROP_BITRATE, + PROP_ACTIVE_ACCESS_POINT, + PROP_WIRELESS_CAPABILITIES, + PROP_ACCESS_POINTS, + PROP_LAST_SCAN, +); typedef struct { NMDBusDeviceWifi *proxy; @@ -40,25 +46,38 @@ typedef struct { gint64 last_scan; } NMDeviceWifiPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_HW_ADDRESS, - PROP_PERM_HW_ADDRESS, - PROP_MODE, - PROP_BITRATE, - PROP_ACTIVE_ACCESS_POINT, - PROP_WIRELESS_CAPABILITIES, - PROP_ACCESS_POINTS, - PROP_LAST_SCAN, -); - enum { ACCESS_POINT_ADDED, ACCESS_POINT_REMOVED, LAST_SIGNAL }; + static guint signals[LAST_SIGNAL] = { 0 }; + +struct _NMDeviceWifi { + NMDevice parent; + NMDeviceWifiPrivate _priv; +}; + +struct _NMDeviceWifiClass { + NMDeviceClass parent; + + void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap); +}; + +G_DEFINE_TYPE (NMDeviceWifi, nm_device_wifi, NM_TYPE_DEVICE) + +#define NM_DEVICE_WIFI_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceWifi, NM_IS_DEVICE_WIFI, NMObject, NMDevice) + +/*****************************************************************************/ + +void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled); +static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); + +/*****************************************************************************/ + /** * nm_device_wifi_get_hw_address: * @device: a #NMDeviceWifi @@ -725,8 +744,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wifi_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class); - g_type_class_add_private (wifi_class, sizeof (NMDeviceWifiPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; @@ -846,8 +863,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *wifi_class) g_signal_new ("access-point-added", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceWifiClass, access_point_added), - NULL, NULL, + 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); diff --git a/libnm/nm-device-wifi.h b/libnm/nm-device-wifi.h index 18ebf24cc..c64641d36 100644 --- a/libnm/nm-device-wifi.h +++ b/libnm/nm-device-wifi.h @@ -34,20 +34,7 @@ G_BEGIN_DECLS /** * NMDeviceWifi: */ -struct _NMDeviceWifi { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /* Signals */ - void (*access_point_added) (NMDeviceWifi *device, NMAccessPoint *ap); - void (*access_point_removed) (NMDeviceWifi *device, NMAccessPoint *ap); - - /*< private >*/ - gpointer padding[4]; -} NMDeviceWifiClass; +typedef struct _NMDeviceWifiClass NMDeviceWifiClass; GType nm_device_wifi_get_type (void); diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index db99a3c0a..c67132397 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -15,24 +15,7 @@ #include "nm-object-private.h" #include "nm-core-internal.h" -G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE) - -#define NM_DEVICE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIMAX, NMDeviceWimaxPrivate)) - -void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled); -static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); - -typedef struct { - char *hw_address; - NMWimaxNsp *active_nsp; - GPtrArray *nsps; - - guint center_freq; - int rssi; - int cinr; - int tx_power; - char *bsid; -} NMDeviceWimaxPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_HW_ADDRESS, @@ -51,8 +34,43 @@ enum { LAST_SIGNAL }; + static guint signals[LAST_SIGNAL] = { 0 }; +typedef struct { + char *hw_address; + NMWimaxNsp *active_nsp; + GPtrArray *nsps; + + guint center_freq; + int rssi; + int cinr; + int tx_power; + char *bsid; +} NMDeviceWimaxPrivate; + +struct _NMDeviceWimax { + NMDevice parent; + NMDeviceWimaxPrivate _priv; +}; + +struct _NMDeviceWimaxClass { + NMDeviceClass parent; + + void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp); +}; + +G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE) + +#define NM_DEVICE_WIMAX_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceWimax, NM_IS_DEVICE_WIMAX, NMObject, NMDevice) + +/*****************************************************************************/ + +void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled); +static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data); + +/*****************************************************************************/ + /** * nm_device_wimax_get_hw_address: * @wimax: a #NMDeviceWimax @@ -505,8 +523,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wimax_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wimax_class); - g_type_class_add_private (wimax_class, sizeof (NMDeviceWimaxPrivate)); - object_class->get_property = get_property; object_class->dispose = dispose; @@ -645,8 +661,7 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class) g_signal_new ("nsp-added", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_added), - NULL, NULL, + 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); diff --git a/libnm/nm-device-wimax.h b/libnm/nm-device-wimax.h index 99260ea59..dc7958f13 100644 --- a/libnm/nm-device-wimax.h +++ b/libnm/nm-device-wimax.h @@ -34,20 +34,7 @@ G_BEGIN_DECLS /** * NMDeviceWimax: */ -struct _NMDeviceWimax { - NMDevice parent; -}; - -typedef struct { - NMDeviceClass parent; - - /* Signals */ - void (*nsp_added) (NMDeviceWimax *self, NMWimaxNsp *nsp); - void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp); - - /*< private >*/ - gpointer padding[4]; -} NMDeviceWimaxClass; +typedef struct _NMDeviceWimaxClass NMDeviceWimaxClass; NM_DEPRECATED_IN_1_2 GType nm_device_wimax_get_type (void); diff --git a/libnm/nm-device-wireguard.c b/libnm/nm-device-wireguard.c index d04799c62..825095eaa 100644 --- a/libnm/nm-device-wireguard.c +++ b/libnm/nm-device-wireguard.c @@ -6,19 +6,26 @@ #include "nm-default.h" #include "nm-device-wireguard.h" + #include "nm-object-private.h" +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PUBLIC_KEY, + PROP_LISTEN_PORT, + PROP_FWMARK, +); + typedef struct { GBytes *public_key; guint listen_port; guint fwmark; } NMDeviceWireGuardPrivate; -/** - * NMDeviceWireGuard: - */ struct _NMDeviceWireGuard { NMDevice parent; + NMDeviceWireGuardPrivate _priv; }; struct _NMDeviceWireGuardClass { @@ -27,13 +34,9 @@ struct _NMDeviceWireGuardClass { G_DEFINE_TYPE (NMDeviceWireGuard, nm_device_wireguard, NM_TYPE_DEVICE) -#define NM_DEVICE_WIREGUARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIREGUARD, NMDeviceWireGuardPrivate)) +#define NM_DEVICE_WIREGUARD_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceWireGuard, NM_IS_DEVICE_WIREGUARD, NMObject, NMDevice) -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PUBLIC_KEY, - PROP_LISTEN_PORT, - PROP_FWMARK, -); +/*****************************************************************************/ /** * nm_device_wireguard_get_public_key: @@ -156,8 +159,6 @@ nm_device_wireguard_class_init (NMDeviceWireGuardClass *wireguard_class) GObjectClass *object_class = G_OBJECT_CLASS (wireguard_class); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wireguard_class); - g_type_class_add_private (wireguard_class, sizeof (NMDeviceWireGuardPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-wireguard.h b/libnm/nm-device-wireguard.h index d2f32032e..1b2bb8405 100644 --- a/libnm/nm-device-wireguard.h +++ b/libnm/nm-device-wireguard.h @@ -21,6 +21,9 @@ G_BEGIN_DECLS #define NM_IS_DEVICE_WIREGUARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIREGUARD)) #define NM_DEVICE_WIREGUARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIREGUARD, NMDeviceWireGuardClass)) +/** + * NMDeviceWireGuard: + */ typedef struct _NMDeviceWireGuardClass NMDeviceWireGuardClass; #define NM_DEVICE_WIREGUARD_PUBLIC_KEY "public-key" diff --git a/libnm/nm-device-wpan.c b/libnm/nm-device-wpan.c index 45595c008..24d16faf1 100644 --- a/libnm/nm-device-wpan.c +++ b/libnm/nm-device-wpan.c @@ -11,28 +11,28 @@ #include "nm-setting-wpan.h" #include "nm-setting-connection.h" +/*****************************************************************************/ + NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_HW_ADDRESS, ); typedef struct { - char *hw_address; + char *hw_address; } NMDeviceWpanPrivate; -/** - * NMDeviceWpan: - */ struct _NMDeviceWpan { - NMDevice parent; + NMDevice parent; + NMDeviceWpanPrivate _priv; }; -typedef struct { - NMDeviceClass parent; -} NMDeviceWpanClass; +struct _NMDeviceWpanClass { + NMDeviceClass parent; +}; G_DEFINE_TYPE (NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE) -#define NM_DEVICE_WPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WPAN, NMDeviceWpanPrivate)) +#define NM_DEVICE_WPAN_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDeviceWpan, NM_IS_DEVICE_WPAN, NMObject, NMDevice) /*****************************************************************************/ @@ -133,8 +133,6 @@ nm_device_wpan_class_init (NMDeviceWpanClass *wpan_class) NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wpan_class); NMDeviceClass *device_class = NM_DEVICE_CLASS (wpan_class); - g_type_class_add_private (wpan_class, sizeof (NMDeviceWpanPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-device-wpan.h b/libnm/nm-device-wpan.h index 7b9dee332..43f8b7b3a 100644 --- a/libnm/nm-device-wpan.h +++ b/libnm/nm-device-wpan.h @@ -23,6 +23,11 @@ G_BEGIN_DECLS #define NM_DEVICE_WPAN_HW_ADDRESS "hw-address" +/** + * NMDeviceWpan: + */ +typedef struct _NMDeviceWpanClass NMDeviceWpanClass; + NM_AVAILABLE_IN_1_14 GType nm_device_wpan_get_type (void); diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 3b6e47f85..1f1027aad 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -29,53 +29,7 @@ #include "introspection/org.freedesktop.NetworkManager.Device.h" -static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error); -static NMLldpNeighbor *nm_lldp_neighbor_dup (NMLldpNeighbor *neighbor); - -G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT); - -#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate)) - -typedef struct { - NMDBusDevice *proxy; - - char *iface; - char *ip_iface; - NMDeviceType device_type; - char *udi; - char *driver; - char *driver_version; - char *firmware_version; - char *type_description; - NMMetered metered; - NMDeviceCapabilities capabilities; - gboolean real; - gboolean managed; - gboolean firmware_missing; - gboolean nm_plugin_missing; - gboolean autoconnect; - NMIPConfig *ip4_config; - NMDhcpConfig *dhcp4_config; - NMIPConfig *ip6_config; - NMDhcpConfig *dhcp6_config; - NMConnectivityState ip4_connectivity; - NMConnectivityState ip6_connectivity; - NMDeviceState state; - NMDeviceState last_seen_state; - NMDeviceStateReason reason; - - NMActiveConnection *active_connection; - GPtrArray *available_connections; - - struct udev *udev; - char *product; - char *vendor, *short_vendor; - char *description, *bus_name; - - char *physical_port_id; - guint32 mtu; - GPtrArray *lldp_neighbors; -} NMDevicePrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_INTERFACE, @@ -117,6 +71,58 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +typedef struct _NMDevicePrivate { + NMDBusDevice *proxy; + + char *iface; + char *ip_iface; + NMDeviceType device_type; + char *udi; + char *driver; + char *driver_version; + char *firmware_version; + char *type_description; + NMMetered metered; + NMDeviceCapabilities capabilities; + gboolean real; + gboolean managed; + gboolean firmware_missing; + gboolean nm_plugin_missing; + gboolean autoconnect; + NMIPConfig *ip4_config; + NMDhcpConfig *dhcp4_config; + NMIPConfig *ip6_config; + NMDhcpConfig *dhcp6_config; + NMConnectivityState ip4_connectivity; + NMConnectivityState ip6_connectivity; + NMDeviceState state; + NMDeviceState last_seen_state; + NMDeviceStateReason reason; + + NMActiveConnection *active_connection; + GPtrArray *available_connections; + + struct udev *udev; + char *product; + char *vendor, *short_vendor; + char *description, *bus_name; + + char *physical_port_id; + guint32 mtu; + GPtrArray *lldp_neighbors; +} NMDevicePrivate; + +G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_OBJECT); + +#define NM_DEVICE_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMDevice, NM_IS_DEVICE, NMObject) + +/*****************************************************************************/ + +static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error); +static NMLldpNeighbor *nm_lldp_neighbor_dup (NMLldpNeighbor *neighbor); + +/*****************************************************************************/ + struct _NMLldpNeighbor { guint refcount; GHashTable *attrs; @@ -125,9 +131,13 @@ struct _NMLldpNeighbor { G_DEFINE_BOXED_TYPE (NMLldpNeighbor, nm_lldp_neighbor, nm_lldp_neighbor_dup, nm_lldp_neighbor_unref) static void -nm_device_init (NMDevice *device) +nm_device_init (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); + NMDevicePrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_DEVICE, NMDevicePrivate); + + self->_priv = priv; priv->ip4_connectivity = NM_CONNECTIVITY_UNKNOWN; priv->ip6_connectivity = NM_CONNECTIVITY_UNKNOWN; diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5d8a1cae6..ede606d8e 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -58,32 +58,7 @@ _NM_DEPRECATED_SYNC_WRITABLE_PROPERTY /** * NMDevice: */ -struct _NMDevice { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /* Signals */ - void (*state_changed) (NMDevice *device, - NMDeviceState new_state, - NMDeviceState old_state, - NMDeviceStateReason reason); - - /* Methods */ - gboolean (*connection_compatible) (NMDevice *device, - NMConnection *connection, - GError **error); - - const char * (*get_type_description) (NMDevice *device); - const char * (*get_hw_address) (NMDevice *device); - - GType (*get_setting_type) (NMDevice *device); - - /*< private >*/ - gpointer padding[8]; -} NMDeviceClass; +typedef struct _NMDeviceClass NMDeviceClass; typedef struct _NMLldpNeighbor NMLldpNeighbor; diff --git a/libnm/nm-dhcp-config.c b/libnm/nm-dhcp-config.c index f92ca200b..df171690b 100644 --- a/libnm/nm-dhcp-config.c +++ b/libnm/nm-dhcp-config.c @@ -14,23 +14,31 @@ #include "nm-object-private.h" #include "nm-utils.h" -G_DEFINE_ABSTRACT_TYPE (NMDhcpConfig, nm_dhcp_config, NM_TYPE_OBJECT) - -#define NM_DHCP_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_CONFIG, NMDhcpConfigPrivate)) - -typedef struct { - GHashTable *options; -} NMDhcpConfigPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_FAMILY, PROP_OPTIONS, ); +typedef struct _NMDhcpConfigPrivate { + GHashTable *options; +} NMDhcpConfigPrivate; + +G_DEFINE_ABSTRACT_TYPE (NMDhcpConfig, nm_dhcp_config, NM_TYPE_OBJECT) + +#define NM_DHCP_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMDhcpConfig, NM_IS_DHCP_CONFIG, NMObject) + +/*****************************************************************************/ + static void -nm_dhcp_config_init (NMDhcpConfig *config) +nm_dhcp_config_init (NMDhcpConfig *self) { - NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (config); + NMDhcpConfigPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_DHCP_CONFIG, NMDhcpConfigPrivate); + + self->_priv = priv; priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); } diff --git a/libnm/nm-dhcp-config.h b/libnm/nm-dhcp-config.h index 78abab029..8f967a583 100644 --- a/libnm/nm-dhcp-config.h +++ b/libnm/nm-dhcp-config.h @@ -24,16 +24,7 @@ G_BEGIN_DECLS /** * NMDhcpConfig: */ -struct _NMDhcpConfig { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /*< private >*/ - gpointer padding[8]; -} NMDhcpConfigClass; +typedef struct _NMDhcpConfigClass NMDhcpConfigClass; #define NM_DHCP_CONFIG_FAMILY "family" #define NM_DHCP_CONFIG_OPTIONS "options" diff --git a/libnm/nm-dhcp4-config.c b/libnm/nm-dhcp4-config.c index 3377c2315..89d3835e0 100644 --- a/libnm/nm-dhcp4-config.c +++ b/libnm/nm-dhcp4-config.c @@ -7,10 +7,20 @@ #include "nm-dhcp4-config.h" -#include "nm-object-private.h" +/*****************************************************************************/ + +struct _NMDhcp4Config { + NMDhcpConfig parent; +}; + +struct _NMDhcp4ConfigClass{ + NMDhcpConfigClass parent; +}; G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DHCP_CONFIG) +/*****************************************************************************/ + static void nm_dhcp4_config_init (NMDhcp4Config *config) { diff --git a/libnm/nm-dhcp4-config.h b/libnm/nm-dhcp4-config.h index e1865a96e..7ce4d8440 100644 --- a/libnm/nm-dhcp4-config.h +++ b/libnm/nm-dhcp4-config.h @@ -17,17 +17,13 @@ #define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass)) #define NM_IS_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP4_CONFIG)) #define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP4_CONFIG)) +#define NM_DHCP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass)) /** * NMDhcp4Config: */ -typedef struct { - NMDhcpConfig parent; -} NMDhcp4Config; - -typedef struct { - NMDhcpConfigClass parent; -} NMDhcp4ConfigClass; +typedef struct _NMDhcp4Config NMDhcp4Config; +typedef struct _NMDhcp4ConfigClass NMDhcp4ConfigClass; GType nm_dhcp4_config_get_type (void); diff --git a/libnm/nm-dhcp6-config.c b/libnm/nm-dhcp6-config.c index 780471c44..acb728769 100644 --- a/libnm/nm-dhcp6-config.c +++ b/libnm/nm-dhcp6-config.c @@ -7,10 +7,20 @@ #include "nm-dhcp6-config.h" -#include "nm-object-private.h" +/*****************************************************************************/ + +struct _NMDhcp6Config { + NMDhcpConfig parent; +}; + +struct _NMDhcp6ConfigClass{ + NMDhcpConfigClass parent; +}; G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DHCP_CONFIG) +/*****************************************************************************/ + static void nm_dhcp6_config_init (NMDhcp6Config *config) { diff --git a/libnm/nm-dhcp6-config.h b/libnm/nm-dhcp6-config.h index 4930bcc09..05223a161 100644 --- a/libnm/nm-dhcp6-config.h +++ b/libnm/nm-dhcp6-config.h @@ -17,17 +17,13 @@ #define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass)) #define NM_IS_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP6_CONFIG)) #define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP6_CONFIG)) +#define NM_DHCP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass)) /** * NMDhcp6Config: */ -typedef struct { - NMDhcpConfig parent; -} NMDhcp6Config; - -typedef struct { - NMDhcpConfigClass parent; -} NMDhcp6ConfigClass; +typedef struct _NMDhcp6Config NMDhcp6Config; +typedef struct _NMDhcp6ConfigClass NMDhcp6ConfigClass; GType nm_dhcp6_config_get_type (void); diff --git a/libnm/nm-ip-config.c b/libnm/nm-ip-config.c index dd5e5d7a4..bc313bb32 100644 --- a/libnm/nm-ip-config.c +++ b/libnm/nm-ip-config.c @@ -16,21 +16,7 @@ #include "nm-utils.h" #include "nm-core-internal.h" -G_DEFINE_ABSTRACT_TYPE (NMIPConfig, nm_ip_config, NM_TYPE_OBJECT) - -#define NM_IP_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP_CONFIG, NMIPConfigPrivate)) - -typedef struct { - char *gateway; - GPtrArray *addresses; - GPtrArray *routes; - char **nameservers; - char **domains; - char **searches; - char **wins; - - gboolean new_style_data; -} NMIPConfigPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_FAMILY, @@ -43,10 +29,32 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_WINS_SERVERS, ); +typedef struct _NMIPConfigPrivate { + char *gateway; + GPtrArray *addresses; + GPtrArray *routes; + char **nameservers; + char **domains; + char **searches; + char **wins; + + gboolean new_style_data; +} NMIPConfigPrivate; + +G_DEFINE_ABSTRACT_TYPE (NMIPConfig, nm_ip_config, NM_TYPE_OBJECT) + +#define NM_IP_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMIPConfig, NM_IS_IP_CONFIG, NMObject) + +/*****************************************************************************/ + static void -nm_ip_config_init (NMIPConfig *config) +nm_ip_config_init (NMIPConfig *self) { - NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (config); + NMIPConfigPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_IP_CONFIG, NMIPConfigPrivate); + + self->_priv = priv; priv->addresses = g_ptr_array_new (); priv->routes = g_ptr_array_new (); diff --git a/libnm/nm-ip-config.h b/libnm/nm-ip-config.h index ea27f2674..56beb1aa8 100644 --- a/libnm/nm-ip-config.h +++ b/libnm/nm-ip-config.h @@ -25,16 +25,7 @@ G_BEGIN_DECLS /** * NMIPConfig: */ -struct _NMIPConfig { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /*< private >*/ - gpointer padding[8]; -} NMIPConfigClass; +typedef struct _NMIPConfigClass NMIPConfigClass; #define NM_IP_CONFIG_FAMILY "family" #define NM_IP_CONFIG_GATEWAY "gateway" diff --git a/libnm/nm-ip4-config.c b/libnm/nm-ip4-config.c index d70f80b69..259c20b03 100644 --- a/libnm/nm-ip4-config.c +++ b/libnm/nm-ip4-config.c @@ -7,10 +7,20 @@ #include "nm-ip4-config.h" -#include "nm-object-private.h" +/*****************************************************************************/ + +struct _NMIP4Config { + NMIPConfig parent; +}; + +struct _NMIP4ConfigClass{ + NMIPConfigClass parent; +}; G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_IP_CONFIG) +/*****************************************************************************/ + static void nm_ip4_config_init (NMIP4Config *config) { diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h index aaeb43c50..3f6a40bb8 100644 --- a/libnm/nm-ip4-config.h +++ b/libnm/nm-ip4-config.h @@ -23,13 +23,8 @@ /** * NMIP4Config: */ -typedef struct { - NMIPConfig parent; -} NMIP4Config; - -typedef struct { - NMIPConfigClass parent; -} NMIP4ConfigClass; +typedef struct _NMIP4Config NMIP4Config; +typedef struct _NMIP4ConfigClass NMIP4ConfigClass; GType nm_ip4_config_get_type (void); diff --git a/libnm/nm-ip6-config.c b/libnm/nm-ip6-config.c index 5f3e68332..9a059edb4 100644 --- a/libnm/nm-ip6-config.c +++ b/libnm/nm-ip6-config.c @@ -7,10 +7,20 @@ #include "nm-ip6-config.h" -#include "nm-object-private.h" +/*****************************************************************************/ + +struct _NMIP6Config { + NMIPConfig parent; +}; + +struct _NMIP6ConfigClass{ + NMIPConfigClass parent; +}; G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_IP_CONFIG) +/*****************************************************************************/ + static void nm_ip6_config_init (NMIP6Config *config) { diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h index 4abe10e63..33c65c898 100644 --- a/libnm/nm-ip6-config.h +++ b/libnm/nm-ip6-config.h @@ -23,13 +23,8 @@ /** * NMIP6Config: */ -typedef struct { - NMIPConfig parent; -} NMIP6Config; - -typedef struct { - NMIPConfigClass parent; -} NMIP6ConfigClass; +typedef struct _NMIP6Config NMIP6Config; +typedef struct _NMIP6ConfigClass NMIP6ConfigClass; GType nm_ip6_config_get_type (void); diff --git a/libnm/nm-libnm-utils.h b/libnm/nm-libnm-utils.h index ff070a587..2e0c792ab 100644 --- a/libnm/nm-libnm-utils.h +++ b/libnm/nm-libnm-utils.h @@ -6,10 +6,6 @@ #ifndef __NM_LIBNM_UTILS_H__ #define __NM_LIBNM_UTILS_H__ -#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) -#error Cannot use this header. -#endif - #include "nm-types.h" /*****************************************************************************/ @@ -117,4 +113,96 @@ char *nm_utils_wincaps_to_dash (const char *caps); char *nm_utils_fixup_vendor_string (const char *desc); char *nm_utils_fixup_product_string (const char *desc); +/*****************************************************************************/ + +struct _NMObjectPrivate; + +struct _NMObject { + GObject parent; + struct _NMObjectPrivate *_priv; +}; + +struct _NMObjectClass { + GObjectClass parent; + + void (*init_dbus) (struct _NMObject *object); + + /* The "object-creation-failed" method is PRIVATE for libnm and + * is not meant for any external usage. It indicates that an error + * occurred during creation of an object. + */ + void (*object_creation_failed) (struct _NMObject *master_object, + const char *failed_path); +}; + +/*****************************************************************************/ + +struct _NMDevicePrivate; + +struct _NMDevice { + NMObject parent; + struct _NMDevicePrivate *_priv; +}; + +struct _NMDeviceClass { + struct _NMObjectClass parent; + + /* Signals */ + void (*state_changed) (NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason); + + /* Methods */ + gboolean (*connection_compatible) (NMDevice *device, + NMConnection *connection, + GError **error); + + const char * (*get_type_description) (NMDevice *device); + const char * (*get_hw_address) (NMDevice *device); + + GType (*get_setting_type) (NMDevice *device); +}; + +/*****************************************************************************/ + +struct _NMActiveConnectionPrivate; + +struct _NMActiveConnection { + NMObject parent; + struct _NMActiveConnectionPrivate *_priv; +}; + +struct _NMActiveConnectionClass { + struct _NMObjectClass parent; +}; + +/*****************************************************************************/ + +struct _NMDhcpConfigPrivate; + +struct _NMDhcpConfig { + NMObject parent; + struct _NMDhcpConfigPrivate *_priv; +}; + +struct _NMDhcpConfigClass { + struct _NMObjectClass parent; +}; + +/*****************************************************************************/ + +struct _NMIPConfigPrivate; + +struct _NMIPConfig { + NMObject parent; + struct _NMIPConfigPrivate *_priv; +}; + +struct _NMIPConfigClass { + struct _NMObjectClass parent; +}; + +/*****************************************************************************/ + #endif /* __NM_LIBNM_UTILS_H__ */ diff --git a/libnm/nm-object.c b/libnm/nm-object.c index de1d15186..e77372446 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -19,27 +19,21 @@ #include "nm-core-internal.h" #include "c-list/src/c-list.h" +/*****************************************************************************/ + static gboolean debug = FALSE; #define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); } NM_CACHED_QUARK_FCN ("nm-obj-nm", _nm_object_obj_nm_quark) -static void nm_object_initable_iface_init (GInitableIface *iface); -static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface); +/*****************************************************************************/ -typedef struct { - GSList *interfaces; -} NMObjectClassPrivate; - -#define NM_OBJECT_CLASS_GET_PRIVATE(k) (G_TYPE_CLASS_GET_PRIVATE ((k), NM_TYPE_OBJECT, NMObjectClassPrivate)) - -G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMObject, nm_object, G_TYPE_OBJECT, - g_type_add_class_private (g_define_type_id, sizeof (NMObjectClassPrivate)); - G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_object_initable_iface_init); - G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_object_async_initable_iface_init); - ) - -#define NM_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_OBJECT, NMObjectPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_PATH, + PROP_DBUS_CONNECTION, + PROP_DBUS_OBJECT, + PROP_DBUS_OBJECT_MANAGER, +); typedef struct { PropertyMarshalFunc func; @@ -48,10 +42,7 @@ typedef struct { const char *signal_prefix; } PropertyInfo; -static void reload_complete (NMObject *object, gboolean emit_now); -static gboolean demarshal_generic (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field); - -typedef struct { +typedef struct _NMObjectPrivate { GDBusObject *object; GDBusObjectManager *object_manager; @@ -73,12 +64,29 @@ typedef struct { char *name_owner_cached; } NMObjectPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_PATH, - PROP_DBUS_CONNECTION, - PROP_DBUS_OBJECT, - PROP_DBUS_OBJECT_MANAGER, -); +typedef struct { + GSList *interfaces; +} NMObjectClassPrivate; + +static void nm_object_initable_iface_init (GInitableIface *iface); +static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface); + +G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMObject, nm_object, G_TYPE_OBJECT, + g_type_add_class_private (g_define_type_id, sizeof (NMObjectClassPrivate)); + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_object_initable_iface_init); + G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_object_async_initable_iface_init); + ) + +#define NM_OBJECT_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR(self, NMObject, NM_IS_OBJECT) + +#define NM_OBJECT_CLASS_GET_PRIVATE(k) (G_TYPE_CLASS_GET_PRIVATE ((k), NM_TYPE_OBJECT, NMObjectClassPrivate)) + +/*****************************************************************************/ + +static void reload_complete (NMObject *object, gboolean emit_now); +static gboolean demarshal_generic (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field); + +/*****************************************************************************/ /** * nm_object_get_path: @@ -1308,7 +1316,8 @@ static gboolean init_finish (GAsyncInitable *initable, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); - NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (initable); + NMObject *self = NM_OBJECT (initable); + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); priv->inited = TRUE; @@ -1345,7 +1354,12 @@ nm_object_async_initable_iface_init (GAsyncInitableIface *iface) static void nm_object_init (NMObject *object) { - NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); + NMObject *self = NM_OBJECT (object); + NMObjectPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_OBJECT, NMObjectPrivate); + + self->_priv = priv; c_list_init (&priv->notify_items); c_list_init (&priv->pending); diff --git a/libnm/nm-object.h b/libnm/nm-object.h index 96e214b38..d9ee4444c 100644 --- a/libnm/nm-object.h +++ b/libnm/nm-object.h @@ -30,26 +30,7 @@ G_BEGIN_DECLS /** * NMObject: */ -struct _NMObject { - GObject parent; -}; - -typedef struct { - GObjectClass parent; - - /* Methods */ - void (*init_dbus) (NMObject *object); - - /* The "object-creation-failed" method is PRIVATE for libnm and - * is not meant for any external usage. It indicates that an error - * occurred during creation of an object. - */ - void (*object_creation_failed) (NMObject *master_object, - const char *failed_path); - - /*< private >*/ - gpointer padding[8]; -} NMObjectClass; +typedef struct _NMObjectClass NMObjectClass; GType nm_object_get_type (void); diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index 6a667b13e..c45c7f1fc 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -27,17 +27,7 @@ * NetworkManager D-Bus interface. **/ -static void nm_remote_connection_connection_iface_init (NMConnectionInterface *iface); -static void nm_remote_connection_initable_iface_init (GInitableIface *iface); -static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface); -static GInitableIface *nm_remote_connection_parent_initable_iface; -static GAsyncInitableIface *nm_remote_connection_parent_async_initable_iface; - -G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_remote_connection_connection_iface_init); - G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_connection_initable_iface_init); - G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_connection_async_initable_iface_init); - ) +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE (NMRemoteConnection, PROP_UNSAVED, @@ -56,7 +46,30 @@ typedef struct { gboolean visible; } NMRemoteConnectionPrivate; -#define NM_REMOTE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_REMOTE_CONNECTION, NMRemoteConnectionPrivate)) +struct _NMRemoteConnection { + NMObject parent; + NMRemoteConnectionPrivate _priv; +}; + +struct _NMRemoteConnectionClass { + NMObjectClass parent_class; +}; + +static void nm_remote_connection_connection_iface_init (NMConnectionInterface *iface); +static void nm_remote_connection_initable_iface_init (GInitableIface *iface); +static void nm_remote_connection_async_initable_iface_init (GAsyncInitableIface *iface); + +G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_remote_connection_connection_iface_init); + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_remote_connection_initable_iface_init); + G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_remote_connection_async_initable_iface_init); + ) +#define NM_REMOTE_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMRemoteConnection, NM_IS_REMOTE_CONNECTION, NMObject) + +/*****************************************************************************/ + +static GInitableIface *nm_remote_connection_parent_initable_iface; +static GAsyncInitableIface *nm_remote_connection_parent_async_initable_iface; /*****************************************************************************/ @@ -700,7 +713,7 @@ static gboolean init_sync (GInitable *initable, GCancellable *cancellable, GError **error) { NMRemoteConnection *self = NM_REMOTE_CONNECTION (initable); - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable); + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); GVariant *settings; priv->proxy = NMDBUS_SETTINGS_CONNECTION (_nm_object_get_proxy (NM_OBJECT (initable), NM_DBUS_INTERFACE_SETTINGS_CONNECTION)); @@ -758,7 +771,8 @@ init_get_settings_cb (GObject *proxy, gpointer user_data) { NMRemoteConnectionInitData *init_data = user_data; - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable); + NMRemoteConnection *self = NM_REMOTE_CONNECTION (init_data->initable); + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); GVariant *settings; GError *error = NULL; @@ -781,7 +795,8 @@ init_async (GAsyncInitable *initable, int io_priority, gpointer user_data) { NMRemoteConnectionInitData *init_data; - NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (initable); + NMRemoteConnection *self = NM_REMOTE_CONNECTION (initable); + NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self); init_data = g_slice_new0 (NMRemoteConnectionInitData); init_data->cancellable = cancellable ? g_object_ref (cancellable) : NULL; @@ -798,7 +813,7 @@ init_async (GAsyncInitable *initable, int io_priority, g_signal_connect_object (priv->proxy, "updated", G_CALLBACK (updated_cb), initable, 0); - nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (init_data->initable)->proxy, + nmdbus_settings_connection_call_get_settings (NM_REMOTE_CONNECTION_GET_PRIVATE (NM_REMOTE_CONNECTION (init_data->initable))->proxy, init_data->cancellable, init_get_settings_cb, init_data); } @@ -857,8 +872,6 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class) GObjectClass *object_class = G_OBJECT_CLASS (remote_class); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (remote_class); - g_type_class_add_private (object_class, sizeof (NMRemoteConnectionPrivate)); - object_class->get_property = get_property; object_class->constructed = constructed; object_class->dispose = dispose; diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h index ce6eef993..ed05daad7 100644 --- a/libnm/nm-remote-connection.h +++ b/libnm/nm-remote-connection.h @@ -33,16 +33,7 @@ G_BEGIN_DECLS /** * NMRemoteConnection: */ -struct _NMRemoteConnection { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent_class; - - /*< private >*/ - gpointer padding[8]; -} NMRemoteConnectionClass; +typedef struct _NMRemoteConnectionClass NMRemoteConnectionClass; GType nm_remote_connection_get_type (void); diff --git a/libnm/nm-vpn-connection.c b/libnm/nm-vpn-connection.c index 7ef24aaa9..3927397e3 100644 --- a/libnm/nm-vpn-connection.c +++ b/libnm/nm-vpn-connection.c @@ -16,16 +16,7 @@ #include "introspection/org.freedesktop.NetworkManager.VPN.Connection.h" -G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) - -#define NM_VPN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_CONNECTION, NMVpnConnectionPrivate)) - -G_STATIC_ASSERT (sizeof (NMVpnConnectionStateReason) == sizeof (NMActiveConnectionStateReason)); - -typedef struct { - char *banner; - NMVpnConnectionState vpn_state; -} NMVpnConnectionPrivate; +/*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE (NMVpnConnection, PROP_VPN_STATE, @@ -40,6 +31,28 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +typedef struct { + char *banner; + NMVpnConnectionState vpn_state; +} NMVpnConnectionPrivate; + +struct _NMVpnConnection { + NMActiveConnection parent; + NMVpnConnectionPrivate _priv; +}; + +struct _NMVpnConnectionClass { + NMActiveConnectionClass parent; +}; + +G_DEFINE_TYPE (NMVpnConnection, nm_vpn_connection, NM_TYPE_ACTIVE_CONNECTION) + +#define NM_VPN_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMVpnConnection, NM_IS_VPN_CONNECTION, NMObject, NMActiveConnection) + +G_STATIC_ASSERT (sizeof (NMVpnConnectionStateReason) == sizeof (NMActiveConnectionStateReason)); + +/*****************************************************************************/ + /** * nm_vpn_connection_get_banner: * @vpn: a #NMVpnConnection @@ -159,8 +172,6 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) GObjectClass *object_class = G_OBJECT_CLASS (connection_class); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (connection_class); - g_type_class_add_private (connection_class, sizeof (NMVpnConnectionPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; @@ -196,8 +207,7 @@ nm_vpn_connection_class_init (NMVpnConnectionClass *connection_class) g_signal_new ("vpn-state-changed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMVpnConnectionClass, vpn_state_changed), - NULL, NULL, NULL, + 0, NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); G_GNUC_END_IGNORE_DEPRECATIONS diff --git a/libnm/nm-vpn-connection.h b/libnm/nm-vpn-connection.h index 6e826a67c..5c7b4ca15 100644 --- a/libnm/nm-vpn-connection.h +++ b/libnm/nm-vpn-connection.h @@ -29,31 +29,7 @@ G_BEGIN_DECLS /** * NMVpnConnection: */ -struct _NMVpnConnection { - NMActiveConnection parent; -}; - -typedef struct { - NMActiveConnectionClass parent; - - /* Signals */ - - /* NMVpnConnectionStateReason got deprecated in 1.8.0. Thus, vpn_state_changed() - * uses a deprecated type and is itself deprecated. - * - * If you use this signal slot, you are advised to cast the reason - * to the NMActiveConnectionStateReason type, which is fully compatible. - */ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - NM_DEPRECATED_IN_1_8 - void (*vpn_state_changed) (NMVpnConnection *connection, - NMVpnConnectionState state, - NMVpnConnectionStateReason reason); - G_GNUC_END_IGNORE_DEPRECATIONS - - /*< private >*/ - gpointer padding[4]; -} NMVpnConnectionClass; +typedef struct _NMVpnConnectionClass NMVpnConnectionClass; GType nm_vpn_connection_get_type (void); diff --git a/libnm/nm-wifi-p2p-peer.c b/libnm/nm-wifi-p2p-peer.c index 993f4dc93..73dc5fc04 100644 --- a/libnm/nm-wifi-p2p-peer.c +++ b/libnm/nm-wifi-p2p-peer.c @@ -47,9 +47,6 @@ typedef struct { guint8 strength; } NMWifiP2PPeerPrivate; -/** - * NMWifiP2PPeer: - */ struct _NMWifiP2PPeer { NMObject parent; NMWifiP2PPeerPrivate _priv; diff --git a/libnm/nm-wifi-p2p-peer.h b/libnm/nm-wifi-p2p-peer.h index 1eadef3fc..0a8b4d39c 100644 --- a/libnm/nm-wifi-p2p-peer.h +++ b/libnm/nm-wifi-p2p-peer.h @@ -32,6 +32,9 @@ G_BEGIN_DECLS #define NM_WIFI_P2P_PEER_STRENGTH "strength" #define NM_WIFI_P2P_PEER_LAST_SEEN "last-seen" +/** + * NMWifiP2PPeer: + */ typedef struct _NMWifiP2PPeerClass NMWifiP2PPeerClass; NM_AVAILABLE_IN_1_16 diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index 91dc5dae2..fac6bd08e 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -14,9 +14,13 @@ #include "nm-object-private.h" #include "nm-enum-types.h" -G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT) +/*****************************************************************************/ -#define NM_WIMAX_NSP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WIMAX_NSP, NMWimaxNspPrivate)) +NM_GOBJECT_PROPERTIES_DEFINE_BASE ( + PROP_NAME, + PROP_SIGNAL_QUALITY, + PROP_NETWORK_TYPE, +); typedef struct { char *name; @@ -24,11 +28,20 @@ typedef struct { NMWimaxNspNetworkType network_type; } NMWimaxNspPrivate; -NM_GOBJECT_PROPERTIES_DEFINE_BASE ( - PROP_NAME, - PROP_SIGNAL_QUALITY, - PROP_NETWORK_TYPE, -); +struct _NMWimaxNsp { + NMObject parent; + NMWimaxNspPrivate _priv; +}; + +struct _NMWimaxNspClass { + NMObjectClass parent; +}; + +G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT) + +#define NM_WIMAX_NSP_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMWimaxNsp, NM_IS_WIMAX_NSP, NMObject) + +/*****************************************************************************/ /** * nm_wimax_nsp_get_name: @@ -217,8 +230,6 @@ nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class) GObjectClass *object_class = G_OBJECT_CLASS (nsp_class); NMObjectClass *nm_object_class = NM_OBJECT_CLASS (nsp_class); - g_type_class_add_private (nsp_class, sizeof (NMWimaxNspPrivate)); - object_class->get_property = get_property; object_class->finalize = finalize; diff --git a/libnm/nm-wimax-nsp.h b/libnm/nm-wimax-nsp.h index 50a40a16b..7c1bfaf5c 100644 --- a/libnm/nm-wimax-nsp.h +++ b/libnm/nm-wimax-nsp.h @@ -29,16 +29,7 @@ G_BEGIN_DECLS /** * NMWimaxNsp: */ -struct _NMWimaxNsp { - NMObject parent; -}; - -typedef struct { - NMObjectClass parent; - - /*< private >*/ - gpointer padding[4]; -} NMWimaxNspClass; +typedef struct _NMWimaxNspClass NMWimaxNspClass; GType nm_wimax_nsp_get_type (void);