diff options
author | Federico Mena Quintero <federico@novell.com> | 2010-03-17 03:34:18 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@novell.com> | 2010-03-18 06:08:15 +0800 |
commit | cf7854f416e9dbaaadf3c5edf7e9399151c9f79c (patch) | |
tree | 45da374bccbddcc4310a9d46ecc6e941fd0b14de | |
parent | 5cedd8e7692a0b36267281b0465f50b3e80bd5fc (diff) | |
download | gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar.gz gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar.bz2 gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar.lz gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar.xz gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.tar.zst gsoc2013-evolution-cf7854f416e9dbaaadf3c5edf7e9399151c9f79c.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>
-rw-r--r-- | 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 e5324e9e5a..1d62d8222e 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) |