aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-09-23 02:53:26 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-09-23 02:53:26 +0800
commitd60e250a6e858889c7d6e7c1a0d7f0e511a6e320 (patch)
treef55684e1df2e357139ee18be19ca137e45f469fc
parent6abd6e01b3f220a127c780ffdf2ea9a80f028238 (diff)
downloadgsoc2013-evolution-d60e250a6e858889c7d6e7c1a0d7f0e511a6e320.tar.gz
gsoc2013-evolution-d60e250a6e858889c7d6e7c1a0d7f0e511a6e320.tar.zst
gsoc2013-evolution-d60e250a6e858889c7d6e7c1a0d7f0e511a6e320.zip
implement, we hook into the mail progress reporting stuff by overriding
2003-09-21 Not Zed <NotZed@Ximian.com> * mail-session.c (ms_thread_msg_new): implement, we hook into the mail progress reporting stuff by overriding the CamelOperation member with one from a dummy mail_msg. (ms_thread_msg_free): handle freeing. * mail-mt.c (mail_msg_free): mute the camel-operaiton when we free it so we no longer get updates. svn path=/trunk/; revision=22649
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/mail-mt.c4
-rw-r--r--mail/mail-session.c46
3 files changed, 59 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d18667cb82..df11d8e83e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2003-09-21 Not Zed <NotZed@Ximian.com>
+
+ * mail-session.c (ms_thread_msg_new): implement, we hook into the
+ mail progress reporting stuff by overriding the CamelOperation
+ member with one from a dummy mail_msg.
+ (ms_thread_msg_free): handle freeing.
+
+ * mail-mt.c (mail_msg_free): mute the camel-operaiton when we free
+ it so we no longer get updates.
+
2003-09-19 Jeffrey Stedfast <fejj@ximian.com>
* em-message-browser.c (emmb_set_message): Set the window title to
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 66b8d68130..603e55dd50 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -201,8 +201,10 @@ void mail_msg_free(void *msg)
MAIL_MT_UNLOCK(mail_msg_lock);
- if (m->cancel)
+ if (m->cancel) {
+ camel_operation_mute(m->cancel);
camel_operation_unref(m->cancel);
+ }
camel_exception_clear(&m->ex);
/*g_free(m->priv->what);*/
diff --git a/mail/mail-session.c b/mail/mail-session.c
index c2b233b1c6..65b537246b 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -77,11 +77,17 @@ typedef struct _MailSessionClass {
} MailSessionClass;
+static CamelSessionClass *ms_parent_class;
+
static char *get_password(CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, CamelService *service, const char *item, CamelException *ex);
static void forget_password(CamelSession *session, CamelService *service, const char *item, CamelException *ex);
static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const char *prompt, gboolean cancel);
static CamelFilterDriver *get_filter_driver(CamelSession *session, const char *type, CamelException *ex);
+static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc);
+static void *ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
+static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m);
+
static void
init (MailSession *session)
{
@@ -106,6 +112,10 @@ class_init (MailSessionClass *mail_session_class)
camel_session_class->forget_password = forget_password;
camel_session_class->alert_user = alert_user;
camel_session_class->get_filter_driver = get_filter_driver;
+
+ camel_session_class->thread_msg_new = ms_thread_msg_new;
+ camel_session_class->thread_msg_free = ms_thread_msg_free;
+ camel_session_class->thread_status = ms_thread_status;
}
static CamelType
@@ -114,6 +124,7 @@ mail_session_get_type (void)
static CamelType mail_session_type = CAMEL_INVALID_TYPE;
if (mail_session_type == CAMEL_INVALID_TYPE) {
+ ms_parent_class = (CamelSessionClass *)camel_session_get_type();
mail_session_type = camel_type_register (
camel_session_get_type (),
"MailSession",
@@ -641,6 +652,41 @@ get_filter_driver (CamelSession *session, const char *type, CamelException *ex)
session, type, ex);
}
+/* TODO: This is very temporary, until we have a better way to do the progress reporting,
+ we just borrow a dummy mail-mt thread message and hook it onto out camel thread message */
+
+static mail_msg_op_t ms_thread_ops_dummy = { NULL };
+
+static void *ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size)
+{
+ CamelSessionThreadMsg *msg = ms_parent_class->thread_msg_new(session, ops, size);
+
+ /* We create a dummy mail_msg, and then copy its cancellation port over to ours, so
+ we get cancellation and progress in common with hte existing mail code, for free */
+ if (msg) {
+ struct _mail_msg *m = mail_msg_new(&ms_thread_ops_dummy, NULL, sizeof(struct _mail_msg));
+
+ msg->data = m;
+ camel_operation_unref(msg->op);
+ msg->op = m->cancel;
+ camel_operation_ref(msg->op);
+ }
+
+ return msg;
+}
+
+static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m)
+{
+ mail_msg_free(m->data);
+ ms_parent_class->thread_msg_free(session, m);
+}
+
+static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc)
+{
+ /* This should never be called since we bypass it in alloc! */
+ printf("Thread status '%s' %d%%\n", text, pc);
+}
+
char *
mail_session_get_password (const char *url_string)
{