diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-folder.c | 24 | ||||
-rw-r--r-- | camel/camel-folder.h | 10 | ||||
-rw-r--r-- | camel/camel-mime-message.h | 2 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 65 | ||||
-rw-r--r-- | camel/providers/MH/mh-uid.c | 1 | ||||
-rw-r--r-- | camel/providers/MH/mh-utils.c | 2 |
6 files changed, 85 insertions, 19 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 652306c740..524252da1c 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -56,9 +56,8 @@ static gint _append_message (CamelFolder *folder, CamelMimeMessage *message); static const GList *_list_permanent_flags (CamelFolder *folder); static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder); -static gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message); -static gchar *_get_message_uid_by_number (CamelFolder *folder, gint message_number); -static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, gchar *uid); +static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message); +static CamelMimeMessage *_get_message_by_uid (CamelFolder *folder, const gchar *uid); static GList *_get_uid_list (CamelFolder *folder); @@ -97,7 +96,6 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->list_permanent_flags = _list_permanent_flags; camel_folder_class->copy_message_to; camel_folder_class->get_message_uid = _get_message_uid; - camel_folder_class->get_message_uid_by_number = _get_message_uid_by_number; camel_folder_class->get_message_by_uid = _get_message_by_uid; camel_folder_class->get_uid_list = _get_uid_list; @@ -1026,7 +1024,7 @@ camel_folder_has_uid_capability (CamelFolder *folder) -static gchar * +static const gchar * _get_message_uid (CamelFolder *folder, CamelMimeMessage *message) { return NULL; @@ -1044,7 +1042,7 @@ _get_message_uid (CamelFolder *folder, CamelMimeMessage *message) * * Return value: The UID of the message in the folder **/ -gchar * +const gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message) { if (!folder->has_uid_capability) return NULL; @@ -1052,7 +1050,9 @@ camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message) } -static gchar * + +/* the next two func are left there temporarily */ +static const gchar * _get_message_uid_by_number (CamelFolder *folder, gint message_number) { return NULL; @@ -1070,16 +1070,16 @@ _get_message_uid_by_number (CamelFolder *folder, gint message_number) * * Return value: **/ -gchar * +const gchar * camel_folder_get_message_uid_by_number (CamelFolder *folder, gint message_number) { - if (!folder->has_uid_capability) return NULL; - return CF_CLASS (folder)->get_message_uid_by_number (folder, message_number); + //if (!folder->has_uid_capability) return NULL; + //return CF_CLASS (folder)->get_message_uid_by_number (folder, message_number); } static CamelMimeMessage * -_get_message_by_uid (CamelFolder *folder, gchar *uid) +_get_message_by_uid (CamelFolder *folder, const gchar *uid) { return NULL; } @@ -1097,7 +1097,7 @@ _get_message_by_uid (CamelFolder *folder, gchar *uid) * Return value: Message corresponding to the UID **/ CamelMimeMessage * -camel_folder_get_message_by_uid (CamelFolder *folder, gchar *uid) +camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid) { if (!folder->has_uid_capability) return NULL; return CF_CLASS (folder)->get_message_by_uid (folder, uid); diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 443186803e..0d30351d9d 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -113,9 +113,8 @@ typedef struct { const GList * (*list_permanent_flags) (CamelFolder *folder); void (*copy_message_to) (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *dest_folder); - gchar * (*get_message_uid) (CamelFolder *folder, CamelMimeMessage *message); - gchar * (*get_message_uid_by_number) (CamelFolder *folder, gint message_number); - CamelMimeMessage * (*get_message_by_uid) (CamelFolder *folder, gchar *uid); + const gchar * (*get_message_uid) (CamelFolder *folder, CamelMimeMessage *message); + CamelMimeMessage * (*get_message_by_uid) (CamelFolder *folder, const gchar *uid); GList * (*get_uid_list) (CamelFolder *folder); } CamelFolderClass; @@ -154,9 +153,8 @@ CamelFolderSummary *camel_folder_get_summary (CamelFolder *folder); gboolean camel_folder_has_uid_capability (CamelFolder *folder); -gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message); -gchar * camel_folder_get_message_uid_by_number (CamelFolder *folder, gint message_number); -CamelMimeMessage *camel_folder_get_message_by_uid (CamelFolder *folder, gchar *uid); +const gchar * camel_folder_get_message_uid (CamelFolder *folder, CamelMimeMessage *message); +CamelMimeMessage *camel_folder_get_message_by_uid (CamelFolder *folder, const gchar *uid); GList *camel_folder_get_uid_list (CamelFolder *folder); #ifdef __cplusplus diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h index 15238782e5..e43c2fc859 100644 --- a/camel/camel-mime-message.h +++ b/camel/camel-mime-message.h @@ -71,6 +71,8 @@ struct _CamelMimeMessage gboolean expunged; guint message_number; /* set by folder object when retrieving message */ + gchar *message_uid; + CamelFolder *folder; CamelSession *session; diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 1afc441cad..231c79039a 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -39,6 +39,7 @@ #include "camel-folder-summary.h" #include "gmime-utils.h" #include "mh-utils.h" +#include "mh-uid.h" static CamelFolderClass *parent_class=NULL; @@ -738,6 +739,70 @@ _copy_message_to (CamelFolder *folder, CamelMimeMessage *message, CamelFolder *d +/** UID **/ + +static const gchar * +_get_message_uid (CamelFolder *folder, CamelMimeMessage *message) +{ + +} + + +static CamelMimeMessage * +_get_message_by_uid (CamelFolder *folder, const gchar *uid) +{ + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER (folder); + GArray *uid_array; + gboolean found = FALSE; + MhUidCouple *uid_couple; + gint file_number; + gchar *filename; + CamelMimeMessage *message = NULL; + CamelStream *input_stream; + int i; + + /* + * because they are constructed with md5 + * signatures, all MH uids are 16 bytes long + */ + if (strlen (uid) != 16) return NULL; + + uid_array = mh_folder->uid_array; + uid_couple = (MhUidCouple *)uid_array->data; + + found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar)); + for (i=0; (i<uid_array->len) && (!found); i++) { + uid_couple++; + found = !strncmp (uid, uid_couple->uid, 16 * sizeof (guchar)); + } + if (found) { + /* physically retrieve the message */ + file_number = uid_couple->file_number; + filename = g_strdup_printf ("%d", file_number); + input_stream = camel_stream_buffered_fs_new_with_name (filename, CAMEL_STREAM_BUFFERED_FS_READ); + + if (input_stream != NULL) { +#warning use session field here + message = camel_mime_message_new_with_session ( (CamelSession *)NULL); + camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); + gtk_object_unref (GTK_OBJECT (input_stream)); + + /* set message UID in CamelMimeMessage */ + message->message_uid = g_strdup (uid); + + } + g_free (filename); + } + + return message; + +} + +static GList * +_get_uid_list (CamelFolder *folder) +{ + return NULL; +} diff --git a/camel/providers/MH/mh-uid.c b/camel/providers/MH/mh-uid.c index f0a3e93417..1c71f10fb6 100644 --- a/camel/providers/MH/mh-uid.c +++ b/camel/providers/MH/mh-uid.c @@ -24,6 +24,7 @@ #include <config.h> #include "mh-uid.h" +#include "camel-log.h" #include "camel-stream.h" #include "camel-stream-fs.h" #include "camel-stream-buffered-fs.h" diff --git a/camel/providers/MH/mh-utils.c b/camel/providers/MH/mh-utils.c index bc708a98ee..51bb84bc65 100644 --- a/camel/providers/MH/mh-utils.c +++ b/camel/providers/MH/mh-utils.c @@ -20,7 +20,7 @@ * USA */ -#include "config.h" +#include <config.h> #include "mh-utils.h" #include <sys/stat.h> |