aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder.c
diff options
context:
space:
mode:
author7 <NotZed@Ximian.com>2001-10-27 14:00:34 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-27 14:00:34 +0800
commitc4d87ba45ad016d5a6607df96ed27ba02910e2e6 (patch)
tree5a48e3bbf61529642f7d0159642a69d8e8c57146 /camel/camel-folder.c
parentf4bb7b53dd93f67afb214a465828fe0cc3295f79 (diff)
downloadgsoc2013-evolution-c4d87ba45ad016d5a6607df96ed27ba02910e2e6.tar.gz
gsoc2013-evolution-c4d87ba45ad016d5a6607df96ed27ba02910e2e6.tar.zst
gsoc2013-evolution-c4d87ba45ad016d5a6607df96ed27ba02910e2e6.zip
Finished implementation.
2001-10-27 <NotZed@Ximian.com> * providers/imap/camel-imap-store.c (rename_folder): Finished implementation. * providers/local/camel-local-folder.c (local_rename): Implement local rename of folder objects. 2001-10-26 <NotZed@Ximian.com> * camel-vee-folder.c (camel_vee_folder_class_init): Hook into rename function. (vee_rename): Implement the veefolder rename function. (camel_vee_folder_class_init): (folder_changed_change): Kill a warning with a cast. * camel-vee-store.c (vee_rename_folder): Emit a folder_renamed event properly, also call parent to do some rename stuff. * camel-store.h: Added a CamelRenameInfo for the rename event. * camel-folder.c (camel_folder_rename): New function to rename a folder object. (camel_folder_class_init): Added a renamed event. (folder_rename): Default impl, set full_name, and set name assuming the dir separator is '/'. * camel-store.c (camel_store_class_init): Added folder_renamed event. (camel_store_rename_folder): Rename an active folder object if we have one, and update the folder table. (rename_folder): Make a default implementation that handles updating the folder tree. svn path=/trunk/; revision=14204
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r--camel/camel-folder.c69
1 files changed, 50 insertions, 19 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index f28572f8ba..9bc38df846 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -87,29 +87,21 @@ static GPtrArray *get_summary (CamelFolder *folder);
static void free_summary (CamelFolder *folder,
GPtrArray *array);
-static CamelMimeMessage *get_message (CamelFolder *folder,
- const gchar *uid,
- CamelException *ex);
+static CamelMimeMessage *get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
-static CamelMessageInfo *get_message_info (CamelFolder *folder, const char *uid);
-static void free_message_info (CamelFolder *folder, CamelMessageInfo *info);
-static void ref_message_info (CamelFolder *folder, CamelMessageInfo *info);
+static CamelMessageInfo *get_message_info (CamelFolder *folder, const char *uid);
+static void free_message_info (CamelFolder *folder, CamelMessageInfo *info);
+static void ref_message_info (CamelFolder *folder, CamelMessageInfo *info);
static GPtrArray *search_by_expression (CamelFolder *folder, const char *exp, CamelException *ex);
static GPtrArray *search_by_uids (CamelFolder *folder, const char *exp, GPtrArray *uids, CamelException *ex);
static void search_free (CamelFolder * folder, GPtrArray *result);
-static void copy_messages_to (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *dest,
- CamelException *ex);
+static void copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex);
+static void move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex);
-static void move_messages_to (CamelFolder *source,
- GPtrArray *uids,
- CamelFolder *dest,
- CamelException *ex);
-
-static void delete (CamelFolder *folder);
+static void delete (CamelFolder *folder);
+static void folder_rename (CamelFolder *folder, const char *new);
static void freeze (CamelFolder *folder);
static void thaw (CamelFolder *folder);
@@ -159,6 +151,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->copy_messages_to = copy_messages_to;
camel_folder_class->move_messages_to = move_messages_to;
camel_folder_class->delete = delete;
+ camel_folder_class->rename = folder_rename;
camel_folder_class->freeze = freeze;
camel_folder_class->thaw = thaw;
camel_folder_class->is_frozen = is_frozen;
@@ -169,6 +162,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_object_class_declare_event (camel_object_class,
"message_changed", message_changed);
camel_object_class_declare_event (camel_object_class, "deleted", NULL);
+ camel_object_class_declare_event (camel_object_class, "renamed", NULL);
}
static void
@@ -1324,7 +1318,7 @@ delete (CamelFolder *folder)
* camel_folder_delete:
* @folder: folder
*
- * Marks a folder as deleted and performs any required cleanup.
+ * Marks a folder object as deleted and performs any required cleanup.
**/
void
camel_folder_delete (CamelFolder *folder)
@@ -1340,13 +1334,50 @@ camel_folder_delete (CamelFolder *folder)
folder->folder_flags |= CAMEL_FOLDER_HAS_BEEN_DELETED;
CF_CLASS (folder)->delete (folder);
-
+
CAMEL_FOLDER_UNLOCK (folder, lock);
-
+
camel_object_trigger_event (CAMEL_OBJECT (folder), "deleted", NULL);
}
static void
+folder_rename (CamelFolder *folder, const char *new)
+{
+ char *tmp;
+
+ printf("CamelFolder:rename('%s')\n", new);
+
+ g_free(folder->full_name);
+ folder->full_name = g_strdup(new);
+ g_free(folder->name);
+ tmp = strrchr(new, '/');
+ folder->name = g_strdup(tmp?tmp+1:new);
+}
+
+/**
+ * camel_folder_rename:
+ * @folder:
+ * @new:
+ *
+ * Mark an active folder object as renamed.
+ *
+ * NOTE: This is an internal function used by camel stores, no locking
+ * is performed on the folder.
+ **/
+void
+camel_folder_rename(CamelFolder *folder, const char *new)
+{
+ char *old;
+
+ old = g_strdup(folder->full_name);
+
+ CF_CLASS (folder)->rename(folder, new);
+
+ camel_object_trigger_event (CAMEL_OBJECT (folder), "renamed", old);
+ g_free(old);
+}
+
+static void
freeze (CamelFolder *folder)
{
CAMEL_FOLDER_LOCK(folder, change_lock);