aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/camel-folder.c13
-rw-r--r--camel/camel-folder.h2
-rw-r--r--camel/gmime-rfc2047.c2
-rw-r--r--camel/providers/MH/camel-mh-folder.c47
4 files changed, 57 insertions, 7 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 6753789bd6..f8c5f34ee3 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -316,6 +316,13 @@ _can_hold_messages (CamelFolder *folder)
+static gboolean
+_exists (CamelFolder *folder)
+{
+ return FALSE;
+}
+
+
/**
* _exists: tests if the folder object exists in its parent store.
* @folder: folder object
@@ -326,10 +333,10 @@ _can_hold_messages (CamelFolder *folder)
*
* Return value: true if the folder exists on the store false otherwise
**/
-static gboolean
-_exists (CamelFolder *folder)
+gboolean
+camel_folder_exists (CamelFolder *folder)
{
- return FALSE;
+ return (CF_CLASS(folder)->exists (folder));
}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index eea6bcd36e..fd9c94761e 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -122,7 +122,7 @@ const gchar *camel_folder_get_name (CamelFolder *folder);
/* void camel_folder_set_full_name (CamelFolder *folder, const gchar *name); */
const gchar *camel_folder_get_full_name (CamelFolder *folder);
CamelMimeMessage *camel_folder_get_message (CamelFolder *folder, gint number);
-
+gboolean camel_folder_exists (CamelFolder *folder);
diff --git a/camel/gmime-rfc2047.c b/camel/gmime-rfc2047.c
index 780a866006..7266cb1159 100644
--- a/camel/gmime-rfc2047.c
+++ b/camel/gmime-rfc2047.c
@@ -131,7 +131,7 @@ gchar
gchar *charset, *encoding, *text, *end;
gchar dc[4096];
charset = data+1;
- encoding = strchr(charset, '?');
+ encoding = strchr (charset, '?');
if (!encoding) break;
encoding++;
diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c
index 6f7b419841..50c0ad34d4 100644
--- a/camel/providers/MH/camel-mh-folder.c
+++ b/camel/providers/MH/camel-mh-folder.c
@@ -32,6 +32,7 @@
#include "camel-mh-store.h"
#include "gstring-util.h"
#include "camel-log.h"
+#include "camel-stream-fs.h"
static CamelFolderClass *parent_class=NULL;
@@ -48,6 +49,7 @@ static gboolean _create(CamelFolder *folder);
static gboolean _delete (CamelFolder *folder, gboolean recurse);
static gboolean _delete_messages (CamelFolder *folder);
static GList *_list_subfolders (CamelFolder *folder);
+static CamelMimeMessage *_get_message (CamelFolder *folder, gint number);
static void
camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
@@ -64,6 +66,7 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class)
camel_folder_class->delete = _delete;
camel_folder_class->delete_messages = _delete_messages;
camel_folder_class->list_subfolders = _list_subfolders;
+ camel_folder_class->get_message = _get_message;
}
@@ -216,7 +219,7 @@ _delete (CamelFolder *folder, gboolean recurse)
CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete removing directory %s\n", directory_path);
rmdir_error = rmdir (directory_path);
if (rmdir_error == -1) {
- CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path);
+ CAMEL_LOG_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path);
CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
}
@@ -265,7 +268,7 @@ _delete_messages (CamelFolder *folder)
unlink_error = unlink(entry_name);
if (unlink_error == -1) {
- CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", entry_name);
+ CAMEL_LOG_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", entry_name);
CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno));
}
}
@@ -335,3 +338,43 @@ _list_subfolders(CamelFolder *folder)
+static CamelMimeMessage *
+_get_message (CamelFolder *folder, gint number)
+{
+ CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder);
+ gchar *directory_path;
+ gchar *message_file_name;
+ struct stat stat_buf;
+ gint stat_error = 0;
+ CamelStream *input_stream;
+ CamelMimeMessage *message;
+
+ g_assert(folder);
+
+ /* call default implementation */
+ parent_class->delete_messages (folder);
+
+ directory_path = mh_folder->directory_path;
+ if (!directory_path) return NULL;
+
+ if (!camel_folder_exists (folder)) return NULL;
+
+ message_file_name = g_strdup_printf ("%s/%d", directory_path, number);
+ stat_error = stat (message_file_name, &stat_buf);
+
+ if ((stat_error == -1) || (!S_ISREG (stat_buf.st_mode))) {
+ g_free (message_file_name);
+ return NULL;
+ } else {
+ input_stream = camel_stream_fs_new_with_name (message_file_name, CAMEL_STREAM_FS_READ);
+ g_free (message_file_name);
+ if (!input_stream) return 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));
+
+ }
+
+ return message;
+}