aboutsummaryrefslogtreecommitdiffstats
path: root/capplet/settings
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-03-17 03:34:18 +0800
committerMichael Meeks <michael.meeks@novell.com>2010-04-07 19:01:16 +0800
commit92145ffeb494b823c430f3101771ee05b2c31be0 (patch)
tree148ba5255f0b667c5635247a8ec93b640e91512a /capplet/settings
parent2e5b6ea7a491c1f236aac3a75c3bac5493e890dd (diff)
downloadgsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar.gz
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar.bz2
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar.lz
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar.xz
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.tar.zst
gsoc2013-evolution-92145ffeb494b823c430f3101771ee05b2c31be0.zip
Basic logic to guess mail autoconfig when offline
We will use a set of hardcoded autoconfiguration files, based on the ones from mozillamessaging.com, so that we can auto-configure mail accounts even when we can't read their information from the net. Signed-off-by: Federico Mena Quintero <federico@novell.com>
Diffstat (limited to 'capplet/settings')
-rw-r--r--capplet/settings/mail-guess-servers.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/capplet/settings/mail-guess-servers.c b/capplet/settings/mail-guess-servers.c
index aa5ebd7de4..f956058262 100644
--- a/capplet/settings/mail-guess-servers.c
+++ b/capplet/settings/mail-guess-servers.c
@@ -217,8 +217,14 @@ parse_soup_message (SoupMessage *msg, EmailProvider *provider)
return parse_message (msg->response_body->data, msg->response_body->length, provider);
}
-gboolean
-mail_guess_servers(EmailProvider *provider)
+static gboolean
+is_offline (void)
+{
+ return FALSE; /* FIXME */
+}
+
+static gboolean
+guess_when_online (EmailProvider *provider)
{
const gchar *cafile = NULL;
gchar *url;
@@ -230,7 +236,6 @@ mail_guess_servers(EmailProvider *provider)
parsed = soup_uri_new (url);
soup_uri_free (parsed);
-
session = soup_session_sync_new_with_options (
SOUP_SESSION_SSL_CA_FILE, cafile,
SOUP_SESSION_USER_AGENT, "get ",
@@ -246,7 +251,7 @@ mail_guess_servers(EmailProvider *provider)
if (!msg)
return FALSE;
- parse_msg(msg, provider);
+ parse_soup_message (msg, provider);
g_object_unref (msg);
g_object_unref(session);
@@ -256,6 +261,47 @@ mail_guess_servers(EmailProvider *provider)
}
+static char *
+get_filename_for_offline_autoconfig (const char *domain)
+{
+ return NULL; /* FIXME */
+}
+
+static gboolean
+guess_when_offline (EmailProvider *provider)
+{
+ char *filename;
+ char *contents;
+ gssize length;
+ gboolean success;
+
+ if (!provider->domain || provider->domain[0] == 0)
+ return FALSE;
+
+ success = FALSE;
+
+ filename = get_filename_for_offline_autoconfig (provider->domain);
+ if (!g_file_get_contents (filename, &contents, &length, NULL)) /* NULL-GError */
+ goto out;
+
+ success = parse_message (contents, (int) length, provider);
+
+out:
+ g_free (filename);
+ g_free (contents);
+
+ return success;
+}
+
+gboolean
+mail_guess_servers(EmailProvider *provider)
+{
+ if (is_offline ())
+ return guess_when_offline (provider);
+ else
+ return guess_when_online (provider);
+}
+
#ifdef TEST
gint
main (gint argc, gchar **argv)