diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2008-12-04 23:53:37 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-12-04 23:53:37 +0800 |
commit | c86b544193b498fbfbbd755963ac60a6339f7ea3 (patch) | |
tree | 2c4304de1f4417bd83baf8429ea25f8d51e6aaa9 | |
parent | a3b8881d09c0a6854b12551dcee89c87c28739fe (diff) | |
download | gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar.gz gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar.bz2 gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar.lz gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar.xz gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.tar.zst gsoc2013-evolution-c86b544193b498fbfbbd755963ac60a6339f7ea3.zip |
** Fixes bug #552583
2008-12-04 Matthew Barnes <mbarnes@redhat.com>
** Fixes bug #552583
* mail/mail-config.c (mail_config_get_account_by_source_url),
(mail_config_get_account_by_transport_url):
For the purpose of matching a URL to an EAccount, only compare
the protocol, user, host and port and disregard the rest.
svn path=/trunk/; revision=36832
-rw-r--r-- | mail/ChangeLog | 9 | ||||
-rw-r--r-- | mail/mail-config.c | 71 |
2 files changed, 49 insertions, 31 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 2f615c2a1c..3af8a105d7 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2008-12-04 Matthew Barnes <mbarnes@redhat.com> + + ** Fixes bug #552583 + + * mail-config.c (mail_config_get_account_by_source_url), + (mail_config_get_account_by_transport_url): + For the purpose of matching a URL to an EAccount, only compare + the protocol, user, host and port and disregard the rest. + 2008-11-23 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #552850 diff --git a/mail/mail-config.c b/mail/mail-config.c index 001b5399c7..c5a807e8d4 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -800,18 +800,40 @@ mail_config_get_account_by_uid (const char *uid) return (EAccount *) e_account_list_find (config->accounts, E_ACCOUNT_FIND_UID, uid); } +static gboolean +mail_config_account_url_equal (const CamelURL *u1, + const CamelURL *u2) +{ + /* For the purpose of matching a URL to an EAccount, only compare + * the protocol, user, host and port and disregard the rest. */ + + if (g_strcmp0 (u1->protocol, u2->protocol) != 0) + return FALSE; + + if (g_strcmp0 (u1->user, u2->user) != 0) + return FALSE; + + if (g_strcmp0 (u1->host, u2->host) != 0) + return FALSE; + + return (u1->port == u2->port); +} + EAccount * mail_config_get_account_by_source_url (const char *source_url) { EAccount *account = NULL; EIterator *iter; + CamelURL *url; g_return_val_if_fail (source_url != NULL, NULL); + url = camel_url_new (source_url, NULL); + g_return_val_if_fail (url != NULL, NULL); + iter = e_list_get_iterator ((EList *) config->accounts); - while (e_iterator_is_valid (iter)) { - CamelURL *url; - gchar *string; + while (account == NULL && e_iterator_is_valid (iter)) { + CamelURL *account_url; account = (EAccount *) e_iterator_get (iter); @@ -826,27 +848,19 @@ mail_config_get_account_by_source_url (const char *source_url) else if (*account->source->url == '\0') continue; - url = camel_url_new (account->source->url, NULL); - if (url == NULL) + account_url = camel_url_new (account->source->url, NULL); + if (account_url == NULL) continue; - /* Simplify the account URL for comparison. */ - string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - if (string == NULL || strcmp (string, source_url) != 0) + if (!mail_config_account_url_equal (url, account_url)) account = NULL; /* not a match */ - camel_url_free (url); - g_free (string); - - if (account != NULL) { - g_object_unref (iter); - return account; - } + camel_url_free (account_url); } g_object_unref (iter); - return NULL; + return account; } EAccount * @@ -854,13 +868,16 @@ mail_config_get_account_by_transport_url (const char *transport_url) { EAccount *account = NULL; EIterator *iter; + CamelURL *url; g_return_val_if_fail (transport_url != NULL, NULL); + url = camel_url_new (transport_url, NULL); + g_return_val_if_fail (url != NULL, NULL); + iter = e_list_get_iterator ((EList *) config->accounts); - while (e_iterator_is_valid (iter)) { - CamelURL *url; - gchar *string; + while (account == NULL && e_iterator_is_valid (iter)) { + CamelURL *account_url; account = (EAccount *) e_iterator_get (iter); @@ -875,27 +892,19 @@ mail_config_get_account_by_transport_url (const char *transport_url) else if (*account->transport->url == '\0') continue; - url = camel_url_new (account->transport->url, NULL); - if (url == NULL) + account_url = camel_url_new (account->transport->url, NULL); + if (account_url == NULL) continue; - /* Simplify the account URL for comparison. */ - string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); - if (string == NULL || strcmp (string, transport_url) != 0) + if (!mail_config_account_url_equal (url, account_url)) account = NULL; /* not a match */ camel_url_free (url); - g_free (string); - - if (account != NULL) { - g_object_unref (iter); - return account; - } } g_object_unref (iter); - return NULL; + return account; } int |