예제 #1
0
static void
on_import_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
    g_autoptr(GTask) task = G_TASK (user_data);
    source_import_closure *closure = g_task_get_task_data (task);
    g_autoptr(GError) error = NULL;
    g_autofree gchar *errmsg = NULL;

    g_assert (closure->requests > 0);
    seahorse_progress_end (closure->cancellable, GUINT_TO_POINTER (closure->requests));
    closure->requests--;

    if (hkp_message_propagate_error (closure->source, message, &error)) {
        g_task_return_error (task, g_steal_pointer (&error));
        return;
    }

    if ((errmsg = get_send_result (message->response_body->data)) != NULL) {
        g_task_return_new_error (task, HKP_ERROR_DOMAIN, message->status_code,
                                 "%s", errmsg);
        return;
    }

    /* A successful status from the server is all we want in this case */
    if (closure->requests == 0) {
        /* We don't know which keys got imported, so just return NULL */
        g_task_return_pointer (task, NULL, NULL);
    }
}
예제 #2
0
static void
on_search_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
    g_autoptr(GTask) task = G_TASK (user_data);
    source_search_closure *closure = g_task_get_task_data (task);
    g_autoptr(GError) error = NULL;
    GList *keys, *l;

    seahorse_progress_end (closure->cancellable, message);

    if (hkp_message_propagate_error (closure->source, message, &error)) {
        g_task_return_error (task, g_steal_pointer (&error));
        return;
    }

    keys = parse_hkp_index (message->response_body->data);
    for (l = keys; l; l = g_list_next (l)) {
        g_object_set (l->data, "place", closure->source, NULL);
        gcr_simple_collection_add (closure->results, l->data);
    }
    g_list_free_full (keys, g_object_unref);

    g_task_return_boolean (task, TRUE);
}
예제 #3
0
static void
on_import_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
	GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
	source_import_closure *closure = g_simple_async_result_get_op_res_gpointer (res);
	GError *error = NULL;
	gchar *errmsg;

	g_assert (closure->requests > 0);
	seahorse_progress_end (closure->cancellable, GUINT_TO_POINTER (closure->requests));
	closure->requests--;

	if (hkp_message_propagate_error (closure->source, message, &error)) {
		g_simple_async_result_take_error (res, error);
		g_simple_async_result_complete_in_idle (res);

	} else if ((errmsg = get_send_result (message->response_body->data)) != NULL) {
		g_set_error (&error, HKP_ERROR_DOMAIN, message->status_code, "%s", errmsg);
		g_simple_async_result_take_error (res, error);
		g_simple_async_result_complete_in_idle (res);
		g_free (errmsg);

	/* A successful status from the server is all we want in this case */
	} else {
		if (closure->requests == 0)
			g_simple_async_result_complete_in_idle (res);
	}

	g_object_unref (res);
}
예제 #4
0
static void
on_search_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
	GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
	source_search_closure *closure = g_simple_async_result_get_op_res_gpointer (res);
	GError *error = NULL;
	GList *keys, *l;

	seahorse_progress_end (closure->cancellable, message);

	if (hkp_message_propagate_error (closure->source, message, &error)) {
		g_simple_async_result_take_error (res, error);

	} else {
		keys = parse_hkp_index (message->response_body->data);
		for (l = keys; l; l = g_list_next (l)) {
			g_object_set (l->data, "place", closure->source, NULL);
			gcr_simple_collection_add (closure->results, l->data);
		}
		g_list_free_full (keys, g_object_unref);
	}

	g_simple_async_result_complete_in_idle (res);
	g_object_unref (res);
}
예제 #5
0
static void
on_export_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
    g_autoptr(GTask) task = G_TASK (user_data);
    ExportClosure *closure = g_task_get_task_data (task);
    g_autoptr(GError) error = NULL;
    const gchar *start, *end, *text;
    guint len;

    seahorse_progress_end (closure->cancellable, message);

    if (hkp_message_propagate_error (closure->source, message, &error)) {
        g_task_return_error (task, g_steal_pointer (&error));
        return;
    }

    end = text = message->response_body->data;
    len = message->response_body->length;

    for (;;) {
        len -= end - text;
        text = end;

        if (!detect_key (text, len, &start, &end))
            break;

        g_string_append_len (closure->data, start, end - start);
        g_string_append_c (closure->data, '\n');
    }

    g_assert (closure->requests > 0);
    closure->requests--;

    if (closure->requests == 0) {
        closure->data_len = closure->data->len;
        g_task_return_pointer (task,
                               g_string_free (g_steal_pointer (&closure->data), FALSE),
                               g_free);
    }
}
예제 #6
0
static void
on_export_message_complete (SoupSession *session,
                            SoupMessage *message,
                            gpointer user_data)
{
	GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
	ExportClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
	GError *error = NULL;
	const gchar *start;
	const gchar *end;
	const gchar *text;
	guint len;

	seahorse_progress_end (closure->cancellable, message);

	if (hkp_message_propagate_error (closure->source, message, &error)) {
		g_simple_async_result_take_error (res, error);
	} else {
		end = text = message->response_body->data;
		len = message->response_body->length;

		for (;;) {

			len -= end - text;
			text = end;

			if (!detect_key (text, len, &start, &end))
				break;

			g_string_append_len (closure->data, start, end - start);
			g_string_append_c (closure->data, '\n');
		}
	}

	g_assert (closure->requests > 0);
	closure->requests--;

	if (closure->requests == 0)
		g_simple_async_result_complete_in_idle (res);

	g_object_unref (res);
}