[gcalctool] Use GIO instead of libsoup



commit 1dd21f580704997724fa0a518745672f38f3ac1e
Author: Robert Ancell <robert ancell gmail com>
Date:   Sat Mar 6 20:42:52 2010 +1100

    Use GIO instead of libsoup

 NEWS           |    2 ++
 configure.ac   |    2 +-
 src/currency.c |   29 ++++++++++++++---------------
 3 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/NEWS b/NEWS
index baf8347..2bcf6e8 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ Overview of changes in gcalctool 5.30.0
     * Fix spacebar not working when display has focus (Bug #611971)
 
     * Load currency rates when doing typed currency conversion
+    
+    * Use GIO instead of libsoup
 
 Overview of changes in gcalctool 5.29.92
 
diff --git a/configure.ac b/configure.ac
index 8575f26..9185afe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ GCONF_REQUIRED=1.1.9
 PKG_CHECK_MODULES(GCALCTOOL, [
     gtk+-2.0 >= $GTK_REQUIRED
     gconf-2.0 >= $GCONF_REQUIRED
+    gio-2.0
     libxml-2.0
-    libsoup-2.4
     gmodule-export-2.0
 ])
 
diff --git a/src/currency.c b/src/currency.c
index 9d0a10f..e78da52 100644
--- a/src/currency.c
+++ b/src/currency.c
@@ -2,10 +2,10 @@
 
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <gio/gio.h>
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
-#include <libsoup/soup.h>
 
 #include "currency.h"
 #include "mp.h"
@@ -76,28 +76,26 @@ currency_download_rates()
 {
     gchar *filename, *directory;
     GError *e = NULL;
-    SoupSession *session = soup_session_sync_new();
-    SoupMessage *msg = soup_message_new("GET",
-                                        "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";);
-    soup_session_send_message(session, msg);
-    if (msg->status_code != 200) {
-        return 0;
-    }
+    GFile *source, *dest;
+   
     filename = get_rate_filepath();
     directory = g_path_get_dirname(filename);
     g_mkdir_with_parents(directory, 0755);
     g_free(directory);
 
-    g_file_set_contents(filename,
-                        msg->response_body->data,
-                        msg->response_body->length,
-                        &e);
+    source = g_file_new_for_uri ("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";);
+    dest = g_file_new_for_path (filename);
+    g_free(filename);
+
+    g_file_copy (source, dest, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &e);
+    g_object_unref(source);
+    g_object_unref(dest);
+
     if (e != NULL) {
         fprintf(stderr, "Couldn't download currency file: %s\n", e->message);
+        g_error_free (e);
         return 0;
     }
-    g_free(filename);
-    g_object_unref(session);
 
     return 1;
 }
@@ -117,7 +115,8 @@ set_rate (xmlNodePtr node, currency *cur)
     }
 }
 
-void currency_load_rates()
+void
+currency_load_rates()
 {
     char *filename = get_rate_filepath();
     xmlDocPtr document;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]