aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-09-26 05:49:55 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-09-26 05:49:55 +0800
commit3efafe586b428af5061eb619abcfb5cb79c3dff0 (patch)
treee8eff23fa0f69b19b4ec8d5e588e202c5e233736 /mail
parent3a5399b3af0ab3c859c4f9c1b25bf155ad5ee50d (diff)
downloadgsoc2013-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')
-rw-r--r--mail/ChangeLog7
-rw-r--r--mail/Makefile.am1
-rw-r--r--mail/message-list.c52
3 files changed, 54 insertions, 6 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 200f4df407..e3e3ccdb46 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,10 @@
+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
+
2000-09-25 Dan Winship <danw@helixcode.com>
* mail-ops.c: CamelException is not for compile-time errors.
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 3e198c1d9e..83ae9cf4be 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -87,6 +87,7 @@ evolution_mail_LDADD = \
$(CAMEL_OBJS_EXTRA) \
$(top_builddir)/camel/libcamel.la \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/e-util/ename/libename.la \
$(top_builddir)/libibex/libibex.la \
$(top_builddir)/filter/libfilter.la \
$(BONOBO_VFS_GNOME_LIBS) \
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);
}
}