diff options
Diffstat (limited to 'camel/providers')
-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 |
9 files changed, 105 insertions, 23 deletions
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 */ |