[librest/gwagner/oauth2: 1/2] general cleanup
- From: Günther Wagner <gwagner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librest/gwagner/oauth2: 1/2] general cleanup
- Date: Sun, 14 Nov 2021 16:43:01 +0000 (UTC)
commit 62f43e93b62b8329e624f8c49f575788c89101db
Author: Günther Wagner <info gunibert de>
Date: Fri Nov 5 17:26:37 2021 +0100
general cleanup
AUTHORS | 1 +
ChangeLog | 0
INSTALL | 237 --------------------------
Makefile.am | 36 ----
NEWS | 4 +
autogen.sh | 24 ---
build/Makefile.am | 1 -
build/introspection.m4 | 94 ----------
configure.ac | 161 ------------------
docs/Makefile.am | 1 -
docs/meson.build | 16 +-
docs/reference/Makefile.am | 1 -
docs/reference/rest/Makefile.am | 92 ----------
docs/reference/rest/meson.build | 26 ---
docs/reference/rest/rest-docs.xml | 51 ------
docs/reference/rest/rest-overrides.txt | 0
docs/reference/rest/rest-sections.txt | 303 ---------------------------------
docs/reference/rest/rest.types | 12 --
examples/Makefile.am | 13 --
meson.build | 25 ++-
meson_options.txt | 15 +-
rest-extras/Makefile.am | 79 ---------
rest-extras/meson.build | 2 +-
rest/Makefile.am | 139 ---------------
rest/meson.build | 9 +-
rest/rest-proxy-call.c | 4 -
rest/rest-proxy.c | 4 +-
tests/Makefile.am | 18 --
tests/proxy.c | 128 ++++++++------
29 files changed, 135 insertions(+), 1361 deletions(-)
---
diff --git a/AUTHORS b/AUTHORS
index 1a3ad8a..c309f7e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
Rob Bradford <rob linux intel com>
Ross Burton <ross linux intel com>
+Günther Wagner <info gunibert de>
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..b88ef0b
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,4 @@
+Overview of changes for 0.9
+===========================
+* introduced meson as buildsystem
+* introduced the possibility to build librest with soup-2.4 or soup-3.0
diff --git a/docs/meson.build b/docs/meson.build
index 2eeb084..601e306 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -1,5 +1,3 @@
-subdir('reference/rest')
-
if get_option('gtk_doc') and get_option('introspection')
dependency('gi-docgen', version: '>= 2021.6',
fallback: ['gi-docgen', 'dummy_dep'],
@@ -39,5 +37,19 @@ if get_option('gtk_doc') and get_option('introspection')
install_dir: rest_docdir,
)
+ if get_option('tests')
+ test('doc-check',
+ gidocgen,
+ args: [
+ 'check',
+ '--config', rest_toml,
+ '--add-include-path=@0@'.format(meson.current_build_dir() / '../rest'),
+ librest_gir[0],
+ ],
+ depends: librest_gir[0],
+ suite: ['docs'],
+ )
+ endif
+
endif
diff --git a/meson.build b/meson.build
index 81c5ed1..6ea2f6d 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
project('rest', 'c',
version: '0.9.0',
license: 'LGPL2.1+',
- meson_version: '>= 0.49',
+ meson_version: '>= 0.53',
)
# Versioning
@@ -73,11 +73,13 @@ config_h_inc = include_directories('.')
# Subdirectories
subdir('rest')
subdir('rest-extras')
-subdir('tests')
+if get_option('tests')
+ subdir('tests')
+endif
if get_option('examples')
subdir('examples')
endif
-if get_option('gtk_doc')
+if get_option('gtk_doc').enabled()
subdir('docs')
endif
@@ -103,3 +105,20 @@ pkgconfig.generate(librest_extras_lib,
'apiversion=@0@'.format(librest_api_version),
],
)
+
+summary({
+ 'prefix': get_option('prefix'),
+ 'libdir': get_option('prefix') / get_option('libdir'),
+ },
+ section: 'Directories',
+)
+
+summary({
+ 'Introspection': get_option('introspection').enabled() or get_option('introspection').auto(),
+ 'Documentation': get_option('gtk_doc').enabled() or get_option('gtk_doc').auto(),
+ 'Tests': get_option('tests'),
+ 'Soup 2': get_option('soup2'),
+ },
+ section: 'Build',
+ bool_yn: true,
+)
diff --git a/meson_options.txt b/meson_options.txt
index 49f7a2d..da253e8 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,8 +9,9 @@ option('ca_certificates_path',
description: 'List of paths to the system Certificate Authority list. If empty, a default set of paths
will be tried.',
)
option('introspection',
- type: 'boolean',
- value: true,
+ type: 'feature',
+ value: 'enabled',
+ yield: true,
description: 'Generate GObject Introspection (.gir) files',
)
option('examples',
@@ -19,8 +20,9 @@ option('examples',
description: 'Build the examples',
)
option('gtk_doc',
- type: 'boolean',
- value: false,
+ type: 'feature',
+ value: 'auto',
+ yield: true,
description: 'Build the gtk-doc reference docs',
)
option('soup2',
@@ -28,3 +30,8 @@ option('soup2',
value: true,
description: 'Whether to build with libsoup2',
)
+option('tests',
+ type: 'boolean',
+ value: true,
+ description: 'Whether to build the tests',
+)
diff --git a/rest-extras/meson.build b/rest-extras/meson.build
index 1ad9ee1..a94f0aa 100644
--- a/rest-extras/meson.build
+++ b/rest-extras/meson.build
@@ -45,7 +45,7 @@ librest_extras_dep = declare_dependency(
link_with: librest_extras_lib,
)
-if get_option('introspection')
+if get_option('introspection').enabled()
librest_extras_gir = gnome.generate_gir(librest_extras_lib,
sources: librest_extras_sources + librest_extras_headers,
namespace: 'RestExtras',
diff --git a/rest/meson.build b/rest/meson.build
index 396ec83..a153660 100644
--- a/rest/meson.build
+++ b/rest/meson.build
@@ -65,8 +65,10 @@ install_headers(librest_headers,
subdir: librest_pkg_string / 'rest',
)
+rest_dep_sources = []
+
# GObject Introspection
-if get_option('introspection')
+if get_option('introspection').enabled()
librest_gir_extra_args = [
'--accept-unprefixed',
'--c-include=rest/rest-enum-types.h',
@@ -84,10 +86,15 @@ if get_option('introspection')
extra_args: librest_gir_extra_args,
install: true,
)
+
+ rest_dep_sources += librest_gir
endif
librest_dep = declare_dependency(
+ sources: rest_dep_sources,
link_with: librest_lib,
+ include_directories: include_directories('..'),
+ dependencies: librest_deps,
)
# Test suite
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 62b00da..a4a0958 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -1491,11 +1491,7 @@ rest_proxy_call_get_payload_length (RestProxyCall *call)
g_return_val_if_fail (REST_IS_PROXY_CALL (call), 0);
payload = GET_PRIVATE (call)->payload;
-#ifdef WITH_SOUP_2
- return payload ? g_bytes_get_size (payload) - 1 : 0;
-#else
return payload ? g_bytes_get_size (payload) : 0;
-#endif
}
/**
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index 171f6cb..8231b6f 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -763,7 +763,7 @@ message_finished_cb (SoupSession *session,
GError *error = NULL;
body = g_bytes_new (message->response_body->data,
- message->response_body->length + 1);
+ message->response_body->length);
data->callback (message, body, error, data->user_data);
g_free (data);
}
@@ -894,7 +894,7 @@ _rest_proxy_send_message (RestProxy *proxy,
#ifdef WITH_SOUP_2
soup_session_send_message (priv->session, message);
body = g_bytes_new (message->response_body->data,
- message->response_body->length + 1);
+ message->response_body->length);
#else
body = soup_session_send_and_read (priv->session,
message,
diff --git a/tests/proxy.c b/tests/proxy.c
index d6c05a5..c80c362 100644
--- a/tests/proxy.c
+++ b/tests/proxy.c
@@ -48,36 +48,85 @@ static int errors = 0;
SoupServer *server;
GMainLoop *server_loop;
-static void
#ifdef WITH_SOUP_2
-server_callback (SoupServer *server, SoupMessage *msg,
- const char *path, GHashTable *query,
- SoupClientContext *client, gpointer user_data)
-#else
-server_callback (SoupServer *server, SoupServerMessage *msg,
- const char *path, GHashTable *query, gpointer user_data)
-#endif
+static void
+server_callback_soup (SoupServer *server,
+ SoupMessage *msg,
+ const gchar *path,
+ GHashTable *query,
+ SoupClientContext *client,
+ gpointer user_data)
{
- if (g_str_equal (path, "/ping")) {
-#ifdef WITH_SOUP_2
+ if (g_str_equal (path, "/ping") && g_strcmp0 ("GET", soup_server_message_get_method (msg)) == 0) {
soup_message_set_status (msg, SOUP_STATUS_OK);
-#else
- soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
-#endif
}
else if (g_str_equal (path, "/echo")) {
const char *value;
value = g_hash_table_lookup (query, "value");
-#ifdef WITH_SOUP_2
soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
value, strlen (value));
soup_message_set_status (msg, SOUP_STATUS_OK);
+ }
+ else if (g_str_equal (path, "/reverse")) {
+ char *value;
+
+ value = g_strdup (g_hash_table_lookup (query, "value"));
+ g_strreverse (value);
+ soup_message_set_response (msg, "text/plain", SOUP_MEMORY_TAKE,
+ value, strlen (value));
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+ }
+ else if (g_str_equal (path, "/status")) {
+ const char *value;
+ int status;
+
+ value = g_hash_table_lookup (query, "status");
+ if (value) {
+ status = atoi (value);
+ soup_message_set_status (msg, status ?: SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ } else {
+ soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ }
+ }
+ else if (g_str_equal (path, "/useragent/none")) {
+ SoupMessageHeaders *request_headers = msg->request_headers;
+
+ if (soup_message_headers_get (request_headers, "User-Agent") == NULL) {
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+ } else {
+ soup_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED);
+ }
+ }
+ else if (g_str_equal (path, "/useragent/testsuite")) {
+ SoupMessageHeaders *request_headers = msg->request_headers;
+ const char *value;
+ value = soup_message_headers_get (request_headers, "User-Agent");
+ if (g_strcmp0 (value, "TestSuite-1.0") == 0) {
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+ } else {
+ soup_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED);
+ }
+ }
+}
#else
+static void
+server_callback (SoupServer *server,
+ SoupServerMessage *msg,
+ const char *path,
+ GHashTable *query,
+ gpointer user_data)
+{
+ if (g_str_equal (path, "/ping") && g_strcmp0 ("GET", soup_server_message_get_method (msg)) == 0) {
+ soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
+ }
+ else if (g_str_equal (path, "/echo")) {
+ const char *value;
+
+ value = g_hash_table_lookup (query, "value");
soup_server_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
value, strlen (value));
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
-#endif
}
else if (g_str_equal (path, "/reverse")) {
char *value;
@@ -85,15 +134,9 @@ server_callback (SoupServer *server, SoupServerMessage *msg,
value = g_strdup (g_hash_table_lookup (query, "value"));
g_strreverse (value);
-#ifdef WITH_SOUP_2
- soup_message_set_response (msg, "text/plain", SOUP_MEMORY_TAKE,
- value, strlen (value));
- soup_message_set_status (msg, SOUP_STATUS_OK);
-#else
soup_server_message_set_response (msg, "text/plain", SOUP_MEMORY_TAKE,
value, strlen (value));
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
-#endif
}
else if (g_str_equal (path, "/status")) {
const char *value;
@@ -102,64 +145,33 @@ server_callback (SoupServer *server, SoupServerMessage *msg,
value = g_hash_table_lookup (query, "status");
if (value) {
status = atoi (value);
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, status ?: SOUP_STATUS_INTERNAL_SERVER_ERROR);
-#else
soup_server_message_set_status (msg, status ?: SOUP_STATUS_INTERNAL_SERVER_ERROR, NULL);
-#endif
} else {
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
-#else
soup_server_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR, NULL);
-#endif
}
}
else if (g_str_equal (path, "/useragent/none")) {
-#ifdef WITH_SOUP_2
- SoupMessageHeaders *request_headers = msg->request_headers;
-#else
SoupMessageHeaders *request_headers = soup_server_message_get_request_headers (msg);
-#endif
if (soup_message_headers_get (request_headers, "User-Agent") == NULL) {
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, SOUP_STATUS_OK);
-#else
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
-#endif
} else {
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED);
-#else
soup_server_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED, NULL);
-#endif
}
}
else if (g_str_equal (path, "/useragent/testsuite")) {
-#ifdef WITH_SOUP_2
- SoupMessageHeaders *request_headers = msg->request_headers;
-#else
SoupMessageHeaders *request_headers = soup_server_message_get_request_headers (msg);
-#endif
const char *value;
value = soup_message_headers_get (request_headers, "User-Agent");
if (g_strcmp0 (value, "TestSuite-1.0") == 0) {
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, SOUP_STATUS_OK);
-#else
soup_server_message_set_status (msg, SOUP_STATUS_OK, NULL);
-#endif
} else {
-#ifdef WITH_SOUP_2
- soup_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED);
-#else
soup_server_message_set_status (msg, SOUP_STATUS_EXPECTATION_FAILED, NULL);
-#endif
-
}
}
}
+#endif
+
static void
ping_test (RestProxy *proxy)
@@ -169,6 +181,7 @@ ping_test (RestProxy *proxy)
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_function (call, "ping");
+ rest_proxy_call_set_method (call, "GET");
if (!rest_proxy_call_sync (call, &error)) {
g_printerr ("2: Call failed: %s\n", error->message);
@@ -366,8 +379,11 @@ static void *
server_thread_func (gpointer data)
{
server_loop = g_main_loop_new (NULL, TRUE);
- /*SoupServer *server = soup_server_new (NULL);*/
+#ifdef WITH_SOUP_2
soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
+#else
+ soup_server_add_handler (server, NULL, server_callback, NULL, NULL);
+#endif
soup_server_listen_local (server, PORT, 0, NULL);
g_main_loop_run (server_loop);
@@ -381,7 +397,7 @@ main (int argc, char **argv)
char *url;
RestProxy *proxy;
- server = soup_server_new (NULL);
+ server = g_object_new (SOUP_TYPE_SERVER, NULL);
g_thread_new ("Server Thread", server_thread_func, NULL);
url = g_strdup_printf ("http://127.0.0.1:%d/", PORT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]