aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-11-08 19:19:23 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-11-08 20:23:36 +0800
commitde8aea580de68963bc61838c2889f040f6d3b563 (patch)
treeccff776677cd7fb626a45c577bbb06a4c3c15907 /mail
parente8797d1ed9a99e13fc3f5fdaac0cfc8869d2839a (diff)
downloadgsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar.gz
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar.bz2
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar.lz
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar.xz
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.tar.zst
gsoc2013-evolution-de8aea580de68963bc61838c2889f040f6d3b563.zip
EMailAutoconfig: Use libsoup instead of gvfs.
The GVFS HTTP backend seems to just hang forever when an I/O operation is cancelled. Use libsoup instead. See also: https://bugzilla.gnome.org/678615
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-autoconfig.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/mail/e-mail-autoconfig.c b/mail/e-mail-autoconfig.c
index 5fa0fe23a6..ac03b9a148 100644
--- a/mail/e-mail-autoconfig.c
+++ b/mail/e-mail-autoconfig.c
@@ -330,32 +330,61 @@ mail_autoconfig_resolve_authority (const gchar *domain,
return name_server;
}
+static void
+mail_autoconfig_abort_soup_session_cb (GCancellable *cancellable,
+ SoupSession *soup_session)
+{
+ soup_session_abort (soup_session);
+}
+
static gboolean
mail_autoconfig_lookup (EMailAutoconfig *autoconfig,
const gchar *domain,
GCancellable *cancellable,
GError **error)
{
- GFile *file;
+ SoupMessage *soup_message;
+ SoupSession *soup_session;
+ gulong cancel_id = 0;
+ guint status;
gchar *uri;
- gboolean success;
+
+ soup_session = soup_session_sync_new ();
uri = g_strconcat (AUTOCONFIG_BASE_URI, domain, NULL);
- file = g_file_new_for_uri (uri);
+ soup_message = soup_message_new (SOUP_METHOD_GET, uri);
g_free (uri);
- /* Just to make sure we don't leak. */
- g_free (autoconfig->priv->markup_content);
- autoconfig->priv->markup_content = NULL;
+ if (G_IS_CANCELLABLE (cancellable))
+ cancel_id = g_cancellable_connect (
+ cancellable,
+ G_CALLBACK (mail_autoconfig_abort_soup_session_cb),
+ g_object_ref (soup_session),
+ (GDestroyNotify) g_object_unref);
+
+ status = soup_session_send_message (soup_session, soup_message);
- success = g_file_load_contents (
- file, cancellable,
- &autoconfig->priv->markup_content,
- NULL, NULL, error);
+ if (cancel_id > 0)
+ g_cancellable_disconnect (cancellable, cancel_id);
- g_object_unref (file);
+ if (SOUP_STATUS_IS_SUCCESSFUL (status)) {
- return success;
+ /* Just to make sure we don't leak. */
+ g_free (autoconfig->priv->markup_content);
+
+ autoconfig->priv->markup_content =
+ g_strdup (soup_message->response_body->data);
+ } else {
+ g_set_error_literal (
+ error, SOUP_HTTP_ERROR,
+ soup_message->status_code,
+ soup_message->reason_phrase);
+ }
+
+ g_object_unref (soup_message);
+ g_object_unref (soup_session);
+
+ return SOUP_STATUS_IS_SUCCESSFUL (status);
}
static void