diff options
author | Not Zed <NotZed@Ximian.com> | 2003-09-23 02:53:26 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-09-23 02:53:26 +0800 |
commit | d60e250a6e858889c7d6e7c1a0d7f0e511a6e320 (patch) | |
tree | f55684e1df2e357139ee18be19ca137e45f469fc /mail/mail-session.c | |
parent | 6abd6e01b3f220a127c780ffdf2ea9a80f028238 (diff) | |
download | gsoc2013-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
Diffstat (limited to 'mail/mail-session.c')
-rw-r--r-- | mail/mail-session.c | 46 |
1 files changed, 46 insertions, 0 deletions
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) { |