aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <bertrand@helixcode.com>2000-01-24 23:07:18 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-01-24 23:07:18 +0800
commit98e15c6b5c3757241e3a4017df85ee0e42a5f947 (patch)
treefb7153111faa14d8091793ae258a2a140baf70e7
parentf64b3bb5f2d3f4fa6e05fcc9223aff78fd8c2f12 (diff)
downloadgsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar.gz
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar.bz2
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar.lz
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar.xz
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.tar.zst
gsoc2013-evolution-98e15c6b5c3757241e3a4017df85ee0e42a5f947.zip
add recipient_list to the recipients, not recipients_list. I don't know
2000-01-24 bertrand <bertrand@helixcode.com> * 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 <bertrand@helixcode.com> * 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
-rw-r--r--ChangeLog41
-rw-r--r--camel/camel-exception-list.def3
-rw-r--r--camel/camel-mime-message.c16
-rw-r--r--camel/camel-recipient.c10
-rw-r--r--camel/camel-store.c12
-rw-r--r--camel/camel-store.h1
-rw-r--r--camel/camel-stream-fs.c180
-rw-r--r--camel/camel-stream-fs.h16
-rw-r--r--camel/camel.c4
-rw-r--r--camel/gmime-utils.c2
-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
-rw-r--r--tests/test10.c16
-rw-r--r--tests/test2.c5
16 files changed, 354 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 3475833d25..293dbe0b67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-01-24 bertrand <bertrand@helixcode.com>
+
+ * 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-24 Matt Loper <matt@helixcode.com>
* camel/camel-formatter.c (write_header_info_to_stream): new
@@ -7,6 +14,40 @@
(camel_formatter_make_html): Now tries to deal with
multipart/related, multipart/alternate, and text/(plain|html).
+
+2000-01-23 bertrand <bertrand@helixcode.com>
+
+ * 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.
+
+
2000-01-22 bertrand <bertrand@helixcode.com>
* camel/providers/mbox/camel-mbox-folder.c (_check_get_or_maybe_generate_summary_file):
diff --git a/camel/camel-exception-list.def b/camel/camel-exception-list.def
index b13655e35a..8ad69f378f 100644
--- a/camel/camel-exception-list.def
+++ b/camel/camel-exception-list.def
@@ -12,5 +12,8 @@ CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
CAMEL_EXCEPTION_FOLDER_NON_UID,
CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
+CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+/* CamelStoreException */
+CAMEL_EXCEPTION_STORE_NULL, \ No newline at end of file
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index d9fd90cfc7..18e407115f 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -580,24 +580,31 @@ _write_one_recipient_to_stream (gchar *recipient_type,
static void
_write_recipients_to_stream (CamelMimeMessage *mime_message, CamelStream *stream)
{
- camel_recipient_foreach_recipient_type (mime_message->recipients,
- _write_one_recipient_to_stream,
- (gpointer)stream);
+ camel_recipient_foreach_recipient_type (mime_message->recipients,
+ _write_one_recipient_to_stream,
+ (gpointer)stream);
}
static void
_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
CamelMimeMessage *mm = CAMEL_MIME_MESSAGE (data_wrapper);
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage::write_to_stream\n");
+
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"From\"\n");
WHPT (stream, "From", mm->from);
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Reply-To\"\n");
WHPT (stream, "Reply-To", mm->reply_to);
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing recipients\n");
_write_recipients_to_stream (mm, stream);
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Date\"\n");
WHPT (stream, "Date", mm->received_date);
+
CAMEL_LOG_FULL_DEBUG ( "CamelMimeMessage:: Writing \"Subject\"\n");
WHPT (stream, "Subject", mm->subject);
@@ -616,10 +623,13 @@ static void
_set_recipient_list_from_string (CamelMimeMessage *message, gchar *recipient_type, gchar *recipients_string)
{
GList *recipients_list;
+ GList *tmp;
+
CAMEL_LOG_FULL_DEBUG ("CamelMimeMessage::_set_recipient_list_from_string parsing ##%s##\n", recipients_string);
recipients_list = string_split (
recipients_string, ',', "\t ",
STRING_TRIM_STRIP_TRAILING | STRING_TRIM_STRIP_LEADING);
+
camel_recipient_table_add_list (message->recipients, recipient_type, recipients_list);
}
diff --git a/camel/camel-recipient.c b/camel/camel-recipient.c
index 3a301f201e..7b42cdc9a0 100644
--- a/camel/camel-recipient.c
+++ b/camel/camel-recipient.c
@@ -149,7 +149,6 @@ camel_recipient_table_add (CamelRecipientTable *recipient_table,
/* see if there is already a list for this recipient type */
existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type);
-
/* append the new recipient to the recipient list
if the existent_list is NULL, then a new GList is
automagically created */
@@ -179,17 +178,16 @@ camel_recipient_table_add_list (CamelRecipientTable *recipient_table,
const gchar *recipient_type,
GList *recipient_list)
{
- GList *recipients_list;
GList *existent_list;
-
+
/* see if there is already a list for this recipient type */
existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_hash_table, recipient_type);
-
-
+
if (existent_list)
g_list_concat (existent_list, recipient_list);
else
- g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipients_list);
+ g_hash_table_insert (recipient_table->recipient_hash_table, g_strdup (recipient_type), recipient_list);
+
}
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 590d5e15bd..204e08b5f2 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -260,4 +260,16 @@ _get_default_folder (CamelStore *store, CamelException *ex)
}
+CamelSession *
+camel_store_get_session (CamelStore *store, CamelException *ex)
+{
+ if (!store) {
+ camel_exception_set (ex,
+ CAMEL_EXCEPTION_STORE_NULL,
+ "Store is NULL");
+ return NULL;
+ }
+
+ return store->session;
+}
diff --git a/camel/camel-store.h b/camel/camel-store.h
index e78192bed4..89ad29161b 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -81,6 +81,7 @@ GtkType camel_store_get_type (void);
void camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
CamelFolder *camel_store_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
gchar camel_store_get_separator (CamelStore *store, CamelException *ex);
+CamelSession *camel_store_get_session (CamelStore *store, CamelException *ex);
#ifdef __cplusplus
}
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index c4d6e9be8c..4c5d12eb0c 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -26,6 +26,7 @@
*/
#include <config.h>
#include "camel-stream-fs.h"
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -51,7 +52,10 @@ static void _finalize (GtkObject *object);
static void _destroy (GtkObject *object);
static void _init_with_fd (CamelStreamFs *stream_fs, int fd);
+static void _init_with_fd_and_bounds (CamelStreamFs *stream_fs, int fd, guint32 inf_bound, gint64 sup_bound);
static void _init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode);
+static void _init_with_name_and_bounds (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode,
+ guint32 inf_bound, gint64 sup_bound);
static void
camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
@@ -63,8 +67,10 @@ camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
/* virtual method definition */
camel_stream_fs_class->init_with_fd = _init_with_fd;
+ camel_stream_fs_class->init_with_fd_and_bounds = _init_with_fd_and_bounds;
camel_stream_fs_class->init_with_name = _init_with_name;
-
+ camel_stream_fs_class->init_with_name_and_bounds = _init_with_name_and_bounds;
+
/* virtual method overload */
camel_stream_class->read = _read;
camel_stream_class->write = _write;
@@ -146,21 +152,58 @@ _finalize (GtkObject *object)
CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamFs::finalize\n");
}
+
+
+static void
+_set_bounds (CamelStreamFs *stream_fs, guint32 inf_bound, gint64 sup_bound)
+{
+ /* store the bounds */
+ stream_fs->inf_bound = inf_bound;
+ stream_fs->sup_bound = sup_bound;
+
+ /* go to the first position */
+ lseek ((CAMEL_STREAM_FS (stream_fs))->fd, inf_bound, SEEK_SET);
+
+ stream_fs->cur_pos = inf_bound;
+}
+
+
+
+
static void
_init_with_fd (CamelStreamFs *stream_fs, int fd)
{
+ /* no bounds by default */
+ _set_bounds (stream_fs, 0, -1);
+
stream_fs->fd = fd;
}
+
+
+
+static void
+_init_with_fd_and_bounds (CamelStreamFs *stream_fs, int fd, guint32 inf_bound, gint64 sup_bound)
+{
+
+ CSFS_CLASS (stream_fs)->init_with_fd (stream_fs, fd);
+ _set_bounds (stream_fs, inf_bound, sup_bound);
+
+}
+
+
+
static void
_init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode)
{
struct stat s;
int v, fd;
int flags;
-
+
g_assert (name);
CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_name, name=\"%s\", mode=%d\n", name, mode);
+
+
v = stat (name, &s);
if (mode & CAMEL_STREAM_FS_READ){
@@ -174,6 +217,7 @@ _init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode
else
return;
}
+
if ( (mode & CAMEL_STREAM_FS_READ) && !(mode & CAMEL_STREAM_FS_WRITE) )
if (v == -1) return;
@@ -187,11 +231,25 @@ _init_with_name (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode
stream_fs->name = g_strdup (name);
CSFS_CLASS (stream_fs)->init_with_fd (stream_fs, fd);
-
+ /* no bounds by default */
+ _set_bounds (stream_fs, 0, -1);
+
+
+}
+
+
+static void
+_init_with_name_and_bounds (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode,
+ guint32 inf_bound, gint64 sup_bound)
+{
+ CSFS_CLASS (stream_fs)->init_with_name (stream_fs, name, mode);
+ _set_bounds (stream_fs, inf_bound, sup_bound);
}
+
+
CamelStream *
camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode)
{
@@ -202,6 +260,24 @@ camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode)
return CAMEL_STREAM (stream_fs);
}
+
+
+CamelStream *
+camel_stream_fs_new_with_name_and_bounds (const gchar *name, CamelStreamFsMode mode,
+ guint32 inf_bound, gint64 sup_bound)
+{
+ CamelStreamFs *stream_fs;
+ stream_fs = gtk_type_new (camel_stream_fs_get_type ());
+ CSFS_CLASS (stream_fs)->init_with_name_and_bounds (stream_fs, name, mode, inf_bound, sup_bound);
+
+ return CAMEL_STREAM (stream_fs);
+
+}
+
+
+
+
+
CamelStream *
camel_stream_fs_new_with_fd (int fd)
@@ -216,6 +292,22 @@ camel_stream_fs_new_with_fd (int fd)
return CAMEL_STREAM (stream_fs);
}
+
+
+CamelStream *
+camel_stream_fs_new_with_fd_and_bounds (int fd, guint32 inf_bound, gint64 sup_bound)
+{
+ CamelStreamFs *stream_fs;
+
+ CAMEL_LOG_FULL_DEBUG ( "Entering CamelStream::new_with_fd fd=%d\n",fd);
+ stream_fs = gtk_type_new (camel_stream_fs_get_type ());
+ CSFS_CLASS (stream_fs)->init_with_fd_and_bounds (stream_fs, fd, inf_bound, sup_bound);
+
+ return CAMEL_STREAM (stream_fs);
+}
+
+
+
/**
* _read: read bytes from a stream
* @stream: stream
@@ -229,18 +321,29 @@ camel_stream_fs_new_with_fd (int fd)
static gint
_read (CamelStream *stream, gchar *buffer, gint n)
{
+ CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
gint v;
+ gint nb_to_read;
+
+ if (stream_fs->sup_bound != -1)
+ nb_to_read = stream_fs->sup_bound - stream_fs->cur_pos;
+ else
+ nb_to_read = n;
+
do {
- v = read ( (CAMEL_STREAM_FS (stream))->fd, buffer, n);
+ v = read ( (CAMEL_STREAM_FS (stream))->fd, buffer, nb_to_read);
} while (v == -1 && errno == EINTR);
if (v<0)
CAMEL_LOG_FULL_DEBUG ("CamelStreamFs::read v=%d\n", v);
+ else
+ stream_fs->cur_pos += v;
+
return v;
}
/**
- * _write: read bytes to a stream
+ * _write: write bytes to a stream
* @stream: the stream
* @buffer: byte buffer
* @n: number of bytes to write
@@ -253,12 +356,21 @@ _read (CamelStream *stream, gchar *buffer, gint n)
static gint
_write (CamelStream *stream, const gchar *buffer, gint n)
{
+ CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
int v;
+ gint nb_to_write;
+
g_assert (stream);
- g_assert ((CAMEL_STREAM_FS (stream))->fd);
+ g_assert (stream_fs->fd);
CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs:: entering write. n=%d\n", n);
+
+ if (stream_fs->sup_bound != -1)
+ nb_to_write = stream_fs->sup_bound - stream_fs->cur_pos;
+ else
+ nb_to_write = n;
+
do {
- v = write ( (CAMEL_STREAM_FS (stream))->fd, buffer, n);
+ v = write ( stream_fs->fd, buffer, nb_to_write);
} while (v == -1 && errno == EINTR);
#if HARD_LOG_LEVEL >= FULL_DEBUG
@@ -267,6 +379,10 @@ _write (CamelStream *stream, const gchar *buffer, gint n)
CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs::write could not write bytes in stream\n");
}
#endif
+
+ if (v>0)
+ stream_fs->cur_pos += v;
+
return v;
}
@@ -336,20 +452,62 @@ static gint
_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
{
int whence;
+ gint return_position;
+ gint real_offset;
+ CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
+
switch (policy) {
case CAMEL_STREAM_SET:
- whence = SEEK_SET;
+ real_offset = MAX (stream_fs->inf_bound + offset, stream_fs->inf_bound);
+ if (stream_fs->sup_bound > 0)
+ real_offset = MIN (real_offset, stream_fs->sup_bound);
+ whence = SEEK_SET;
break;
+
case CAMEL_STREAM_CUR:
- whence = SEEK_CUR;
+ if ((stream_fs->sup_bound == -1) && ((stream_fs->cur_pos + offset) > stream_fs->sup_bound)) {
+ real_offset = stream_fs->sup_bound;
+ whence = SEEK_SET;
+ } else if ((stream_fs->cur_pos + offset) < stream_fs->inf_bound) {
+ real_offset = stream_fs->inf_bound;
+ whence = SEEK_SET;
+ } else
+ {
+ real_offset = offset;
+ whence = SEEK_CUR;
+ }
break;
+
case CAMEL_STREAM_END:
- whence = SEEK_END;
+ if (stream_fs->sup_bound != -1) {
+ real_offset = stream_fs->sup_bound - offset;
+ whence = SEEK_SET;
+ } else {
+ real_offset = offset;
+ whence = SEEK_END;
+ }
+
+
break;
default:
return -1;
}
+
- return lseek ((CAMEL_STREAM_FS (stream))->fd, offset, whence);
+ return_position = lseek (stream_fs->fd, real_offset, whence) - stream_fs->inf_bound;
+ stream_fs->cur_pos = return_position;
+
+ return return_position;
}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h
index 85df8f3a2c..dc559bc7c9 100644
--- a/camel/camel-stream-fs.h
+++ b/camel/camel-stream-fs.h
@@ -52,9 +52,14 @@ typedef enum
typedef struct
{
+
CamelStream parent_object;
- gchar *name;
- int fd;
+ gchar *name; /* name of the underlying file */
+ gint fd; /* file descriptor on the underlying file */
+ guint32 cur_pos; /* current postion in the stream */
+ guint32 inf_bound; /* first valid position */
+ gint64 sup_bound; /* last valid position, -1 means, no sup bound */
+
} CamelStreamFs;
@@ -64,7 +69,10 @@ typedef struct {
/* Virtual methods */
void (*init_with_fd) (CamelStreamFs *stream_fs, int fd);
+ void (*init_with_fd_and_bounds) (CamelStreamFs *stream_fs, int fd, guint32 inf_bound, gint64 sup_bound);
void (*init_with_name) (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode);
+ void (*init_with_name_and_bounds) (CamelStreamFs *stream_fs, const gchar *name,
+ CamelStreamFsMode mode, guint32 inf_bound, gint64 sup_bound);
} CamelStreamFsClass;
@@ -76,7 +84,11 @@ GtkType camel_stream_fs_get_type (void);
/* public methods */
CamelStream *camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode);
+CamelStream *camel_stream_fs_new_with_name_and_bounds (const gchar *name, CamelStreamFsMode mode,
+ guint32 inf_bound, gint64 sup_bound);
CamelStream *camel_stream_fs_new_with_fd (int fd);
+CamelStream *camel_stream_fs_new_with_fd_and_bounds (int fd,
+ guint32 inf_bound, gint64 sup_bound);
#ifdef __cplusplus
}
diff --git a/camel/camel.c b/camel/camel.c
index b6b1012a66..2bb3dc163f 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -32,8 +32,8 @@ camel_init()
#ifdef G_THREADS_ENABLED
g_thread_init (NULL);
#else /* G_THREADS_ENABLED */
- printf ("Threads are not supported by glib\n");
+ printf ("Threads are not supported by your version of glib\n");
#endif /* G_THREADS_ENABLED */
- /* return data_wrapper_repository_init (); */
+ return data_wrapper_repository_init ();
}
diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c
index e703e877e9..4e089aeeb6 100644
--- a/camel/gmime-utils.c
+++ b/camel/gmime-utils.c
@@ -85,6 +85,7 @@ gmime_write_header_with_glist_to_stream (CamelStream *stream,
gchar *current;
CAMEL_LOG_FULL_DEBUG ( "write_header_with_glist_to_stream:: entering\n");
+ CAMEL_LOG_FULL_DEBUG ( "\theader name : %s\n", header_name);
if ( (header_name) && (header_values) )
{
gboolean first;
@@ -94,6 +95,7 @@ gmime_write_header_with_glist_to_stream (CamelStream *stream,
first = TRUE;
while (header_values) {
current = (gchar *)header_values->data;
+ CAMEL_LOG_FULL_DEBUG ( "write_header_with_glist_to_stream:: writing value : %s\n", current);
if (current) {
if (!first) camel_stream_write_string (stream, separator);
else first = FALSE;
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;
diff --git a/tests/test10.c b/tests/test10.c
index b223efb8ef..fc8cc326cf 100644
--- a/tests/test10.c
+++ b/tests/test10.c
@@ -105,17 +105,15 @@ main (int argc, char**argv)
"Full description : %s\n", camel_exception_get_description (ex));
return -1;
}
-
+
uid_list = camel_folder_get_uid_list (folder, ex);
- while (uid_list) {
- printf ("UID : %s\n", (gchar *)uid_list->data);
- uid_list = uid_list->next;
- }
-
- camel_folder_close (folder, FALSE, ex);
-
+
+
+ camel_folder_get_message_by_uid (folder, (gchar *)uid_list->data, ex);
+ camel_folder_close (folder, FALSE, ex);
return 1;
-}
+}
+
diff --git a/tests/test2.c b/tests/test2.c
index 20e8b739b9..99dc74d655 100644
--- a/tests/test2.c
+++ b/tests/test2.c
@@ -19,6 +19,7 @@ main (int argc, char**argv)
gtk_init (&argc, &argv);
camel_init ();
camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG;
+
message = camel_mime_message_new_with_session( (CamelSession *)NULL);
@@ -30,6 +31,8 @@ main (int argc, char**argv)
}
camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream);
+
+ camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG;
camel_medium_get_content_object (CAMEL_MEDIUM (message));
camel_stream_close (input_stream);
gtk_object_unref (GTK_OBJECT (input_stream));
@@ -39,7 +42,7 @@ main (int argc, char**argv)
camel_stream_close (output_stream);
gtk_object_unref (GTK_OBJECT (output_stream));
- gtk_object_unref (GTK_OBJECT (message));
+ //gtk_object_unref (GTK_OBJECT (message));
return 0;