[libgovirt] Port to rest-1.0 & soup-3.0
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] Port to rest-1.0 & soup-3.0
- Date: Thu, 7 Jul 2022 13:31:00 +0000 (UTC)
commit 67f5d178be8e63b222fbf30dc7a6cdadb3a2ee1a
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Jul 6 12:05:55 2022 +0400
Port to rest-1.0 & soup-3.0
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
govirt/ovirt-proxy.c | 25 +++++++++++--------------
meson.build | 6 +++---
tests/mock-httpd.c | 38 ++++++++++++++++++++------------------
3 files changed, 34 insertions(+), 35 deletions(-)
---
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index 1cf1ebf..cafb5fa 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -252,26 +252,26 @@ static void rest_call_async_set_error(RestProxyCall *call, GTask *task, const GE
}
static void
-call_async_cb(RestProxyCall *call, const GError *error,
- G_GNUC_UNUSED GObject *weak_object,
+call_async_cb(GObject *source_obj,
+ GAsyncResult *result,
gpointer user_data)
{
+ RestProxyCall *call = REST_PROXY_CALL(source_obj);
+ GError *error = NULL;
OvirtProxyCallAsyncData *data = user_data;
GTask *task = data->task;
gboolean callback_result = TRUE;
+ rest_proxy_call_invoke_finish(call, result, &error);
if (error != NULL) {
- rest_call_async_set_error(call, task, error);
goto exit;
}
if (data->call_async_cb != NULL) {
- GError *call_error = NULL;
callback_result = data->call_async_cb(data->proxy, call,
data->call_user_data,
- &call_error);
- if (call_error != NULL) {
- rest_call_async_set_error(call, task, call_error);
+ &error);
+ if (error != NULL) {
goto exit;
}
}
@@ -279,6 +279,9 @@ call_async_cb(RestProxyCall *call, const GError *error,
g_task_return_boolean(task, callback_result);
exit:
+ if (error != NULL) {
+ rest_call_async_set_error(call, task, error);
+ }
ovirt_proxy_call_async_data_free(data);
}
@@ -291,7 +294,6 @@ void ovirt_rest_call_async(OvirtRestCall *call,
GDestroyNotify destroy_func)
{
OvirtProxy *proxy;
- GError *error = NULL;
OvirtProxyCallAsyncData *data;
g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
@@ -311,12 +313,7 @@ void ovirt_rest_call_async(OvirtRestCall *call,
call, NULL);
}
- if (!rest_proxy_call_async(REST_PROXY_CALL(call), call_async_cb, NULL,
- data, &error)) {
- g_warning("Error while getting collection XML");
- g_task_return_error(task, error);
- ovirt_proxy_call_async_data_free(data);
- }
+ rest_proxy_call_invoke_async(REST_PROXY_CALL (call), cancellable, call_async_cb, data);
}
diff --git a/meson.build b/meson.build
index 955c99d..0f2b797 100644
--- a/meson.build
+++ b/meson.build
@@ -35,13 +35,13 @@ govirt_so_version = '@0@.@1@.@2@'.format(govirt_current - govirt_age,
#
# check for dependencies
#
-glib_version_info = '>= 2.38'
-glib_encoded_version = 'GLIB_VERSION_2_38'
+glib_version_info = '>= 2.66'
+glib_encoded_version = 'GLIB_VERSION_2_66'
gobject_dep = dependency('gobject-2.0', version : glib_version_info)
gio_dep = dependency('gio-2.0', version : glib_version_info)
gthread_dep = dependency('gthread-2.0', version : glib_version_info)
-rest_dep = dependency('rest-0.7', version : '>= 0.7.92')
+rest_dep = dependency('rest-1.0', version : '>= 0.9')
govirt_deps += [
gobject_dep,
diff --git a/tests/mock-httpd.c b/tests/mock-httpd.c
index 5b4632e..f84786f 100644
--- a/tests/mock-httpd.c
+++ b/tests/mock-httpd.c
@@ -67,32 +67,34 @@ govirt_mock_htttpd_request_free (GovirtMockHttpdRequest *request)
static void
-server_callback (SoupServer *server, SoupMessage *msg,
+server_callback (SoupServer *server, SoupServerMessage *msg,
const char *path, GHashTable *query,
- SoupClientContext *context, gpointer data)
+ gpointer data)
{
SoupMessageHeadersIter iter;
const char *name, *value;
const char *content;
GovirtMockHttpd *mock_httpd = data;
- g_debug ("%s %s HTTP/1.%d\n", msg->method, path,
- soup_message_get_http_version (msg));
- soup_message_headers_iter_init (&iter, msg->request_headers);
+ g_debug ("%s %s HTTP/1.%d\n", soup_server_message_get_method(msg), path,
+ soup_server_message_get_http_version (msg));
+ soup_message_headers_iter_init (&iter, soup_server_message_get_request_headers(msg));
while (soup_message_headers_iter_next (&iter, &name, &value))
g_debug ("%s: %s\n", name, value);
- if (msg->request_body->length)
- g_debug ("%s\n", msg->request_body->data);
+ if (soup_server_message_get_request_body(msg)->length)
+ g_debug ("%s\n", soup_server_message_get_request_body(msg)->data);
- content = govirt_mock_httpd_find_request(mock_httpd, msg->method, path);
+ content = govirt_mock_httpd_find_request(mock_httpd, soup_server_message_get_method(msg), path);
if (content == NULL) {
- soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND);
+ soup_server_message_set_status (msg, SOUP_STATUS_NOT_FOUND, NULL);
} else {
- soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC,
+ soup_message_body_append (soup_server_message_get_response_body(msg), SOUP_MEMORY_STATIC,
content, strlen(content));
- soup_message_set_status (msg, SOUP_STATUS_OK);
+ soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
}
- g_debug (" -> %d %s\n\n", msg->status_code, msg->reason_phrase);
+ g_debug (" -> %d %s\n\n",
+ soup_server_message_get_status(msg),
+ soup_server_message_get_reason_phrase(msg));
}
@@ -114,16 +116,16 @@ govirt_httpd_run (gpointer user_data)
cert = g_tls_certificate_new_from_files (abs_srcdir "/https-cert/server-cert.pem",
abs_srcdir "/https-cert/server-key.pem",
&error);
- g_assert (error == NULL);
- server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "simple-soup-httpd ",
- SOUP_SERVER_TLS_CERTIFICATE, cert,
+ g_assert_no_error (error);
+ server = soup_server_new ("server-header", "simple-soup-httpd ",
+ "tls-certificate", cert,
NULL);
g_object_unref (cert);
soup_server_listen_local (server, mock_httpd->port,
SOUP_SERVER_LISTEN_HTTPS, &error);
} else {
- server = soup_server_new (SOUP_SERVER_SERVER_HEADER, "simple-soup-httpd ",
+ server = soup_server_new ("server-header", "simple-soup-httpd ",
NULL);
soup_server_listen_local (server, mock_httpd->port, 0, &error);
}
@@ -135,10 +137,10 @@ govirt_httpd_run (gpointer user_data)
uris = soup_server_get_uris (server);
for (u = uris; u; u = u->next) {
char *str;
- str = soup_uri_to_string (u->data, FALSE);
+ str = g_uri_to_string (u->data);
g_debug ("Listening on %s\n", str);
g_free (str);
- soup_uri_free (u->data);
+ g_uri_unref (u->data);
}
g_slist_free (uris);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]