diff options
| author | Michael Biebl <biebl@debian.org> | 2018-03-13 01:29:54 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-03-13 01:29:54 +0100 |
| commit | 7e9ff09fcb2366b383b7ebbec80d2f6fff117290 (patch) | |
| tree | e48e88b177182607488bcfd2d2645dbc77276866 /clients/cli/connections.c | |
| parent | 50f6b47074e01dffb8dc536c0a20961dcf28ae9b (diff) | |
New upstream version 1.10.6 upstream/1.10.6
Diffstat (limited to 'clients/cli/connections.c')
| -rw-r--r-- | clients/cli/connections.c | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 83b1f28a..e0f55c53 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -616,26 +616,54 @@ get_ac_for_connection (const GPtrArray *active_cons, NMConnection *connection) return ac; } +typedef struct { + GMainLoop *loop; + NMConnection *local; + const char *setting_name; +} GetSecretsData; + +static void +got_secrets (GObject *source_object, GAsyncResult *res, gpointer user_data) +{ + NMRemoteConnection *remote = NM_REMOTE_CONNECTION (source_object); + GetSecretsData *data = user_data; + GVariant *secrets; + GError *error = NULL; + + secrets = nm_remote_connection_get_secrets_finish (remote, res, NULL); + if (secrets) { + if (!nm_connection_update_secrets (data->local, NULL, secrets, &error) && error) { + g_printerr (_("Error updating secrets for %s: %s\n"), + data->setting_name, error->message); + g_clear_error (&error); + } + g_variant_unref (secrets); + } + + g_main_loop_quit (data->loop); +} + /* Put secrets into local connection. */ static void update_secrets_in_connection (NMRemoteConnection *remote, NMConnection *local) { - GVariant *secrets; + GetSecretsData data = { 0, }; int i; - GError *error = NULL; + + data.local = local; + data.loop = g_main_loop_new (NULL, FALSE); for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { - secrets = nm_remote_connection_get_secrets (remote, nm_meta_setting_infos[i].setting_name, NULL, NULL); - if (secrets) { - if (!nm_connection_update_secrets (local, NULL, secrets, &error) && error) { - g_printerr (_("Error updating secrets for %s: %s\n"), - nm_meta_setting_infos[i].setting_name, - error->message); - g_clear_error (&error); - } - g_variant_unref (secrets); - } + data.setting_name = nm_meta_setting_infos[i].setting_name; + nm_remote_connection_get_secrets_async (remote, + nm_meta_setting_infos[i].setting_name, + NULL, + got_secrets, + &data); + g_main_loop_run (data.loop); } + + g_main_loop_unref (data.loop); } static gboolean |