aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-27 21:01:10 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-27 21:01:10 +0800
commit555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576 (patch)
tree938d1b7f190318d9e40b295df7c8c411da608b34
parentd00a56d4cc6f3185004f6babdb1a5f7aad729b5e (diff)
downloadgsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar.gz
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar.bz2
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar.lz
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar.xz
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.tar.zst
gsoc2013-evolution-555c178a7d52ae4aa5a52fa78bbbc0f70f4cc576.zip
Bug #571039 - Shows all selected messages in a preview pane on a slow network
-rw-r--r--mail/e-mail-reader.c15
-rw-r--r--mail/mail-mt.c7
-rw-r--r--mail/mail-ops.c23
-rw-r--r--mail/mail-ops.h6
4 files changed, 36 insertions, 15 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index cdb3761d60..c60054b266 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1845,12 +1845,17 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
html_display_visible = GTK_WIDGET_MAPPED (widget);
selected_uid_changed = g_strcmp0 (cursor_uid, format_uid);
- if (html_display_visible && selected_uid_changed)
- mail_get_messagex (
+ if (html_display_visible && selected_uid_changed) {
+ gint op_id;
+
+ op_id = mail_get_messagex (
message_list->folder, cursor_uid,
mail_reader_message_loaded_cb,
g_object_ref (reader),
mail_msg_fast_ordered_push);
+
+ g_object_set_data (G_OBJECT (reader), "preview-get-message-op-id", GINT_TO_POINTER (op_id));
+ }
} else
em_format_format (EM_FORMAT (html_display), NULL, NULL, NULL);
@@ -1866,6 +1871,12 @@ mail_reader_message_selected_cb (EMailReader *reader,
{
GSource *source;
const gchar *key;
+ gint op_id;
+
+ /* cancel previous message fetching, if any, first */
+ op_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (reader), "preview-get-message-op-id"));
+ if (op_id)
+ mail_msg_cancel (op_id);
/* XXX This is kludgy, but we have no other place to store timeout
* state information. Addendum: See EAttachmentView for an example
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 16d593c0f3..f87a8f2e91 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -309,7 +309,8 @@ mail_msg_check_error (gpointer msg)
if (!camel_exception_is_set(&m->ex)
|| m->ex.id == CAMEL_EXCEPTION_USER_CANCEL
- || m->ex.id == CAMEL_EXCEPTION_FOLDER_INVALID_UID)
+ || m->ex.id == CAMEL_EXCEPTION_FOLDER_INVALID_UID
+ || (m->cancel && camel_operation_cancel_check (m->cancel)))
return;
if (active_errors == NULL)
@@ -527,10 +528,6 @@ mail_msg_proxy (MailMsg *msg)
if (msg->info->desc != NULL && msg->cancel) {
camel_operation_end (msg->cancel);
camel_operation_unregister (msg->cancel);
- MAIL_MT_LOCK (mail_msg_lock);
- camel_operation_unref (msg->cancel);
- msg->cancel = NULL;
- MAIL_MT_UNLOCK (mail_msg_lock);
}
g_async_queue_push (msg_reply_queue, msg);
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 0f17dc2a4a..a251c871a9 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1836,7 +1836,10 @@ get_message_desc (struct _get_message_msg *m)
static void
get_message_exec (struct _get_message_msg *m)
{
- m->message = camel_folder_get_message(m->folder, m->uid, &m->base.ex);
+ if (m->base.cancel && camel_operation_cancel_check (m->base.cancel))
+ m->message = NULL;
+ else
+ m->message = camel_folder_get_message (m->folder, m->uid, &m->base.ex);
}
static void
@@ -1865,12 +1868,13 @@ static MailMsgInfo get_message_info = {
(MailMsgFreeFunc) get_message_free
};
-void
+gint
mail_get_message(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolder *folder, const gchar *uid,
CamelMimeMessage *msg, gpointer data),
gpointer data, MailMsgDispatchFunc dispatch)
{
struct _get_message_msg *m;
+ gint id;
m = mail_msg_new(&get_message_info);
m->folder = folder;
@@ -1879,8 +1883,11 @@ mail_get_message(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolde
m->data = data;
m->done = (void (*) (CamelFolder *, const gchar *, CamelMimeMessage *, gpointer )) done;
m->cancel = camel_operation_new(NULL, NULL);
+ id = m->base.seq;
dispatch (m);
+
+ return id;
}
typedef void (*get_done)(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *);
@@ -1904,11 +1911,12 @@ static MailMsgInfo get_messagex_info = {
/* This is temporary, to avoid having to rewrite everything that uses
mail_get_message; it adds an exception argument to the callback */
-CamelOperation *
+gint
mail_get_messagex(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *),
gpointer data, MailMsgDispatchFunc dispatch)
{
struct _get_message_msg *m;
+ gint id;
m = mail_msg_new(&get_messagex_info);
m->folder = folder;
@@ -1917,10 +1925,11 @@ mail_get_messagex(CamelFolder *folder, const gchar *uid, void (*done) (CamelFold
m->data = data;
m->done = (void (*) (CamelFolder *, const gchar *, CamelMimeMessage *, gpointer )) done;
m->cancel = camel_operation_new(NULL, NULL);
+ id = m->base.seq;
dispatch (m);
- return m->cancel;
+ return id;
}
/* ********************************************************************** */
@@ -1991,12 +2000,13 @@ static MailMsgInfo get_messages_info = {
(MailMsgFreeFunc) get_messages_free
};
-void
+gint
mail_get_messages(CamelFolder *folder, GPtrArray *uids,
void (*done) (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer data),
gpointer data)
{
struct _get_messages_msg *m;
+ gint id;
m = mail_msg_new(&get_messages_info);
m->folder = folder;
@@ -2005,8 +2015,11 @@ mail_get_messages(CamelFolder *folder, GPtrArray *uids,
m->messages = g_ptr_array_new();
m->data = data;
m->done = done;
+ id = m->base.seq;
mail_msg_unordered_push (m);
+
+ return id;
}
/* ** SAVE MESSAGES ******************************************************* */
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 3233f03219..843ada5d54 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -49,18 +49,18 @@ void mail_transfer_messages (CamelFolder *source, GPtrArray *uids,
gpointer data);
/* get a single message, asynchronously */
-void mail_get_message (CamelFolder *folder, const gchar *uid,
+gint mail_get_message (CamelFolder *folder, const gchar *uid,
void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data),
gpointer data,
MailMsgDispatchFunc dispatch);
-CamelOperation *
+gint
mail_get_messagex(CamelFolder *folder, const gchar *uid,
void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *),
gpointer data, MailMsgDispatchFunc dispatch);
/* get several messages */
-void mail_get_messages (CamelFolder *folder, GPtrArray *uids,
+gint mail_get_messages (CamelFolder *folder, GPtrArray *uids,
void (*done) (CamelFolder *folder, GPtrArray *uids, GPtrArray *msgs, gpointer data),
gpointer data);