aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c74
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c12
-rw-r--r--camel/providers/mbox/camel-mbox-summary.h3
-rw-r--r--camel/providers/mbox/camel-mbox-utils.c2
4 files changed, 82 insertions, 9 deletions
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 <config.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
@@ -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 ((i<message_info_array->len) && (!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 <bertrand@helixcode.com>
*
- * 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;