From 8f07a288b4cec7df3d5bcefd43158061a8073886 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 29 Apr 2002 20:19:32 +0000 Subject: Strip leading/trailing whitespace from the username because users 2002-04-29 Jeffrey Stedfast * mail-account-gui.c (save_service): Strip leading/trailing whitespace from the username because users sometimes accidently add extra spaces here and there. Fixes bug #24009 (along with a number of other "bugs"). (mail_account_gui_auto_detect_extra_conf): Use a CamelURL instead of a GHashTable *settings. Also parse out the port # from the hostname. svn path=/trunk/; revision=16633 --- mail/ChangeLog | 3 +++ mail/mail-account-gui.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 3ef4cdfa68..3b8f49b304 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -4,6 +4,9 @@ whitespace from the username because users sometimes accidently add extra spaces here and there. Fixes bug #24009 (along with a number of other "bugs"). + (mail_account_gui_auto_detect_extra_conf): Use a CamelURL instead + of a GHashTable *settings. Also parse out the port # from the + hostname. 2002-04-29 Larry Ewing diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 833e6d9c3a..756fbd2c67 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -213,8 +213,9 @@ mail_account_gui_auto_detect_extra_conf (MailAccountGui *gui) { MailAccountGuiService *service = &gui->source; CamelProvider *prov = service->provider; - GHashTable *settings, *auto_detected; + GHashTable *auto_detected; GtkWidget *path; + CamelURL *url; char *text; if (!prov) @@ -226,27 +227,40 @@ mail_account_gui_auto_detect_extra_conf (MailAccountGui *gui) else path = NULL; - settings = g_hash_table_new (g_str_hash, g_str_equal); + url = g_new0 (CamelURL, 1); + camel_url_set_protocol (url, prov->protocol); + if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_HOST)) { - text = gtk_entry_get_text (service->hostname); - if (text) - g_hash_table_insert (settings, "hostname", text); + text = g_strdup (gtk_entry_get_text (service->hostname)); + if (*text) { + char *port; + + port = strchr (text, ':'); + if (port) { + *port++ = '\0'; + camel_url_set_port (url, atoi (port)); + } + + camel_url_set_host (url, text); + } + g_free (text); } if (CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_USER)) { - text = gtk_entry_get_text (service->username); - if (text) - g_hash_table_insert (settings, "username", text); + text = g_strdup (gtk_entry_get_text (service->username)); + g_strstrip (text); + camel_url_set_user (url, text); + g_free (text); } if (path && CAMEL_PROVIDER_ALLOWS (prov, CAMEL_URL_PART_PATH)) { text = gtk_entry_get_text (service->path); - if (text) - g_hash_table_insert (settings, "path", text); + if (text && *text) + camel_url_set_path (url, text); } - camel_provider_auto_detect (prov, settings, &auto_detected, NULL); - g_hash_table_destroy (settings); + camel_provider_auto_detect (prov, url, &auto_detected, NULL); + camel_url_free (url); if (auto_detected) { CamelProviderConfEntry *entries; -- cgit v1.2.3