aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-10-05 09:49:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-10-05 09:49:13 +0800
commit83b5ac87fca211734b8712b1bbe3247ab89f98fc (patch)
tree14dbc064212f23e88b1a5c1af28b7dec8b229af2 /mail
parent4642513eacfaa1b16a5c71d1a064a251b3b8b176 (diff)
downloadgsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar.gz
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar.bz2
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar.lz
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar.xz
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.tar.zst
gsoc2013-evolution-83b5ac87fca211734b8712b1bbe3247ab89f98fc.zip
Use CamelInternetAddress instead of my quick hack (aka InternetAddress).
2000-10-04 Jeffrey Stedfast <fejj@helixcode.com> * message-list.c (address_compare): Use CamelInternetAddress instead of my quick hack (aka InternetAddress). svn path=/trunk/; revision=5741
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/mail-callbacks.c1
-rw-r--r--mail/message-list.c191
3 files changed, 43 insertions, 154 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index c2dbc6a731..b0c35dfeb4 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2000-10-04 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * message-list.c (address_compare): Use CamelInternetAddress
+ instead of my quick hack (aka InternetAddress).
+
2000-10-05 Iain Holmes <iain@helixcode.com>
* mail-summary.c: Don't watch for the message-changed signal.
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 588c1e087a..474b124786 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -299,7 +299,6 @@ composer_send_cb (EMsgComposer *composer, gpointer data)
void
composer_postpone_cb (EMsgComposer *composer, gpointer data)
{
- /* FIXME: do we want to use post_send_data to set flags and stuff? */
extern CamelFolder *outbox_folder;
CamelMimeMessage *message;
struct post_send_data *psd = data;
diff --git a/mail/message-list.c b/mail/message-list.c
index 46c69ea556..59ce592f7e 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -108,196 +108,81 @@ static struct {
{ NULL, NULL }
};
-typedef struct {
- char *name;
- char *address;
-} InternetAddress;
-
-
-static InternetAddress *
-internet_address_new_from_string (const gchar *string)
+static gint
+address_compare (gconstpointer address1, gconstpointer address2)
{
- /* We have 3 possibilities...
- 1. "Jeffrey Stedfast" <fejj@helixcode.com>
- 2. fejj@helixcode.com
- 3. <fejj@helixcode.com> (Jeffrey Stedfast)
-
- notzed: actually we dont, this isn't spruce, the addresses have already been parsed by camel.
- FIXME: This code wont handle multiple addresses.
- */
-
- InternetAddress *ia;
- gchar *name = NULL, *address = NULL;
- const gchar *ptr;
- const gchar *padding;
- gboolean in_quotes = FALSE;
- gboolean name_first = FALSE;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (*string != '\0', NULL);
+ CamelInternetAddress *ia1, *ia2;
+ const char *name1, *name2;
+ const char *addr1, *addr2;
+ gint retval = 0;
- padding = NULL;
+ ia1 = camel_internet_address_new ();
+ ia2 = camel_internet_address_new ();
- ptr = string;
- while (isspace (*ptr))
- ptr++;
+ camel_address_decode (CAMEL_ADDRESS (ia1), (const char *) address1);
+ camel_address_decode (CAMEL_ADDRESS (ia2), (const char *) address2);
- /* look for padding between parts... */
- for (; *ptr; ptr++) {
- if (*ptr == '"') {
- in_quotes = !in_quotes;
- name_first = TRUE;
- } else if (!in_quotes && isspace (*ptr)) {
- padding = ptr;
- break;
- }
+ if (!camel_internet_address_get (ia1, 0, &name1, &addr1)) {
+ camel_object_unref (CAMEL_OBJECT (ia1));
+ camel_object_unref (CAMEL_OBJECT (ia2));
+ return 1;
}
- if (padding) {
- padding--;
- /* we have a type-one or a type-three address */
- if (name_first) {
- name = g_strndup (string, (gint) (padding - string));
- g_strstrip (name);
-
- /* strip off the quotes */
- if (*name) {
- *(name + strlen (name) - 1) = '\0';
- memmove (name, name + 1, strlen (name) - 1);
- } else {
- g_free (name);
- name = NULL;
- }
-
- address = strchr (padding, '<');
- if (address) {
- address++;
- for (ptr = address; *ptr && *ptr != '>'; ptr++);
-
- address = g_strndup (address, (gint) (ptr - address));
- }
- } else {
- address = g_strndup (string, (gint) (padding - string));
- g_strstrip (address);
-
- /* strip off the braces */
- if (*address) {
- *(address + strlen (address) - 1) = '\0';
- memmove (address, address + 1, strlen (address) - 1);
- } else {
- g_free (address);
- address = NULL;
- }
-
- name = strchr (padding, '(');
- if (name) {
- name++;
- in_quotes = FALSE;
- ptr = name;
-
- while (*ptr) {
- if (*ptr == '"')
- in_quotes = !in_quotes;
- else if (!in_quotes && *ptr == ')')
- break;
- }
-
- name = g_strndup (name, (gint) (ptr - name));
- }
- }
- } else {
- /* we have a type-two address */
- address = g_strdup (string);
- }
-
- if (!address) {
- /* the address is the most important part! */
- g_free (name);
- return NULL;
+ if (!camel_internet_address_get (ia2, 0, &name2, &addr2)) {
+ camel_object_unref (CAMEL_OBJECT (ia1));
+ camel_object_unref (CAMEL_OBJECT (ia2));
+ return -1;
}
- ia = g_new (InternetAddress, 1);
- ia->name = name;
- ia->address = address;
-
- return ia;
-}
-
-static void
-internet_address_destroy (InternetAddress *ia)
-{
- g_return_if_fail (ia != NULL);
-
- g_free (ia->name);
- g_free (ia->address);
- g_free (ia);
-}
-
-static gint
-address_compare (gconstpointer address1, gconstpointer address2)
-{
- InternetAddress *ia1, *ia2;
- 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 (!name1 && !name2) {
/* if neither has a name we should compare addresses */
- retval = g_strcasecmp (ia1->address, ia2->address);
+ retval = g_strcasecmp (addr1, addr2);
} else {
- if (!ia1->name)
+ if (!name1)
retval = -1;
- else if (!ia2->name)
+ else if (!name2)
retval = 1;
else {
- ENameWestern *name1, *name2;
+ ENameWestern *wname1, *wname2;
- name1 = e_name_western_parse (ia1->name);
- name2 = e_name_western_parse (ia2->name);
+ wname1 = e_name_western_parse (name1);
+ wname2 = e_name_western_parse (name2);
- if (!name1->last && !name2->last) {
+ if (!wname1->last && !wname2->last) {
/* neither has a last name */
-
- retval = g_strcasecmp (ia1->name, ia2->name);
+ retval = g_strcasecmp (name1, name2);
} else {
/* compare last names */
-
- if (!name1->last)
+ if (!wname1->last)
retval = -1;
- else if (!name2->last)
+ else if (!wname2->last)
retval = 1;
else {
- retval = g_strcasecmp (name1->last, name2->last);
+ retval = g_strcasecmp (wname1->last, wname2->last);
if (!retval) {
/* last names are identical - compare first names */
-
- if (!name1->first)
+ if (!wname1->first)
retval = -1;
- else if (!name2->first)
+ else if (!wname2->first)
retval = 1;
else {
- retval = g_strcasecmp (name1->first, name2->first);
+ retval = g_strcasecmp (wname1->first, wname2->first);
if (!retval) {
/* first names are identical - compare addresses */
-
- retval = g_strcasecmp (ia1->address, ia2->address);
+ retval = g_strcasecmp (addr1, addr2);
}
}
}
}
}
- e_name_western_free (name1);
- e_name_western_free (name2);
+ e_name_western_free (wname1);
+ e_name_western_free (wname2);
}
}
- internet_address_destroy (ia1);
- internet_address_destroy (ia2);
+ camel_object_unref (CAMEL_OBJECT (ia1));
+ camel_object_unref (CAMEL_OBJECT (ia2));
return retval;
}