From 98e15c6b5c3757241e3a4017df85ee0e42a5f947 Mon Sep 17 00:00:00 2001 From: bertrand Date: Mon, 24 Jan 2000 15:07:18 +0000 Subject: add recipient_list to the recipients, not recipients_list. I don't know 2000-01-24 bertrand * camel/camel-recipient.c (camel_recipient_table_add_list): add recipient_list to the recipients, not recipients_list. I don't know what that variable was doing here. 2000-01-23 bertrand * camel/camel-store.c (camel_store_get_session): added a public get_session method. * camel/providers/mbox/camel-mbox-summary.c (camel_mbox_save_summary): (camel_mbox_load_summary): load/save message sizes in the summary file * camel/providers/mbox/camel-mbox-summary.h: added a size field to the message information structure. * camel/providers/mbox/camel-mbox-utils.c (parsed_information_to_mbox_summary): copy message size to the mbox summary information too. * camel/camel-stream-fs.c (_seek): updated to work with bounded fs streams. (_write): ditto. (_read): ditto. * camel/camel-stream-fs.h (struct ): added the cur_pos, inf_bound and sup_bound members to allow for bounded fs stream. * camel/camel-stream-fs.c (_set_bounds): new func. (_init_with_fd_and_bounds): idem. (_init_with_name_and_bounds): idem. New functions to allow the usage of bounded fs streams. The bounded fs stream allow, for example, to make a stream from a message stored in an mbox file. svn path=/trunk/; revision=1620 --- camel/providers/mbox/camel-mbox-folder.c | 74 ++++++++++++++++++++++++++++++- camel/providers/mbox/camel-mbox-summary.c | 12 ++--- camel/providers/mbox/camel-mbox-summary.h | 3 +- camel/providers/mbox/camel-mbox-utils.c | 2 + 4 files changed, 82 insertions(+), 9 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index 54f38e1210..e47ad29215 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -70,13 +71,14 @@ static GList *_list_subfolders (CamelFolder *folder, CamelException *ex); static gint _get_message_count (CamelFolder *folder, CamelException *ex); static gint _append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); static GList *_get_uid_list (CamelFolder *folder, CamelException *ex); -#if 0 static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex); +#if 0 static void _expunge (CamelFolder *folder, CamelException *ex); static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder, CamelException *ex); static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex); #endif + static void _finalize (GtkObject *object); static void @@ -107,8 +109,9 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class) camel_folder_class->expunge = _expunge; camel_folder_class->copy_message_to = _copy_message_to; camel_folder_class->get_message_uid = _get_message_uid; - camel_folder_class->get_message_by_uid = _get_message_by_uid; #endif + camel_folder_class->get_message_by_uid = _get_message_by_uid; + gtk_object_class->finalize = _finalize; } @@ -1033,6 +1036,73 @@ _get_uid_list (CamelFolder *folder, CamelException *ex) +static CamelMimeMessage * +_get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) +{ + + CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER(folder); + GArray *message_info_array; + CamelMboxSummaryInformation *message_info; + guint32 searched_uid; + int i; + gboolean uid_found; + CamelStreamFs *message_stream; + CamelMimeMessage *message = NULL; + CamelStore *parent_store; + + CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::get_uid_list\n"); + + searched_uid = strtoul(uid, (char **)NULL, 10); + + message_info_array = mbox_folder->summary->message_info; + i=0; + uid_found = FALSE; + + /* first, look for the message that has the searched uid */ + while ((ilen) && (!uid_found)) { + message_info = (CamelMboxSummaryInformation *)(message_info_array->data) + i; + uid_found = (message_info->uid == searched_uid); + i++; + } + + /* if the uid was not found, raise an exception and return */ + if (!uid_found) { + camel_exception_setv (ex, + CAMEL_EXCEPTION_FOLDER_INVALID_UID, + "uid %s not found in the folder", + uid); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::get_uid_list\n"); + return NULL; + } + + /* at this point, the message_info structure + contains the informations concerning the + message that was searched for */ + + /* create a stream bound to the message */ + message_stream = camel_stream_fs_new_with_name_and_bounds (mbox_folder->folder_file_path, + CAMEL_STREAM_FS_READ, + message_info->position, + message_info->position + message_info->size); + + + /* get the parent store */ + parent_store = camel_folder_get_parent_store (folder, ex); + if (camel_exception_get_id (ex)) { + gtk_object_unref (GTK_OBJECT (message_stream)); + return NULL; + } + + + message = camel_mime_message_new_with_session (camel_store_get_session (parent_store, ex)); + camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (message_stream)); + + + + + CAMEL_LOG_FULL_DEBUG ("Leaving CamelMboxFolder::get_uid_list\n"); + return message; +} diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c index 2cbb481700..2d09c61a43 100644 --- a/camel/providers/mbox/camel-mbox-summary.c +++ b/camel/providers/mbox/camel-mbox-summary.c @@ -75,10 +75,10 @@ camel_mbox_save_summary (CamelMboxSummary *summary, const gchar *filename, Camel msg_info = (CamelMboxSummaryInformation *)(summary->message_info->data) + cur_msg; - /* write message position + x-evolution offset - + uid + status */ + /* write message position + message size + + x-evolution offset + uid + status */ write (fd, (gchar *)msg_info, - sizeof (guint32) + sizeof (guint) + + sizeof (guint32) + 2 * sizeof (guint) + sizeof (guint32) + sizeof (guchar)); /* write subject */ @@ -154,10 +154,10 @@ camel_mbox_load_summary (const gchar *filename, CamelException *ex) msg_info = (CamelMboxSummaryInformation *)(summary->message_info->data) + cur_msg; - /* read message position + x-evolution offset - + uid + status */ + /* read message position + message size + + x-evolution offset + uid + status */ read (fd, (gchar *)msg_info, - sizeof (guint32) + sizeof (guint) + + sizeof (guint32) + 2 * sizeof (guint) + sizeof (guint32) + sizeof (guchar)); diff --git a/camel/providers/mbox/camel-mbox-summary.h b/camel/providers/mbox/camel-mbox-summary.h index cdfb88d63a..749a5a49f2 100644 --- a/camel/providers/mbox/camel-mbox-summary.h +++ b/camel/providers/mbox/camel-mbox-summary.h @@ -4,7 +4,7 @@ * * Author : Bertrand Guiheneuf * - * Copyright (C) 1999 Helix Code . + * Copyright (C) 1999 Helix Code (http://www.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 @@ -32,6 +32,7 @@ typedef struct { guint32 position; + guint size; guint x_evolution_offset; guint32 uid; guchar status; diff --git a/camel/providers/mbox/camel-mbox-utils.c b/camel/providers/mbox/camel-mbox-utils.c index 52de0d526e..1f0285be8a 100644 --- a/camel/providers/mbox/camel-mbox-utils.c +++ b/camel/providers/mbox/camel-mbox-utils.c @@ -356,6 +356,8 @@ parsed_information_to_mbox_summary (GArray *parsed_information) cur_sum_info->position = cur_msg_info->message_position; + cur_sum_info->size = cur_msg_info->size; + cur_sum_info->x_evolution_offset = cur_msg_info->x_evolution_offset; cur_sum_info->uid = cur_msg_info->uid; -- cgit v1.2.3