aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/component-factory.c2
-rw-r--r--mail/folder-browser.c2
-rw-r--r--mail/importers/evolution-mbox-importer.c2
-rw-r--r--mail/mail-callbacks.c50
-rw-r--r--mail/mail-importer.c2
-rw-r--r--mail/mail-local.c6
-rw-r--r--mail/mail-ops.c13
-rw-r--r--mail/mail-ops.h2
9 files changed, 58 insertions, 35 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index b905febf5c..f741eea855 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2002-05-13 Dan Winship <danw@ximian.com>
+
+ * (various places): Update for camel_folder_append_message /
+ camel_folder_transfer_messages_to API change.
+
+ * mail-ops.c (mail_append_mail): Pass the appended_uid to the
+ callback.
+
+ * mail-callbacks.c (composer_save_draft_cb, save_draft_done,
+ do_edit_messages): Take advantage of the append_message change to
+ keep track of the UID of the saved draft so that we can delete the
+ old copy of the draft each time we save a new one. Remove the
+ FIXME suggesting we should do that, since we're doing it now. :)
+
2002-05-10 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (do_view_message): Update for the new
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 550b5bdb19..094027fed2 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -483,7 +483,7 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex)
/* append the message to the folder... */
info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (dest, msg, info, ex);
+ camel_folder_append_message (dest, msg, info, NULL, ex);
camel_object_unref (CAMEL_OBJECT (msg));
if (camel_exception_is_set (ex))
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index beae739c3c..b5d87685eb 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -447,7 +447,7 @@ message_rfc822_dnd (CamelFolder *dest, CamelStream *stream, CamelException *ex)
/* append the message to the folder... */
info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (dest, msg, info, ex);
+ camel_folder_append_message (dest, msg, info, NULL, ex);
camel_object_unref (CAMEL_OBJECT (msg));
if (camel_exception_is_set (ex))
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index 2980e06edc..ffa8872fc6 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -182,7 +182,7 @@ process_item_fn (EvolutionImporter *eimporter,
if (deleted == FALSE) {
/* write the mesg */
- camel_folder_append_message (importer->folder, msg, info, ex);
+ camel_folder_append_message (importer->folder, msg, info, NULL, ex);
g_free (info);
}
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 5ae3b8334e..a7c3adbb9f 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -520,9 +520,11 @@ composer_send_cb (EMsgComposer *composer, gpointer data)
}
static void
-append_mail_cleanup (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data)
+append_mail_cleanup (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data)
{
camel_message_info_free (info);
+ if (appended_uid)
+ g_free (appended_uid);
}
void
@@ -551,26 +553,40 @@ composer_postpone_cb (EMsgComposer *composer, gpointer data)
struct _save_draft_info {
EMsgComposer *composer;
- const char *old_uid;
int quit;
};
static void
-save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data)
+save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data)
{
struct _save_draft_info *sdi = data;
-
- /* delete the original draft message */
- if (ok && sdi->old_uid)
- camel_folder_set_message_flags (folder, sdi->old_uid,
+ char *old_uid;
+
+ if (!ok)
+ goto done;
+
+ old_uid = gtk_object_get_data (GTK_OBJECT (sdi->composer), "draft_uid");
+ if (old_uid) {
+ /* delete the original draft message */
+ camel_folder_set_message_flags (folder, old_uid,
CAMEL_MESSAGE_DELETED,
CAMEL_MESSAGE_DELETED);
+ }
+
+ if (appended_uid) {
+ gtk_object_set_data_full (GTK_OBJECT (sdi->composer),
+ "draft_uid", appended_uid,
+ (GtkDestroyNotify)g_free);
+ } else {
+ gtk_object_set_data (GTK_OBJECT (sdi->composer),
+ "draft_uid", NULL);
+ }
- if (ok && sdi->quit)
+ if (sdi->quit)
gtk_widget_destroy (GTK_WIDGET (sdi->composer));
- else
- gtk_object_unref (GTK_OBJECT (sdi->composer));
-
+
+ done:
+ gtk_object_unref (GTK_OBJECT (sdi->composer));
g_free (info);
g_free (sdi);
}
@@ -640,16 +656,8 @@ composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user_data)
sdi = g_malloc (sizeof (struct _save_draft_info));
sdi->composer = composer;
gtk_object_ref (GTK_OBJECT (composer));
- sdi->old_uid = (const char *) user_data;
sdi->quit = quit;
- /* FIXME: we need to have some way of getting the UID of the
- newly appended message so that we can update the data that
- this callback gets called with (user_data is the UID of the
- message being edited) so that if the user saves a
- second/third/fourth/etc time, we keep deleting the previous
- copy of the draft */
-
mail_append_mail (folder, msg, info, save_draft_done, sdi);
camel_object_unref (CAMEL_OBJECT (folder));
camel_object_unref (CAMEL_OBJECT (msg));
@@ -2048,10 +2056,10 @@ do_edit_messages (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, voi
composer_postpone_cb, NULL);
uid = g_strdup (uids->pdata[i]);
- gtk_object_set_data_full (GTK_OBJECT (composer), "uid", uid, (GtkDestroyNotify) g_free);
+ gtk_object_set_data_full (GTK_OBJECT (composer), "draft_uid", uid, (GtkDestroyNotify) g_free);
gtk_signal_connect (GTK_OBJECT (composer), "save-draft",
- composer_save_draft_cb, uid);
+ composer_save_draft_cb, NULL);
gtk_widget_show (GTK_WIDGET (composer));
}
diff --git a/mail/mail-importer.c b/mail/mail-importer.c
index 365baaefb7..5ed406d134 100644
--- a/mail/mail-importer.c
+++ b/mail/mail-importer.c
@@ -138,7 +138,7 @@ mail_importer_add_line (MailImporter *importer,
importer->mstream = NULL;
ex = camel_exception_new ();
- camel_folder_append_message (importer->folder, msg, info, ex);
+ camel_folder_append_message (importer->folder, msg, info, NULL, ex);
camel_object_unref (CAMEL_OBJECT (msg));
camel_exception_free (ex);
diff --git a/mail/mail-local.c b/mail/mail-local.c
index 98a2c78e6f..fcb8305ba1 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -275,7 +275,7 @@ mlf_expunge(CamelFolder *folder, CamelException *ex)
}
static void
-mlf_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex)
+mlf_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, char **appended_uid, CamelException *ex)
{
MailLocalFolder *mlf = MAIL_LOCAL_FOLDER(folder);
CamelFolder *f;
@@ -285,7 +285,7 @@ mlf_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMe
camel_object_ref((CamelObject *)f);
LOCAL_FOLDER_UNLOCK(mlf);
- camel_folder_append_message(f, message, info, ex);
+ camel_folder_append_message(f, message, info, appended_uid, ex);
camel_object_unref((CamelObject *)f);
}
@@ -686,7 +686,7 @@ mail_local_folder_reconfigure (MailLocalFolder *mlf, const char *new_format, int
camel_folder_freeze(mlf->real_folder);
uids = camel_folder_get_uids(fromfolder);
- camel_folder_transfer_messages_to(fromfolder, uids, mlf->real_folder, TRUE, ex);
+ camel_folder_transfer_messages_to(fromfolder, uids, mlf->real_folder, NULL, TRUE, ex);
camel_folder_free_uids(fromfolder, uids);
if (camel_exception_is_set(ex))
goto cleanup;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index a864b87569..c86c5f2208 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -558,7 +558,7 @@ mail_send_message (CamelMimeMessage *message, const char *destination,
}
if (folder) {
- camel_folder_append_message (folder, message, info, ex);
+ camel_folder_append_message (folder, message, info, NULL, ex);
if (camel_exception_is_set (ex)) {
ExceptionId id;
@@ -826,8 +826,9 @@ struct _append_msg {
CamelFolder *folder;
CamelMimeMessage *message;
CamelMessageInfo *info;
+ char *appended_uid;
- void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data);
+ void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data);
void *data;
};
@@ -843,7 +844,7 @@ append_mail_append (struct _mail_msg *mm)
struct _append_msg *m = (struct _append_msg *)mm;
camel_mime_message_set_date(m->message, CAMEL_MESSAGE_DATE_CURRENT, 0);
- camel_folder_append_message(m->folder, m->message, m->info, &mm->ex);
+ camel_folder_append_message(m->folder, m->message, m->info, &m->appended_uid, &mm->ex);
}
static void
@@ -852,7 +853,7 @@ append_mail_appended (struct _mail_msg *mm)
struct _append_msg *m = (struct _append_msg *)mm;
if (m->done)
- m->done(m->folder, m->message, m->info, !camel_exception_is_set(&mm->ex), m->data);
+ m->done(m->folder, m->message, m->info, !camel_exception_is_set(&mm->ex), m->appended_uid, m->data);
}
static void
@@ -873,7 +874,7 @@ static struct _mail_msg_op append_mail_op = {
void
mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info,
- void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data),
+ void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data),
void *data)
{
struct _append_msg *m;
@@ -938,7 +939,7 @@ transfer_messages_transfer (struct _mail_msg *mm)
camel_folder_freeze (m->source);
camel_folder_freeze (dest);
- camel_folder_transfer_messages_to (m->source, m->uids, dest, m->delete, &mm->ex);
+ camel_folder_transfer_messages_to (m->source, m->uids, dest, NULL, m->delete, &mm->ex);
camel_folder_thaw (m->source);
camel_folder_thaw (dest);
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index e9c9caa91a..6aa5627d61 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -39,7 +39,7 @@ extern "C" {
#include "e-util/e-msgport.h"
void mail_append_mail (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info,
- void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, void *data),
+ void (*done)(CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, int ok, char *appended_uid, void *data),
void *data);
void mail_transfer_messages (CamelFolder *source, GPtrArray *uids,