From 6841d27b952ba6afb51cb7fc682c8efbf0707e5e Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Wed, 6 Jul 2016 19:18:20 +0300 Subject: [PATCH] [mms-lib] Fixed compilation against libsoup 2.48 and newer. MER#1616 --- mms-lib/src/mms_task_http.c | 5 +++++ mms-lib/test/common/test_http.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/mms-lib/src/mms_task_http.c b/mms-lib/src/mms_task_http.c index 242d974..a94cedd 100644 --- a/mms-lib/src/mms_task_http.c +++ b/mms-lib/src/mms_task_http.c @@ -32,6 +32,11 @@ # define SOUP_SESSION_LOCAL_ADDRESS "local-address" #endif +#if SOUP_CHECK_VERSION(2,42,0) +# define soup_session_async_new_with_options soup_session_new_with_options +# define soup_session_async_new soup_session_new +#endif + /* Logging */ #define MMS_LOG_MODULE_NAME MMS_TASK_HTTP_LOG #include "mms_lib_log.h" diff --git a/mms-lib/test/common/test_http.c b/mms-lib/test/common/test_http.c index 29a3fec..7dc50e4 100644 --- a/mms-lib/test/common/test_http.c +++ b/mms-lib/test/common/test_http.c @@ -27,6 +27,7 @@ typedef struct test_http_response { struct test_http { gint ref_count; + guint port; SoupServer* server; GPtrArray* responses; GPtrArray* post_data; @@ -97,7 +98,7 @@ guint test_http_get_port( TestHttp* http) { - return soup_server_get_port(http->server); + return http->port; } guint @@ -170,6 +171,16 @@ test_http_add_response( g_ptr_array_add(http->responses, resp); } +#if SOUP_CHECK_VERSION(2,48,0) +static +void +test_http_uri_free( + gpointer uri) +{ + soup_uri_free(uri); +} +#endif + TestHttp* test_http_new( GMappedFile* get_file, @@ -181,9 +192,21 @@ test_http_new( http->responses = g_ptr_array_new_full(0, test_http_response_free); http->post_data = g_ptr_array_new_full(0, test_http_post_data_bytes_free); http->server = g_object_new(SOUP_TYPE_SERVER, NULL); - MMS_DEBUG("Listening on port %hu", soup_server_get_port(http->server)); - soup_server_add_handler(http->server, NULL, test_http_callback, http, NULL); +#if SOUP_CHECK_VERSION(2,48,0) + if (soup_server_listen_local(http->server, 0, 0, NULL)) { + GSList* uris = soup_server_get_uris(http->server); + if (uris) { + SoupURI* uri = uris->data; + http->port = soup_uri_get_port(uri); + g_slist_free_full(uris, test_http_uri_free); + } + } +#else + http->port = soup_server_get_port(http->server); soup_server_run_async(http->server); +#endif + MMS_DEBUG("Listening on port %hu", http->port); + soup_server_add_handler(http->server, NULL, test_http_callback, http, NULL); if (get_file || resp_content_type || resp_status) { test_http_add_response(http, get_file, resp_content_type, resp_status); }