diff options
-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 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) |