[gssdp/wip/libsoup3: 4/4] Port GSSDP to libsoup3 API
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp/wip/libsoup3: 4/4] Port GSSDP to libsoup3 API
- Date: Fri, 29 Oct 2021 16:39:01 +0000 (UTC)
commit e223e6f75e370c3d9b2b402586521fe005f1a0da
Author: Jens Georg <mail jensge org>
Date: Sun Jul 25 11:44:27 2021 +0200
Port GSSDP to libsoup3 API
libgssdp/gssdp-client.c | 7 +++----
libgssdp/gssdp-resource-browser.c | 16 +++++++---------
libgssdp/gssdp-resource-group.c | 7 +++----
meson.build | 8 ++++----
4 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index c9f6e90..5531d98 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -1533,7 +1533,7 @@ parse_http_request (char *buf,
return TRUE;
} else {
- soup_message_headers_free (*headers);
+ soup_message_headers_unref (*headers);
*headers = NULL;
g_free (path);
@@ -1564,8 +1564,7 @@ parse_http_response (char *buf,
return TRUE;
} else {
- soup_message_headers_free (*headers);
- *headers = NULL;
+ g_clear_pointer (headers, soup_message_headers_unref);
return FALSE;
}
@@ -1745,7 +1744,7 @@ out:
g_free (ip_string);
- g_clear_pointer (&headers, soup_message_headers_free);
+ g_clear_pointer (&headers, soup_message_headers_unref);
g_clear_object (&address);
if (messages) {
diff --git a/libgssdp/gssdp-resource-browser.c b/libgssdp/gssdp-resource-browser.c
index 7ebc08a..af1a264 100644
--- a/libgssdp/gssdp-resource-browser.c
+++ b/libgssdp/gssdp-resource-browser.c
@@ -878,17 +878,13 @@ resource_available (GSSDPResourceBrowser *resource_browser,
expires = soup_message_headers_get_one (headers, "Expires");
if (expires) {
- SoupDate *soup_exp_time;
- time_t exp_time, cur_time;
+ GDateTime *exp_time;
- soup_exp_time = soup_date_new_from_string (expires);
- exp_time = soup_date_to_time_t (soup_exp_time);
- soup_date_free (soup_exp_time);
+ exp_time = soup_date_time_new_from_http_string (expires);
+ GDateTime *now = g_date_time_new_now_local ();
- cur_time = time (NULL);
-
- if (exp_time > cur_time)
- timeout = exp_time - cur_time;
+ if (g_date_time_compare (now, exp_time) == 1)
+ timeout = g_date_time_difference (now, exp_time) / 1000 / 1000;
else {
g_warning ("Invalid 'Expires' header. Assuming "
"default max-age of %d.\n"
@@ -898,6 +894,8 @@ resource_available (GSSDPResourceBrowser *resource_browser,
timeout = SSDP_DEFAULT_MAX_AGE;
}
+ g_date_time_unref (exp_time);
+ g_date_time_unref (now);
} else {
g_warning ("No 'Cache-Control' nor any 'Expires' "
"header was specified. Assuming default "
diff --git a/libgssdp/gssdp-resource-group.c b/libgssdp/gssdp-resource-group.c
index 66cf508..64451f0 100644
--- a/libgssdp/gssdp-resource-group.c
+++ b/libgssdp/gssdp-resource-group.c
@@ -1012,7 +1012,6 @@ discovery_response_timeout (gpointer user_data)
{
DiscoveryResponse *response = user_data;
GSSDPClient *client;
- SoupDate *date;
char *al, *date_str, *message;
guint max_age;
char *usn;
@@ -1030,9 +1029,9 @@ discovery_response_timeout (gpointer user_data)
usn = construct_usn (response->resource->usn,
response->target,
response->resource->target);
- date = soup_date_new_from_now (0);
- date_str = soup_date_to_string (date, SOUP_DATE_HTTP);
- soup_date_free (date);
+ GDateTime *date = g_date_time_new_now_local ();
+ date_str = soup_date_time_to_string (date, SOUP_DATE_HTTP);
+ g_date_time_unref (date);
message = g_strdup_printf (SSDP_DISCOVERY_RESPONSE,
(char *) response->resource->locations->data,
diff --git a/meson.build b/meson.build
index e58a940..71dab96 100644
--- a/meson.build
+++ b/meson.build
@@ -42,10 +42,10 @@ conf.set('HAVE_SIOCGIFINDEX', siocgifindex_available)
getipnettable2_available = cc.compiles(files('build-aux/getipnettable2-test.c'), args: '-liphlpapi', name:
'GetIpNetTable2 is available')
conf.set('HAVE_GETIPNETTABLE2', getipnettable2_available)
+glib_version = '2.69'
+conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_70'.format(glib_version.underscorify()))
+conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_70'.format(glib_version.underscorify()))
-glib_version = '2.54'
-conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_@0@'.format(glib_version.underscorify()))
-conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_@0@'.format(glib_version.underscorify()))
# Generate config.h, so all config has to be set up until here
@@ -76,7 +76,7 @@ dependencies = [
dependency('glib-2.0', version : '>= ' + glib_version),
dependency('gobject-2.0', version : '>= ' + glib_version),
dependency('gio-2.0', version : '>= ' + glib_version),
- dependency('libsoup-2.4', version : '>= 2.26.1')
+ dependency('libsoup-3.0', version : '>= 2.99.0')
]
subdir('libgssdp')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]