diff --git a/srcpkgs/libosmgpsmap/patches/libsoup-3.patch b/srcpkgs/libosmgpsmap/patches/libsoup-3.patch new file mode 100644 index 00000000000..97dc4480f60 --- /dev/null +++ b/srcpkgs/libosmgpsmap/patches/libsoup-3.patch @@ -0,0 +1,278 @@ +From a7965751821d5bb55f8fb37b4045295d0c44dd9b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=A9bastien=20Noel?= +Date: Wed, 15 Feb 2023 11:56:48 +0100 +Subject: [PATCH] Port to libsoup3 + +--- + .github/workflows/ci.yml | 2 +- + configure.ac | 2 +- + docs/reference/Makefile.am | 4 +-- + examples/Makefile.am | 4 +-- + osmgpsmap-1.0.pc.in | 2 +- + src/Makefile.am | 4 +-- + src/osm-gps-map-widget.c | 74 +++++++++++++++++++++----------------- + 7 files changed, 50 insertions(+), 42 deletions(-) + +--- a/configure.ac ++++ b/configure.ac +@@ -25,7 +25,7 @@ AM_SILENT_RULES([yes]) + PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16]) + PKG_CHECK_MODULES(GTK, [gtk+-3.0 >= 3.0]) + PKG_CHECK_MODULES(CAIRO, [cairo >= 1.8]) +-PKG_CHECK_MODULES(SOUP24, [libsoup-2.4]) ++PKG_CHECK_MODULES(SOUP30, [libsoup-3.0]) + + # The mapviewer demo also calls g_thread_init, so it needs to link against + # libgthread-2.0. +--- a/docs/reference/Makefile.am ++++ b/docs/reference/Makefile.am +@@ -71,12 +71,12 @@ AM_CFLAGS=-I$(top_srcdir) -I$(top_buildd + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + $(CAIRO_CFLAGS) \ +- $(SOUP24_CFLAGS) ++ $(SOUP30_CFLAGS) + GTKDOC_LIBS=$(top_builddir)/src/libosmgpsmap-1.0.la \ + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(CAIRO_LIBS) \ +- $(SOUP24_LIBS) ++ $(SOUP30_LIBS) + + # This includes the standard gtk-doc make rules, copied by gtkdocize. + include $(top_srcdir)/gtk-doc.make +--- a/examples/Makefile.am ++++ b/examples/Makefile.am +@@ -4,13 +4,13 @@ OSMGPSMAP_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + $(CAIRO_CFLAGS) \ +- $(SOUP24_CFLAGS) ++ $(SOUP30_CFLAGS) + + OSMGPSMAP_LIBS = \ + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(CAIRO_LIBS) \ +- $(SOUP24_LIBS) ++ $(SOUP30_LIBS) + + ## Demo Application + noinst_PROGRAMS = mapviewer polygon editable_track +--- a/osmgpsmap-1.0.pc.in ++++ b/osmgpsmap-1.0.pc.in +@@ -6,6 +6,6 @@ includedir=@includedir@ + Name: @PACKAGE_NAME@ + Description: Moving map widget using openstreet map data + Version: @PACKAGE_VERSION@ +-Requires: gtk+-3.0 libsoup-2.4 ++Requires: gtk+-3.0 libsoup-3.0 + Libs: -L${libdir} -losmgpsmap-1.0 + Cflags: -I${includedir}/osmgpsmap-1.0 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -5,13 +5,13 @@ OSMGPSMAP_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) \ + $(CAIRO_CFLAGS) \ +- $(SOUP24_CFLAGS) ++ $(SOUP30_CFLAGS) + + OSMGPSMAP_LIBS = \ + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(CAIRO_LIBS) \ +- $(SOUP24_LIBS) ++ $(SOUP30_LIBS) + + ## Shared library + libosmgpsmap_1_0_la_CFLAGS = \ +--- a/src/osm-gps-map-widget.c ++++ b/src/osm-gps-map-widget.c +@@ -324,7 +324,7 @@ G_DEFINE_TYPE (OsmGpsMap, osm_gps_map, G + */ + static gchar *replace_string(const gchar *src, const gchar *from, const gchar *to); + static gchar *replace_map_uri(OsmGpsMap *map, const gchar *uri, int zoom, int x, int y); +-static void osm_gps_map_tile_download_complete (SoupSession *session, SoupMessage *msg, gpointer user_data); ++static void osm_gps_map_tile_download_complete (SoupSession *session, GAsyncResult *result, gpointer user_data); + static void osm_gps_map_download_tile (OsmGpsMap *map, int zoom, int x, int y, gboolean redraw); + static GdkPixbuf* osm_gps_map_render_tile_upscaled (OsmGpsMap *map, GdkPixbuf *tile, int tile_zoom, int zoom, int x, int y); + +@@ -740,12 +740,10 @@ osm_gps_map_blit_tile(OsmGpsMap *map, Gd + } + } + +-#define MSG_RESPONSE_BODY(a) ((a)->response_body->data) +-#define MSG_RESPONSE_LEN(a) ((a)->response_body->length) + #define MSG_RESPONSE_LEN_FORMAT "%"G_GOFFSET_FORMAT + + static void +-osm_gps_map_tile_download_complete (SoupSession *session, SoupMessage *msg, gpointer user_data) ++osm_gps_map_tile_download_complete (SoupSession *session, GAsyncResult *result, gpointer user_data) + { + FILE *file; + OsmTileDownload *dl = (OsmTileDownload *)user_data; +@@ -753,15 +751,23 @@ osm_gps_map_tile_download_complete (Soup + OsmGpsMapPrivate *priv = map->priv; + gboolean file_saved = FALSE; + +- if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { ++ GError *error = NULL; ++ SoupMessage *msg = soup_session_get_async_result_message(session, result); ++ SoupStatus soup_status = soup_message_get_status(msg); ++ GBytes *body = soup_session_send_and_read_finish (session, result, &error); ++ ++ GCancellable *cancellable = (GCancellable *)g_hash_table_lookup(priv->tile_queue, dl->uri); ++ g_object_unref (cancellable); ++ ++ if (SOUP_STATUS_IS_SUCCESSFUL (soup_status)) { + /* save tile into cachedir if one has been specified */ + if (priv->cache_dir) { + if (g_mkdir_with_parents(dl->folder,0700) == 0) { + file = g_fopen(dl->filename, "wb"); + if (file != NULL) { +- fwrite (MSG_RESPONSE_BODY(msg), 1, MSG_RESPONSE_LEN(msg), file); ++ fwrite (g_bytes_get_data(body, NULL), 1, g_bytes_get_size(body), file); + file_saved = TRUE; +- g_debug("Wrote "MSG_RESPONSE_LEN_FORMAT" bytes to %s", MSG_RESPONSE_LEN(msg), dl->filename); ++ g_debug("Wrote "MSG_RESPONSE_LEN_FORMAT" bytes to %s", g_bytes_get_size(body), dl->filename); + fclose (file); + + } +@@ -786,7 +792,7 @@ osm_gps_map_tile_download_complete (Soup + /* parse file directly from memory */ + if (extension) { + loader = gdk_pixbuf_loader_new_with_type (extension+1, NULL); +- if (!gdk_pixbuf_loader_write (loader, (unsigned char*)MSG_RESPONSE_BODY(msg), MSG_RESPONSE_LEN(msg), NULL)) ++ if (!gdk_pixbuf_loader_write (loader, (unsigned char*)g_bytes_get_data(body, NULL), g_bytes_get_size(body), NULL)) + { + g_warning("Error: Decoding of image failed"); + } +@@ -824,21 +830,21 @@ osm_gps_map_tile_download_complete (Soup + g_free(dl->filename); + g_free(dl); + } else { +- if ((msg->status_code == SOUP_STATUS_NOT_FOUND) || (msg->status_code == SOUP_STATUS_FORBIDDEN)) { ++ if ((soup_status == SOUP_STATUS_NOT_FOUND) || (soup_status == SOUP_STATUS_FORBIDDEN)) { + g_hash_table_insert(priv->missing_tiles, dl->uri, NULL); + g_hash_table_remove(priv->tile_queue, dl->uri); + g_object_notify(G_OBJECT(map), "tiles-queued"); +- } else if (msg->status_code == SOUP_STATUS_CANCELLED) { ++ } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + /* called as application exit or after osm_gps_map_download_cancel_all */ + g_hash_table_remove(priv->tile_queue, dl->uri); + g_object_notify(G_OBJECT(map), "tiles-queued"); + } else { +- g_warning("Error downloading tile: %d - %s", msg->status_code, msg->reason_phrase); +- dl->ttl--; +- if (dl->ttl) { +- soup_session_requeue_message(session, msg); +- return; +- } ++ g_warning("Error downloading tile: %d - %s", soup_status, soup_status_get_phrase(soup_status)); ++ //dl->ttl--; ++ //if (dl->ttl) { ++ // soup_session_requeue_message(session, msg); ++ // return; ++ //} + + g_hash_table_remove(priv->tile_queue, dl->uri); + g_object_notify(G_OBJECT(map), "tiles-queued"); +@@ -888,21 +894,26 @@ osm_gps_map_download_tile (OsmGpsMap *ma + if (priv->is_google) { + //Set maps.google.com as the referrer + g_debug("Setting Google Referrer"); +- soup_message_headers_append(msg->request_headers, "Referer", "http://maps.google.com/"); ++ soup_message_headers_append(soup_message_get_request_headers(msg), "Referer", "http://maps.google.com/"); + //For google satelite also set the appropriate cookie value + if (priv->uri_format & URI_HAS_Q) { + const char *cookie = g_getenv("GOOGLE_COOKIE"); + if (cookie) { + g_debug("Adding Google Cookie"); +- soup_message_headers_append(msg->request_headers, "Cookie", cookie); ++ soup_message_headers_append(soup_message_get_request_headers(msg), "Cookie", cookie); + } + } + } + +- g_hash_table_insert (priv->tile_queue, dl->uri, msg); ++ GCancellable *cancellable = g_cancellable_new (); ++ g_hash_table_insert (priv->tile_queue, dl->uri, cancellable); + g_object_notify (G_OBJECT (map), "tiles-queued"); + /* the soup session unrefs the message when the download finishes */ +- soup_session_queue_message (priv->soup_session, msg, osm_gps_map_tile_download_complete, dl); ++ soup_session_send_and_read_async(priv->soup_session, msg, ++ G_PRIORITY_DEFAULT, ++ cancellable, ++ (GAsyncReadyCallback)osm_gps_map_tile_download_complete, ++ dl); + } else { + g_warning("Could not create soup message"); + g_free(dl->uri); +@@ -1686,11 +1697,8 @@ osm_gps_map_init (OsmGpsMap *object) + soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT, + USER_AGENT, NULL); + #else +- // lisoup since 2.42.0 has universal session, only methods can be sync/async +- // and we use async +- priv->soup_session = +- soup_session_new_with_options(SOUP_SESSION_USER_AGENT, +- USER_AGENT, NULL); ++ priv->soup_session = soup_session_new (); ++ soup_session_set_user_agent (priv->soup_session, USER_AGENT); + #endif + + /* Hash table which maps tile d/l URIs to SoupMessage requests, the hashtable +@@ -1922,10 +1930,10 @@ osm_gps_map_set_property (GObject *objec + g_debug("Setting proxy server: %s", priv->proxy_uri); + + GValue val = {0}; +- SoupURI* uri = soup_uri_new(priv->proxy_uri); +- g_value_init(&val, SOUP_TYPE_URI); ++ GUri* uri = g_uri_parse(priv->proxy_uri, SOUP_HTTP_URI_FLAGS, NULL); ++ g_value_init(&val, G_TYPE_URI); + g_value_take_boxed(&val, uri); +- g_object_set_property(G_OBJECT(priv->soup_session),SOUP_SESSION_PROXY_URI,&val); ++ g_object_set_property(G_OBJECT(priv->soup_session),"proxy-resolver",&val); + + } else { + g_free(priv->proxy_uri); +@@ -1945,7 +1953,7 @@ osm_gps_map_set_property (GObject *objec + priv->user_agent = NULL; + g_value_set_string (&full_user_agent, USER_AGENT); + } +- g_object_set_property(G_OBJECT(priv->soup_session),SOUP_SESSION_USER_AGENT, &full_user_agent); ++ g_object_set_property(G_OBJECT(priv->soup_session),"user-agent", &full_user_agent); + break; + case PROP_TILE_CACHE_DIR: + if ( g_value_get_string(value) ) { +@@ -2987,9 +2995,9 @@ osm_gps_map_download_maps (OsmGpsMap *ma + } + + static void +-cancel_message (char *key, SoupMessage *value, SoupSession *user_data) ++cancel_message (char *key, GCancellable *cancellable, void *userdata) + { +- soup_session_cancel_message (user_data, value, SOUP_STATUS_CANCELLED); ++ g_cancellable_cancel(cancellable); + } + + /** +@@ -2997,7 +3005,7 @@ cancel_message (char *key, SoupMessage * + * @map: a #OsmGpsMap widget + * + * Cancels all tiles currently being downloaded. Typically used if you wish to +- * cacel a large number of tiles queued using osm_gps_map_download_maps() ++ * cancel a large number of tiles queued using osm_gps_map_download_maps() + * + * Since: 0.7.0 + **/ +@@ -3005,7 +3013,7 @@ void + osm_gps_map_download_cancel_all (OsmGpsMap *map) + { + OsmGpsMapPrivate *priv = map->priv; +- g_hash_table_foreach (priv->tile_queue, (GHFunc)cancel_message, priv->soup_session); ++ g_hash_table_foreach (priv->tile_queue, (GHFunc)cancel_message, NULL); + } + + /** diff --git a/srcpkgs/libosmgpsmap/template b/srcpkgs/libosmgpsmap/template index f6ad04d5715..a1d7888b807 100644 --- a/srcpkgs/libosmgpsmap/template +++ b/srcpkgs/libosmgpsmap/template @@ -1,12 +1,12 @@ # Template file for 'libosmgpsmap' pkgname=libosmgpsmap version=1.2.0 -revision=2 +revision=3 build_style=gnu-configure build_helper="gir" configure_args="$(vopt_enable gir introspection)" -hostmakedepends="pkg-config gtk-doc" -makedepends="libsoup-devel gtk+3-devel cairo-devel" +hostmakedepends="pkg-config gtk-doc automake libtool" +makedepends="libsoup3-devel gtk+3-devel cairo-devel" short_desc="Gtk+ Widget for Displaying OpenStreetMap tiles" maintainer="lemmi " license="GPL-2.0-or-later" @@ -18,6 +18,10 @@ checksum=ddec11449f37b5dffb4bca134d024623897c6140af1f9981a8acc512dbf6a7a5 build_options="gir" build_options_default="gir" +pre_configure() { + autoreconf -fi +} + libosmgpsmap-doc_package() { depends="${sourcepkg}>=${version}_${revision}" short_desc+=" - Documentation"