diff options
author | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-10 19:53:46 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-10 19:53:46 +0800 |
commit | 6cb08f0bc177cd0de35b852fac94a181f4d2233c (patch) | |
tree | 5a83d501fe75db56369872745834981ec460a06b /camel | |
parent | 317000107d2209d45c60a2241f1e69cb6cd2489d (diff) | |
download | gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar.gz gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar.bz2 gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar.lz gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar.xz gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.tar.zst gsoc2013-evolution-6cb08f0bc177cd0de35b852fac94a181f4d2233c.zip |
some test files
svn path=/trunk/; revision=1101
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-folder.c | 15 | ||||
-rw-r--r-- | camel/camel-folder.h | 5 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 66 |
3 files changed, 84 insertions, 2 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 5fa22a5b72..2d0a29faab 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -51,6 +51,8 @@ static GList *_list_subfolders (CamelFolder *folder); static GList *_expunge (CamelFolder *folder); static CamelMimeMessage *_get_message (CamelFolder *folder, gint number); static gint _get_message_count (CamelFolder *folder); +static gint _append_message (CamelFolder *folder, CamelMimeMessage *message); + static void camel_folder_class_init (CamelFolderClass *camel_folder_class) @@ -78,6 +80,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->expunge = _expunge; camel_folder_class->get_message = _get_message; camel_folder_class->get_message_count = _get_message_count; + camel_folder_class->append_message = _append_message; /* virtual method overload */ } @@ -784,3 +787,15 @@ camel_folder_get_message_count (CamelFolder *folder) return CF_CLASS (folder)->get_message_count (folder); } + +static gint +_append_message (CamelFolder *folder, CamelMimeMessage *message) +{ + return -1; +} + + +gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message) +{ + return CF_CLASS (folder)->append_message (folder, message); +} diff --git a/camel/camel-folder.h b/camel/camel-folder.h index b678631eea..e980e39e15 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -100,7 +100,7 @@ typedef struct { GList * (*expunge) (CamelFolder *folder); CamelMimeMessage * (*get_message) (CamelFolder *folder, gint number); gint (*get_message_count) (CamelFolder *folder); - + gint (*append_message) (CamelFolder *folder, CamelMimeMessage *message); } CamelFolderClass; @@ -125,7 +125,8 @@ const gchar *camel_folder_get_name (CamelFolder *folder); const gchar *camel_folder_get_full_name (CamelFolder *folder); CamelMimeMessage *camel_folder_get_message (CamelFolder *folder, gint number); gboolean camel_folder_exists (CamelFolder *folder); -gint camel_get_message_count (CamelFolder *folder); +gint camel_folder_get_message_count (CamelFolder *folder); +gint camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message); diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 2e19349e67..a1c78fd309 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -51,6 +51,8 @@ static gboolean _delete_messages (CamelFolder *folder); static GList *_list_subfolders (CamelFolder *folder); static CamelMimeMessage *_get_message (CamelFolder *folder, gint number); static gint _get_message_count (CamelFolder *folder); +static gint _append_message (CamelFolder *folder, CamelMimeMessage *message); + static void camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) @@ -69,6 +71,7 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) camel_folder_class->list_subfolders = _list_subfolders; camel_folder_class->get_message = _get_message; camel_folder_class->get_message_count = _get_message_count; + camel_folder_class->append_message = _append_message; } @@ -480,3 +483,66 @@ _get_message_count (CamelFolder *folder) closedir (dir_handle); return message_count; } + + + + +static gint +_append_message (CamelFolder *folder, CamelMimeMessage *message) +{ + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + const gchar *directory_path; + struct dirent *dir_entry; + DIR *dir_handle; + guint last_max_message_number = 0; + guint current_message_number; + guint new_message_number; + gchar *new_message_filename; + CamelStream *output_stream; + gboolean error; + + CAMEL_LOG_FULL_DEBUG ("Entering CamelMhFolder::append_message\n"); + + g_assert(folder); + + directory_path = mh_folder->directory_path; + if (!directory_path) return -1; + + if (!camel_folder_exists (folder)) return 0; + + dir_handle = opendir (directory_path); + + /* read first entry in the directory */ + dir_entry = readdir (dir_handle); + while (dir_entry != NULL) { + /* tests if the entry correspond to a message file */ + if (_is_a_message_file (dir_entry->d_name, directory_path)) { + /* see if the message number is the biggest found */ + current_message_number = atoi (dir_entry->d_name); + if (current_message_number > last_max_message_number) + last_max_message_number = current_message_number; + } + /* read next entry */ + dir_entry = readdir (dir_handle); + } + closedir (dir_handle); + + new_message_number = last_max_message_number + 1; + new_message_filename = g_strdup_printf ("%s/%d", directory_path, new_message_number); + CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::append_message new message path is %s\n", new_message_filename); + + output_stream = camel_stream_fs_new_with_name (new_message_filename, CAMEL_STREAM_FS_WRITE); + if (output_stream != NULL) { + camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream); + camel_stream_close (output_stream); + } else { + CAMEL_LOG_WARNING ("CamelMhFolder::append_message could not open %s for writing\n", new_message_filename); + CAMEL_LOG_FULL_DEBUG (" Full error text is : %s\n", strerror(errno)); + error = TRUE; + } + + g_free (new_message_filename); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelMhFolder::append_message\n"); + if (error) return -1; + else return new_message_number; +} |