mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 17:00:40 +01:00
tui: cleanup secrets_requested() function to use cleanup attribute
No explicit unref/free. Resources should be owned by somebody, like an auto variable with a cleanup attribute.
This commit is contained in:
parent
fe5dfe97f9
commit
62d742625d
1 changed files with 5 additions and 11 deletions
|
|
@ -34,7 +34,6 @@ secrets_requested(NMSecretAgentSimple *agent,
|
|||
GPtrArray *secrets,
|
||||
gpointer user_data)
|
||||
{
|
||||
NmtNewtForm *form;
|
||||
NMConnection *connection = NM_CONNECTION(user_data);
|
||||
gboolean success = FALSE;
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ secrets_requested(NMSecretAgentSimple *agent,
|
|||
|
||||
if (nm_streq0(nm_setting_vpn_get_service_type(s_vpn),
|
||||
NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT)) {
|
||||
GError *error = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
nmt_newt_message_dialog(_("openconnect will be run to authenticate.\nIt will return to "
|
||||
"nmtui when completed."));
|
||||
|
|
@ -55,26 +54,21 @@ secrets_requested(NMSecretAgentSimple *agent,
|
|||
|
||||
newtResume();
|
||||
|
||||
if (!success) {
|
||||
if (!success)
|
||||
nmt_newt_message_dialog(_("Error: openconnect failed: %s"), error->message);
|
||||
g_clear_error(&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
gs_unref_object NmtNewtForm *form = NULL;
|
||||
|
||||
form = nmt_password_dialog_new(request_id, title, msg, secrets);
|
||||
nmt_newt_form_run_sync(form);
|
||||
|
||||
success = nmt_password_dialog_succeeded(NMT_PASSWORD_DIALOG(form));
|
||||
|
||||
g_object_unref(form);
|
||||
}
|
||||
|
||||
if (success)
|
||||
nm_secret_agent_simple_response(agent, request_id, secrets);
|
||||
else
|
||||
nm_secret_agent_simple_response(agent, request_id, NULL);
|
||||
nm_secret_agent_simple_response(agent, request_id, success ? secrets : NULL);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue