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