aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-04-05 08:08:23 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-04-05 08:08:23 +0800
commit49e82f8b9fb67aba12f536c6ea29a640b7a10104 (patch)
tree74f0a25c023551fa3839ee2ed231536bd4ef9d77 /camel
parentbee1faf0a3ad4d71b76a831466b955bdde00e95d (diff)
downloadgsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar.gz
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar.bz2
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar.lz
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar.xz
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.tar.zst
gsoc2013-evolution-49e82f8b9fb67aba12f536c6ea29a640b7a10104.zip
Simplified since we can now decode in-reply-to without getting extra
2002-04-04 Jeffrey Stedfast <fejj@ximian.com> * camel-folder-summary.c (message_info_new): Simplified since we can now decode in-reply-to without getting extra cruft. Get rid of the FIXME about having to check scan->id because of the possibility of it being NULL, this can no longer happen. * camel-mime-utils.c (header_references_inreplyto_decode): New function to decode in-reply-to headers. Only grabs the first thing that looks like a message-id and then returns. (header_references_decode): Loop calling header_references_decode_single (a new internal function). svn path=/trunk/; revision=16361
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog13
-rw-r--r--camel/camel-folder-summary.c28
-rw-r--r--camel/camel-mime-utils.c59
-rw-r--r--camel/camel-mime-utils.h3
4 files changed, 61 insertions, 42 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 71c40ec9d6..49f3e64c11 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,16 @@
+2002-04-04 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-folder-summary.c (message_info_new): Simplified since we
+ can now decode in-reply-to without getting extra cruft. Get rid of
+ the FIXME about having to check scan->id because of the
+ possibility of it being NULL, this can no longer happen.
+
+ * camel-mime-utils.c (header_references_inreplyto_decode): New
+ function to decode in-reply-to headers. Only grabs the first thing
+ that looks like a message-id and then returns.
+ (header_references_decode): Loop calling
+ header_references_decode_single (a new internal function).
+
2002-04-04 Not Zed <NotZed@Ximian.com>
* camel-remote-store.c (remote_connect): Reset the keepalive
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 6aa37010a6..6dd0cddc20 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1588,26 +1588,9 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
/* decode our references and in-reply-to headers */
refs = header_references_decode (header_raw_find (&h, "references", NULL));
- irt = header_references_decode (header_raw_find (&h, "in-reply-to", NULL));
+ irt = header_references_inreplyto_decode (header_raw_find (&h, "in-reply-to", NULL));
if (refs || irt) {
if (irt) {
- struct _header_references *n, *r = irt;
-
- /* If there are multiple things in In-Reply-To that look like Message-IDs,
- only use the first one of them: odds are that the later ones are actually
- email addresses, not IDs. */
-
- /* since header_references_decode() returns the list in reverse order,
- free all but the last In-Reply-To message-id */
- while (r->next) {
- n = r->next;
- g_free (r->id);
- g_free (r);
- r = n;
- }
-
- irt = r;
-
/* The References field is populated from the ``References'' and/or ``In-Reply-To''
headers. If both headers exist, take the first thing in the In-Reply-To header
that looks like a Message-ID, and append it to the References header. */
@@ -1623,12 +1606,9 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
count = 0;
scan = refs;
while (scan) {
- /* FIXME: the id might be NULL because of a small bug in camel-mime-utils */
- if (scan->id) {
- md5_get_digest(scan->id, strlen(scan->id), digest);
- memcpy(mi->references->references[count].id.hash, digest, sizeof(mi->message_id.id.hash));
- count++;
- }
+ md5_get_digest(scan->id, strlen(scan->id), digest);
+ memcpy(mi->references->references[count].id.hash, digest, sizeof(mi->message_id.id.hash));
+ count++;
scan = scan->next;
}
mi->references->size = count;
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 86a8021cba..beff671e96 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -2675,37 +2675,62 @@ header_references_list_clear(struct _header_references **list)
*list = NULL;
}
-/* generate a list of references, from most recent up */
-struct _header_references *
-header_references_decode(const char *in)
+static void
+header_references_decode_single (const char **in, struct _header_references **head)
{
- const char *inptr = in;
- struct _header_references *head = NULL, *node;
+ struct _header_references *ref;
+ const char *inptr = *in;
char *id, *word;
-
- if (in == NULL || in[0] == '\0')
- return NULL;
-
+
while (*inptr) {
- header_decode_lwsp(&inptr);
+ header_decode_lwsp (&inptr);
if (*inptr == '<') {
- id = header_msgid_decode_internal(&inptr);
+ id = header_msgid_decode_internal (&inptr);
if (id) {
- node = g_malloc(sizeof(*node));
- node->next = head;
- head = node;
- node->id = id;
+ ref = g_malloc (sizeof (struct _header_references));
+ ref->next = *head;
+ ref->id = id;
+ *head = ref;
+ break;
}
} else {
- word = header_decode_word(&inptr);
+ word = header_decode_word (&inptr);
if (word)
g_free (word);
else if (*inptr != '\0')
inptr++; /* Stupid mailer tricks */
}
}
+
+ *in = inptr;
+}
- return head;
+struct _header_references *
+header_references_inreplyto_decode (const char *in)
+{
+ struct _header_references *ref = NULL;
+
+ if (in == NULL || in[0] == '\0')
+ return NULL;
+
+ header_references_decode_single (&in, &ref);
+
+ return ref;
+}
+
+/* generate a list of references, from most recent up */
+struct _header_references *
+header_references_decode (const char *in)
+{
+ struct _header_references *refs = NULL;
+
+ if (in == NULL || in[0] == '\0')
+ return NULL;
+
+ while (*in)
+ header_references_decode_single (&in, &refs);
+
+ return refs;
}
struct _header_references *
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 8936012cbd..2c29f5cc43 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -188,7 +188,8 @@ char *header_msgid_decode (const char *in);
/* generate msg id */
char *header_msgid_generate (void);
-/* decode a References header */
+/* decode a References or In-Reply-To header */
+struct _header_references *header_references_inreplyto_decode (const char *in);
struct _header_references *header_references_decode(const char *in);
void header_references_list_clear(struct _header_references **list);
void header_references_list_append_asis(struct _header_references **list, char *ref);