summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0001-libxfce4ui-Avoid-deprecated-functions.patch79
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0002-parsers-Generalise-input-to-array-of-gchar.patch289
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0003-libsoup-Port-to-libsoup-3.0.patch563
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0004-Report-UPower-Glib-support.patch20
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0005-Make-libsoup-v3-support-optional.patch626
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.11.3.bb18
-rw-r--r--meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.12.0.bb15
7 files changed, 15 insertions, 1595 deletions
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0001-libxfce4ui-Avoid-deprecated-functions.patch b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0001-libxfce4ui-Avoid-deprecated-functions.patch
deleted file mode 100644
index 981ba560d4..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0001-libxfce4ui-Avoid-deprecated-functions.patch
+++ /dev/null
@@ -1,79 +0,0 @@
1From 9a3fc89f924f7a322c3b537256621640561daf95 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
3 <congdanhqx@gmail.com>
4Date: Fri, 1 Mar 2024 21:56:34 +0700
5Subject: [PATCH 1/5] libxfce4ui: Avoid deprecated functions
6
7- xfce_titled_dialog_new_with_buttons is deprecated from 4.16.
8- xfce_spawn_command_line_on_screen is deprecated from 4.16
9
10- xfce_titled_dialog_new_with_mixed_buttons is available from 4.14
11- xfce_spawn_command_line is available from 4.16
12
13Upstream-Status: Backport [https://github.com/xfce-mirror/xfce4-weather-plugin/commit/9115037ed7cfe722d3739ca800d5247f4bb3bc53]
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 configure.ac | 2 +-
17 panel-plugin/weather-config.c | 4 ++--
18 panel-plugin/weather-search.c | 20 +++++++++++---------
19 3 files changed, 14 insertions(+), 12 deletions(-)
20
21diff --git a/configure.ac b/configure.ac
22index e0516e6..cf82b7e 100644
23--- a/configure.ac
24+++ b/configure.ac
25@@ -66,7 +66,7 @@ XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.22.0])
26 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.64.0])
27 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.64.0])
28 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
29-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
30+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.16.0])
31 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.14.0])
32 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
33 XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
34diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
35index 9f77340..2645408 100644
36--- a/panel-plugin/weather-config.c
37+++ b/panel-plugin/weather-config.c
38@@ -958,8 +958,8 @@ button_icons_dir_clicked(GtkWidget *button,
39 g_mkdir_with_parents(dir, 0755);
40 command = g_strdup_printf("exo-open %s", dir);
41 g_free(dir);
42- xfce_spawn_command_line_on_screen(gdk_screen_get_default(),
43- command, FALSE, TRUE, NULL);
44+ xfce_spawn_command_line(gdk_screen_get_default(), command, FALSE,
45+ TRUE, TRUE, NULL);
46 g_free(command);
47 }
48
49diff --git a/panel-plugin/weather-search.c b/panel-plugin/weather-search.c
50index 83f1d71..7e87ae8 100644
51--- a/panel-plugin/weather-search.c
52+++ b/panel-plugin/weather-search.c
53@@ -205,15 +205,17 @@ create_search_dialog(GtkWindow *parent,
54 dialog->session = session;
55
56 dialog->dialog =
57- xfce_titled_dialog_new_with_buttons(_("Search location"),
58- parent,
59- GTK_DIALOG_MODAL |
60- GTK_DIALOG_DESTROY_WITH_PARENT,
61- _("Cancel"),
62- GTK_RESPONSE_REJECT,
63- _("OK"),
64- GTK_RESPONSE_ACCEPT,
65- NULL);
66+ xfce_titled_dialog_new_with_mixed_buttons(_("Search location"),
67+ parent,
68+ GTK_DIALOG_MODAL |
69+ GTK_DIALOG_DESTROY_WITH_PARENT,
70+ "",
71+ _("Cancel"),
72+ GTK_RESPONSE_REJECT,
73+ "",
74+ _("OK"),
75+ GTK_RESPONSE_ACCEPT,
76+ NULL);
77 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog),
78 GTK_RESPONSE_ACCEPT, FALSE);
79 gtk_window_set_icon_name(GTK_WINDOW(dialog->dialog), "edit-find");
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0002-parsers-Generalise-input-to-array-of-gchar.patch b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0002-parsers-Generalise-input-to-array-of-gchar.patch
deleted file mode 100644
index a76a7741bf..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0002-parsers-Generalise-input-to-array-of-gchar.patch
+++ /dev/null
@@ -1,289 +0,0 @@
1From 3c095487e3a6c14f2900762c18c6e2170d22a283 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
3 <congdanhqx@gmail.com>
4Date: Fri, 1 Mar 2024 21:56:34 +0700
5Subject: [PATCH 2/5] parsers: Generalise input to array of gchar
6
7In a later change, we will move to libsoup-3.0, which doesn't expose
8`response_body' in SoupMessage.
9
10Prepare for that move.
11
12Upstream-Status: Backport [https://github.com/xfce-mirror/xfce4-weather-plugin/commit/3c095487e3a6c14f2900762c18c6e2170d22a283]
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 panel-plugin/weather-config.c | 18 +++++++++++++++--
16 panel-plugin/weather-parsers.c | 36 ++++++++++++++++++----------------
17 panel-plugin/weather-parsers.h | 7 +++----
18 panel-plugin/weather-search.c | 18 +++++++++++++++--
19 panel-plugin/weather.c | 26 ++++++++++++++++++++----
20 5 files changed, 76 insertions(+), 29 deletions(-)
21
22diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
23index 2645408..19fa1d8 100644
24--- a/panel-plugin/weather-config.c
25+++ b/panel-plugin/weather-config.c
26@@ -245,6 +245,13 @@ cb_lookup_altitude(SoupSession *session,
27 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
28 xml_altitude *altitude;
29 gdouble alt = 0;
30+ const gchar *body = NULL;
31+ gsize len = 0;
32+
33+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
34+ body = msg->response_body->data;
35+ len = msg->response_body->length;
36+ }
37
38 if (global_dialog == NULL) {
39 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
40@@ -252,7 +259,7 @@ cb_lookup_altitude(SoupSession *session,
41 }
42
43 altitude = (xml_altitude *)
44- parse_xml_document(msg, (XmlParseFunc) parse_altitude);
45+ parse_xml_document(body, len, (XmlParseFunc) parse_altitude);
46
47 if (altitude) {
48 alt = string_to_double(altitude->altitude, -9999);
49@@ -274,6 +281,13 @@ cb_lookup_timezone(SoupSession *session,
50 {
51 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
52 xml_timezone *xml_tz;
53+ const gchar *body = NULL;
54+ gsize len = 0;
55+
56+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
57+ body = msg->response_body->data;
58+ len = msg->response_body->length;
59+ }
60
61 if (global_dialog == NULL) {
62 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
63@@ -281,7 +295,7 @@ cb_lookup_timezone(SoupSession *session,
64 }
65
66 xml_tz = (xml_timezone *)
67- parse_xml_document(msg, (XmlParseFunc) parse_timezone);
68+ parse_xml_document(body, len, (XmlParseFunc) parse_timezone);
69 weather_dump(weather_dump_timezone, xml_tz);
70
71 if (xml_tz) {
72diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
73index d53a2bc..28934c4 100644
74--- a/panel-plugin/weather-parsers.c
75+++ b/panel-plugin/weather-parsers.c
76@@ -791,49 +791,51 @@ parse_timezone(xmlNode *cur_node)
77
78
79 xmlDoc *
80-get_xml_document(SoupMessage *msg)
81+get_xml_document(const gchar *data, gsize len)
82 {
83- if (G_LIKELY(msg && msg->response_body && msg->response_body->data)) {
84- if (g_utf8_validate(msg->response_body->data, -1, NULL)) {
85+ if (G_LIKELY(data && len)) {
86+ if (g_utf8_validate(data, len, NULL)) {
87 /* force parsing as UTF-8, the XML encoding header may lie */
88- return xmlReadMemory(msg->response_body->data,
89- strlen(msg->response_body->data),
90+ return xmlReadMemory(data, len,
91 NULL, "UTF-8", 0);
92 } else {
93- return xmlParseMemory(msg->response_body->data,
94- strlen(msg->response_body->data));
95+ return xmlParseMemory(data, len);
96 }
97 }
98 return NULL;
99 }
100
101 json_object *
102-get_json_tree(SoupMessage *msg)
103+get_json_tree(const gchar *data, gsize len)
104 {
105 json_object *res=NULL;
106- enum json_tokener_error err;
107+ struct json_tokener *tok = json_tokener_new();
108
109- if (G_LIKELY(msg && msg->response_body && msg->response_body->data)) {
110- res = json_tokener_parse_verbose(msg->response_body->data, &err);
111- if (err != json_tokener_success)
112- g_warning("get_json_tree: error =%d",err);
113+ if (G_UNLIKELY(tok == NULL)) {
114+ return NULL;
115+ } else if (G_LIKELY(data && len)) {
116+ res = json_tokener_parse_ex(tok, data, len);
117+ if (res == NULL)
118+ g_warning("get_json_tree: error =%d",
119+ json_tokener_get_error(tok));
120 }
121+ json_tokener_free(tok);
122 return res;
123 }
124
125 gpointer
126-parse_xml_document(SoupMessage *msg,
127+parse_xml_document(const gchar *data, gsize len,
128 XmlParseFunc parse_func)
129 {
130 xmlDoc *doc;
131 xmlNode *root_node;
132 gpointer user_data = NULL;
133
134- g_assert(msg != NULL);
135- if (G_UNLIKELY(msg == NULL))
136+ g_assert(data != NULL);
137+ if (G_UNLIKELY(data == NULL || len == 0))
138 return NULL;
139
140- doc = get_xml_document(msg);
141+ doc = get_xml_document(data, len);
142 if (G_LIKELY(doc)) {
143 root_node = xmlDocGetRootElement(doc);
144 if (G_LIKELY(root_node))
145diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
146index a9d019d..09b9c02 100644
147--- a/panel-plugin/weather-parsers.h
148+++ b/panel-plugin/weather-parsers.h
149@@ -22,7 +22,6 @@
150 #include <glib.h>
151 #include <gtk/gtk.h>
152 #include <libxml/parser.h>
153-#include <libsoup/soup.h>
154 #include <json-c/json_tokener.h>
155
156 #define DATA_EXPIRY_TIME (24 * 3600)
157@@ -157,11 +156,11 @@ xml_astro *get_astro(const GArray *astrodata,
158 const time_t day_t,
159 guint *index);
160
161-xmlDoc *get_xml_document(SoupMessage *msg);
162+xmlDoc *get_xml_document(const gchar *data, gsize len);
163
164-json_object *get_json_tree(SoupMessage *msg);
165+json_object *get_json_tree(const gchar *data, gsize len);
166
167-gpointer parse_xml_document(SoupMessage *msg,
168+gpointer parse_xml_document(const gchar *data, gsize len,
169 XmlParseFunc parse_func);
170
171 xml_astro *xml_astro_copy(const xml_astro *src);
172diff --git a/panel-plugin/weather-search.c b/panel-plugin/weather-search.c
173index 7e87ae8..6a2ba1f 100644
174--- a/panel-plugin/weather-search.c
175+++ b/panel-plugin/weather-search.c
176@@ -89,6 +89,13 @@ cb_searchdone(SoupSession *session,
177 gint found = 0;
178 GtkTreeIter iter;
179 GtkTreeSelection *selection;
180+ const gchar *body = NULL;
181+ gsize len = 0;
182+
183+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
184+ body = msg->response_body->data;
185+ len = msg->response_body->length;
186+ }
187
188 if (global_dialog == NULL) {
189 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
190@@ -97,7 +104,7 @@ cb_searchdone(SoupSession *session,
191
192 gtk_widget_set_sensitive(dialog->find_button, TRUE);
193
194- doc = get_xml_document(msg);
195+ doc = get_xml_document(body, len);
196 if (!doc)
197 return;
198
199@@ -385,6 +392,13 @@ cb_geolocation(SoupSession *session,
200 xml_geolocation *geo;
201 gchar *full_loc;
202 units_config *units;
203+ const gchar *body = NULL;
204+ gsize len = 0;
205+
206+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
207+ body = msg->response_body->data;
208+ len = msg->response_body->length;
209+ }
210
211 if (global_dialog == NULL) {
212 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
213@@ -392,7 +406,7 @@ cb_geolocation(SoupSession *session,
214 }
215
216 geo = (xml_geolocation *)
217- parse_xml_document(msg, (XmlParseFunc) parse_geolocation);
218+ parse_xml_document(body, len, (XmlParseFunc) parse_geolocation);
219 weather_dump(weather_dump_geolocation, geo);
220
221 if (!geo) {
222diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
223index 0a92b4e..b75c633 100644
224--- a/panel-plugin/weather.c
225+++ b/panel-plugin/weather.c
226@@ -489,11 +489,17 @@ cb_astro_update_sun(SoupSession *session,
227 json_object *json_tree;
228 time_t now_t;
229 guint astro_forecast_days;
230+ const gchar *body = NULL;
231+ gsize len = 0;
232
233 data->msg_parse->sun_msg_processed++;
234 data->astro_update->http_status_code = msg->status_code;
235 if ((msg->status_code == 200 || msg->status_code == 203)) {
236- json_tree = get_json_tree(msg);
237+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
238+ body = msg->response_body->data;
239+ len = msg->response_body->length;
240+ }
241+ json_tree = get_json_tree(body, len);
242 if (G_LIKELY(json_tree)) {
243 if (!parse_astrodata_sun(json_tree, data->astrodata)) {
244 data->msg_parse->sun_msg_parse_error++;
245@@ -545,11 +551,17 @@ cb_astro_update_moon(SoupSession *session,
246 json_object *json_tree;
247 time_t now_t;
248 guint astro_forecast_days;
249+ const gchar *body = NULL;
250+ gsize len = 0;
251
252 data->msg_parse->moon_msg_processed++;
253 data->astro_update->http_status_code = msg->status_code;
254 if ((msg->status_code == 200 || msg->status_code == 203)) {
255- json_tree = get_json_tree(msg);
256+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
257+ body = msg->response_body->data;
258+ len = msg->response_body->length;
259+ }
260+ json_tree = get_json_tree(body, len);
261 if (G_LIKELY(json_tree)) {
262 if (!parse_astrodata_moon(json_tree, data->astrodata)) {
263 data->msg_parse->moon_msg_parse_error++;
264@@ -606,17 +618,23 @@ cb_weather_update(SoupSession *session,
265 gpointer user_data)
266 {
267 plugin_data *data = user_data;
268- xmlDoc *doc;
269+ xmlDoc *doc = NULL;
270 xmlNode *root_node;
271 time_t now_t;
272 gboolean parsing_error = TRUE;
273+ const gchar *body = NULL;
274+ gsize len = 0;
275
276 weather_debug("Processing downloaded weather data.");
277 time(&now_t);
278 data->weather_update->attempt++;
279 data->weather_update->http_status_code = msg->status_code;
280 if (msg->status_code == 200 || msg->status_code == 203) {
281- doc = get_xml_document(msg);
282+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
283+ body = msg->response_body->data;
284+ len = msg->response_body->length;
285+ }
286+ doc = get_xml_document(body, len);
287 if (G_LIKELY(doc)) {
288 root_node = xmlDocGetRootElement(doc);
289 if (G_LIKELY(root_node))
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0003-libsoup-Port-to-libsoup-3.0.patch b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0003-libsoup-Port-to-libsoup-3.0.patch
deleted file mode 100644
index 3970df672b..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0003-libsoup-Port-to-libsoup-3.0.patch
+++ /dev/null
@@ -1,563 +0,0 @@
1From 05b3ab7c755d7a6667852576ed11944304acdd4a Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
3 <congdanhqx@gmail.com>
4Date: Fri, 1 Mar 2024 21:56:34 +0700
5Subject: [PATCH 3/5] libsoup: Port to libsoup-3.0
6
7Upstream-Status: Backport [https://github.com/xfce-mirror/xfce4-weather-plugin/commit/05b3ab7c755d7a6667852576ed11944304acdd4a]
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 README | 4 +-
11 configure.ac | 2 +-
12 panel-plugin/weather-config.c | 32 ++++---
13 panel-plugin/weather-search.c | 37 ++++++---
14 panel-plugin/weather-summary.c | 23 ++++--
15 panel-plugin/weather.c | 147 +++++++++++++++------------------
16 panel-plugin/weather.h | 2 +-
17 7 files changed, 132 insertions(+), 115 deletions(-)
18
19diff --git a/README b/README
20index 6587581..3530b1f 100644
21--- a/README
22+++ b/README
23@@ -152,10 +152,10 @@ using gdb or any other debugger should the plugin crash:
24 BUILD REQUIREMENTS AND DEPENDENCIES
25 ==========================================================================
26 To be able to build the plugin, the following requirements have to be
27-met in addition to those of XFCE-4.14:
28+met in addition to those of XFCE-4.16:
29
30 * >=libxml-2.4.0
31-* >=libsoup-2.42.0
32+* >=libsoup-3.0.0
33 * >=upower-0.9.0 (optional)
34
35 You might also need developer libraries necessary for building other
36diff --git a/configure.ac b/configure.ac
37index cf82b7e..15e8b46 100644
38--- a/configure.ac
39+++ b/configure.ac
40@@ -70,7 +70,7 @@ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.16.0])
41 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.14.0])
42 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
43 XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
44-XDT_CHECK_PACKAGE([SOUP], [libsoup-2.4], [2.42.0])
45+XDT_CHECK_PACKAGE([SOUP], [libsoup-3.0], [3.0.0])
46 XDT_CHECK_PACKAGE([JSON], [json-c], [0.13.1])
47 XDT_CHECK_OPTIONAL_PACKAGE([UPOWER_GLIB], [upower-glib], [0.9.0], [upower],
48 [upower for adapting update interval to power state])
49diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
50index 19fa1d8..d27c825 100644
51--- a/panel-plugin/weather-config.c
52+++ b/panel-plugin/weather-config.c
53@@ -238,8 +238,8 @@ sanitize_location_name(const gchar *location_name)
54
55
56 static void
57-cb_lookup_altitude(SoupSession *session,
58- SoupMessage *msg,
59+cb_lookup_altitude(GObject *source,
60+ GAsyncResult *result,
61 gpointer user_data)
62 {
63 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
64@@ -247,11 +247,14 @@ cb_lookup_altitude(SoupSession *session,
65 gdouble alt = 0;
66 const gchar *body = NULL;
67 gsize len = 0;
68+ GError *error = NULL;
69+ GBytes *response =
70+ soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
71
72- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
73- body = msg->response_body->data;
74- len = msg->response_body->length;
75- }
76+ if (G_UNLIKELY(error))
77+ g_error_free(error);
78+ else
79+ body = g_bytes_get_data(response, &len);
80
81 if (global_dialog == NULL) {
82 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
83@@ -271,23 +274,27 @@ cb_lookup_altitude(SoupSession *session,
84 else if (dialog->pd->units->altitude == FEET)
85 alt /= 0.3048;
86 gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->spin_alt), alt);
87+ g_bytes_unref(response);
88 }
89
90
91 static void
92-cb_lookup_timezone(SoupSession *session,
93- SoupMessage *msg,
94+cb_lookup_timezone(GObject *source,
95+ GAsyncResult *result,
96 gpointer user_data)
97 {
98 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
99 xml_timezone *xml_tz;
100 const gchar *body = NULL;
101 gsize len = 0;
102+ GError *error = NULL;
103+ GBytes *response =
104+ soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
105
106- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
107- body = msg->response_body->data;
108- len = msg->response_body->length;
109- }
110+ if (G_UNLIKELY(error))
111+ g_error_free(error);
112+ else
113+ body = g_bytes_get_data(response, &len);
114
115 if (global_dialog == NULL) {
116 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
117@@ -304,6 +311,7 @@ cb_lookup_timezone(SoupSession *session,
118 xml_timezone_free(xml_tz);
119 } else
120 gtk_entry_set_text(GTK_ENTRY(dialog->text_timezone), "");
121+ g_bytes_unref(response);
122 }
123
124
125diff --git a/panel-plugin/weather-search.c b/panel-plugin/weather-search.c
126index 6a2ba1f..e030ff8 100644
127--- a/panel-plugin/weather-search.c
128+++ b/panel-plugin/weather-search.c
129@@ -78,8 +78,8 @@ sanitize_str(const gchar *str)
130
131
132 static void
133-cb_searchdone(SoupSession *session,
134- SoupMessage *msg,
135+cb_searchdone(GObject *source,
136+ GAsyncResult *result,
137 gpointer user_data)
138 {
139 search_dialog *dialog = (search_dialog *) user_data;
140@@ -91,11 +91,14 @@ cb_searchdone(SoupSession *session,
141 GtkTreeSelection *selection;
142 const gchar *body = NULL;
143 gsize len = 0;
144+ GError *error = NULL;
145+ GBytes *response =
146+ soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
147
148- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
149- body = msg->response_body->data;
150- len = msg->response_body->length;
151- }
152+ if (G_UNLIKELY(error))
153+ g_error_free(error);
154+ else
155+ body = g_bytes_get_data(response, &len);
156
157 if (global_dialog == NULL) {
158 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
159@@ -105,8 +108,10 @@ cb_searchdone(SoupSession *session,
160 gtk_widget_set_sensitive(dialog->find_button, TRUE);
161
162 doc = get_xml_document(body, len);
163- if (!doc)
164+ if (!doc) {
165+ g_bytes_unref(response);
166 return;
167+ }
168
169 cur_node = xmlDocGetRootElement(doc);
170 if (cur_node) {
171@@ -140,6 +145,7 @@ cb_searchdone(SoupSession *session,
172 }
173
174 gtk_tree_view_column_set_title(dialog->column, _("Results"));
175+ g_bytes_unref(response);
176 }
177
178
179@@ -384,8 +390,8 @@ get_preferred_units(const gchar *country_code)
180
181
182 static void
183-cb_geolocation(SoupSession *session,
184- SoupMessage *msg,
185+cb_geolocation(GObject *source,
186+ GAsyncResult *result,
187 gpointer user_data)
188 {
189 geolocation_data *data = (geolocation_data *) user_data;
190@@ -394,11 +400,14 @@ cb_geolocation(SoupSession *session,
191 units_config *units;
192 const gchar *body = NULL;
193 gsize len = 0;
194+ GError *error = NULL;
195+ GBytes *response =
196+ soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
197
198- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
199- body = msg->response_body->data;
200- len = msg->response_body->length;
201- }
202+ if (G_UNLIKELY(error))
203+ g_error_free(error);
204+ else
205+ body = g_bytes_get_data(response, &len);
206
207 if (global_dialog == NULL) {
208 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
209@@ -411,6 +420,7 @@ cb_geolocation(SoupSession *session,
210
211 if (!geo) {
212 data->cb(NULL, NULL, NULL, NULL, data->user_data);
213+ g_bytes_unref(response);
214 g_free(data);
215 return;
216 }
217@@ -441,6 +451,7 @@ cb_geolocation(SoupSession *session,
218 g_slice_free(units_config, units);
219 xml_geolocation_free(geo);
220 g_free(full_loc);
221+ g_bytes_unref(response);
222 g_free(data);
223 }
224
225diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
226index a6a2f56..224bb34 100644
227--- a/panel-plugin/weather-summary.c
228+++ b/panel-plugin/weather-summary.c
229@@ -234,22 +234,29 @@ get_logo_path(void)
230
231
232 static void
233-logo_fetched(SoupSession *session,
234- SoupMessage *msg,
235+logo_fetched(GObject *source,
236+ GAsyncResult *result,
237 gpointer user_data)
238 {
239- if (msg && msg->response_body && msg->response_body->length > 0) {
240+ GError *error = NULL;
241+ GBytes *response =
242+ soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
243+
244+ if (G_LIKELY(error == NULL)) {
245+ gsize len = 0;
246+ const gchar *body = g_bytes_get_data(response, &len);
247 gchar *path = get_logo_path();
248- GError *error = NULL;
249 GdkPixbuf *pixbuf = NULL;
250 gint scale_factor;
251- if (!g_file_set_contents(path, msg->response_body->data,
252- msg->response_body->length, &error)) {
253+ g_file_set_contents(path, body, len, &error);
254+ g_bytes_unref(response);
255+ if (error) {
256 g_warning("Error downloading met.no logo image to %s, "
257 "reason: %s\n", path,
258 error ? error->message : "unknown");
259 g_error_free(error);
260 g_free(path);
261+ g_bytes_unref(response);
262 return;
263 }
264 scale_factor = gtk_widget_get_scale_factor(user_data);
265@@ -261,7 +268,9 @@ logo_fetched(SoupSession *session,
266 cairo_surface_destroy(surface);
267 g_object_unref(pixbuf);
268 }
269- }
270+ g_bytes_unref(response);
271+ } else
272+ g_error_free(error);
273 }
274
275
276diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
277index b75c633..1a84537 100644
278--- a/panel-plugin/weather.c
279+++ b/panel-plugin/weather.c
280@@ -23,6 +23,8 @@
281 #include <string.h>
282 #include <sys/stat.h>
283
284+#include <glib.h>
285+
286 #include <libxfce4util/libxfce4util.h>
287 #include <libxfce4ui/libxfce4ui.h>
288 #include <xfconf/xfconf.h>
289@@ -106,13 +108,14 @@ static void schedule_next_wakeup(plugin_data *data);
290 void
291 weather_http_queue_request(SoupSession *session,
292 const gchar *uri,
293- SoupSessionCallback callback_func,
294+ GAsyncReadyCallback callback_func,
295 gpointer user_data)
296 {
297 SoupMessage *msg;
298
299 msg = soup_message_new("GET", uri);
300- soup_session_queue_message(session, msg, callback_func, user_data);
301+ soup_session_send_and_read_async(session, msg, G_PRIORITY_DEFAULT, NULL,
302+ callback_func, user_data);
303 }
304
305
306@@ -481,8 +484,8 @@ calc_next_download_time(const update_info *upi,
307 * Process downloaded sun astro data and schedule next astro update.
308 */
309 static void
310-cb_astro_update_sun(SoupSession *session,
311- SoupMessage *msg,
312+cb_astro_update_sun(GObject *source,
313+ GAsyncResult *result,
314 gpointer user_data)
315 {
316 plugin_data *data = user_data;
317@@ -491,14 +494,17 @@ cb_astro_update_sun(SoupSession *session,
318 guint astro_forecast_days;
319 const gchar *body = NULL;
320 gsize len = 0;
321+ SoupMessage *msg;
322+ GError *error = NULL;
323+ GBytes *response;
324
325+ msg = soup_session_get_async_result_message(SOUP_SESSION(source), result);
326 data->msg_parse->sun_msg_processed++;
327- data->astro_update->http_status_code = msg->status_code;
328- if ((msg->status_code == 200 || msg->status_code == 203)) {
329- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
330- body = msg->response_body->data;
331- len = msg->response_body->length;
332- }
333+ data->astro_update->http_status_code = soup_message_get_status(msg);
334+ response = soup_session_send_and_read_finish(SOUP_SESSION(source),
335+ result, &error);
336+ if (G_LIKELY(error == NULL)) {
337+ body = g_bytes_get_data(response, &len);
338 json_tree = get_json_tree(body, len);
339 if (G_LIKELY(json_tree)) {
340 if (!parse_astrodata_sun(json_tree, data->astrodata)) {
341@@ -514,10 +520,12 @@ cb_astro_update_sun(SoupSession *session,
342 g_warning("Error parsing sun astronomical data!");
343 weather_debug("No json_tree");
344 }
345+ g_bytes_unref(response);
346 } else {
347 data->msg_parse->http_msg_fail = TRUE;
348- g_warning_once("Download of sun astronomical data failed with HTTP Status Code %d, Reason phrase: %s",
349- msg->status_code, msg->reason_phrase);
350+ g_warning_once("Download of sun astronomical data failed: %s",
351+ error->message);
352+ g_error_free(error);
353 }
354
355 astro_forecast_days = data->forecast_days + 1;
356@@ -543,8 +551,8 @@ cb_astro_update_sun(SoupSession *session,
357 * Process downloaded moon astro data and schedule next astro update.
358 */
359 static void
360-cb_astro_update_moon(SoupSession *session,
361- SoupMessage *msg,
362+cb_astro_update_moon(GObject *source,
363+ GAsyncResult *result,
364 gpointer user_data)
365 {
366 plugin_data *data = user_data;
367@@ -553,14 +561,17 @@ cb_astro_update_moon(SoupSession *session,
368 guint astro_forecast_days;
369 const gchar *body = NULL;
370 gsize len = 0;
371+ SoupMessage *msg;
372+ GError *error = NULL;
373+ GBytes *response;
374
375+ response = soup_session_send_and_read_finish(SOUP_SESSION(source),
376+ result, &error);
377+ msg = soup_session_get_async_result_message(SOUP_SESSION(source), result);
378 data->msg_parse->moon_msg_processed++;
379- data->astro_update->http_status_code = msg->status_code;
380- if ((msg->status_code == 200 || msg->status_code == 203)) {
381- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
382- body = msg->response_body->data;
383- len = msg->response_body->length;
384- }
385+ data->astro_update->http_status_code = soup_message_get_status(msg);
386+ if (G_LIKELY(error == NULL)) {
387+ body = g_bytes_get_data(response, &len);
388 json_tree = get_json_tree(body, len);
389 if (G_LIKELY(json_tree)) {
390 if (!parse_astrodata_moon(json_tree, data->astrodata)) {
391@@ -576,10 +587,12 @@ cb_astro_update_moon(SoupSession *session,
392 g_warning("Error parsing moon astronomical data");
393 weather_debug("No json_tree");
394 }
395+ g_bytes_unref(response);
396 } else {
397 data->msg_parse->http_msg_fail = TRUE;
398- g_warning_once("Download of moon astronomical data failed with HTTP Status Code %d, Reason phrase: %s",
399- msg->status_code, msg->reason_phrase);
400+ g_warning_once("Download of moon astronomical data failed: %s",
401+ error->message);
402+ g_error_free(error);
403 }
404
405 astro_forecast_days = data->forecast_days + 1;
406@@ -613,8 +626,8 @@ cb_astro_update_moon(SoupSession *session,
407 * Process downloaded weather data and schedule next weather update.
408 */
409 static void
410-cb_weather_update(SoupSession *session,
411- SoupMessage *msg,
412+cb_weather_update(GObject *source,
413+ GAsyncResult *result,
414 gpointer user_data)
415 {
416 plugin_data *data = user_data;
417@@ -624,16 +637,19 @@ cb_weather_update(SoupSession *session,
418 gboolean parsing_error = TRUE;
419 const gchar *body = NULL;
420 gsize len = 0;
421+ SoupMessage *msg;
422+ GError *error = NULL;
423+ GBytes *response = NULL;
424
425 weather_debug("Processing downloaded weather data.");
426+ response = soup_session_send_and_read_finish(SOUP_SESSION(source),
427+ result, &error);
428+ msg = soup_session_get_async_result_message(SOUP_SESSION(source), result);
429 time(&now_t);
430 data->weather_update->attempt++;
431- data->weather_update->http_status_code = msg->status_code;
432- if (msg->status_code == 200 || msg->status_code == 203) {
433- if (G_LIKELY(msg->response_body && msg->response_body->data)) {
434- body = msg->response_body->data;
435- len = msg->response_body->length;
436- }
437+ data->weather_update->http_status_code = soup_message_get_status(msg);
438+ if (G_LIKELY(error == NULL)) {
439+ body = g_bytes_get_data(response, &len);
440 doc = get_xml_document(body, len);
441 if (G_LIKELY(doc)) {
442 root_node = xmlDocGetRootElement(doc);
443@@ -645,12 +661,13 @@ cb_weather_update(SoupSession *session,
444 }
445 xmlFreeDoc(doc);
446 }
447+ g_bytes_unref(response);
448 if (parsing_error)
449 g_warning("Error parsing weather data!");
450- } else
451- weather_debug
452- ("Download of weather data failed with HTTP Status Code %d, "
453- "Reason phrase: %s", msg->status_code, msg->reason_phrase);
454+ } else {
455+ weather_debug("Download of weather data failed: %s", error->message);
456+ g_error_free(error);
457+ }
458 data->weather_update->next = calc_next_download_time(data->weather_update,
459 now_t);
460
461@@ -1708,32 +1725,6 @@ mi_click(GtkWidget *widget,
462 update_weatherdata_with_reset(data);
463 }
464
465-static void
466-proxy_auth(SoupSession *session,
467- SoupMessage *msg,
468- SoupAuth *auth,
469- gboolean retrying,
470- gpointer user_data)
471-{
472- SoupURI *soup_proxy_uri;
473- const gchar *proxy_uri;
474-
475- if (!retrying) {
476- if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
477- proxy_uri = g_getenv("HTTP_PROXY");
478- if (!proxy_uri)
479- proxy_uri = g_getenv("http_proxy");
480- if (proxy_uri) {
481- soup_proxy_uri = soup_uri_new(proxy_uri);
482- soup_auth_authenticate(auth,
483- soup_uri_get_user(soup_proxy_uri),
484- soup_uri_get_password(soup_proxy_uri));
485- soup_uri_free(soup_proxy_uri);
486- }
487- }
488- }
489-}
490-
491
492 #ifdef HAVE_UPOWER_GLIB
493 static void
494@@ -2037,9 +2028,10 @@ static plugin_data *
495 xfceweather_create_control(XfcePanelPlugin *plugin)
496 {
497 plugin_data *data = g_slice_new0(plugin_data);
498- SoupURI *soup_proxy_uri;
499+ GProxyResolver *proxy_resolver;
500 const gchar *proxy_uri;
501- const gchar *proxy_user;
502+ const gchar *no_proxy;
503+ gchar **no_proxy_lst = NULL;
504 GtkWidget *refresh;
505 cairo_surface_t *icon = NULL;
506 data_types lbl;
507@@ -2077,29 +2069,26 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
508
509 /* Setup session for HTTP connections */
510 data->session = soup_session_new();
511- g_object_set(data->session, SOUP_SESSION_USER_AGENT,
512- PACKAGE_NAME "-" PACKAGE_VERSION, NULL);
513- g_object_set(data->session, SOUP_SESSION_TIMEOUT,
514- CONN_TIMEOUT, NULL);
515+ soup_session_set_user_agent(data->session,
516+ PACKAGE_NAME "-" PACKAGE_VERSION);
517+ soup_session_set_timeout(data->session, CONN_TIMEOUT);
518
519 /* Set the proxy URI from environment */
520 proxy_uri = g_getenv("HTTP_PROXY");
521 if (!proxy_uri)
522 proxy_uri = g_getenv("http_proxy");
523 if (proxy_uri) {
524- soup_proxy_uri = soup_uri_new(proxy_uri);
525- g_object_set(data->session, SOUP_SESSION_PROXY_URI,
526- soup_proxy_uri, NULL);
527-
528- /* check if uri contains authentication info */
529- proxy_user = soup_uri_get_user(soup_proxy_uri);
530- if (proxy_user && strlen(proxy_user) > 0) {
531- g_signal_connect(G_OBJECT(data->session), "authenticate",
532- G_CALLBACK(proxy_auth), NULL);
533- }
534-
535- soup_uri_free(soup_proxy_uri);
536- }
537+ no_proxy = g_getenv("no_proxy");
538+ if (!no_proxy)
539+ no_proxy = g_getenv("NO_PROXY");
540+ if (no_proxy)
541+ no_proxy_lst = g_strsplit(no_proxy, ",", -1);
542+ proxy_resolver = g_simple_proxy_resolver_new(proxy_uri, no_proxy_lst);
543+ g_strfreev(no_proxy_lst);
544+ soup_session_set_proxy_resolver(data->session, proxy_resolver);
545+ g_object_unref(proxy_resolver);
546+ }
547+ /* Otherwise, g_proxy_resolver_get_default() will be used */
548
549 data->scrollbox = gtk_scrollbox_new();
550
551diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
552index 208de09..01974ce 100644
553--- a/panel-plugin/weather.h
554+++ b/panel-plugin/weather.h
555@@ -183,7 +183,7 @@ extern gboolean debug_mode;
556
557 void weather_http_queue_request(SoupSession *session,
558 const gchar *uri,
559- SoupSessionCallback callback_func,
560+ GAsyncReadyCallback callback_func,
561 gpointer user_data);
562
563 void scrollbox_set_visible(plugin_data *data);
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0004-Report-UPower-Glib-support.patch b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0004-Report-UPower-Glib-support.patch
deleted file mode 100644
index d7ee7b8135..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0004-Report-UPower-Glib-support.patch
+++ /dev/null
@@ -1,20 +0,0 @@
1From 34ac536970d2e9f3c3f8ffd691d6a8ef6f434b1a Mon Sep 17 00:00:00 2001
2From: Andrzej Radecki <andrzejr@xfce.org>
3Date: Sun, 10 Nov 2024 16:24:28 +0000
4Subject: [PATCH 4/5] Report UPower Glib support
5
6Upstream-Status: Submitted [Upstream-Status: Backport [https://github.com/xfce-mirror/xfce4-weather-plugin/commit/34ac536970d2e9f3c3f8ffd691d6a8ef6f434b1a]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 configure.ac | 1 +
10 1 file changed, 1 insertion(+)
11
12diff --git a/configure.ac b/configure.ac
13index 15e8b46..da98a5e 100644
14--- a/configure.ac
15+++ b/configure.ac
16@@ -120,3 +120,4 @@ echo
17 echo "Build Configuration:"
18 echo
19 echo "* Debug Support: $enable_debug"
20+echo "* UPower Glib Support: ${UPOWER_GLIB_FOUND:-no}"
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0005-Make-libsoup-v3-support-optional.patch b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0005-Make-libsoup-v3-support-optional.patch
deleted file mode 100644
index 46042154f9..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin/0005-Make-libsoup-v3-support-optional.patch
+++ /dev/null
@@ -1,626 +0,0 @@
1From 663c416c59ea8e063d4b5a181104f26e4bd1658c Mon Sep 17 00:00:00 2001
2From: Andrzej Radecki <andrzejr@xfce.org>
3Date: Sun, 10 Nov 2024 16:29:21 +0000
4Subject: [PATCH 5/5] Make libsoup v3 support optional
5
6The plugin still targets Xfce4.16 and its contemporary is libsoup-2.4.
7This commit is to be reverted when support for libsoup-2.4 is
8no longer needed as all the #if's make the libsoup code less maintainable.
9
10Upstream-Status: Submitted [Upstream-Status: Backport [https://github.com/xfce-mirror/xfce4-weather-plugin/commit/663c416c59ea8e063d4b5a181104f26e4bd1658c]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 configure.ac | 5 +-
14 panel-plugin/weather-config.c | 28 +++++++
15 panel-plugin/weather-search.c | 32 ++++++++
16 panel-plugin/weather-summary.c | 21 +++++
17 panel-plugin/weather.c | 140 ++++++++++++++++++++++++++++++++-
18 panel-plugin/weather.h | 4 +
19 6 files changed, 225 insertions(+), 5 deletions(-)
20
21diff --git a/configure.ac b/configure.ac
22index da98a5e..f60ad64 100644
23--- a/configure.ac
24+++ b/configure.ac
25@@ -70,7 +70,9 @@ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.16.0])
26 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.14.0])
27 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
28 XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
29-XDT_CHECK_PACKAGE([SOUP], [libsoup-3.0], [3.0.0])
30+dnl XDT_CHECK_PACKAGE([SOUP], [libsoup-3.0], [3.0.0])
31+XDT_CHECK_PACKAGE([SOUP], [libsoup-3.0], [3.0.0], [],
32+ [XDT_CHECK_PACKAGE([SOUP], [libsoup-2.4], [2.42.0])])
33 XDT_CHECK_PACKAGE([JSON], [json-c], [0.13.1])
34 XDT_CHECK_OPTIONAL_PACKAGE([UPOWER_GLIB], [upower-glib], [0.9.0], [upower],
35 [upower for adapting update interval to power state])
36@@ -121,3 +123,4 @@ echo "Build Configuration:"
37 echo
38 echo "* Debug Support: $enable_debug"
39 echo "* UPower Glib Support: ${UPOWER_GLIB_FOUND:-no}"
40+echo "* Soup Version: ${SOUP_VERSION:-no}"
41diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
42index d27c825..1035ddd 100644
43--- a/panel-plugin/weather-config.c
44+++ b/panel-plugin/weather-config.c
45@@ -238,8 +238,13 @@ sanitize_location_name(const gchar *location_name)
46
47
48 static void
49+#if SOUP_CHECK_VERSION(3, 0, 0)
50 cb_lookup_altitude(GObject *source,
51 GAsyncResult *result,
52+#else
53+cb_lookup_altitude(SoupSession *session,
54+ SoupMessage *msg,
55+#endif
56 gpointer user_data)
57 {
58 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
59@@ -247,6 +252,7 @@ cb_lookup_altitude(GObject *source,
60 gdouble alt = 0;
61 const gchar *body = NULL;
62 gsize len = 0;
63+#if SOUP_CHECK_VERSION(3, 0, 0)
64 GError *error = NULL;
65 GBytes *response =
66 soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
67@@ -255,6 +261,12 @@ cb_lookup_altitude(GObject *source,
68 g_error_free(error);
69 else
70 body = g_bytes_get_data(response, &len);
71+#else
72+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
73+ body = msg->response_body->data;
74+ len = msg->response_body->length;
75+ }
76+#endif
77
78 if (global_dialog == NULL) {
79 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
80@@ -274,19 +286,27 @@ cb_lookup_altitude(GObject *source,
81 else if (dialog->pd->units->altitude == FEET)
82 alt /= 0.3048;
83 gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->spin_alt), alt);
84+#if SOUP_CHECK_VERSION(3, 0, 0)
85 g_bytes_unref(response);
86+#endif
87 }
88
89
90 static void
91+#if SOUP_CHECK_VERSION(3, 0, 0)
92 cb_lookup_timezone(GObject *source,
93 GAsyncResult *result,
94+#else
95+cb_lookup_timezone(SoupSession *session,
96+ SoupMessage *msg,
97+#endif
98 gpointer user_data)
99 {
100 xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
101 xml_timezone *xml_tz;
102 const gchar *body = NULL;
103 gsize len = 0;
104+#if SOUP_CHECK_VERSION(3, 0, 0)
105 GError *error = NULL;
106 GBytes *response =
107 soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
108@@ -295,6 +315,12 @@ cb_lookup_timezone(GObject *source,
109 g_error_free(error);
110 else
111 body = g_bytes_get_data(response, &len);
112+#else
113+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
114+ body = msg->response_body->data;
115+ len = msg->response_body->length;
116+ }
117+#endif
118
119 if (global_dialog == NULL) {
120 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
121@@ -311,7 +337,9 @@ cb_lookup_timezone(GObject *source,
122 xml_timezone_free(xml_tz);
123 } else
124 gtk_entry_set_text(GTK_ENTRY(dialog->text_timezone), "");
125+#if SOUP_CHECK_VERSION(3, 0, 0)
126 g_bytes_unref(response);
127+#endif
128 }
129
130
131diff --git a/panel-plugin/weather-search.c b/panel-plugin/weather-search.c
132index e030ff8..b07627e 100644
133--- a/panel-plugin/weather-search.c
134+++ b/panel-plugin/weather-search.c
135@@ -78,8 +78,13 @@ sanitize_str(const gchar *str)
136
137
138 static void
139+#if SOUP_CHECK_VERSION(3, 0, 0)
140 cb_searchdone(GObject *source,
141 GAsyncResult *result,
142+#else
143+cb_searchdone(SoupSession *session,
144+ SoupMessage *msg,
145+#endif
146 gpointer user_data)
147 {
148 search_dialog *dialog = (search_dialog *) user_data;
149@@ -91,6 +96,7 @@ cb_searchdone(GObject *source,
150 GtkTreeSelection *selection;
151 const gchar *body = NULL;
152 gsize len = 0;
153+#if SOUP_CHECK_VERSION(3, 0, 0)
154 GError *error = NULL;
155 GBytes *response =
156 soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
157@@ -99,6 +105,12 @@ cb_searchdone(GObject *source,
158 g_error_free(error);
159 else
160 body = g_bytes_get_data(response, &len);
161+#else
162+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
163+ body = msg->response_body->data;
164+ len = msg->response_body->length;
165+ }
166+#endif
167
168 if (global_dialog == NULL) {
169 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
170@@ -109,7 +121,9 @@ cb_searchdone(GObject *source,
171
172 doc = get_xml_document(body, len);
173 if (!doc) {
174+#if SOUP_CHECK_VERSION(3, 0, 0)
175 g_bytes_unref(response);
176+#endif
177 return;
178 }
179
180@@ -145,7 +159,9 @@ cb_searchdone(GObject *source,
181 }
182
183 gtk_tree_view_column_set_title(dialog->column, _("Results"));
184+#if SOUP_CHECK_VERSION(3, 0, 0)
185 g_bytes_unref(response);
186+#endif
187 }
188
189
190@@ -390,8 +406,13 @@ get_preferred_units(const gchar *country_code)
191
192
193 static void
194+#if SOUP_CHECK_VERSION(3, 0, 0)
195 cb_geolocation(GObject *source,
196 GAsyncResult *result,
197+#else
198+cb_geolocation(SoupSession *session,
199+ SoupMessage *msg,
200+#endif
201 gpointer user_data)
202 {
203 geolocation_data *data = (geolocation_data *) user_data;
204@@ -400,6 +421,7 @@ cb_geolocation(GObject *source,
205 units_config *units;
206 const gchar *body = NULL;
207 gsize len = 0;
208+#if SOUP_CHECK_VERSION(3, 0, 0)
209 GError *error = NULL;
210 GBytes *response =
211 soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
212@@ -408,6 +430,12 @@ cb_geolocation(GObject *source,
213 g_error_free(error);
214 else
215 body = g_bytes_get_data(response, &len);
216+#else
217+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
218+ body = msg->response_body->data;
219+ len = msg->response_body->length;
220+ }
221+#endif
222
223 if (global_dialog == NULL) {
224 weather_debug("%s called after dialog was destroyed", G_STRFUNC);
225@@ -420,7 +448,9 @@ cb_geolocation(GObject *source,
226
227 if (!geo) {
228 data->cb(NULL, NULL, NULL, NULL, data->user_data);
229+#if SOUP_CHECK_VERSION(3, 0, 0)
230 g_bytes_unref(response);
231+#endif
232 g_free(data);
233 return;
234 }
235@@ -451,7 +481,9 @@ cb_geolocation(GObject *source,
236 g_slice_free(units_config, units);
237 xml_geolocation_free(geo);
238 g_free(full_loc);
239+#if SOUP_CHECK_VERSION(3, 0, 0)
240 g_bytes_unref(response);
241+#endif
242 g_free(data);
243 }
244
245diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
246index 224bb34..8e79b0a 100644
247--- a/panel-plugin/weather-summary.c
248+++ b/panel-plugin/weather-summary.c
249@@ -234,10 +234,16 @@ get_logo_path(void)
250
251
252 static void
253+#if SOUP_CHECK_VERSION(3, 0, 0)
254 logo_fetched(GObject *source,
255 GAsyncResult *result,
256+#else
257+logo_fetched(SoupSession *session,
258+ SoupMessage *msg,
259+#endif
260 gpointer user_data)
261 {
262+#if SOUP_CHECK_VERSION(3, 0, 0)
263 GError *error = NULL;
264 GBytes *response =
265 soup_session_send_and_read_finish(SOUP_SESSION(source), result, &error);
266@@ -251,12 +257,23 @@ logo_fetched(GObject *source,
267 g_file_set_contents(path, body, len, &error);
268 g_bytes_unref(response);
269 if (error) {
270+#else
271+ if (msg && msg->response_body && msg->response_body->length > 0) {
272+ gchar *path = get_logo_path();
273+ GError *error = NULL;
274+ GdkPixbuf *pixbuf = NULL;
275+ gint scale_factor;
276+ if (!g_file_set_contents(path, msg->response_body->data,
277+ msg->response_body->length, &error)) {
278+#endif
279 g_warning("Error downloading met.no logo image to %s, "
280 "reason: %s\n", path,
281 error ? error->message : "unknown");
282 g_error_free(error);
283 g_free(path);
284+#if SOUP_CHECK_VERSION(3, 0, 0)
285 g_bytes_unref(response);
286+#endif
287 return;
288 }
289 scale_factor = gtk_widget_get_scale_factor(user_data);
290@@ -268,9 +285,13 @@ logo_fetched(GObject *source,
291 cairo_surface_destroy(surface);
292 g_object_unref(pixbuf);
293 }
294+#if SOUP_CHECK_VERSION(3, 0, 0)
295 g_bytes_unref(response);
296 } else
297 g_error_free(error);
298+#else
299+ }
300+#endif
301 }
302
303
304diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
305index 1a84537..db123fa 100644
306--- a/panel-plugin/weather.c
307+++ b/panel-plugin/weather.c
308@@ -108,14 +108,22 @@ static void schedule_next_wakeup(plugin_data *data);
309 void
310 weather_http_queue_request(SoupSession *session,
311 const gchar *uri,
312+#if SOUP_CHECK_VERSION(3, 0, 0)
313 GAsyncReadyCallback callback_func,
314+#else
315+ SoupSessionCallback callback_func,
316+#endif
317 gpointer user_data)
318 {
319 SoupMessage *msg;
320
321 msg = soup_message_new("GET", uri);
322+#if SOUP_CHECK_VERSION(3, 0, 0)
323 soup_session_send_and_read_async(session, msg, G_PRIORITY_DEFAULT, NULL,
324 callback_func, user_data);
325+#else
326+ soup_session_queue_message(session, msg, callback_func, user_data);
327+#endif
328 }
329
330
331@@ -484,8 +492,13 @@ calc_next_download_time(const update_info *upi,
332 * Process downloaded sun astro data and schedule next astro update.
333 */
334 static void
335+#if SOUP_CHECK_VERSION(3, 0, 0)
336 cb_astro_update_sun(GObject *source,
337 GAsyncResult *result,
338+#else
339+cb_astro_update_sun(SoupSession *session,
340+ SoupMessage *msg,
341+#endif
342 gpointer user_data)
343 {
344 plugin_data *data = user_data;
345@@ -494,6 +507,7 @@ cb_astro_update_sun(GObject *source,
346 guint astro_forecast_days;
347 const gchar *body = NULL;
348 gsize len = 0;
349+#if SOUP_CHECK_VERSION(3, 0, 0)
350 SoupMessage *msg;
351 GError *error = NULL;
352 GBytes *response;
353@@ -505,6 +519,15 @@ cb_astro_update_sun(GObject *source,
354 result, &error);
355 if (G_LIKELY(error == NULL)) {
356 body = g_bytes_get_data(response, &len);
357+#else
358+ data->msg_parse->sun_msg_processed++;
359+ data->astro_update->http_status_code = msg->status_code;
360+ if ((msg->status_code == 200 || msg->status_code == 203)) {
361+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
362+ body = msg->response_body->data;
363+ len = msg->response_body->length;
364+ }
365+#endif
366 json_tree = get_json_tree(body, len);
367 if (G_LIKELY(json_tree)) {
368 if (!parse_astrodata_sun(json_tree, data->astrodata)) {
369@@ -520,12 +543,19 @@ cb_astro_update_sun(GObject *source,
370 g_warning("Error parsing sun astronomical data!");
371 weather_debug("No json_tree");
372 }
373+#if SOUP_CHECK_VERSION(3, 0, 0)
374 g_bytes_unref(response);
375- } else {
376+#endif
377+ } else {
378 data->msg_parse->http_msg_fail = TRUE;
379+#if SOUP_CHECK_VERSION(3, 0, 0)
380 g_warning_once("Download of sun astronomical data failed: %s",
381 error->message);
382 g_error_free(error);
383+#else
384+ g_warning_once("Download of sun astronomical data failed with HTTP Status Code %d, Reason phrase: %s",
385+ msg->status_code, msg->reason_phrase);
386+#endif
387 }
388
389 astro_forecast_days = data->forecast_days + 1;
390@@ -551,8 +581,13 @@ cb_astro_update_sun(GObject *source,
391 * Process downloaded moon astro data and schedule next astro update.
392 */
393 static void
394+#if SOUP_CHECK_VERSION(3, 0, 0)
395 cb_astro_update_moon(GObject *source,
396 GAsyncResult *result,
397+#else
398+cb_astro_update_moon(SoupSession *session,
399+ SoupMessage *msg,
400+#endif
401 gpointer user_data)
402 {
403 plugin_data *data = user_data;
404@@ -561,6 +596,7 @@ cb_astro_update_moon(GObject *source,
405 guint astro_forecast_days;
406 const gchar *body = NULL;
407 gsize len = 0;
408+#if SOUP_CHECK_VERSION(3, 0, 0)
409 SoupMessage *msg;
410 GError *error = NULL;
411 GBytes *response;
412@@ -572,6 +608,15 @@ cb_astro_update_moon(GObject *source,
413 data->astro_update->http_status_code = soup_message_get_status(msg);
414 if (G_LIKELY(error == NULL)) {
415 body = g_bytes_get_data(response, &len);
416+#else
417+ data->msg_parse->moon_msg_processed++;
418+ data->astro_update->http_status_code = msg->status_code;
419+ if ((msg->status_code == 200 || msg->status_code == 203)) {
420+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
421+ body = msg->response_body->data;
422+ len = msg->response_body->length;
423+ }
424+#endif
425 json_tree = get_json_tree(body, len);
426 if (G_LIKELY(json_tree)) {
427 if (!parse_astrodata_moon(json_tree, data->astrodata)) {
428@@ -587,13 +632,20 @@ cb_astro_update_moon(GObject *source,
429 g_warning("Error parsing moon astronomical data");
430 weather_debug("No json_tree");
431 }
432+#if SOUP_CHECK_VERSION(3, 0, 0)
433 g_bytes_unref(response);
434- } else {
435+#endif
436+ } else {
437 data->msg_parse->http_msg_fail = TRUE;
438+#if SOUP_CHECK_VERSION(3, 0, 0)
439 g_warning_once("Download of moon astronomical data failed: %s",
440 error->message);
441 g_error_free(error);
442- }
443+#else
444+ g_warning_once("Download of moon astronomical data failed with HTTP Status Code %d, Reason phrase: %s",
445+ msg->status_code, msg->reason_phrase);
446+#endif
447+ }
448
449 astro_forecast_days = data->forecast_days + 1;
450 if (data->msg_parse->sun_msg_processed == astro_forecast_days && data->msg_parse->moon_msg_processed == astro_forecast_days) {
451@@ -626,8 +678,13 @@ cb_astro_update_moon(GObject *source,
452 * Process downloaded weather data and schedule next weather update.
453 */
454 static void
455+#if SOUP_CHECK_VERSION(3, 0, 0)
456 cb_weather_update(GObject *source,
457 GAsyncResult *result,
458+#else
459+cb_weather_update(SoupSession *session,
460+ SoupMessage *msg,
461+#endif
462 gpointer user_data)
463 {
464 plugin_data *data = user_data;
465@@ -637,6 +694,7 @@ cb_weather_update(GObject *source,
466 gboolean parsing_error = TRUE;
467 const gchar *body = NULL;
468 gsize len = 0;
469+#if SOUP_CHECK_VERSION(3, 0, 0)
470 SoupMessage *msg;
471 GError *error = NULL;
472 GBytes *response = NULL;
473@@ -650,6 +708,17 @@ cb_weather_update(GObject *source,
474 data->weather_update->http_status_code = soup_message_get_status(msg);
475 if (G_LIKELY(error == NULL)) {
476 body = g_bytes_get_data(response, &len);
477+#else
478+ weather_debug("Processing downloaded weather data.");
479+ time(&now_t);
480+ data->weather_update->attempt++;
481+ data->weather_update->http_status_code = msg->status_code;
482+ if (msg->status_code == 200 || msg->status_code == 203) {
483+ if (G_LIKELY(msg->response_body && msg->response_body->data)) {
484+ body = msg->response_body->data;
485+ len = msg->response_body->length;
486+ }
487+#endif
488 doc = get_xml_document(body, len);
489 if (G_LIKELY(doc)) {
490 root_node = xmlDocGetRootElement(doc);
491@@ -661,14 +730,22 @@ cb_weather_update(GObject *source,
492 }
493 xmlFreeDoc(doc);
494 }
495+#if SOUP_CHECK_VERSION(3, 0, 0)
496 g_bytes_unref(response);
497+#endif
498 if (parsing_error)
499 g_warning("Error parsing weather data!");
500 } else {
501+#if SOUP_CHECK_VERSION(3, 0, 0)
502 weather_debug("Download of weather data failed: %s", error->message);
503 g_error_free(error);
504+#else
505+ weather_debug
506+ ("Download of weather data failed with HTTP Status Code %d, "
507+ "Reason phrase: %s", msg->status_code, msg->reason_phrase);
508+#endif
509 }
510- data->weather_update->next = calc_next_download_time(data->weather_update,
511+ data->weather_update->next = calc_next_download_time(data->weather_update,
512 now_t);
513
514 xml_weather_clean(data->weatherdata);
515@@ -1725,6 +1802,33 @@ mi_click(GtkWidget *widget,
516 update_weatherdata_with_reset(data);
517 }
518
519+#if !SOUP_CHECK_VERSION(3, 0, 0)
520+static void
521+proxy_auth(SoupSession *session,
522+ SoupMessage *msg,
523+ SoupAuth *auth,
524+ gboolean retrying,
525+ gpointer user_data)
526+{
527+ SoupURI *soup_proxy_uri;
528+ const gchar *proxy_uri;
529+
530+ if (!retrying) {
531+ if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
532+ proxy_uri = g_getenv("HTTP_PROXY");
533+ if (!proxy_uri)
534+ proxy_uri = g_getenv("http_proxy");
535+ if (proxy_uri) {
536+ soup_proxy_uri = soup_uri_new(proxy_uri);
537+ soup_auth_authenticate(auth,
538+ soup_uri_get_user(soup_proxy_uri),
539+ soup_uri_get_password(soup_proxy_uri));
540+ soup_uri_free(soup_proxy_uri);
541+ }
542+ }
543+ }
544+}
545+#endif
546
547 #ifdef HAVE_UPOWER_GLIB
548 static void
549@@ -2028,10 +2132,18 @@ static plugin_data *
550 xfceweather_create_control(XfcePanelPlugin *plugin)
551 {
552 plugin_data *data = g_slice_new0(plugin_data);
553+#if SOUP_CHECK_VERSION(3, 0, 0)
554 GProxyResolver *proxy_resolver;
555+#else
556+ SoupURI *soup_proxy_uri;
557+#endif
558 const gchar *proxy_uri;
559+#if SOUP_CHECK_VERSION(3, 0, 0)
560 const gchar *no_proxy;
561 gchar **no_proxy_lst = NULL;
562+#else
563+ const gchar *proxy_user;
564+#endif
565 GtkWidget *refresh;
566 cairo_surface_t *icon = NULL;
567 data_types lbl;
568@@ -2069,15 +2181,23 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
569
570 /* Setup session for HTTP connections */
571 data->session = soup_session_new();
572+#if SOUP_CHECK_VERSION(3, 0, 0)
573 soup_session_set_user_agent(data->session,
574 PACKAGE_NAME "-" PACKAGE_VERSION);
575 soup_session_set_timeout(data->session, CONN_TIMEOUT);
576+#else
577+ g_object_set(data->session, SOUP_SESSION_USER_AGENT,
578+ PACKAGE_NAME "-" PACKAGE_VERSION, NULL);
579+ g_object_set(data->session, SOUP_SESSION_TIMEOUT,
580+ CONN_TIMEOUT, NULL);
581+#endif
582
583 /* Set the proxy URI from environment */
584 proxy_uri = g_getenv("HTTP_PROXY");
585 if (!proxy_uri)
586 proxy_uri = g_getenv("http_proxy");
587 if (proxy_uri) {
588+#if SOUP_CHECK_VERSION(3, 0, 0)
589 no_proxy = g_getenv("no_proxy");
590 if (!no_proxy)
591 no_proxy = g_getenv("NO_PROXY");
592@@ -2087,6 +2207,18 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
593 g_strfreev(no_proxy_lst);
594 soup_session_set_proxy_resolver(data->session, proxy_resolver);
595 g_object_unref(proxy_resolver);
596+#else
597+ soup_proxy_uri = soup_uri_new(proxy_uri);
598+ g_object_set(data->session, SOUP_SESSION_PROXY_URI,
599+ soup_proxy_uri, NULL);
600+ /* check if uri contains authentication info */
601+ proxy_user = soup_uri_get_user(soup_proxy_uri);
602+ if (proxy_user && strlen(proxy_user) > 0) {
603+ g_signal_connect(G_OBJECT(data->session), "authenticate",
604+ G_CALLBACK(proxy_auth), NULL);
605+ }
606+ soup_uri_free(soup_proxy_uri);
607+#endif
608 }
609 /* Otherwise, g_proxy_resolver_get_default() will be used */
610
611diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
612index 01974ce..87a6157 100644
613--- a/panel-plugin/weather.h
614+++ b/panel-plugin/weather.h
615@@ -183,7 +183,11 @@ extern gboolean debug_mode;
616
617 void weather_http_queue_request(SoupSession *session,
618 const gchar *uri,
619+#if SOUP_CHECK_VERSION(3, 0, 0)
620 GAsyncReadyCallback callback_func,
621+#else
622+ SoupSessionCallback callback_func,
623+#endif
624 gpointer user_data);
625
626 void scrollbox_set_visible(plugin_data *data);
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.11.3.bb b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.11.3.bb
deleted file mode 100644
index c0c2ad3313..0000000000
--- a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.11.3.bb
+++ /dev/null
@@ -1,18 +0,0 @@
1SUMMARY = "Panel plugin to display current temperature and weather condition"
2HOMEPAGE = "https://docs.xfce.org/panel-plugins/xfce4-weather-plugin/start"
3LICENSE = "GPL-2.0-only"
4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
5
6inherit xfce-panel-plugin
7
8DEPENDS += "libsoup dbus-glib upower json-c"
9
10SRC_URI += "file://0001-libxfce4ui-Avoid-deprecated-functions.patch \
11 file://0002-parsers-Generalise-input-to-array-of-gchar.patch \
12 file://0003-libsoup-Port-to-libsoup-3.0.patch \
13 file://0004-Report-UPower-Glib-support.patch \
14 file://0005-Make-libsoup-v3-support-optional.patch \
15"
16SRC_URI[sha256sum] = "002d1fe63906d2f3a012f3cb58cceff1dfbcc466759e36c76d3b03dd01c0dc57"
17
18FILES:${PN} += "${datadir}/xfce4/weather"
diff --git a/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.12.0.bb b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.12.0.bb
new file mode 100644
index 0000000000..35a55383bc
--- /dev/null
+++ b/meta-xfce/recipes-panel-plugins/weather/xfce4-weather-plugin_0.12.0.bb
@@ -0,0 +1,15 @@
1SUMMARY = "Panel plugin to display current temperature and weather condition"
2HOMEPAGE = "https://docs.xfce.org/panel-plugins/xfce4-weather-plugin/start"
3LICENSE = "GPL-2.0-only"
4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
5
6XFCEBASEBUILDCLASS = "meson"
7XFCE_COMPRESS_TYPE = "xz"
8
9inherit xfce-panel-plugin
10
11DEPENDS += "libsoup dbus-glib upower json-c"
12
13SRC_URI[sha256sum] = "5dd90b032c06ef4b64b818023154ef9463a2c694a0290e57f3412296c7545ff6"
14
15FILES:${PN} += "${datadir}/xfce4/weather"