[evolution/express-offline-mail-guesser: 3/5] Basic logic to guess mail autoconfig when offline
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/express-offline-mail-guesser: 3/5] Basic logic to guess mail autoconfig when offline
- Date: Wed, 17 Mar 2010 00:02:20 +0000 (UTC)
commit 103408aba5aae73e85bd0345025b162862fcf822
Author: Federico Mena Quintero <federico novell com>
Date: Tue Mar 16 13:34:18 2010 -0600
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>
capplet/settings/mail-guess-servers.c | 54 ++++++++++++++++++++++++++++++--
1 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/capplet/settings/mail-guess-servers.c b/capplet/settings/mail-guess-servers.c
index e5324e9..1d62d82 100644
--- a/capplet/settings/mail-guess-servers.c
+++ b/capplet/settings/mail-guess-servers.c
@@ -218,8 +218,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 char *cafile = NULL;
char *url;
@@ -232,7 +238,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 ",
@@ -248,7 +253,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);
@@ -258,6 +263,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
int
main (int argc, char **argv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]