[Xfce4-commits] <xfce4-weather-plugin:master> Use libsoup to fetch logo from met.no website.

Harald Judt noreply at xfce.org
Tue Nov 20 20:18:09 CET 2012


Updating branch refs/heads/master
         to aa5ef7f3044b5b2d40b7d588f40e97b449664c85 (commit)
       from db5786b6ddc4ee7ab244a53eb81c2ecf4c8d9c27 (commit)

commit aa5ef7f3044b5b2d40b7d588f40e97b449664c85
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Nov 20 20:05:13 2012 +0100

    Use libsoup to fetch logo from met.no website.

 panel-plugin/weather-summary.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index 7224e23..0a458c3 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -218,23 +218,22 @@ get_logo_path(void)
 
 
 static void
-logo_fetched (const gboolean succeed,
-              gchar *result,
-              const size_t len,
-              gpointer user_data)
+logo_fetched(SoupSession *session,
+             SoupMessage *msg,
+             gpointer user_data)
 {
-    if (succeed && result) {
+    if (msg && msg->response_body && msg->response_body->length > 0) {
         gchar *path = get_logo_path();
         GError *error = NULL;
         GdkPixbuf *pixbuf = NULL;
-        if (!g_file_set_contents(path, result, len, &error)) {
-            printf("err %s\n", error?error->message:"?");
+        if (!g_file_set_contents(path, msg->response_body->data,
+                                 msg->response_body->length, &error)) {
+            g_warning("Error downloading met.no logo image to %s, "
+                      "err %s\n", path, error ? error->message : "?");
             g_error_free(error);
-            g_free(result);
             g_free(path);
             return;
         }
-        g_free(result);
         pixbuf = gdk_pixbuf_new_from_file(path, NULL);
         g_free(path);
         if (pixbuf) {
@@ -255,9 +254,8 @@ weather_summary_get_logo(xfceweather_data *data)
     pixbuf = gdk_pixbuf_new_from_file(path, NULL);
     g_free(path);
     if (pixbuf == NULL)
-        weather_http_receive_data("met.no", "/filestore/met.no-logo.gif",
-                                  data->proxy_host, data->proxy_port,
-                                  logo_fetched, image);
+        weather_http_queue_request("http://met.no/filestore/met.no-logo.gif",
+                                   logo_fetched, image);
     else {
         gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
         g_object_unref(pixbuf);


More information about the Xfce4-commits mailing list