aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-03-13 00:51:50 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-03-13 00:51:50 +0800
commit2dc2990d215dae20c8ebdb93f10338730b8f514e (patch)
tree4236c6b902ca8c79b19750ed8dbf5450ac85b479 /mail
parent956377822c6b7eebe36889950c6f7a749e78a8d0 (diff)
downloadgsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar.gz
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar.bz2
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar.lz
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar.xz
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.tar.zst
gsoc2013-evolution-2dc2990d215dae20c8ebdb93f10338730b8f514e.zip
Removed. No longer in use (hasn't been since before 1.2).
2004-03-12 Jeffrey Stedfast <fejj@ximian.com> * mail-ops.c (mail_send_mail): Removed. No longer in use (hasn't been since before 1.2). (send_queue_send): Before enetring the main send loop, create a temporary uid array containing ONLY the messages we will send (ie. not any that have been marked deleted) so that we can more accurately report the number of messages total that we are sending. Also continue sending even if we encounter an exeption in mail_send_message() (unless, of course, it is a user-cancel). Merge any exceptions we get into the master exception variable and ALWAYS sync/expunge the queue folder. svn path=/trunk/; revision=25043
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog13
-rw-r--r--mail/mail-ops.c181
-rw-r--r--mail/mail-ops.h5
3 files changed, 80 insertions, 119 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e3dcc02d70..9f907f81a8 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,16 @@
+2004-03-12 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-ops.c (mail_send_mail): Removed. No longer in use (hasn't
+ been since before 1.2).
+ (send_queue_send): Before enetring the main send loop, create a
+ temporary uid array containing ONLY the messages we will send
+ (ie. not any that have been marked deleted) so that we can more
+ accurately report the number of messages total that we are
+ sending. Also continue sending even if we encounter an exeption in
+ mail_send_message() (unless, of course, it is a
+ user-cancel). Merge any exceptions we get into the master
+ exception variable and ALWAYS sync/expunge the queue folder.
+
2004-03-11 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-browser.c (emfb_set_folder): Reverted signal blocking
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 112b59f8ca..99a7367378 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -585,90 +585,6 @@ mail_send_message (CamelMimeMessage *message, const char *destination,
g_string_free (err, TRUE);
}
-/* ********************************************************************** */
-
-struct _send_mail_msg {
- struct _mail_msg msg;
-
- CamelFilterDriver *driver;
- char *destination;
- CamelMimeMessage *message;
-
- void (*done)(char *uri, CamelMimeMessage *message, gboolean sent, void *data);
- void *data;
-};
-
-static char *
-send_mail_desc (struct _mail_msg *mm, int done)
-{
- struct _send_mail_msg *m = (struct _send_mail_msg *)mm;
- const char *subject;
-
- subject = camel_mime_message_get_subject (m->message);
-
- if (subject)
- return g_strdup_printf (_("Sending \"%s\""), subject);
- else
- return g_strdup (_("Sending message"));
-}
-
-static void
-send_mail_send (struct _mail_msg *mm)
-{
- struct _send_mail_msg *m = (struct _send_mail_msg *)mm;
-
- mail_send_message (m->message, m->destination, m->driver, &mm->ex);
-}
-
-static void
-send_mail_sent (struct _mail_msg *mm)
-{
- struct _send_mail_msg *m = (struct _send_mail_msg *)mm;
-
- if (m->done)
- m->done (m->destination, m->message, !camel_exception_is_set (&mm->ex), m->data);
-}
-
-static void
-send_mail_free (struct _mail_msg *mm)
-{
- struct _send_mail_msg *m = (struct _send_mail_msg *)mm;
-
- camel_object_unref (m->driver);
- camel_object_unref (m->message);
- g_free (m->destination);
-}
-
-static struct _mail_msg_op send_mail_op = {
- send_mail_desc,
- send_mail_send,
- send_mail_sent,
- send_mail_free,
-};
-
-int
-mail_send_mail (const char *uri, CamelMimeMessage *message,
- void (*done) (char *uri, CamelMimeMessage *message, gboolean sent, void *data),
- void *data)
-{
- struct _send_mail_msg *m;
- int id;
-
- m = mail_msg_new (&send_mail_op, NULL, sizeof (*m));
- m->destination = g_strdup (uri);
- m->message = message;
- camel_object_ref (message);
- m->data = data;
- m->done = done;
-
- id = m->msg.seq;
-
- m->driver = camel_session_get_filter_driver (session, FILTER_SOURCE_OUTGOING, NULL);
-
- e_thread_put (mail_thread_new, (EMsg *)m);
- return id;
-}
-
/* ** SEND MAIL QUEUE ***************************************************** */
struct _send_queue_msg {
@@ -708,58 +624,95 @@ send_queue_send(struct _mail_msg *mm)
{
struct _send_queue_msg *m = (struct _send_queue_msg *)mm;
CamelFolder *sent_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT);
- GPtrArray *uids;
- int i;
+ GPtrArray *uids, *send_uids = NULL;
+ CamelException ex;
+ int i, j;
d(printf("sending queue\n"));
- uids = camel_folder_get_uids (m->queue);
- if (uids == NULL || uids->len == 0)
+ if (!(uids = camel_folder_get_uids (m->queue)))
return;
-
- if (m->cancel)
- camel_operation_register (m->cancel);
-
- for (i = 0; i < uids->len; i++) {
- CamelMimeMessage *message;
+
+ send_uids = g_ptr_array_sized_new (uids->len);
+ for (i = 0, j = 0; i < uids->len; i++) {
CamelMessageInfo *info;
- int pc = (100 * i) / uids->len;
-
- report_status (m, CAMEL_FILTER_STATUS_START, pc, _("Sending message %d of %d"), i+1, uids->len);
info = camel_folder_get_message_info (m->queue, uids->pdata[i]);
if (info && info->flags & CAMEL_MESSAGE_DELETED)
continue;
- message = camel_folder_get_message (m->queue, uids->pdata[i], &mm->ex);
- if (camel_exception_is_set (&mm->ex))
- break;
+ send_uids->pdata[j++] = uids->pdata[i];
+ }
+
+ send_uids->len = j;
+ if (send_uids->len == 0) {
+ /* nothing to send */
+ camel_folder_free_uids (m->queue, uids);
+ g_ptr_array_free (send_uids, TRUE);
+ return;
+ }
+
+ if (m->cancel)
+ camel_operation_register (m->cancel);
+
+ camel_exception_init (&ex);
+
+ for (i = 0, j = 0; i < send_uids->len; i++) {
+ int pc = (100 * i) / send_uids->len;
+ CamelMimeMessage *message;
- mail_send_message (message, m->destination, m->driver, &mm->ex);
+ report_status (m, CAMEL_FILTER_STATUS_START, pc, _("Sending message %d of %d"), i+1, send_uids->len);
- if (camel_exception_is_set (&mm->ex))
- break;
+ if (!(message = camel_folder_get_message (m->queue, send_uids->pdata[i], &ex))) {
+ /* I guess ignore errors where we can't get the message (should never happen anyway)? */
+ camel_exception_clear (&ex);
+ continue;
+ }
- camel_folder_set_message_flags (m->queue, uids->pdata[i], CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
+ mail_send_message (message, m->destination, m->driver, &ex);
+ if (!camel_exception_is_set (&ex)) {
+ camel_folder_set_message_flags (m->queue, send_uids->pdata[i], CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
+ } else if (ex.id != CAMEL_EXCEPTION_USER_CANCEL) {
+ /* merge exceptions into one */
+ if (camel_exception_is_set (&mm->ex))
+ camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SYSTEM, "%s\n\n%s", mm->ex.desc, ex.desc);
+ else
+ camel_exception_xfer (&mm->ex, &ex);
+ camel_exception_clear (&ex);
+
+ /* keep track of the number of failures */
+ j++;
+ } else {
+ /* transfer the USER_CANCEL exeption to the async op exception and then break */
+ camel_exception_xfer (&mm->ex, &ex);
+ break;
+ }
}
-
- if (camel_exception_is_set (&mm->ex))
- report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d of %d"), i+1, uids->len);
+
+ j += (send_uids->len - i);
+
+ if (j > 0)
+ report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Failed to send %d of %d messages"), j, send_uids->len);
+ else if (mm->ex.id == CAMEL_EXCEPTION_USER_CANCEL)
+ report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Cancelled."));
else
report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Complete."));
-
+
if (m->driver) {
camel_object_unref (m->driver);
m->driver = NULL;
}
-
+
camel_folder_free_uids (m->queue, uids);
-
- if (!camel_exception_is_set (&mm->ex))
- camel_folder_expunge (m->queue, &mm->ex);
+ g_ptr_array_free (send_uids, TRUE);
- if (sent_folder)
- camel_folder_sync (sent_folder, FALSE, NULL);
+ camel_folder_sync (m->queue, TRUE, &ex);
+ camel_exception_clear (&ex);
+
+ if (sent_folder) {
+ camel_folder_sync (sent_folder, FALSE, &ex);
+ camel_exception_clear (&ex);
+ }
if (m->cancel)
camel_operation_unregister (m->cancel);
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 090beef9fc..eb4c216ed1 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -120,11 +120,6 @@ int mail_save_part (CamelMimePart *part, const char *path,
void (*done)(CamelMimePart *part, char *path, int saved, void *data),
void *data);
-int mail_send_mail (const char *uri, CamelMimeMessage *message,
- void (*done) (char *uri, CamelMimeMessage *message, gboolean sent, void *data),
- void *data);
-
-
/* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */
void mail_send_queue (CamelFolder *queue, const char *destination,
const char *type, CamelOperation *cancel,