From 86ba66ee9be6596a522dd497aab57e7c608b83e4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 23 Dec 2019 09:23:19 +0100 Subject: [PATCH] agent-manager: expose NMSecretAgent struct in header for tight coupling with NMAgentManager NMAgentManager and NMSecretAgent work closely together. In particular, the NMAgentManager creates and tracks the NMSecretAgents and controls it. Move NMSecretAgent struct to the header, so that some fields may become accessible to NMAgentManager. In particular, we will track secret agents with a CList, and this CList element can be embedded in the NMSecretAgent structure. --- src/settings/nm-secret-agent.c | 23 ++++++++++++----------- src/settings/nm-secret-agent.h | 7 +++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c index 82a8c904a5..480e774241 100644 --- a/src/settings/nm-secret-agent.c +++ b/src/settings/nm-secret-agent.c @@ -34,33 +34,28 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -typedef struct { +typedef struct _NMSecretAgentPrivate { CList permissions; + CList requests; + GDBusConnection *dbus_connection; char *description; NMAuthSubject *subject; char *identifier; char *owner_username; char *dbus_owner; - GDBusConnection *dbus_connection; GCancellable *name_owner_cancellable; - CList requests; - NMSecretAgentCapabilities capabilities; guint name_owner_changed_id; + NMSecretAgentCapabilities capabilities; bool shutdown_wait_obj_registered:1; } NMSecretAgentPrivate; -struct _NMSecretAgent { - GObject parent; - NMSecretAgentPrivate _priv; -}; - struct _NMSecretAgentClass { GObjectClass parent; }; G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT) -#define NM_SECRET_AGENT_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSecretAgent, NM_IS_SECRET_AGENT) +#define NM_SECRET_AGENT_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMSecretAgent, NM_IS_SECRET_AGENT) /*****************************************************************************/ @@ -765,7 +760,11 @@ nm_secret_agent_new (GDBusMethodInvocation *context, static void nm_secret_agent_init (NMSecretAgent *self) { - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + NMSecretAgentPrivate *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NM_TYPE_SECRET_AGENT, NMSecretAgentPrivate); + + self->_priv = priv; c_list_init (&priv->permissions); c_list_init (&priv->requests); @@ -814,6 +813,8 @@ nm_secret_agent_class_init (NMSecretAgentClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); + g_type_class_add_private (object_class, sizeof (NMSecretAgentPrivate)); + object_class->dispose = dispose; object_class->finalize = finalize; diff --git a/src/settings/nm-secret-agent.h b/src/settings/nm-secret-agent.h index ea86e432ad..d6e2feba66 100644 --- a/src/settings/nm-secret-agent.h +++ b/src/settings/nm-secret-agent.h @@ -20,6 +20,13 @@ typedef struct _NMSecretAgentClass NMSecretAgentClass; typedef struct _NMSecretAgentCallId NMSecretAgentCallId; +struct _NMSecretAgentPrivate; + +struct _NMSecretAgent { + GObject parent; + struct _NMSecretAgentPrivate *_priv; +}; + GType nm_secret_agent_get_type (void); NMSecretAgent *nm_secret_agent_new (GDBusMethodInvocation *context,