static void test_add_connection (void) { NMConnection *connection; time_t start, now; gboolean done = FALSE; connection = nmtst_create_minimal_connection (TEST_CON_ID, NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nm_client_add_connection_async (client, connection, TRUE, NULL, add_cb, &done); start = time (NULL); do { now = time (NULL); g_main_context_iteration (NULL, FALSE); } while ((done == FALSE) && (now - start < 5)); g_assert (done == TRUE); g_assert (remote != NULL); /* Make sure the connection is the same as what we added */ g_assert (nm_connection_compare (connection, NM_CONNECTION (remote), NM_SETTING_COMPARE_FLAG_EXACT) == TRUE); g_object_unref (connection); }
static void add_connection (NMClient *client, GMainLoop *loop, const char *con_name) { NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIP4Config *s_ip4; char *uuid; /* Create a new connection object */ connection = nm_simple_connection_new (); /* Build up the 'connection' Setting */ s_con = (NMSettingConnection *) nm_setting_connection_new (); uuid = nm_utils_uuid_generate (); g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_ID, con_name, NM_SETTING_CONNECTION_TYPE, "802-3-ethernet", NULL); g_free (uuid); nm_connection_add_setting (connection, NM_SETTING (s_con)); /* Build up the 'wired' Setting */ s_wired = (NMSettingWired *) nm_setting_wired_new (); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* Build up the 'ipv4' Setting */ s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new (); g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); /* Ask the settings service to add the new connection; we'll quit the * mainloop and exit when the callback is called. */ nm_client_add_connection_async (client, connection, TRUE, NULL, added_cb, loop); g_object_unref (connection); }
static void ok_button_clicked_save_connection (NMConnectionEditor *self) { /* Copy the modified connection to the original connection */ nm_connection_replace_settings_from_connection (self->orig_connection, self->connection); nm_connection_editor_set_busy (self, TRUE); /* Save new CA cert ignore values to GSettings */ eap_method_ca_cert_ignore_save (self->connection); if (self->is_new_connection) { nm_client_add_connection_async (self->client, self->orig_connection, TRUE, NULL, added_connection_cb, self); } else { nm_remote_connection_commit_changes_async (NM_REMOTE_CONNECTION (self->orig_connection), TRUE, NULL, updated_connection_cb, self); } }