mate.libmateweather: build against libsoup_3 (#398828)

authored by

Bobby Rong and committed by
GitHub
42cc251a 68745297

+587 -4
+12 -4
pkgs/desktops/mate/libmateweather/default.nix
··· 1 { 2 lib, 3 stdenv, 4 fetchurl, 5 pkg-config, 6 gettext, ··· 8 glib-networking, 9 libxml2, 10 gtk3, 11 - libsoup_2_4, 12 tzdata, 13 mateUpdateScript, 14 }: 15 - 16 stdenv.mkDerivation rec { 17 pname = "libmateweather"; 18 version = "1.28.0"; ··· 22 sha256 = "VUNz3rWzk7nYSydd0spmyaSi0ObskgRPq4qlPjAy0rU="; 23 }; 24 25 strictDeps = true; 26 27 nativeBuildInputs = [ 28 pkg-config 29 gettext 30 glib # glib-compile-schemas 31 libxml2 # xmllint 32 ]; 33 34 buildInputs = [ 35 - libsoup_2_4 36 tzdata 37 ]; 38 ··· 44 45 configureFlags = [ 46 "--with-zoneinfo-dir=${tzdata}/share/zoneinfo" 47 - "--enable-locations-compression" 48 ]; 49 50 preFixup = "rm -f $out/share/icons/mate/icon-theme.cache";
··· 1 { 2 lib, 3 stdenv, 4 + autoreconfHook, 5 fetchurl, 6 pkg-config, 7 gettext, ··· 9 glib-networking, 10 libxml2, 11 gtk3, 12 + gtk-doc, 13 + libsoup_3, 14 tzdata, 15 mateUpdateScript, 16 }: 17 stdenv.mkDerivation rec { 18 pname = "libmateweather"; 19 version = "1.28.0"; ··· 23 sha256 = "VUNz3rWzk7nYSydd0spmyaSi0ObskgRPq4qlPjAy0rU="; 24 }; 25 26 + patches = [ 27 + # https://github.com/mate-desktop/libmateweather/pull/133 28 + ./libsoup_3_support.patch 29 + ]; 30 + 31 strictDeps = true; 32 33 nativeBuildInputs = [ 34 + autoreconfHook # the libsoup patch changes the autoconf file 35 pkg-config 36 gettext 37 glib # glib-compile-schemas 38 + gtk-doc # required for autoconf 39 libxml2 # xmllint 40 ]; 41 42 buildInputs = [ 43 + libxml2 44 + libsoup_3 45 tzdata 46 ]; 47 ··· 53 54 configureFlags = [ 55 "--with-zoneinfo-dir=${tzdata}/share/zoneinfo" 56 ]; 57 58 preFixup = "rm -f $out/share/icons/mate/icon-theme.cache";
+575
pkgs/desktops/mate/libmateweather/libsoup_3_support.patch
···
··· 1 + diff --git a/configure.ac b/configure.ac 2 + index 133108e..d9fcf9c 100644 3 + --- a/configure.ac 4 + +++ b/configure.ac 5 + @@ -8,6 +8,7 @@ AC_CONFIG_AUX_DIR([build-aux]) 6 + AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-xz tar-ustar check-news]) 7 + m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 8 + 9 + +AC_USE_SYSTEM_EXTENSIONS 10 + # Before making a release, the LT_VERSION string should be modified. 11 + # The string is of the form C:R:A. 12 + # - If interfaces have been changed or added, but binary compatibility has 13 + @@ -23,7 +24,7 @@ AC_CANONICAL_HOST 14 + 15 + GLIB_REQUIRED=2.56.0 16 + GTK_REQUIRED=3.22.0 17 + -LIBSOUP_REQUIRED=2.34.0 18 + +LIBSOUP_REQUIRED=3.0.0 19 + GIO_REQUIRED=2.25.0 20 + LIBXML_REQUIRED=2.6.0 21 + 22 + @@ -65,7 +66,7 @@ dnl -- Check for libxml (required) ------------------------------------------ 23 + PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED) 24 + 25 + dnl -- check for libsoup (required) ----------------------------------------- 26 + -PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= $LIBSOUP_REQUIRED]) 27 + +PKG_CHECK_MODULES(LIBSOUP, [libsoup-3.0 >= $LIBSOUP_REQUIRED]) 28 + 29 + dnl -- check for gio (required) ----------------------------------------- 30 + PKG_CHECK_MODULES(GIO, 31 + @@ -100,6 +101,7 @@ AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec, 32 + [AC_MSG_ERROR([No regex library found])])]) 33 + AC_SUBST(REGEX_LIBS) 34 + 35 + +AC_CHECK_FUNC(memmem,[],[AC_MSG_ERROR([memmem is required])]) 36 + 37 + dnl *************************************************************************** 38 + dnl *** Check for presence of tm.tm_gmtoff on the system *** 39 + diff --git a/libmateweather/mateweather-uninstalled.pc.in b/libmateweather/mateweather-uninstalled.pc.in 40 + index 03e7461..c692842 100644 41 + --- a/libmateweather/mateweather-uninstalled.pc.in 42 + +++ b/libmateweather/mateweather-uninstalled.pc.in 43 + @@ -8,6 +8,6 @@ Name: MateWeather 44 + Description: MateWeather shared library 45 + Version: @VERSION@ 46 + Requires: glib-2.0 gobject-2.0 gdk-pixbuf-2.0 gtk+-3.0 gio-2.0 47 + -Requires.private: libxml-2.0 libsoup-2.4 48 + +Requires.private: libxml-2.0 libsoup-3.0 49 + Libs: ${pc_top_builddir}/${pcfiledir}/libmateweather.la 50 + Cflags: -I${pc_top_builddir}/${pcfiledir}/.. 51 + diff --git a/libmateweather/mateweather.pc.in b/libmateweather/mateweather.pc.in 52 + index a617c33..bea024d 100644 53 + --- a/libmateweather/mateweather.pc.in 54 + +++ b/libmateweather/mateweather.pc.in 55 + @@ -8,7 +8,7 @@ Name: MateWeather 56 + Description: MateWeather shared library 57 + Version: @VERSION@ 58 + Requires: glib-2.0 gobject-2.0 gdk-pixbuf-2.0 gtk+-3.0 gio-2.0 59 + -Requires.private: libxml-2.0 libsoup-2.4 60 + +Requires.private: libxml-2.0 libsoup-3.0 61 + Libs: -L${libdir} -lmateweather 62 + Libs.private: -lm 63 + Cflags: -I${includedir} 64 + diff --git a/libmateweather/weather-bom.c b/libmateweather/weather-bom.c 65 + index 47b2d0b..f5c7a87 100644 66 + --- a/libmateweather/weather-bom.c 67 + +++ b/libmateweather/weather-bom.c 68 + @@ -27,34 +27,45 @@ 69 + #include "weather-priv.h" 70 + 71 + static void 72 + -bom_finish (SoupSession *session, SoupMessage *msg, gpointer data) 73 + +bom_finish (GObject *source, GAsyncResult *result, gpointer data) 74 + { 75 + char *p, *rp; 76 + WeatherInfo *info = (WeatherInfo *)data; 77 + + GError *error = NULL; 78 + + GBytes *bytes; 79 + + const char *response_body = NULL; 80 + + gsize len = 0; 81 + 82 + g_return_if_fail (info != NULL); 83 + 84 + - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { 85 + - g_warning ("Failed to get BOM forecast data: %d %s.\n", 86 + - msg->status_code, msg->reason_phrase); 87 + - request_done (info, FALSE); 88 + - return; 89 + + bytes = soup_session_send_and_read_finish (SOUP_SESSION(source), 90 + + result, &error); 91 + + 92 + + if (error != NULL) { 93 + + g_warning ("Failed to get BOM forecast data: %s.\n", error->message); 94 + + request_done (info, error); 95 + + g_error_free (error); 96 + + return; 97 + } 98 + 99 + - p = strstr (msg->response_body->data, "Forecast for the rest"); 100 + + response_body = g_bytes_get_data (bytes, &len); 101 + + 102 + + p = xstrnstr (response_body, len, "Forecast for the rest"); 103 + if (p != NULL) { 104 + - rp = strstr (p, "The next routine forecast will be issued"); 105 + + rp = xstrnstr (p, len - (p - response_body), 106 + + "The next routine forecast will be issued"); 107 + if (rp == NULL) 108 + - info->forecast = g_strdup (p); 109 + + info->forecast = g_strndup (p, len - (p - response_body)); 110 + else 111 + info->forecast = g_strndup (p, rp - p); 112 + } 113 + 114 + if (info->forecast == NULL) 115 + - info->forecast = g_strdup (msg->response_body->data); 116 + + info->forecast = g_strndup (response_body, len); 117 + 118 + + g_bytes_unref (bytes); 119 + g_print ("%s\n", info->forecast); 120 + - request_done (info, TRUE); 121 + + request_done (info, NULL); 122 + } 123 + 124 + void 125 + @@ -70,7 +81,8 @@ bom_start_open (WeatherInfo *info) 126 + loc->zone + 1); 127 + 128 + msg = soup_message_new ("GET", url); 129 + - soup_session_queue_message (info->session, msg, bom_finish, info); 130 + + soup_session_send_and_read_async (info->session, msg, G_PRIORITY_DEFAULT, 131 + + NULL, bom_finish, info); 132 + g_free (url); 133 + 134 + info->requests_pending++; 135 + diff --git a/libmateweather/weather-iwin.c b/libmateweather/weather-iwin.c 136 + index 9f7ff38..b1dc1ff 100644 137 + --- a/libmateweather/weather-iwin.c 138 + +++ b/libmateweather/weather-iwin.c 139 + @@ -93,7 +93,7 @@ hasAttr (xmlNode *node, const char *attr_name, const char *attr_value) 140 + } 141 + 142 + static GSList * 143 + -parseForecastXml (const char *buff, WeatherInfo *master_info) 144 + +parseForecastXml (const char *buff, gsize len, WeatherInfo *master_info) 145 + { 146 + GSList *res = NULL; 147 + xmlDocPtr doc; 148 + @@ -107,7 +107,7 @@ parseForecastXml (const char *buff, WeatherInfo *master_info) 149 + #define XC (const xmlChar *) 150 + #define isElem(_node,_name) g_str_equal ((const char *)_node->name, _name) 151 + 152 + - doc = xmlParseMemory (buff, strlen (buff)); 153 + + doc = xmlParseMemory (buff, len); 154 + if (!doc) 155 + return NULL; 156 + 157 + @@ -380,26 +380,36 @@ parseForecastXml (const char *buff, WeatherInfo *master_info) 158 + } 159 + 160 + static void 161 + -iwin_finish (SoupSession *session, SoupMessage *msg, gpointer data) 162 + +iwin_finish (GObject *source, GAsyncResult *result, gpointer data) 163 + { 164 + WeatherInfo *info = (WeatherInfo *)data; 165 + + GError *error = NULL; 166 + + GBytes *bytes; 167 + + const char *response_body = NULL; 168 + + gsize len = 0; 169 + 170 + g_return_if_fail (info != NULL); 171 + 172 + - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { 173 + + bytes = soup_session_send_and_read_finish (SOUP_SESSION(source), 174 + + result, &error); 175 + + 176 + + if (error != NULL) { 177 + /* forecast data is not really interesting anyway ;) */ 178 + - g_warning ("Failed to get IWIN forecast data: %d %s\n", 179 + - msg->status_code, msg->reason_phrase); 180 + - request_done (info, FALSE); 181 + + g_warning ("Failed to get IWIN forecast data: %s\n", 182 + + error->message); 183 + + request_done (info, error); 184 + + g_error_free (error); 185 + return; 186 + } 187 + 188 + + response_body = g_bytes_get_data (bytes, &len); 189 + if (info->forecast_type == FORECAST_LIST) 190 + - info->forecast_list = parseForecastXml (msg->response_body->data, info); 191 + + info->forecast_list = parseForecastXml (response_body, len, info); 192 + else 193 + - info->forecast = formatWeatherMsg (g_strdup (msg->response_body->data)); 194 + + info->forecast = formatWeatherMsg (g_strndup (response_body, len)); 195 + 196 + - request_done (info, TRUE); 197 + + g_bytes_unref (bytes); 198 + + request_done (info, NULL); 199 + } 200 + 201 + /* Get forecast into newly alloc'ed string */ 202 + @@ -439,7 +449,9 @@ iwin_start_open (WeatherInfo *info) 203 + 204 + msg = soup_message_new ("GET", url); 205 + g_free (url); 206 + - soup_session_queue_message (info->session, msg, iwin_finish, info); 207 + + soup_session_send_and_read_async (info->session, msg, 208 + + G_PRIORITY_DEFAULT, 209 + + NULL, iwin_finish, info); 210 + 211 + info->requests_pending++; 212 + } 213 + @@ -470,7 +482,8 @@ iwin_start_open (WeatherInfo *info) 214 + 215 + msg = soup_message_new ("GET", url); 216 + g_free (url); 217 + - soup_session_queue_message (info->session, msg, iwin_finish, info); 218 + + soup_session_send_and_read_async (info->session, msg, G_PRIORITY_DEFAULT, 219 + + NULL, iwin_finish, info); 220 + 221 + info->requests_pending++; 222 + } 223 + diff --git a/libmateweather/weather-met.c b/libmateweather/weather-met.c 224 + index 164e9f2..7022abb 100644 225 + --- a/libmateweather/weather-met.c 226 + +++ b/libmateweather/weather-met.c 227 + @@ -119,19 +119,20 @@ met_reprocess (char *x, int len) 228 + */ 229 + 230 + static gchar * 231 + -met_parse (const gchar *meto) 232 + +met_parse (const gchar *meto, gsize len) 233 + { 234 + gchar *p; 235 + gchar *rp; 236 + gchar *r = g_strdup ("Met Office Forecast\n"); 237 + gchar *t; 238 + + const gchar *end = meto + len; 239 + 240 + g_return_val_if_fail (meto != NULL, r); 241 + 242 + - p = strstr (meto, "Summary: </b>"); 243 + + p = xstrnstr (meto, len, "Summary: </b>"); 244 + g_return_val_if_fail (p != NULL, r); 245 + 246 + - rp = strstr (p, "Text issued at:"); 247 + + rp = xstrnstr (p, end - p, "Text issued at:"); 248 + g_return_val_if_fail (rp != NULL, r); 249 + 250 + p += 13; 251 + @@ -143,21 +144,31 @@ met_parse (const gchar *meto) 252 + } 253 + 254 + static void 255 + -met_finish (SoupSession *session, SoupMessage *msg, gpointer data) 256 + +met_finish (GObject *source, GAsyncResult *result, gpointer data) 257 + { 258 + WeatherInfo *info = (WeatherInfo *)data; 259 + + GError *error = NULL; 260 + + GBytes *bytes; 261 + + const char *response_body = NULL; 262 + + gsize len = 0; 263 + 264 + g_return_if_fail (info != NULL); 265 + 266 + - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { 267 + - g_warning ("Failed to get Met Office forecast data: %d %s.\n", 268 + - msg->status_code, msg->reason_phrase); 269 + - request_done (info, FALSE); 270 + + bytes = soup_session_send_and_read_finish (SOUP_SESSION(source), 271 + + result, &error); 272 + + 273 + + if (error != NULL) { 274 + + g_warning ("Failed to get Met Office forecast data: %s.\n", 275 + + error->message); 276 + + request_done (info, error); 277 + + g_error_free (error); 278 + return; 279 + } 280 + 281 + - info->forecast = met_parse (msg->response_body->data); 282 + - request_done (info, TRUE); 283 + + response_body = g_bytes_get_data (bytes, &len); 284 + + info->forecast = met_parse (response_body, len); 285 + + g_bytes_unref (bytes); 286 + + request_done (info, NULL); 287 + } 288 + 289 + void 290 + @@ -171,7 +182,8 @@ metoffice_start_open (WeatherInfo *info) 291 + url = g_strdup_printf ("http://www.metoffice.gov.uk/weather/europe/uk/%s.html", loc->zone + 1); 292 + 293 + msg = soup_message_new ("GET", url); 294 + - soup_session_queue_message (info->session, msg, met_finish, info); 295 + + soup_session_send_and_read_async (info->session, msg, G_PRIORITY_DEFAULT, 296 + + NULL, met_finish, info); 297 + g_free (url); 298 + 299 + info->requests_pending++; 300 + diff --git a/libmateweather/weather-metar.c b/libmateweather/weather-metar.c 301 + index 7bc24fc..d470822 100644 302 + --- a/libmateweather/weather-metar.c 303 + +++ b/libmateweather/weather-metar.c 304 + @@ -486,43 +486,60 @@ metar_parse (gchar *metar, WeatherInfo *info) 305 + } 306 + 307 + static void 308 + -metar_finish (SoupSession *session, SoupMessage *msg, gpointer data) 309 + +metar_finish (GObject *source, GAsyncResult *result, gpointer data) 310 + { 311 + WeatherInfo *info = (WeatherInfo *)data; 312 + WeatherLocation *loc; 313 + - const gchar *p, *endtag; 314 + + const gchar *p, *end, *endtag; 315 + gchar *searchkey, *metar; 316 + gboolean success = FALSE; 317 + + GError *error = NULL; 318 + + GBytes *bytes; 319 + + const char *response_body = NULL; 320 + + gsize len = 0; 321 + 322 + g_return_if_fail (info != NULL); 323 + 324 + - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { 325 + - if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) 326 + + bytes = soup_session_send_and_read_finish (SOUP_SESSION(source), 327 + + result, &error); 328 + + 329 + + if (error != NULL) { 330 + + /* https://libsoup.org/libsoup-3.0/migrating-from-libsoup-2.html#status-codes-no-longer-used-for-internal-errors */ 331 + + switch (error->code) { 332 + + case SOUP_SESSION_ERROR_PARSING: 333 + + case SOUP_SESSION_ERROR_ENCODING: 334 + + case SOUP_SESSION_ERROR_TOO_MANY_REDIRECTS: 335 + info->network_error = TRUE; 336 + - else { 337 + - /* Translators: %d is an error code, and %s the error string */ 338 + - g_warning (_("Failed to get METAR data: %d %s.\n"), 339 + - msg->status_code, msg->reason_phrase); 340 + + break; 341 + + default: 342 + + break; 343 + } 344 + - request_done (info, FALSE); 345 + + g_warning (_("Failed to get METAR data: %s.\n"), 346 + + error->message); 347 + + request_done (info, error); 348 + + g_error_free (error); 349 + return; 350 + } 351 + 352 + loc = info->location; 353 + 354 + searchkey = g_strdup_printf ("<raw_text>%s", loc->code); 355 + - p = strstr (msg->response_body->data, searchkey); 356 + - g_free (searchkey); 357 + + 358 + + response_body = g_bytes_get_data (bytes, &len); 359 + + end = response_body + len; 360 + + 361 + + p = xstrnstr (response_body, len, searchkey); 362 + if (p) { 363 + p += WEATHER_LOCATION_CODE_LEN + 11; 364 + endtag = strstr (p, "</raw_text>"); 365 + + endtag = xstrnstr (p, end - p, "</raw_text>"); 366 + if (endtag) 367 + metar = g_strndup (p, endtag - p); 368 + else 369 + - metar = g_strdup (p); 370 + + metar = g_strndup (p, end - p); 371 + success = metar_parse (metar, info); 372 + g_free (metar); 373 + - } else if (!strstr (msg->response_body->data, "aviationweather.gov")) { 374 + + } else if (!xstrnstr (response_body, len, "aviationweather.gov")) { 375 + /* The response doesn't even seem to have come from NOAA... 376 + * most likely it is a wifi hotspot login page. Call that a 377 + * network error. 378 + @@ -531,7 +548,8 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data) 379 + } 380 + 381 + info->valid = success; 382 + - request_done (info, TRUE); 383 + + request_done (info, NULL); 384 + + g_bytes_unref(bytes); 385 + } 386 + 387 + /* Read current conditions and fill in info structure */ 388 + @@ -540,6 +558,7 @@ metar_start_open (WeatherInfo *info) 389 + { 390 + WeatherLocation *loc; 391 + SoupMessage *msg; 392 + + char *query; 393 + 394 + g_return_if_fail (info != NULL); 395 + info->valid = info->network_error = FALSE; 396 + @@ -549,8 +568,7 @@ metar_start_open (WeatherInfo *info) 397 + return; 398 + } 399 + 400 + - msg = soup_form_request_new ( 401 + - "GET", "https://aviationweather.gov/cgi-bin/data/dataserver.php", 402 + + query = soup_form_encode ( 403 + "dataSource", "metars", 404 + "requestType", "retrieve", 405 + "format", "xml", 406 + @@ -559,7 +577,11 @@ metar_start_open (WeatherInfo *info) 407 + "fields", "raw_text", 408 + "stationString", loc->code, 409 + NULL); 410 + - soup_session_queue_message (info->session, msg, metar_finish, info); 411 + + msg = soup_message_new_from_encoded_form ( 412 + + "GET", "https://aviationweather.gov/cgi-bin/data/dataserver.php", 413 + + query); 414 + + soup_session_send_and_read_async (info->session, msg, G_PRIORITY_DEFAULT, 415 + + NULL, metar_finish, info); 416 + 417 + info->requests_pending++; 418 + } 419 + diff --git a/libmateweather/weather-priv.h b/libmateweather/weather-priv.h 420 + index 817f13c..03cdcbd 100644 421 + --- a/libmateweather/weather-priv.h 422 + +++ b/libmateweather/weather-priv.h 423 + @@ -21,6 +21,7 @@ 424 + 425 + #include "config.h" 426 + 427 + +#include <string.h> 428 + #include <time.h> 429 + #include <libintl.h> 430 + #include <math.h> 431 + @@ -34,6 +35,8 @@ const char *mateweather_dpgettext (const char *context, const char *str) G_GNUC_ 432 + #define _(str) (mateweather_gettext (str)) 433 + #define C_(context, str) (mateweather_dpgettext (context, str)) 434 + #define N_(str) (str) 435 + +#define xstrnstr(haystack, hlen, needle) \ 436 + + memmem(haystack, hlen, needle, strlen(needle)) 437 + 438 + #define WEATHER_LOCATION_CODE_LEN 4 439 + 440 + @@ -95,7 +98,6 @@ struct _WeatherInfo { 441 + GSList *forecast_list; /* list of WeatherInfo* for the forecast, NULL if not available */ 442 + gchar *radar_buffer; 443 + gchar *radar_url; 444 + - GdkPixbufLoader *radar_loader; 445 + GdkPixbufAnimation *radar; 446 + SoupSession *session; 447 + gint requests_pending; 448 + @@ -167,7 +169,7 @@ gboolean metar_parse (gchar *metar, 449 + 450 + gboolean requests_init (WeatherInfo *info); 451 + void request_done (WeatherInfo *info, 452 + - gboolean ok); 453 + + GError *error); 454 + 455 + void ecl2equ (gdouble t, 456 + gdouble eclipLon, 457 + diff --git a/libmateweather/weather-wx.c b/libmateweather/weather-wx.c 458 + index e29cecc..11f7336 100644 459 + --- a/libmateweather/weather-wx.c 460 + +++ b/libmateweather/weather-wx.c 461 + @@ -25,48 +25,51 @@ 462 + #include "weather-priv.h" 463 + 464 + static void 465 + -wx_finish (SoupSession *session, SoupMessage *msg, gpointer data) 466 + +wx_finish (GObject *source, GAsyncResult *result, gpointer data) 467 + { 468 + WeatherInfo *info = (WeatherInfo *)data; 469 + GdkPixbufAnimation *animation; 470 + + GError *error = NULL; 471 + 472 + g_return_if_fail (info != NULL); 473 + 474 + - if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { 475 + - g_warning ("Failed to get radar map image: %d %s.\n", 476 + - msg->status_code, msg->reason_phrase); 477 + - g_object_unref (info->radar_loader); 478 + - request_done (info, FALSE); 479 + - return; 480 + - } 481 + + animation = gdk_pixbuf_animation_new_from_stream_finish (result, &error); 482 + 483 + - gdk_pixbuf_loader_close (info->radar_loader, NULL); 484 + - animation = gdk_pixbuf_loader_get_animation (info->radar_loader); 485 + + if (error != NULL) { 486 + + g_warning ("Failed to get radar map image: %s.\n", error->message); 487 + + request_done (info, error); 488 + + g_error_free (error); 489 + + return; 490 + + } 491 + if (animation != NULL) { 492 + - if (info->radar) 493 + - g_object_unref (info->radar); 494 + - info->radar = animation; 495 + - g_object_ref (info->radar); 496 + + if (info->radar) 497 + + g_object_unref (info->radar); 498 + + info->radar = animation; 499 + + g_object_ref (info->radar); 500 + } 501 + - g_object_unref (info->radar_loader); 502 + 503 + - request_done (info, TRUE); 504 + + request_done (info, NULL); 505 + } 506 + 507 + static void 508 + -wx_got_chunk (SoupMessage *msg, SoupBuffer *chunk, gpointer data) 509 + +wx_got_chunk (GObject *source, GAsyncResult *result, gpointer data) 510 + { 511 + WeatherInfo *info = (WeatherInfo *)data; 512 + GError *error = NULL; 513 + + GInputStream *istream; 514 + 515 + g_return_if_fail (info != NULL); 516 + 517 + - gdk_pixbuf_loader_write (info->radar_loader, (guchar *)chunk->data, 518 + - chunk->length, &error); 519 + - if (error) { 520 + - g_print ("%s \n", error->message); 521 + - g_error_free (error); 522 + + istream = soup_session_send_finish (SOUP_SESSION (source), result, &error); 523 + + 524 + + if (error != NULL) { 525 + + g_warning ("Failed to get radar map image: %s.\n", error->message); 526 + + g_error_free (error); 527 + + request_done (info, error); 528 + + return; 529 + } 530 + + 531 + + gdk_pixbuf_animation_new_from_stream_async (istream, NULL, wx_finish, data); 532 + } 533 + 534 + /* Get radar map and into newly allocated pixmap */ 535 + @@ -79,7 +82,6 @@ wx_start_open (WeatherInfo *info) 536 + 537 + g_return_if_fail (info != NULL); 538 + info->radar = NULL; 539 + - info->radar_loader = gdk_pixbuf_loader_new (); 540 + loc = info->location; 541 + g_return_if_fail (loc != NULL); 542 + 543 + @@ -98,9 +100,8 @@ wx_start_open (WeatherInfo *info) 544 + return; 545 + } 546 + 547 + - g_signal_connect (msg, "got-chunk", G_CALLBACK (wx_got_chunk), info); 548 + - soup_message_body_set_accumulate (msg->response_body, FALSE); 549 + - soup_session_queue_message (info->session, msg, wx_finish, info); 550 + + soup_session_send_async (info->session, msg, G_PRIORITY_DEFAULT, NULL, 551 + + wx_got_chunk, info); 552 + g_free (url); 553 + 554 + info->requests_pending++; 555 + diff --git a/libmateweather/weather.c b/libmateweather/weather.c 556 + index 86453fc..1d7533a 100644 557 + --- a/libmateweather/weather.c 558 + +++ b/libmateweather/weather.c 559 + @@ -348,12 +348,13 @@ requests_init (WeatherInfo *info) 560 + return TRUE; 561 + } 562 + 563 + -void request_done (WeatherInfo *info, gboolean ok) 564 + +void request_done (WeatherInfo *info, GError *error) 565 + { 566 + - if (ok) { 567 + + if (error == NULL) { 568 + (void) calc_sun (info); 569 + info->moonValid = info->valid && calc_moon (info); 570 + - } 571 + + } else if (error->code == G_IO_ERROR_CANCELLED) 572 + + return; /* Caused by soup_session_abort */ 573 + if (!--info->requests_pending) 574 + info->finish_cb (info, info->cb_data); 575 + }