aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-01 04:04:46 +0800
committerDan Winship <danw@src.gnome.org>2000-07-01 04:04:46 +0800
commit39361c665a62e68991e51a9c13c2b2074a130ed4 (patch)
tree4ee1bc049ec3bf8608f32159b209ac880589b02d
parent83387a7fddc83a28a04c7a649762474ac591b961 (diff)
downloadgsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar.gz
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar.bz2
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar.lz
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar.xz
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.tar.zst
gsoc2013-evolution-39361c665a62e68991e51a9c13c2b2074a130ed4.zip
New function, to move a message from one folder to another. The default
* camel-folder.c (camel_folder_move_message_to): New function, to move a message from one folder to another. The default implementation just uses append_message and delete_message, but providers can implement more efficient versions for use when both folders are on the same store. svn path=/trunk/; revision=3832
-rw-r--r--camel/ChangeLog8
-rw-r--r--camel/camel-folder.c52
-rw-r--r--camel/camel-folder.h17
3 files changed, 75 insertions, 2 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 8c8dedb695..00bdee683a 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,11 @@
+2000-06-30 Dan Winship <danw@helixcode.com>
+
+ * camel-folder.c (camel_folder_move_message_to): New function, to
+ move a message from one folder to another. The default
+ implementation just uses append_message and delete_message, but
+ providers can implement more efficient versions for use when both
+ folders are on the same store.
+
2000-06-29 Jeffrey Stedfast <fejj@helixcode.com>
* providers/imap/camel-imap-folder.c (imap_expunge): Should now
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index f3cea51af2..39415e16cd 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -122,6 +122,11 @@ static const CamelMessageInfo *summary_get_by_uid (CamelFolder *folder,
static GList *search_by_expression (CamelFolder *folder, const char *exp,
CamelException *ex);
+static void move_message_to (CamelFolder *source,
+ const char *uid,
+ CamelFolder *dest,
+ CamelException *ex);
+
static void
camel_folder_class_init (CamelFolderClass *camel_folder_class)
{
@@ -159,6 +164,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->free_summary = free_summary;
camel_folder_class->search_by_expression = search_by_expression;
camel_folder_class->summary_get_by_uid = summary_get_by_uid;
+ camel_folder_class->move_message_to = move_message_to;
/* virtual method overload */
gtk_object_class->finalize = finalize;
@@ -1013,3 +1019,49 @@ camel_folder_search_by_expression (CamelFolder *folder, const char *expression,
return CF_CLASS (folder)->search_by_expression (folder, expression, ex);
}
+
+
+static void
+move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest,
+ CamelException *ex)
+{
+ CamelMimeMessage *msg;
+
+ /* Default implementation. */
+
+ msg = camel_folder_get_message_by_uid (source, uid, ex);
+ if (!msg)
+ return;
+ camel_folder_append_message (dest, msg, ex);
+ gtk_object_unref (GTK_OBJECT (msg));
+ if (camel_exception_is_set (ex))
+ return;
+ camel_folder_delete_message_by_uid (source, uid, ex);
+}
+
+/**
+ * camel_folder_move_message_to:
+ * @source: source folder
+ * @uid: UID of message in @source
+ * @dest: destination folder
+ * @ex: a CamelException
+ *
+ * This moves a message from one folder to another. If the @source and
+ * @dest folders have the same parent_store, this may be more efficient
+ * than a camel_folder_append_message() followed by
+ * camel_folder_delete_message_by_uid().
+ **/
+void
+camel_folder_move_message_to (CamelFolder *source, const char *uid,
+ CamelFolder *dest, CamelException *ex)
+{
+ g_return_if_fail (CAMEL_IS_FOLDER (source));
+ g_return_if_fail (CAMEL_IS_FOLDER (dest));
+ g_return_if_fail (uid != NULL);
+
+ if (source->parent_store == dest->parent_store) {
+ return CF_CLASS (source)->move_message_to (source, uid,
+ dest, ex);
+ } else
+ return move_message_to (source, uid, dest, ex);
+}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 9e9acc6afd..d0a7ceea02 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -155,9 +155,17 @@ typedef struct {
gboolean (*has_search_capability) (CamelFolder *folder);
- GList * (*search_by_expression) (CamelFolder *folder, const char *expression, CamelException *ex);
+ GList * (*search_by_expression) (CamelFolder *folder,
+ const char *expression,
+ CamelException *ex);
- const CamelMessageInfo * (*summary_get_by_uid) (CamelFolder *, const char *uid);
+ const CamelMessageInfo * (*summary_get_by_uid) (CamelFolder *,
+ const char *uid);
+
+ void (*move_message_to) (CamelFolder *source,
+ const char *uid,
+ CamelFolder *destination,
+ CamelException *ex);
} CamelFolderClass;
@@ -271,6 +279,11 @@ GList * camel_folder_search_by_expression (CamelFolder *folder, const char
const CamelMessageInfo *camel_folder_summary_get_by_uid (CamelFolder *summary,
const char *uid);
+void camel_folder_move_message_to (CamelFolder *source,
+ const char *uid,
+ CamelFolder *dest,
+ CamelException *ex);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */