summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-01-24 16:18:56 +0100
committerThomas Haller <thaller@redhat.com>2019-02-05 08:34:23 +0100
commitbd590579dabd1940049822026357f45b4ab4d4af (patch)
treefb11bde83bf58be4d34ba71f3627a7b4e3ed6899
parent787f5f7a4645e4dd5331c56b44ec58e66c2a1ba1 (diff)
downloadNetworkManager-bd590579dabd1940049822026357f45b4ab4d4af.tar.gz
core: pass hints as strv to nm_act_request_get_secrets()
Extend nm_act_request_get_secrets() API to allow for the underlying flexibility (of the API that it calls) to accept a strv list of hints.
-rw-r--r--src/devices/wifi/nm-device-iwd.c4
-rw-r--r--src/devices/wwan/nm-modem.c10
-rw-r--r--src/nm-act-request.c3
-rw-r--r--src/nm-act-request.h2
-rw-r--r--src/ppp/nm-ppp-manager.c10
5 files changed, 15 insertions, 14 deletions
diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c
index 71b8d15153..88422eb150 100644
--- a/src/devices/wifi/nm-device-iwd.c
+++ b/src/devices/wifi/nm-device-iwd.c
@@ -1380,7 +1380,7 @@ wifi_secrets_get_one (NMDeviceIwd *self,
TRUE,
setting_name,
flags,
- setting_key,
+ NM_MAKE_STRV (setting_key),
wifi_secrets_cb,
nm_utils_user_data_pack (self, invocation));
}
@@ -1894,7 +1894,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
TRUE,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION,
- "psk",
+ NM_MAKE_STRV ("psk"),
act_psk_cb,
self);
nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index 11ada549da..1ad12b9d8e 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -948,7 +948,7 @@ nm_modem_get_secrets (NMModem *self,
FALSE,
setting_name,
flags,
- hint,
+ NM_MAKE_STRV (hint),
modem_secrets_cb,
self);
g_return_if_fail (priv->secrets_id);
@@ -986,8 +986,7 @@ nm_modem_act_stage1_prepare (NMModem *self,
setting_name = nm_connection_need_secrets (connection, &hints);
if (!setting_name) {
- /* Ready to connect */
- g_assert (!hints);
+ nm_assert (!hints);
return NM_MODEM_GET_CLASS (self)->act_stage1_prepare (self, connection, out_failure_reason);
}
@@ -995,11 +994,14 @@ nm_modem_act_stage1_prepare (NMModem *self,
if (priv->secrets_tries++)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
+ if (hints)
+ g_ptr_array_add (hints, NULL);
+
priv->secrets_id = nm_act_request_get_secrets (req,
FALSE,
setting_name,
flags,
- hints ? g_ptr_array_index (hints, 0) : NULL,
+ hints ? (const char *const*) hints->pdata : NULL,
modem_secrets_cb,
self);
g_return_val_if_fail (priv->secrets_id, NM_ACT_STAGE_RETURN_FAILURE);
diff --git a/src/nm-act-request.c b/src/nm-act-request.c
index cd81696490..584eceab12 100644
--- a/src/nm-act-request.c
+++ b/src/nm-act-request.c
@@ -166,7 +166,7 @@ nm_act_request_get_secrets (NMActRequest *self,
gboolean ref_self,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
- const char *hint,
+ const char *const*hints,
NMActRequestSecretsFunc callback,
gpointer callback_data)
{
@@ -175,7 +175,6 @@ nm_act_request_get_secrets (NMActRequest *self,
NMSettingsConnectionCallId *call_id_s;
NMSettingsConnection *settings_connection;
NMConnection *applied_connection;
- const char *hints[2] = { hint, NULL };
g_return_val_if_fail (NM_IS_ACT_REQUEST (self), NULL);
diff --git a/src/nm-act-request.h b/src/nm-act-request.h
index af2b749055..e16e1ecfdc 100644
--- a/src/nm-act-request.h
+++ b/src/nm-act-request.h
@@ -69,7 +69,7 @@ NMActRequestGetSecretsCallId *nm_act_request_get_secrets (NMActRequest *req,
gboolean take_ref,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
- const char *hint,
+ const char *const*hints,
NMActRequestSecretsFunc callback,
gpointer callback_data);
diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c
index 122901fcd8..548f46606f 100644
--- a/src/ppp/nm-ppp-manager.c
+++ b/src/ppp/nm-ppp-manager.c
@@ -363,7 +363,7 @@ impl_ppp_manager_need_secrets (NMDBusObject *obj,
const char *username = NULL;
const char *password = NULL;
guint32 tries;
- GPtrArray *hints = NULL;
+ gs_unref_ptrarray GPtrArray *hints = NULL;
GError *error = NULL;
NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
@@ -393,18 +393,18 @@ impl_ppp_manager_need_secrets (NMDBusObject *obj,
if (tries > 1)
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
+ if (hints)
+ g_ptr_array_add (hints, NULL);
+
priv->secrets_id = nm_act_request_get_secrets (priv->act_req,
FALSE,
priv->secrets_setting_name,
flags,
- hints ? g_ptr_array_index (hints, 0) : NULL,
+ hints ? (const char *const*) hints->pdata : NULL,
ppp_secrets_cb,
self);
g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries));
priv->pending_secrets_context = invocation;
-
- if (hints)
- g_ptr_array_free (hints, TRUE);
}
static void