From 93c848ca036d96396bbc5ecd9486b682f08b4fef Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 22 Jan 2019 12:51:10 +0100 Subject: [PATCH] clients: don't tread secret agent as NMSecretAgentOld Most of the times we actually need a NMSecretAgentSimple typed pointer. This way, need need to cast less. But even if we would need to cast more, it's better to have pointers point to the actual type, not merely to avoid shortcomings of C. --- clients/cli/agent.c | 2 +- clients/cli/common.c | 2 +- clients/cli/connections.c | 5 ++--- clients/cli/devices.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/nmcli.h | 4 ++-- clients/common/nm-secret-agent-simple.c | 2 +- clients/common/nm-secret-agent-simple.h | 2 +- clients/tui/nmtui-connect.c | 8 ++++---- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/clients/cli/agent.c b/clients/cli/agent.c index 05cc5dca5..55a5ba6b8 100644 --- a/clients/cli/agent.c +++ b/clients/cli/agent.c @@ -149,7 +149,7 @@ do_agent_secret (NmCli *nmc, int argc, char **argv) /* We keep running */ nmc->should_wait++; - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), NULL); + nm_secret_agent_simple_enable (nmc->secret_agent, NULL); g_signal_connect (nmc->secret_agent, NM_SECRET_AGENT_SIMPLE_REQUEST_SECRETS, G_CALLBACK (secrets_requested), diff --git a/clients/cli/common.c b/clients/cli/common.c index 85b5005e4..56e5062f5 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -778,7 +778,7 @@ nmc_secrets_requested (NMSecretAgentSimple *agent, /* Unregister our secret agent on failure, so that another agent * may be tried */ if (nmc->secret_agent) { - nm_secret_agent_old_unregister (nmc->secret_agent, NULL, NULL); + nm_secret_agent_old_unregister (NM_SECRET_AGENT_OLD (nmc->secret_agent), NULL, NULL); g_clear_object (&nmc->secret_agent); } } diff --git a/clients/cli/connections.c b/clients/cli/connections.c index e2c23cb8c..b8fac54e5 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2474,7 +2474,7 @@ check_activated (ActivateConnectionInfo *info) if (nmc->secret_agent) { NMRemoteConnection *connection = nm_active_connection_get_connection (info->active); - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), + nm_secret_agent_simple_enable (nmc->secret_agent, nm_connection_get_path (NM_CONNECTION (connection))); } break; @@ -2776,7 +2776,6 @@ nmc_activate_connection (NmCli *nmc, g_hash_table_destroy (nmc->pwds_hash); nmc->pwds_hash = pwds_hash; - /* Create secret agent */ nmc->secret_agent = nm_secret_agent_simple_new ("nmcli-connect"); if (nmc->secret_agent) { g_signal_connect (nmc->secret_agent, @@ -6728,7 +6727,7 @@ progress_activation_editor_cb (gpointer user_data) NMRemoteConnection *connection; connection = nm_active_connection_get_connection (ac); - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (info->nmc->secret_agent), + nm_secret_agent_simple_enable (info->nmc->secret_agent, nm_object_get_path (NM_OBJECT (connection))); } diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 44573fb64..d17cf7998 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1961,7 +1961,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data) if (nmc->secret_agent) { NMRemoteConnection *connection = nm_active_connection_get_connection (active); - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (nmc->secret_agent), + nm_secret_agent_simple_enable (nmc->secret_agent, nm_connection_get_path (NM_CONNECTION (connection))); } diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index a554a382a..6d38a5885 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -1017,7 +1017,7 @@ nmc_cleanup (NmCli *nmc) g_string_free (g_steal_pointer (&nmc->return_text), TRUE); if (nmc->secret_agent) { - nm_secret_agent_old_unregister (nmc->secret_agent, NULL, NULL); + nm_secret_agent_old_unregister (NM_SECRET_AGENT_OLD (nmc->secret_agent), NULL, NULL); g_clear_object (&nmc->secret_agent); } diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 0ccf1653d..cd50333a9 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -20,7 +20,7 @@ #ifndef NMC_NMCLI_H #define NMC_NMCLI_H -#include "nm-secret-agent-old.h" +#include "nm-secret-agent-simple.h" #include "nm-meta-setting-desc.h" struct _NMPolkitListener; @@ -129,7 +129,7 @@ typedef struct _NmCli { int timeout; /* Operation timeout */ - NMSecretAgentOld *secret_agent; /* Secret agent */ + NMSecretAgentSimple *secret_agent; /* Secret agent */ GHashTable *pwds_hash; /* Hash table with passwords in passwd-file */ struct _NMPolkitListener *pk_listener; /* polkit agent listener */ diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c index b4530af61..034f6052a 100644 --- a/clients/common/nm-secret-agent-simple.c +++ b/clients/common/nm-secret-agent-simple.c @@ -1116,7 +1116,7 @@ nm_secret_agent_simple_init (NMSecretAgentSimple *agent) * Returns: a new #NMSecretAgentSimple if the agent creation is successful * or %NULL in case of a failure. */ -NMSecretAgentOld * +NMSecretAgentSimple * nm_secret_agent_simple_new (const char *name) { return g_initable_new (NM_TYPE_SECRET_AGENT_SIMPLE, NULL, NULL, diff --git a/clients/common/nm-secret-agent-simple.h b/clients/common/nm-secret-agent-simple.h index 89e4cf3cc..8cae17a8c 100644 --- a/clients/common/nm-secret-agent-simple.h +++ b/clients/common/nm-secret-agent-simple.h @@ -56,7 +56,7 @@ typedef struct _NMSecretAgentSimpleClass NMSecretAgentSimpleClass; GType nm_secret_agent_simple_get_type (void); -NMSecretAgentOld *nm_secret_agent_simple_new (const char *name); +NMSecretAgentSimple *nm_secret_agent_simple_new (const char *name); void nm_secret_agent_simple_response (NMSecretAgentSimple *self, const char *request_id, diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c index 6f29e13e9..e43c22e4f 100644 --- a/clients/tui/nmtui-connect.c +++ b/clients/tui/nmtui-connect.c @@ -240,7 +240,7 @@ activate_connection (NMConnection *connection, NMObject *specific_object) { NmtNewtForm *form; - gs_unref_object NMSecretAgentOld *agent = NULL; + gs_unref_object NMSecretAgentSimple *agent = NULL; NmtNewtWidget *label; NmtSyncOp op; const char *specific_object_path; @@ -257,7 +257,7 @@ activate_connection (NMConnection *connection, agent = nm_secret_agent_simple_new ("nmtui"); if (agent) { if (connection) { - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent), + nm_secret_agent_simple_enable (agent, nm_object_get_path (NM_OBJECT (connection))); } g_signal_connect (agent, @@ -303,7 +303,7 @@ activate_connection (NMConnection *connection, if (agent && !connection) { connection = NM_CONNECTION (nm_active_connection_get_connection (ac)); if (connection) { - nm_secret_agent_simple_enable (NM_SECRET_AGENT_SIMPLE (agent), + nm_secret_agent_simple_enable (agent, nm_object_get_path (NM_OBJECT (connection))); } } @@ -341,7 +341,7 @@ activate_connection (NMConnection *connection, g_object_unref (form); if (agent) - nm_secret_agent_old_unregister (agent, NULL, NULL); + nm_secret_agent_old_unregister (NM_SECRET_AGENT_OLD (agent), NULL, NULL); } static void