diff options
-rw-r--r-- | ChangeLog | 39 | ||||
-rw-r--r-- | camel/camel-folder-summary.c | 16 | ||||
-rw-r--r-- | camel/camel-folder-summary.h | 10 | ||||
-rw-r--r-- | camel/providers/mbox/Makefile.am | 6 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.c | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.h | 4 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-parser.c | 46 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-parser.h | 10 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-store.c | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-store.h | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-utils.c | 51 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-utils.h | 5 | ||||
-rw-r--r-- | tests/test9.c | 2 |
13 files changed, 159 insertions, 36 deletions
@@ -1,3 +1,42 @@ +2000-01-18 bertrand <bertrand@helixcode.com> + + * camel/providers/mbox/camel-mbox-summary.c (camel_mbox_save_summary): + (mbox_load_summary): summary file read/write routines. + + * camel/providers/mbox/camel-mbox-utils.c (parsed_information_to_mbox_summary): + routine to construct the summary after the mbox + file has been parsed and the x-evolution fields + inserted. + +2000-01-17 bertrand <bertrand@helixcode.com> + + * camel/providers/mbox/camel-mbox-utils.c (camel_mbox_write_xev): + dont use the x_evolution field but rather the uid to + determine the presence of "X-Evolution" in the mail. + + * camel/providers/mbox/camel-mbox-parser.c (camel_mbox_parse_file): + parse the status and uid values if the x-evolution + has been found. + + * camel/providers/mbox/camel-mbox-utils.c (camel_mbox_xev_parse_header_content): + return the parsed status field correctly. + + * camel/providers/mbox/camel-mbox-utils.h: + fixed bad prototype. + + * camel/providers/mbox/camel-mbox-parser.c (camel_mbox_parse_file): + parse and store the "To:" header. + + * camel/providers/mbox/camel-mbox-parser.h: + added a "to" field + + * camel/camel-folder-summary.c: + create the arrays here. + + * camel/camel-folder-summary.h: the list of + summary information is no longer a GList but + rather a GArray. + 2000-01-17 Chrsitopher James Lahey <clahey@helixcode.com> * head.png, phone.png, email.png, web.png, snailmail.png: Images diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 2c6b45b718..4d1745e3b2 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -34,8 +34,8 @@ static GtkObjectClass *parent_class=NULL; #define CFS_CLASS(so) CAMEL_FOLDER_SUMMARY_CLASS (GTK_OBJECT(so)->klass) -static const GList *_get_subfolder_info_list (CamelFolderSummary *summary); -static const GList *_get_message_info_list (CamelFolderSummary *summary); +static const GArray *_get_subfolder_info_list (CamelFolderSummary *summary); +static const GArray *_get_message_info_list (CamelFolderSummary *summary); static void _finalize (GtkObject *object); @@ -65,8 +65,8 @@ camel_folder_summary_init (gpointer object, gpointer klass) CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (object); CAMEL_LOG_FULL_DEBUG ( "camel_folder_summary_init:: Entering\n"); - summary->subfolder_info_list = NULL; - summary->message_info_list = NULL; + summary->subfolder_info_list = g_array_new (FALSE, FALSE, sizeof (CamelFolderInfo); + summary->message_info_list = g_array_new (FALSE, FALSE, sizeof (CamelMessageInfo); CAMEL_LOG_FULL_DEBUG ( "camel_folder_summary_init:: Leaving\n"); } @@ -116,14 +116,14 @@ camel_folder_summary_new () return gtk_type_new (CAMEL_FOLDER_SUMMARY_TYPE); } -static const GList * +static const GArray * _get_subfolder_info_list (CamelFolderSummary *summary) { return summary->subfolder_info_list; } -const GList * +const GArray * camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary) { return CFS_CLASS (summary)->get_subfolder_info_list (summary); @@ -132,13 +132,13 @@ camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary) -static const GList * +static const GArray * _get_message_info_list (CamelFolderSummary *summary) { return summary->message_info_list; } -const GList * +const GArray * camel_folder_summary_get_message_info_list (CamelFolderSummary *summary) { return CFS_CLASS (summary)->get_message_info_list (summary); diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index 0c8f26ed5c..b89c546090 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -72,9 +72,9 @@ typedef struct { typedef struct { GtkObject parent_object; - - GList *subfolder_info_list; /* informations on subfolders */ - GList *message_info_list; /* informations on messages */ + + GArray *subfolder_info_list; /* informations on subfolders */ + GArray *message_info_list; /* informations on messages */ } CamelFolderSummary; @@ -100,8 +100,8 @@ GtkType camel_folder_summary_get_type (void); CamelFolderSummary *camel_folder_summary_new (); /* get information about the messages and the subfolders in the directory */ -const GList *camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary); -const GList *camel_folder_summary_get_message_info_list (CamelFolderSummary *summary); +const GArray *camel_folder_summary_get_subfolder_info_list (CamelFolderSummary *summary); +const GArray *camel_folder_summary_get_message_info_list (CamelFolderSummary *summary); diff --git a/camel/providers/mbox/Makefile.am b/camel/providers/mbox/Makefile.am index 247ce55f1d..5dffdc4eff 100644 --- a/camel/providers/mbox/Makefile.am +++ b/camel/providers/mbox/Makefile.am @@ -13,14 +13,16 @@ INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \ libcamelmbox_la_SOURCES = \ camel-mbox-folder.c \ - camel-mbox-store.c \ camel-mbox-parser.c \ + camel-mbox-store.c \ + camel-mbox-summary.c \ camel-mbox-utils.c libcamelmboxinclude_HEADERS = \ camel-mbox-folder.h \ - camel-mbox-store.h \ camel-mbox-parser.h \ + camel-mbox-store.h \ + camel-mbox-summary.h \ camel-mbox-utils.h diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 82e5bc15b3..2420e59f43 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -2,6 +2,7 @@ /* camel-mbox-folder.c : Abstract class for an email folder */ /* + * Author : Bertrand Guiheneuf <bertrand@helixcode.com> * * Copyright (C) 1999 Helix Code . * @@ -21,7 +22,6 @@ * USA */ -/* Author : Bertrand Guiheneuf <bertrand@helixcode.com> */ #include <config.h> diff --git a/camel/providers/mbox/camel-mbox-folder.h b/camel/providers/mbox/camel-mbox-folder.h index 6a0d8d66db..1f010ce605 100644 --- a/camel/providers/mbox/camel-mbox-folder.h +++ b/camel/providers/mbox/camel-mbox-folder.h @@ -3,7 +3,9 @@ /* * - * Copyright (C) 1999 Bertrand Guiheneuf <bertrand@helixcode.com> . + * Author : Bertrand Guiheneuf <bertrand@helixcode.com> + * + * Copyright (C) 1999 Helix Code . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/camel/providers/mbox/camel-mbox-parser.c b/camel/providers/mbox/camel-mbox-parser.c index eee41b83db..7eee449f1d 100644 --- a/camel/providers/mbox/camel-mbox-parser.c +++ b/camel/providers/mbox/camel-mbox-parser.c @@ -3,7 +3,9 @@ /* * - * Copyright (C) 1999 Bertrand Guiheneuf <bertrand@helixcode.com> . + * Author : Bertrand Guiheneuf <bertrand@helixcode.com> + * + * Copyright (C) 1999 Helix Code . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -24,6 +26,7 @@ #include <config.h> #include "camel-mbox-parser.h" +#include "camel-mbox-utils.h" #include "camel-log.h" #include "camel-exception.h" #include <sys/types.h> @@ -46,6 +49,9 @@ #define MBOX_PARSER_SUBJECT_KW "subject:" #define MBOX_PARSER_SUBJECT_KW_SZ 8 +#define MBOX_PARSER_TO_KW "to:" +#define MBOX_PARSER_TO_KW_SZ 3 + #define MBOX_PARSER_X_EVOLUTION_KW "x-evolution:" #define MBOX_PARSER_X_EVOLUTION_KW_SZ 12 @@ -100,15 +106,14 @@ clear_message_info (CamelMboxParserMessageInfo *preparsing_info) preparsing_info->from = NULL; preparsing_info->date = NULL; preparsing_info->subject = NULL; - preparsing_info->status = NULL; preparsing_info->priority = NULL; preparsing_info->references = NULL; preparsing_info->body_summary = NULL; preparsing_info->end_of_headers_offset = 0; - preparsing_info->x_evolution = NULL; preparsing_info->x_evolution_offset = 0; - /* reparsing_info->x_evolution_length = 0; */ + preparsing_info->status = 0; + preparsing_info->uid = 0; } @@ -571,6 +576,8 @@ camel_mbox_parse_file (int fd, int real_interval; gboolean newline; GArray *return_value; + gchar *x_ev_header_content; + /* get file size */ fstat_result = fstat (fd, &stat_buf); @@ -674,6 +681,21 @@ camel_mbox_parse_file (int fd, } + /* is the next part a "To" header ? */ + if (g_strncasecmp (parser->buffer + parser->current_position, + MBOX_PARSER_TO_KW, + MBOX_PARSER_TO_KW_SZ) == 0) { + + advance_n_chars (parser, MBOX_PARSER_TO_KW_SZ); + read_header (parser, (gchar **) ((gchar *)parser + + G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) + + G_STRUCT_OFFSET (CamelMboxParserMessageInfo, to))); + + newline = TRUE; + continue; + } + + /* is the next part a "X-evolution" header ? */ if (g_strncasecmp (parser->buffer + parser->current_position, MBOX_PARSER_X_EVOLUTION_KW, @@ -685,9 +707,19 @@ camel_mbox_parse_file (int fd, parser->current_message_info.x_evolution_offset = parser->real_position - parser->current_message_info.message_position; advance_n_chars (parser, MBOX_PARSER_X_EVOLUTION_KW_SZ); - read_header (parser, (gchar **) ((gchar *)parser + - G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) + - G_STRUCT_OFFSET (CamelMboxParserMessageInfo, x_evolution))); + + /* read the header */ + read_header (parser, &x_ev_header_content); + + /* parse it and put the result in the uid and status fields */ + camel_mbox_xev_parse_header_content (x_ev_header_content, + (guint32 *) ((gchar *)parser + + G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) + + G_STRUCT_OFFSET (CamelMboxParserMessageInfo, uid)), + (guchar *) ((gchar *)parser + + G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) + + G_STRUCT_OFFSET (CamelMboxParserMessageInfo, status))); + g_free (x_ev_header_content); /* parser->current_message_info.x_evolution_length = diff --git a/camel/providers/mbox/camel-mbox-parser.h b/camel/providers/mbox/camel-mbox-parser.h index a4b3af9aff..be01c2e0a5 100644 --- a/camel/providers/mbox/camel-mbox-parser.h +++ b/camel/providers/mbox/camel-mbox-parser.h @@ -3,7 +3,9 @@ /* * - * Copyright (C) 1999 Bertrand Guiheneuf <bertrand@helixcode.com> . + * Author : Bertrand Guiheneuf <bertrand@helixcode.com> + * + * Copyright (C) 1999 Helix Code . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -30,10 +32,11 @@ typedef struct { glong message_position; glong size; + gchar *from; + gchar *to; gchar *date; gchar *subject; - gchar *status; gchar *priority; gchar *references; gchar *body_summary; @@ -41,7 +44,8 @@ typedef struct { gchar *x_evolution; gshort x_evolution_offset; - /* gshort x_evolution_length; */ + guint32 uid; + guchar status; } CamelMboxParserMessageInfo; diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c index d0b1d15cbc..83704ea018 100644 --- a/camel/providers/mbox/camel-mbox-store.c +++ b/camel/providers/mbox/camel-mbox-store.c @@ -3,7 +3,7 @@ /* * - * Copyright (C) 1999 Bertrand Guiheneuf <bertrand@helixcode.com> . + * Copyright (C) 2000 HelixCode <bertrand@helixcode.com> . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h index 2f93c98c0e..8033d9d695 100644 --- a/camel/providers/mbox/camel-mbox-store.h +++ b/camel/providers/mbox/camel-mbox-store.h @@ -3,7 +3,7 @@ /* * - * Copyright (C) 1999 Bertrand Guiheneuf <bertrand@helixcode.com> . + * Copyright (C) 2000 HelixCode <bertrand@helixcode.com> . * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/camel/providers/mbox/camel-mbox-utils.c b/camel/providers/mbox/camel-mbox-utils.c index f4cbe34899..d0b0db5518 100644 --- a/camel/providers/mbox/camel-mbox-utils.c +++ b/camel/providers/mbox/camel-mbox-utils.c @@ -57,6 +57,8 @@ #include <glib.h> #include "camel-mbox-utils.h" #include "camel-mbox-parser.h" +#include "camel-folder-summary.h" +#include "camel-mbox-summary.h" @@ -132,7 +134,7 @@ string_to_flag (gchar string) void camel_mbox_xev_parse_header_content (gchar header_content[6], guint32 *uid, - guchar status) + guchar *status) { /* we assume that the first 4 characters of the header content @@ -140,7 +142,7 @@ camel_mbox_xev_parse_header_content (gchar header_content[6], toooo bad. */ *uid = string_to_uid (header_content); - status = string_to_flag (header_content[5]); + *status = string_to_flag (header_content[5]); } void @@ -249,7 +251,7 @@ camel_mbox_write_xev (gchar *mbox_file_name, cur_msg_info = (CamelMboxParserMessageInfo *)(summary_information->data) + cur_msg; end_of_last_message = cur_msg_info->message_position + cur_msg_info->size; - if ( !cur_msg_info->x_evolution) { + if (cur_msg_info->uid == 0) { bytes_to_copy = cur_msg_info->message_position + cur_msg_info->end_of_headers_offset @@ -265,9 +267,10 @@ camel_mbox_write_xev (gchar *mbox_file_name, goto end; } - printf ("Writing the x-ev header\n"); - printf ("Current message number : %d\n", cur_msg); - camel_mbox_xev_write_header_content (xev_header + 12, next_free_uid++, 0); + cur_msg_info->uid = next_free_uid; + cur_msg_info->status = 0; + camel_mbox_xev_write_header_content (xev_header + 12, next_free_uid, 0); + next_free_uid++; write (fd2, xev_header, 19); cur_offset += 19; cur_msg_info->size += 19; @@ -333,5 +336,41 @@ camel_mbox_write_xev (gchar *mbox_file_name, +GArray * +parsed_information_to_mbox_summary (GArray *parsed_information) +{ + guint cur_msg; + CamelMboxParserMessageInfo *cur_msg_info; + GArray *mbox_summary; + CamelMboxSummaryInformation cur_sum_info; + + mbox_summary = g_array_new (FALSE, FALSE, sizeof (CamelMboxSummaryInformation)); + mbox_summary = g_array_set_size (mbox_summary, parsed_information->len); + + for (cur_msg = 0; cur_msg < parsed_information->len; cur_msg++) { + + cur_msg_info = (CamelMboxParserMessageInfo *)(parsed_information->data) + cur_msg; + + cur_sum_info.position = cur_msg_info->message_position; + + cur_sum_info.x_evolution_offset = cur_msg_info->x_evolution_offset; + + cur_sum_info.uid = cur_msg_info->uid; + + cur_sum_info.status = cur_msg_info->status; + cur_sum_info.subject = cur_msg_info->subject; + cur_msg_info->subject = NULL; + cur_sum_info.sender = cur_msg_info->from; + cur_msg_info->from = NULL; + + cur_sum_info.to = cur_msg_info->to; + cur_msg_info->to = NULL; + + g_array_append_vals (mbox_summary, &cur_sum_info, 1); + + } + + return mbox_summary; +} diff --git a/camel/providers/mbox/camel-mbox-utils.h b/camel/providers/mbox/camel-mbox-utils.h index cacabd2f19..25e611392e 100644 --- a/camel/providers/mbox/camel-mbox-utils.h +++ b/camel/providers/mbox/camel-mbox-utils.h @@ -39,7 +39,7 @@ extern "C" { void camel_mbox_xev_parse_header_content (gchar header_content[6], guint32 *uid, - guchar status); + guchar *status); void camel_mbox_xev_write_header_content (gchar header_content[6], @@ -52,6 +52,9 @@ camel_mbox_write_xev (gchar *mbox_file_name, glong last_uid, CamelException *ex); +GArray * +parsed_information_to_mbox_summary (GArray *parsed_information); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/tests/test9.c b/tests/test9.c index 6356bad41f..c7a1626458 100644 --- a/tests/test9.c +++ b/tests/test9.c @@ -43,6 +43,8 @@ main (int argc, char**argv) printf ("Exception caught in camel_mbox_write_xev : %s\n", camel_exception_get_description (ex)); } + + } |