aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/mbox/camel-mbox-folder.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-07 08:06:29 +0800
committerDan Winship <danw@src.gnome.org>2000-06-07 08:06:29 +0800
commit4d5427769cfec587d9b8f727bd57ac1a1d2ae340 (patch)
tree4298b8ea452be219ecce2d96a4bc927782cabc31 /camel/providers/mbox/camel-mbox-folder.c
parentecd4fe3af090f79f30dd9df18bc4c087c366157b (diff)
downloadgsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar.gz
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar.bz2
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar.lz
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar.xz
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.tar.zst
gsoc2013-evolution-4d5427769cfec587d9b8f727bd57ac1a1d2ae340.zip
Remove exists, create, delete. A CamelFolder now always references an
* camel-folder.c: Remove exists, create, delete. A CamelFolder now always references an existing folder. Remove delete_messages too since it wasn't being used. Add a "create" flag to get_subfolder saying whether or not to create the subfolder if it doesn't yet exist. * camel-store.c (camel_store_get_folder): Add a "create" flag to say whether or not to create the folder if it doesn't yet exist. (camel_store_delete_folder): New method, moved from CamelFolder. (cache_folder, uncache_folder): Fix up a bit. (get_folder_name): Explain what this is for. * providers/mbox/camel-mbox-folder.c: * providers/mbox/camel-mbox-store.c: Update. Remove support for hierarchical folders to simplify this for now, since we're not using it, and it's not completely clear how they should work in an ELocalStorage world. Needs to be revisited. * providers/pop3/camel-pop3-folder.c (delete_messages): Remove. * providers/pop3/camel-pop3-store.c (get_folder): Update. * providers/vee/camel-vee-folder.c (exists): Remove. * providers/vee/camel-vee-store.c (vee_get_folder): Update. svn path=/trunk/; revision=3453
Diffstat (limited to 'camel/providers/mbox/camel-mbox-folder.c')
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c301
1 files changed, 0 insertions, 301 deletions
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 56af83a98b..305935fcdd 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -62,10 +62,6 @@ static void mbox_init (CamelFolder *folder, CamelStore *parent_store,
static void mbox_open (CamelFolder *folder, CamelFolderOpenMode mode, CamelException *ex);
static void mbox_close (CamelFolder *folder, gboolean expunge, CamelException *ex);
-static gboolean mbox_exists (CamelFolder *folder, CamelException *ex);
-static gboolean mbox_create(CamelFolder *folder, CamelException *ex);
-static gboolean mbox_delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean mbox_delete_messages (CamelFolder *folder, CamelException *ex);
static gint mbox_get_message_count (CamelFolder *folder, CamelException *ex);
static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex);
@@ -102,10 +98,6 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->init = mbox_init;
camel_folder_class->open = mbox_open;
camel_folder_class->close = mbox_close;
- camel_folder_class->exists = mbox_exists;
- camel_folder_class->create = mbox_create;
- camel_folder_class->delete = mbox_delete;
- camel_folder_class->delete_messages = mbox_delete_messages;
camel_folder_class->get_message_count = mbox_get_message_count;
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_uids = mbox_get_uids;
@@ -285,299 +277,6 @@ mbox_expunge (CamelFolder *folder, CamelException *ex)
gtk_signal_emit_by_name((GtkObject *)folder, "folder_changed", 0);
}
-/* FIXME: clean up this snot */
-static gboolean
-mbox_exists (CamelFolder *folder, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder;
- struct stat stat_buf;
- gint stat_error;
- gboolean exists;
-
- g_assert(folder != NULL);
-
- mbox_folder = CAMEL_MBOX_FOLDER (folder);
-
- /* check if the mbox file path is determined */
- if (!mbox_folder->folder_file_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "undetermined folder file path. Maybe use set_name ?");
- return FALSE;
- }
-
- /* check if the mbox dir path is determined */
- if (!mbox_folder->folder_dir_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "undetermined folder directory path. Maybe use set_name ?");
- return FALSE;
- }
-
-
- /* we should not check for that here */
-#if 0
- /* check if the mbox directory exists */
- access_result = access (mbox_folder->folder_dir_path, F_OK);
- if (access_result < 0) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- strerror(errno));
- return FALSE;
- }
- stat_error = stat (mbox_folder->folder_dir_path, &stat_buf);
- if (stat_error == -1) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- strerror(errno));
- return FALSE;
- }
- exists = S_ISDIR (stat_buf.st_mode);
- if (!exists) return FALSE;
-#endif
-
-
- /* check if the mbox file exists */
- stat_error = stat (mbox_folder->folder_file_path, &stat_buf);
- if (stat_error == -1)
- return FALSE;
-
- exists = S_ISREG (stat_buf.st_mode);
- /* we should check the rights here */
-
- return exists;
-}
-
-/* FIXME: clean up this snot */
-static gboolean
-mbox_create (CamelFolder *folder, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- const gchar *folder_file_path, *folder_dir_path;
- mode_t dir_mode = S_IRWXU;
- gint mkdir_error;
- gboolean folder_already_exists;
- int creat_fd;
-
- g_assert(folder != NULL);
-
- /* call default implementation */
- parent_class->create (folder, ex);
-
- /* get the paths of what we need to create */
- folder_file_path = mbox_folder->folder_file_path;
- folder_dir_path = mbox_folder->folder_dir_path;
-
- if (!(folder_file_path || folder_dir_path)) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* if the folder already exists, simply return */
- folder_already_exists = camel_folder_exists (folder,ex);
- if (camel_exception_get_id (ex))
- return FALSE;
-
- if (folder_already_exists)
- return TRUE;
-
-
- /* create the directory for the subfolders */
- mkdir_error = mkdir (folder_dir_path, dir_mode);
- if (mkdir_error == -1)
- goto io_error;
-
-
- /* create the mbox file */
- /* it must be rw for the user and none for the others */
- creat_fd = open (folder_file_path,
- O_WRONLY | O_CREAT | O_APPEND,
- 0600);
- if (creat_fd == -1)
- goto io_error;
-
- close (creat_fd);
-
- return TRUE;
-
- /* exception handling for io errors */
- io_error :
- if (errno == EACCES) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "You don't have the permission to create the mbox file.");
- return FALSE;
- } else {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to create the mbox file.");
- return FALSE;
- }
-}
-
-
-/* FIXME: cleanup */
-static gboolean
-mbox_delete (CamelFolder *folder, gboolean recurse, CamelException *ex)
-{
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- const gchar *folder_file_path, *folder_dir_path;
- gint rmdir_error = 0;
- gint unlink_error = 0;
- gboolean folder_already_exists;
-
- g_assert(folder != NULL);
-
- /* check if the folder object exists */
-
- /* in the case where the folder does not exist,
- return immediatly */
- folder_already_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex))
- return FALSE;
-
- if (!folder_already_exists)
- return TRUE;
-
-
- /* call default implementation.
- It should delete the messages in the folder
- and recurse the operation to subfolders */
- parent_class->delete (folder, recurse, ex);
-
-
- /* get the paths of what we need to be deleted */
- folder_file_path = mbox_folder->folder_file_path;
- folder_dir_path = mbox_folder->folder_file_path;
-
- if (!(folder_file_path || folder_dir_path)) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* physically delete the directory */
- rmdir_error = rmdir (folder_dir_path);
- if (rmdir_error == -1)
- switch (errno) {
- case EACCES :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Not enough permission to delete the mbox folder");
- return FALSE;
- break;
-
- case ENOTEMPTY :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_NON_EMPTY,
- "mbox folder not empty. Cannot delete it. Maybe use recurse flag ?");
- return FALSE;
- break;
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
- return FALSE;
- }
-
- /* physically delete the file */
- unlink_error = unlink (folder_dir_path);
- if (unlink_error == -1)
- switch (errno) {
- case EACCES :
- case EPERM :
- case EROFS :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "Not enough permission to delete the mbox file");
- return FALSE;
- break;
-
- case EFAULT :
- case ENOENT :
- case ENOTDIR :
- case EISDIR :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_PATH,
- "Invalid mbox file");
- return FALSE;
- break;
-
- default :
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to delete the mbox folder.");
- return FALSE;
- }
-
-
- return TRUE;
-}
-
-/* TODO: remove this */
-gboolean
-mbox_delete_messages (CamelFolder *folder, CamelException *ex)
-{
-
- CamelMboxFolder *mbox_folder = CAMEL_MBOX_FOLDER (folder);
- const gchar *folder_file_path;
- gboolean folder_already_exists;
- int creat_fd;
- g_assert(folder!=NULL);
-
- /* in the case where the folder does not exist,
- return immediatly */
- folder_already_exists = camel_folder_exists (folder, ex);
- if (camel_exception_get_id (ex)) return FALSE;
-
- if (!folder_already_exists) return TRUE;
-
-
-
- /* get the paths of the mbox file we need to delete */
- folder_file_path = mbox_folder->folder_file_path;
-
- if (!folder_file_path) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID,
- "invalid folder path. Use set_name ?");
- return FALSE;
- }
-
-
- /* create the mbox file */
- /* it must be rw for the user and none for the others */
- creat_fd = open (folder_file_path,
- O_WRONLY | O_TRUNC,
- 0600);
- if (creat_fd == -1)
- goto io_error;
- close (creat_fd);
-
- return TRUE;
-
- /* exception handling for io errors */
- io_error :
- if (errno == EACCES) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_FOLDER_INSUFFICIENT_PERMISSION,
- "You don't have the permission to write in the mbox file.");
- return FALSE;
- } else {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_SYSTEM,
- "Unable to write in the mbox file.");
- return FALSE;
- }
-
-
-}
-
static gint
mbox_get_message_count (CamelFolder *folder, CamelException *ex)
{