mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 12:50:09 +01:00
libnm: hide NMClient struct from public headers and use direct private field
Having the NMClient/NMClientClass structs in the public header allows the user to subclass these types. Subclassing this type was never intended, nor is it supported, nor does it seem useful. Subclassing only makes sense if the type has suitable hooks to extend the type in a meaningful way. NMClient hasn't, and everybody trying to derive from this class would better delegate the actions. Also, having these structs in the public header prevents us from embedding the private data in the object structure itself. It has thus an runtime overhead and is less convenient for debugging (it's hard to find the private data pointer in gdb). Most importantly, there is no easy way to find the offset of the private data fields, short of calling NM_CLIENT_GET_PRIVATE() -- which currently is a macro. Later we want to generically lookup the offset of the private data, we would need NM_CLIENT_GET_PRIVATE() as a function. Instead, by having an internally, statically known offset, we can use that offset instead. Also drop all signal hooks. They are also not useful. This is an ABI and API change, but of something that we never wanted to be part of the ABI/API, and which hopefull nobody is using.
This commit is contained in:
parent
ba64c162dc
commit
35b024acaa
2 changed files with 17 additions and 36 deletions
|
|
@ -149,12 +149,21 @@ typedef struct {
|
|||
bool udev_inited:1;
|
||||
} NMClientPrivate;
|
||||
|
||||
struct _NMClient {
|
||||
GObject parent;
|
||||
NMClientPrivate _priv;
|
||||
};
|
||||
|
||||
struct _NMClientClass {
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMClient, nm_client, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, nm_client_initable_iface_init);
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, nm_client_async_initable_iface_init);
|
||||
)
|
||||
|
||||
#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
|
||||
#define NM_CLIENT_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMClient, NM_IS_CLIENT)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -3863,8 +3872,6 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (client_class);
|
||||
|
||||
g_type_class_add_private (client_class, sizeof (NMClientPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->constructed = constructed;
|
||||
|
|
@ -4246,8 +4253,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_DEVICE_ADDED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, device_added),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
|
||||
|
|
@ -4263,8 +4269,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_DEVICE_REMOVED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, device_removed),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
|
||||
|
|
@ -4280,8 +4285,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_ANY_DEVICE_ADDED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, any_device_added),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
|
||||
|
|
@ -4297,8 +4301,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_ANY_DEVICE_REMOVED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, any_device_removed),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
|
||||
|
|
@ -4327,8 +4330,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_CONNECTION_ADDED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, connection_added),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
NM_TYPE_REMOTE_CONNECTION);
|
||||
|
||||
|
|
@ -4343,8 +4345,7 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
g_signal_new (NM_CLIENT_CONNECTION_REMOVED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (NMClientClass, connection_removed),
|
||||
NULL, NULL, NULL,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
NM_TYPE_REMOTE_CONNECTION);
|
||||
|
||||
|
|
|
|||
|
|
@ -199,27 +199,7 @@ gboolean nm_dns_entry_get_vpn (NMDnsEntry *entry);
|
|||
/**
|
||||
* NMClient:
|
||||
*/
|
||||
struct _NMClient {
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Signals */
|
||||
void (*device_added) (NMClient *client, NMDevice *device);
|
||||
void (*device_removed) (NMClient *client, NMDevice *device);
|
||||
void (*any_device_added) (NMClient *client, NMDevice *device);
|
||||
void (*any_device_removed) (NMClient *client, NMDevice *device);
|
||||
void (*permission_changed) (NMClient *client,
|
||||
NMClientPermission permission,
|
||||
NMClientPermissionResult result);
|
||||
void (*connection_added) (NMClient *client, NMRemoteConnection *connection);
|
||||
void (*connection_removed) (NMClient *client, NMRemoteConnection *connection);
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[6];
|
||||
} NMClientClass;
|
||||
typedef struct _NMClientClass NMClientClass;
|
||||
|
||||
GType nm_client_get_type (void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue