diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-12-11 02:30:29 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-12-11 02:30:29 +0800 |
commit | d158af8cdfa6e4bf85c1e74769e8d61bc469494c (patch) | |
tree | ba55b970ae3a23e5ade4edbddc4eb8dcaf3033bd /mail/mail-config.c | |
parent | dc0d0ee010319425b19d8d8d493f0bc489d5fd07 (diff) | |
download | gsoc2013-evolution-d158af8cdfa6e4bf85c1e74769e8d61bc469494c.tar.gz gsoc2013-evolution-d158af8cdfa6e4bf85c1e74769e8d61bc469494c.tar.zst gsoc2013-evolution-d158af8cdfa6e4bf85c1e74769e8d61bc469494c.zip |
Merge revisions 36811:36865 from trunk.
svn path=/branches/kill-bonobo/; revision=36867
Diffstat (limited to 'mail/mail-config.c')
-rw-r--r-- | mail/mail-config.c | 99 |
1 files changed, 53 insertions, 46 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c index 8993e3b915..8333b02e09 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -801,53 +801,66 @@ 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); e_iterator_next (iter); - if (account->source == NULL) - continue; - - else if (account->source->url == NULL) - continue; - - else if (*account->source->url == '\0') + if ( !account || (account->source == NULL) || + (account->source->url == NULL) || (*account->source->url == '\0')) { + account = NULL; 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) { + account = 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 * @@ -855,48 +868,42 @@ 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); e_iterator_next (iter); - if (account->transport == NULL) - continue; - - else if (account->transport->url == NULL) - continue; - - else if (*account->transport->url == '\0') - continue; + if ( !account || (account->transport == NULL) || + (account->transport->url == NULL) || (*account->transport->url == '\0')) { + account = NULL; + 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) { + account = 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 |