Esempio n. 1
0
static void
save_connection_and_exit (NmtNewtButton *button,
                          gpointer       user_data)
{
	NmtEditor *editor = user_data;
	NmtEditorPrivate *priv = NMT_EDITOR_GET_PRIVATE (editor);
	NmtSyncOp op;
	GError *error = NULL;

	if (!nm_connection_replace_settings_from_connection (priv->orig_connection,
	                                                     priv->edit_connection,
	                                                     &error)) {
		nmt_newt_message_dialog (_("Error saving connection: %s"), error->message);
		g_error_free (error);
		return;
	}

	nmt_sync_op_init (&op);
	if (NM_IS_REMOTE_CONNECTION (priv->orig_connection)) {
		nm_remote_connection_commit_changes (NM_REMOTE_CONNECTION (priv->orig_connection),
		                                     connection_updated, &op);
		if (!nmt_sync_op_wait_boolean (&op, &error)) {
			nmt_newt_message_dialog (_("Unable to save connection: %s"),
			                         error->message);
			g_error_free (error);
			return;
		}

		/* Clear secrets so they don't lay around in memory; they'll get
		 * requested again anyway next time the connection is edited.
		 */
		nm_connection_clear_secrets (priv->orig_connection);
	} else {
		nm_remote_settings_add_connection (nm_settings, priv->orig_connection,
		                                   connection_added, &op);
		if (!nmt_sync_op_wait_boolean (&op, &error)) {
			nmt_newt_message_dialog (_("Unable to add new connection: %s"),
			                         error->message);
			g_error_free (error);
			return;
		}
	}

	nmt_newt_form_quit (NMT_NEWT_FORM (editor));
}
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);
	}
}