aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-folder.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-07-01 09:35:19 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-07-01 09:35:19 +0800
commitf278d3041bc2829db097cc0e5cf99ba443501a9a (patch)
tree8014fb0a1fa2fc17589391eb10773e7b9fd75f59 /camel/providers/imap/camel-imap-folder.c
parentc07840479d0b23443c06e20599bf4948e6d3509b (diff)
downloadgsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar.gz
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar.bz2
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar.lz
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar.xz
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.tar.zst
gsoc2013-evolution-f278d3041bc2829db097cc0e5cf99ba443501a9a.zip
New function, to copy a message from one folder to another. The default
2000-06-30 Jeffrey Stedfast <fejj@helixcode.com> * camel-folder.c (camel_folder_copy_message_to): New function, to copy a message from one folder to another. The default implementation just uses append_message, but providers can implement more efficient versions for use when both folders are on the same store. * broken-date-parser.[c,h]: Utilities for parsing broken date strings. * providers/imap/camel-imap-folder.c (imap_move_message_to): (imap_copy_message_to): Implemented. * camel-mime-utils.c (header_decode_date): Wrote some code to try and un-mangle broken date formats and then parse that new string instead. svn path=/trunk/; revision=3841
Diffstat (limited to 'camel/providers/imap/camel-imap-folder.c')
-rw-r--r--camel/providers/imap/camel-imap-folder.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 2024f9687a..431c705f65 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -62,13 +62,10 @@ static void imap_init (CamelFolder *folder, CamelStore *parent_store,
CamelException *ex);
static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
-#if 0
-static gboolean imap_exists (CamelFolder *folder, CamelException *ex);
-static gboolean imap_delete (CamelFolder *folder, gboolean recurse, CamelException *ex);
-static gboolean imap_delete_messages (CamelFolder *folder, CamelException *ex);
-#endif
static gint imap_get_message_count (CamelFolder *folder, CamelException *ex);
static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
+static void imap_copy_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
+static void imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex);
static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex);
static gboolean imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder);
static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex);
@@ -79,13 +76,6 @@ static CamelMimeMessage *imap_get_message_by_uid (CamelFolder *folder, const gch
static void imap_expunge (CamelFolder *folder, CamelException *ex);
-#if 0
-static void _copy_message_to (CamelFolder *folder, CamelMimeMessage *message,
- CamelFolder *dest_folder, CamelException *ex);
-static const gchar *_get_message_uid (CamelFolder *folder, CamelMimeMessage *message,
- CamelException *ex);
-#endif
-
static void imap_delete_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex);
static const CamelMessageInfo *imap_summary_get_by_uid (CamelFolder *f, const char *uid);
@@ -126,6 +116,8 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->get_message_by_uid = imap_get_message_by_uid;
camel_folder_class->append_message = imap_append_message;
camel_folder_class->delete_message_by_uid = imap_delete_message_by_uid;
+ camel_folder_class->copy_message_to = imap_copy_message_to;
+ camel_folder_class->move_message_to = imap_move_message_to;
camel_folder_class->get_summary = imap_get_summary;
camel_folder_class->summary_get_by_uid = imap_summary_get_by_uid;
@@ -453,8 +445,6 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex)
return imap_folder->count;
}
-/* TODO: Optimize this later - there may be times when moving/copying a message from the
- same IMAP store in which case we'd want to use IMAP's COPY command */
static void
imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex)
{
@@ -511,6 +501,39 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept
}
static void
+imap_copy_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex)
+{
+ CamelStore *store = CAMEL_STORE (source->parent_store);
+ CamelURL *url = CAMEL_SERVICE (store)->url;
+ char *result, *folder_path;
+ int status;
+
+ if (url && url->path && *(url->path + 1) && strcmp (destination->full_name, "INBOX"))
+ folder_path = g_strdup_printf ("%s/%s", url->path + 1, destination->full_name);
+ else
+ folder_path = g_strdup (destination->full_name);
+
+ status = camel_imap_command (CAMEL_IMAP_STORE (store), NULL, &result,
+ "COPY %s %s", uid, folder_path);
+
+ if (status != CAMEL_IMAP_OK) {
+ CamelService *service = CAMEL_SERVICE (store);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not COPY message %s to %s on IMAP server %s: %s.",
+ uid, folder_path, service->url->host,
+ status == CAMEL_IMAP_ERR ? result :
+ "Unknown error");
+ g_free (result);
+ g_free (folder_path);
+ return;
+ }
+
+ g_free (result);
+ g_free (folder_path);
+}
+
+/* FIXME: Duplication of code! */
+static void
imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex)
{
CamelStore *store = CAMEL_STORE (source->parent_store);