aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-06-03 02:09:18 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-06-03 02:09:18 +0800
commit4cf5bbfa5a228f47256e74a7a11180e2d512561b (patch)
tree102fe3a9d0607fe08e971e11ac6f7bc13ec2bf15
parentdb7feeef33e7d9beb72ededf321acc11fe471c96 (diff)
downloadgsoc2013-evolution-4cf5bbfa5a228f47256e74a7a11180e2d512561b.tar.gz
gsoc2013-evolution-4cf5bbfa5a228f47256e74a7a11180e2d512561b.tar.zst
gsoc2013-evolution-4cf5bbfa5a228f47256e74a7a11180e2d512561b.zip
If we get a funny result, just throw it out. Basically a fix for the one
2000-06-02 Not Zed <NotZed@HelixCode.com> * camel-mime-utils.c (header_decode_date): If we get a funny result, just throw it out. Basically a fix for the one true broken TradeClient. 2000-06-01 Not Zed <NotZed@HelixCode.com> * camel-folder-summary.c (message_info_free): Free references/messsage id. (message_info_save): Save them. (message_info_load): Load them. (message_info_new): And get them from the new message. (CAMEL_FOLDER_SUMMARY_VERSION): Bumped for new changes. * camel-folder-summary.h: Added references and messageid to summary. svn path=/trunk/; revision=3391
-rw-r--r--camel/ChangeLog19
-rw-r--r--camel/camel-folder-summary.c35
-rw-r--r--camel/camel-folder-summary.h4
-rw-r--r--camel/camel-mime-utils.c89
-rw-r--r--camel/camel-mime-utils.h12
5 files changed, 149 insertions, 10 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 64ae632671..661a4f8d2c 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,21 @@
+2000-06-02 Not Zed <NotZed@HelixCode.com>
+
+ * camel-mime-utils.c (header_decode_date): If we get a funny
+ result, just throw it out. Basically a fix for the one true
+ broken TradeClient.
+
+2000-06-01 Not Zed <NotZed@HelixCode.com>
+
+ * camel-folder-summary.c (message_info_free): Free
+ references/messsage id.
+ (message_info_save): Save them.
+ (message_info_load): Load them.
+ (message_info_new): And get them from the new message.
+ (CAMEL_FOLDER_SUMMARY_VERSION): Bumped for new changes.
+
+ * camel-folder-summary.h: Added references and messageid to
+ summary.
+
2000-06-02 Christopher James Lahey <clahey@helixcode.com>
* camel-session.c: Ref and unref objects in the service cache
@@ -26,6 +44,7 @@
* camel-data-wrapper.c (finalize): unref the stream, if it exists.
2000-06-01 Not Zed <NotZed@HelixCode.com>
+>>>>>>> 1.212
* camel-mime-part.c (construct_from_parser): For a message part,
set the default content-type to message/rfc822. Maybe needs to be
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 9e3b478236..1224047b29 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -48,7 +48,7 @@
extern int strdup_count, malloc_count, free_count;
#endif
-#define CAMEL_FOLDER_SUMMARY_VERSION (4)
+#define CAMEL_FOLDER_SUMMARY_VERSION (5)
struct _CamelFolderSummaryPrivate {
GHashTable *filter_charset; /* CamelMimeFilterCharset's indexed by source charset */
@@ -969,7 +969,16 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
mi->user_flags = NULL;
mi->date_sent = header_decode_date(header_raw_find(&h, "date", NULL), NULL);
mi->date_received = 0;
-
+ mi->message_id = header_msgid_decode(header_raw_find(&h, "message-id", NULL));
+ /* if we have a references, use that, otherwise, see if we have an in-reply-to
+ header, with parsable content, otherwise *shrug* */
+ mi->references = header_references_decode(header_raw_find(&h, "references", NULL));
+ if (mi->references == NULL) {
+ char *id;
+ id = header_msgid_decode(header_raw_find(&h, "in-reply-to", NULL));
+ if (id)
+ header_references_list_append_asis(&mi->references, id);
+ }
return mi;
}
@@ -995,6 +1004,15 @@ message_info_load(CamelFolderSummary *s, FILE *in)
camel_folder_summary_decode_string(in, &mi->to);
mi->content = NULL;
+ camel_folder_summary_decode_string(in, &mi->message_id);
+
+ camel_folder_summary_decode_uint32(in, &count);
+ for (i=0;i<count;i++) {
+ char *id;
+ camel_folder_summary_decode_string(in, &id);
+ header_references_list_append_asis(&mi->references, id);
+ }
+
camel_folder_summary_decode_uint32(in, &count);
for (i=0;i<count;i++) {
char *name;
@@ -1011,6 +1029,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
{
guint32 count;
CamelFlag *flag;
+ struct _header_references *refs;
io(printf("Saving message info\n"));
@@ -1023,6 +1042,16 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
camel_folder_summary_encode_string(out, mi->from);
camel_folder_summary_encode_string(out, mi->to);
+ camel_folder_summary_encode_string(out, mi->message_id);
+
+ count = header_references_list_size(&mi->references);
+ camel_folder_summary_encode_uint32(out, count);
+ refs = mi->references;
+ while (refs) {
+ camel_folder_summary_encode_string(out, refs->id);
+ refs = refs->next;
+ }
+
count = camel_flag_list_size(&mi->user_flags);
camel_folder_summary_encode_uint32(out, count);
flag = mi->user_flags;
@@ -1040,6 +1069,8 @@ message_info_free(CamelFolderSummary *s, CamelMessageInfo *mi)
g_free(mi->subject);
g_free(mi->from);
g_free(mi->to);
+ g_free(mi->message_id);
+ header_references_list_clear(&mi->references);
camel_flag_list_free(&mi->user_flags);
g_free(mi);
}
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index a22172c41b..1281415368 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -79,6 +79,10 @@ typedef struct {
time_t date_sent;
time_t date_received;
+ /* Message-ID / References structures */
+ char *message_id; /* for this message */
+ struct _header_references *references; /* from parent to root */
+
struct _CamelFlag *user_flags;
/* tree of content description - NULL if it is not available */
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index af7e9356e1..c893c10050 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1505,17 +1505,14 @@ header_decode_address(const char **in)
return addr;
}
-char *
-header_msgid_decode(const char *in)
+static char *
+header_msgid_decode_internal(const char **in)
{
- const char *inptr = in;
+ const char *inptr = *in;
char *msgid = NULL;
d(printf("decoding Message-ID: '%s'\n", in));
- if (in == NULL)
- return NULL;
-
header_decode_lwsp(&inptr);
if (*inptr == '<') {
inptr++;
@@ -1534,10 +1531,82 @@ header_msgid_decode(const char *in)
} else {
w(g_warning("missing opening '<' on message id: %s", in));
}
+ *in = inptr;
return msgid;
}
+char *
+header_msgid_decode(const char *in)
+{
+ if (in == NULL)
+ return NULL;
+
+ return header_msgid_decode_internal(&in);
+}
+
+void
+header_references_list_append_asis(struct _header_references **list, char *ref)
+{
+ struct _header_references *w = (struct _header_references *)list, *n;
+ while (w->next)
+ w = w->next;
+ n = g_malloc(sizeof(*n));
+ n->id = ref;
+ n->next = 0;
+ w->next = n;
+}
+
+int
+header_references_list_size(struct _header_references **list)
+{
+ int count = 0;
+ struct _header_references *w = *list;
+ while (w) {
+ count++;
+ w = w->next;
+ }
+ return count;
+}
+
+void
+header_references_list_clear(struct _header_references **list)
+{
+ struct _header_references *w = *list, *n;
+ while (w) {
+ n = w->next;
+ g_free(w->id);
+ g_free(w);
+ w = n;
+ }
+ *list = NULL;
+}
+
+/* generate a list of references, from most recent up */
+struct _header_references *
+header_references_decode(const char *in)
+{
+ const char *inptr = in, *intmp;
+ struct _header_references *head = NULL, *node;
+ char *id, *last;
+
+ if (in == NULL)
+ return NULL;
+
+ do {
+ last = inptr;
+ id = header_msgid_decode_internal(&inptr);
+ if (id) {
+ node = g_malloc(sizeof(*node));
+ node->next = head;
+ head = node;
+ node->id = id;
+ }
+ } while (last != inptr);
+
+ return head;
+}
+
struct _header_address *
header_mailbox_decode(const char *in)
{
@@ -1891,8 +1960,12 @@ header_decode_date(const char *in, int *saveoffset)
header_decode_lwsp(&inptr);
if (*inptr == ',')
inptr++;
- else
- w(g_warning("day not followed by ','"));
+ else {
+ w(g_warning("day not followed by ',' its probably a broken TradeClient, so we'll ignore its date entirely"));
+ if (saveoffset)
+ *saveoffset = 0;
+ return 0;
+ }
}
}
tm.tm_mday = header_decode_int(&inptr);
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index f95f76363c..5f715243d0 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -23,6 +23,12 @@
#include <time.h>
+/* a list of references for this message */
+struct _header_references {
+ struct _header_references *next;
+ char *id;
+};
+
struct _header_param {
struct _header_param *next;
char *name;
@@ -137,6 +143,12 @@ char *header_format_date(time_t time, int offset);
/* decode a message id */
char *header_msgid_decode(const char *in);
+/* decode a References header */
+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);
+int header_references_list_size(struct _header_references **list);
+
/* decode the mime-type header */
void header_mime_decode(const char *in, int *maj, int *min);