aboutsummaryrefslogtreecommitdiffstats
path: root/my-evolution/e-summary-rdf.c
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2002-01-17 01:56:22 +0800
committerIain Holmes <iain@src.gnome.org>2002-01-17 01:56:22 +0800
commit82cb9e15be22f43794345c93cbbef1bf0da06158 (patch)
treedb2d4f6d5bde131dcadbe7ee4c6a3c03a3b661db /my-evolution/e-summary-rdf.c
parent95de7c6dc800504a12b6fc7557e282e646250422 (diff)
downloadgsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar.gz
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar.bz2
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar.lz
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar.xz
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.tar.zst
gsoc2013-evolution-82cb9e15be22f43794345c93cbbef1bf0da06158.zip
Use soup to transfer HTTP files and other bugs fixed
svn path=/trunk/; revision=15344
Diffstat (limited to 'my-evolution/e-summary-rdf.c')
-rw-r--r--my-evolution/e-summary-rdf.c166
1 files changed, 38 insertions, 128 deletions
diff --git a/my-evolution/e-summary-rdf.c b/my-evolution/e-summary-rdf.c
index 015f75246e..1fe6d33003 100644
--- a/my-evolution/e-summary-rdf.c
+++ b/my-evolution/e-summary-rdf.c
@@ -33,8 +33,12 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
+
+
#include <gal/widgets/e-unicode.h>
-#include <libgnomevfs/gnome-vfs.h>
+
+#include <libsoup/soup.h>
+
#include "e-summary.h"
struct _ESummaryRDF {
@@ -49,14 +53,14 @@ struct _ESummaryRDF {
typedef struct _RDF {
char *uri;
char *html;
- GnomeVFSAsyncHandle *handle;
- GString *string;
- char *buffer;
xmlDocPtr cache;
ESummary *summary;
gboolean shown;
+
+ /* Soup stuff */
+ SoupMessage *message;
} RDF;
int xmlSubstituteEntitiesDefaultValue = 1;
@@ -314,120 +318,35 @@ display_doc (RDF *r)
}
static void
-close_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- RDF *r)
+message_finished (SoupMessage *msg,
+ gpointer userdata)
{
- ESummary *summary;
- char *xml;
xmlDocPtr doc;
+ RDF *r = (RDF *) userdata;
- summary = r->summary;
- if (summary->rdf->connection->callback) {
- ESummaryConnection *connection = summary->rdf->connection;
- connection->callback (summary, connection->callback_closure);
- }
+ if (SOUP_MESSAGE_IS_ERROR (msg)) {
+ g_warning ("Message failed: %d\n%s", msg->errorcode,
+ msg->errorphrase);
+ r->cache = NULL;
+ r->message = NULL;
- if (r->handle == NULL) {
- g_free (r->buffer);
- r->buffer = NULL;
- g_string_free (r->string, TRUE);
- r->string = NULL;
+ display_doc (r);
return;
}
- r->handle = NULL;
- g_free (r->buffer);
- r->buffer = NULL;
- xml = r->string->str;
- g_string_free (r->string, FALSE);
- r->string = NULL;
-
if (r->cache != NULL) {
xmlFreeDoc (r->cache);
r->cache = NULL;
}
- doc = xmlParseMemory (xml, strlen (xml));
-#if 0
- if (doc == NULL) {
- g_free (r->html);
- r->html = g_strdup ("<b>Error parsing XML</b>");
-
- e_summary_draw (r->summary);
- g_free (xml);
- return;
- }
-#endif
- g_free (xml);
+ doc = xmlParseMemory (msg->response.body, msg->response.length);
r->cache = doc;
+ r->message = NULL;
- /* Draw it */
+ /* Display it */
display_doc (r);
}
-static void
-read_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- gpointer buffer,
- GnomeVFSFileSize bytes_requested,
- GnomeVFSFileSize bytes_read,
- RDF *r)
-{
- if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
- char *str;
-
- g_free (r->html);
- str = g_strdup_printf ("<b>%s:</b><br>%s", _("Error downloading RDF"),
- r->uri);
- r->html = e_utf8_from_locale_string (str);
-
- g_free (str);
-
- e_summary_draw (r->summary);
- r->handle = NULL;
- gnome_vfs_async_close (handle,
- (GnomeVFSAsyncCloseCallback) close_callback, r);
- return;
- }
-
- if (bytes_read == 0) {
- gnome_vfs_async_close (handle,
- (GnomeVFSAsyncCloseCallback) close_callback, r);
- } else {
- *((char *) buffer + bytes_read) = 0;
- g_string_append (r->string, (const char *) buffer);
- gnome_vfs_async_read (handle, buffer, 4095,
- (GnomeVFSAsyncReadCallback) read_callback, r);
- }
-}
-
-static void
-open_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- RDF *r)
-{
- if (result != GNOME_VFS_OK) {
- char *str;
-
- r->handle = NULL;
- g_free (r->html);
- str = g_strdup_printf ("<b>%s:</b><br>%s", _("Error downloading RDF"),
- r->uri);
- r->html = e_utf8_from_locale_string (str);
- g_free (str);
-
- display_doc (r);
- return;
- }
-
- r->string = g_string_new ("");
- r->buffer = g_new (char, 4096);
-
- gnome_vfs_async_read (handle, r->buffer, 4095,
- (GnomeVFSAsyncReadCallback) read_callback, r);
-}
-
gboolean
e_summary_rdf_update (ESummary *summary)
{
@@ -439,27 +358,23 @@ e_summary_rdf_update (ESummary *summary)
}
for (r = summary->rdf->rdfs; r; r = r->next) {
+ SoupContext *context;
RDF *rdf = r->data;
- if (rdf->handle) {
- gnome_vfs_async_cancel (rdf->handle);
- rdf->handle = NULL;
+ if (rdf->message) {
+ soup_message_cancel (rdf->message);
}
- if (rdf->buffer) {
- g_free (rdf->buffer);
- rdf->buffer = NULL;
- }
-
- if (rdf->string) {
- g_string_free (rdf->string, TRUE);
- rdf->string = NULL;
+ context = soup_context_get (rdf->uri);
+ if (context == NULL) {
+ g_warning ("Invalid URL: %s", rdf->uri);
+ soup_context_unref (context);
+ continue;
}
- g_warning ("Opening %s", rdf->uri);
- gnome_vfs_async_open (&rdf->handle, rdf->uri,
- GNOME_VFS_OPEN_READ,
- (GnomeVFSAsyncOpenCallback) open_callback, rdf);
+ rdf->message = soup_message_new (context, SOUP_METHOD_GET);
+ soup_context_unref (context);
+ soup_message_queue (rdf->message, message_finished, rdf);
}
return TRUE;
@@ -510,7 +425,7 @@ e_summary_rdf_count (ESummary *summary,
for (p = rdf->rdfs; p; p = p->next) {
RDF *r = p->data;
- if (r->handle != NULL) {
+ if (r->message != NULL) {
count++;
}
}
@@ -541,7 +456,7 @@ e_summary_rdf_add (ESummary *summary,
for (p = rdf->rdfs; p; p = p->next) {
RDF *r = p->data;
- if (r->handle != NULL) {
+ if (r->message != NULL) {
ESummaryConnectionData *d;
d = make_connection (r);
@@ -556,17 +471,12 @@ static void
rdf_free (RDF *r)
{
/* Stop the download */
- if (r->handle) {
- gnome_vfs_async_cancel (r->handle);
+ if (r->message) {
+ soup_message_cancel (r->message);
}
g_free (r->uri);
g_free (r->html);
- g_free (r->buffer);
-
- if (r->string) {
- g_string_free (r->string, TRUE);
- }
if (r->cache) {
xmlFreeDoc (r->cache);
@@ -599,9 +509,9 @@ e_summary_rdf_set_online (ESummary *summary,
RDF *r;
r = p->data;
- if (r->handle) {
- gnome_vfs_async_cancel (r->handle);
- r->handle = NULL;
+ if (r->message) {
+ soup_message_cancel (r->message);
+ r->message = NULL;
}
}