diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-09-26 05:49:55 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-09-26 05:49:55 +0800 |
commit | 3efafe586b428af5061eb619abcfb5cb79c3dff0 (patch) | |
tree | e8eff23fa0f69b19b4ec8d5e588e202c5e233736 /mail/message-list.c | |
parent | 3a5399b3af0ab3c859c4f9c1b25bf155ad5ee50d (diff) | |
download | gsoc2013-evolution-3efafe586b428af5061eb619abcfb5cb79c3dff0.tar.gz gsoc2013-evolution-3efafe586b428af5061eb619abcfb5cb79c3dff0.tar.zst gsoc2013-evolution-3efafe586b428af5061eb619abcfb5cb79c3dff0.zip |
Updated to use Nat's ENameWestern parser.
2000-09-25 Jeffrey Stedfast <fejj@helixcode.com>
* message-list.c (address_compare): Updated to use Nat's
ENameWestern parser.
* Makefile.am: link against e-util/ename/libename.la
svn path=/trunk/; revision=5583
Diffstat (limited to 'mail/message-list.c')
-rw-r--r-- | mail/message-list.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/mail/message-list.c b/mail/message-list.c index 4fc773e77e..82915ea528 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -15,6 +15,7 @@ #include <bonobo/bonobo-main.h> #include <camel/camel-exception.h> #include <camel/camel-folder.h> +#include <e-util/ename/e-name-western.h> #include <string.h> #include <ctype.h> @@ -131,9 +132,9 @@ internet_address_new_from_string (const gchar *string) g_return_val_if_fail (string != NULL, NULL); g_return_val_if_fail (*string != '\0', NULL); - + padding = NULL; - + ptr = string; while (isspace (*ptr)) ptr++; @@ -233,11 +234,14 @@ static gint address_compare (gconstpointer address1, gconstpointer address2) { InternetAddress *ia1, *ia2; - gint retval; + gint retval = 0; ia1 = internet_address_new_from_string ((const char *) address1); ia2 = internet_address_new_from_string ((const char *) address2); + g_return_val_if_fail (ia1 != NULL, -1); + g_return_val_if_fail (ia2 != NULL, 1); + if (!ia1->name && !ia2->name) { /* if neither has a name we should compare addresses */ retval = g_strcasecmp (ia1->address, ia2->address); @@ -247,9 +251,45 @@ address_compare (gconstpointer address1, gconstpointer address2) else if (!ia2->name) retval = 1; else { - /* FIXME: use Nat's e-western-name parser - * so we can compare last name then first */ - retval = g_strcasecmp (ia1->name, ia2->name); + ENameWestern *name1, *name2; + + name1 = e_name_western_parse (ia1->name); + name2 = e_name_western_parse (ia2->name); + + if (!name1->last && !name2->last) { + /* neither has a last name */ + + retval = g_strcasecmp (ia1->name, ia2->name); + } else { + /* compare last names */ + + if (!name1->last) + retval = -1; + else if (!name2->last) + retval = 1; + else { + retval = g_strcasecmp (name1->last, name2->last); + if (!retval) { + /* last names are identical - compare first names */ + + if (!name1->first) + retval = -1; + else if (!name2->first) + retval = 1; + else { + retval = g_strcasecmp (name1->first, name2->first); + if (!retval) { + /* first names are identical - compare addresses */ + + retval = g_strcasecmp (ia1->address, ia2->address); + } + } + } + } + } + + e_name_western_free (name1); + e_name_western_free (name2); } } |