diff options
author | Not Zed <NotZed@Ximian.com> | 2005-03-04 11:15:38 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2005-03-04 11:15:38 +0800 |
commit | 2fad54d49c8a2380e9ab135160652c9aec6e8b7a (patch) | |
tree | 23c15b438926f27c41d44931bf9448f76311aa54 /mail | |
parent | 65d329aa11b37ca3fad9c76db0c8fa92ae451800 (diff) | |
download | gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar.gz gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar.bz2 gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar.lz gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar.xz gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.tar.zst gsoc2013-evolution-2fad54d49c8a2380e9ab135160652c9aec6e8b7a.zip |
** See bug #66592
2005-03-03 Not Zed <NotZed@Ximian.com>
** See bug #66592
* mail-tools.c (mail_tool_make_message_attachment): jus call
camel_medium_remove_header to remove the bcc header, don't need to
loop.
* mail-ops.c (mail_send_message): try to find the account by uid
first, fall back to name.
* em-composer-utils.c (composer_get_message): set
x-evolution-account by uid, not name.
2005-03-02 Not Zed <NotZed@Ximian.com>
** See bug #66592
* em-composer-utils.c (got_post_folder): no longer needed.
(composer_get_message): remove 'post' and 'no_recipeints' args.
* mail-ops.c (mail_send_message): change for xev changes. Also
handle postto if set.
* mail-tools.c (mail_tool_remove_xevolution_headers)
(mail_tool_restore_xevolution_headers): fix for api change.
(mail_tool_destroy_xevolution): remove.
* mail-tools.h: remove XEvolution, just use a struct _header_raw
for it.
* em-composer-utils.c (em_utils_composer_send_cb): don't post
message here, just queue it like any other outgoing mail.
svn path=/trunk/; revision=28950
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 34 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 128 | ||||
-rw-r--r-- | mail/mail-ops.c | 119 | ||||
-rw-r--r-- | mail/mail-tools.c | 69 | ||||
-rw-r--r-- | mail/mail-tools.h | 16 |
5 files changed, 158 insertions, 208 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index f449bede7c..445d7c5e7c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,37 @@ +2005-03-03 Not Zed <NotZed@Ximian.com> + + ** See bug #66592 + + * mail-tools.c (mail_tool_make_message_attachment): jus call + camel_medium_remove_header to remove the bcc header, don't need to + loop. + + * mail-ops.c (mail_send_message): try to find the account by uid + first, fall back to name. + + * em-composer-utils.c (composer_get_message): set + x-evolution-account by uid, not name. + +2005-03-02 Not Zed <NotZed@Ximian.com> + + ** See bug #66592 + + * em-composer-utils.c (got_post_folder): no longer needed. + (composer_get_message): remove 'post' and 'no_recipeints' args. + + * mail-ops.c (mail_send_message): change for xev changes. Also + handle postto if set. + + * mail-tools.c (mail_tool_remove_xevolution_headers) + (mail_tool_restore_xevolution_headers): fix for api change. + (mail_tool_destroy_xevolution): remove. + + * mail-tools.h: remove XEvolution, just use a struct _header_raw + for it. + + * em-composer-utils.c (em_utils_composer_send_cb): don't post + message here, just queue it like any other outgoing mail. + 2005-03-02 Not Zed <NotZed@Ximian.com> ** See "bug" 73100 diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index d47563603d..4f8ecb951a 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -228,18 +228,19 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag } static CamelMimeMessage * -composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_object_data, gboolean *no_recipients) +composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) { CamelMimeMessage *message = NULL; EDestination **recipients, **recipients_bcc; gboolean send_html, confirm_html; CamelInternetAddress *cia; int hidden = 0, shown = 0; - int num = 0, num_bcc = 0; + int num = 0, num_bcc = 0, num_post = 0; const char *subject; GConfClient *gconf; EAccount *account; int i; + GList *postlist; gconf = mail_config_get_gconf_client (); @@ -291,16 +292,16 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ } camel_object_unref (cia); + + postlist = e_msg_composer_hdrs_get_post_to((EMsgComposerHdrs *) composer->hdrs); + num_post = g_list_length(postlist); + g_list_foreach(postlist, (GFunc)g_free, NULL); + g_list_free(postlist); /* I'm sensing a lack of love, er, I mean recipients. */ - if (num == 0) { - if (post) { - if (no_recipients) - *no_recipients = TRUE; - } else { - e_error_run((GtkWindow *)composer, "mail:send-no-recipients", NULL); - goto finished; - } + if (num == 0 && num_post == 0) { + e_error_run((GtkWindow *)composer, "mail:send-no-recipients", NULL); + goto finished; } if (num > 0 && (num == num_bcc || shown == 0)) { @@ -348,7 +349,8 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ account = e_msg_composer_get_preferred_account (composer); if (account) { - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Account", account->name); + /* FIXME: Why isn't this crap just in e_msg_composer_get_message? */ + camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Account", account->uid); camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Transport", account->transport->url); camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc", account->sent_folder_uri); if (account->id->organization && *account->id->organization) { @@ -368,101 +370,37 @@ composer_get_message (EMsgComposer *composer, gboolean post, gboolean save_html_ return message; } -static void -got_post_folder (char *uri, CamelFolder *folder, void *data) -{ - CamelFolder **fp = data; - - *fp = folder; - - if (folder) - camel_object_ref (folder); -} - void em_utils_composer_send_cb (EMsgComposer *composer, gpointer user_data) { CamelMimeMessage *message; CamelMessageInfo *info; struct _send_data *send; - gboolean no_recipients = FALSE; - CamelFolder *mail_folder = NULL, *tmpfldr; - GList *post_folders = NULL, *post_ptr; - XEvolution *xev; - GList *postlist; - - postlist = e_msg_composer_hdrs_get_post_to ((EMsgComposerHdrs *) composer->hdrs); - while (postlist) { - mail_msg_wait (mail_get_folder (postlist->data, 0, got_post_folder, &tmpfldr, mail_thread_new)); - if (tmpfldr) - post_folders = g_list_append (post_folders, tmpfldr); - postlist = g_list_next (postlist); - } - + CamelFolder *mail_folder; + + if (!(message = composer_get_message (composer, FALSE))) + return; + mail_folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX); camel_object_ref (mail_folder); - if (!post_folders && !mail_folder) - return; - - if (!(message = composer_get_message (composer, post_folders != NULL, FALSE, &no_recipients))) - return; - - if (no_recipients) { - /* we're doing a post with no recipients */ - camel_object_unref (mail_folder); - mail_folder = NULL; - } - - if (mail_folder) { - /* mail the message */ - info = camel_message_info_new(NULL); - camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0); - - send = g_malloc (sizeof (*send)); - send->emcs = user_data; - if (send->emcs) - emcs_ref (send->emcs); - send->send = TRUE; - send->composer = composer; - g_object_ref (composer); - gtk_widget_hide (GTK_WIDGET (composer)); - - e_msg_composer_set_enable_autosave (composer, FALSE); - - mail_append_mail (mail_folder, message, info, composer_send_queued_cb, send); - camel_object_unref (mail_folder); - } - - if (post_folders) { - /* Remove the X-Evolution* headers if we are in Post-To mode */ - xev = mail_tool_remove_xevolution_headers (message); - mail_tool_destroy_xevolution (xev); + /* mail the message */ + info = camel_message_info_new(NULL); + camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0); - /* mail the message */ - info = camel_message_info_new(NULL); - camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0); + send = g_malloc (sizeof (*send)); + send->emcs = user_data; + if (send->emcs) + emcs_ref (send->emcs); + send->send = TRUE; + send->composer = composer; + g_object_ref (composer); + gtk_widget_hide (GTK_WIDGET (composer)); + + e_msg_composer_set_enable_autosave (composer, FALSE); - post_ptr = post_folders; - while (post_ptr) { - send = g_malloc (sizeof (*send)); - send->emcs = user_data; - if (send->emcs) - emcs_ref (send->emcs); - send->send = FALSE; - send->composer = composer; - g_object_ref (composer); - gtk_widget_hide (GTK_WIDGET (composer)); - - e_msg_composer_set_enable_autosave (composer, FALSE); - - mail_append_mail ((CamelFolder *) post_ptr->data, message, info, composer_send_queued_cb, send); - camel_object_unref ((CamelFolder *) post_ptr->data); - - post_ptr = g_list_next (post_ptr); - } - } - + mail_append_mail (mail_folder, message, info, composer_send_queued_cb, send); + camel_object_unref (mail_folder); camel_object_unref (message); } diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 3c80c7c535..98de077b36 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -448,58 +448,54 @@ mail_send_message(CamelFolder *queue, const char *uid, const char *destination, EAccount *account = NULL; const CamelInternetAddress *iaddr; CamelAddress *from, *recipients; - CamelMessageInfo *info; + CamelMessageInfo *info = NULL; CamelTransport *xport = NULL; char *transport_url = NULL; char *sent_folder_uri = NULL; - const char *resent_from; + const char *resent_from, *tmp; CamelFolder *folder = NULL; GString *err = NULL; - XEvolution *xev; + struct _camel_header_raw *xev, *header; CamelMimeMessage *message; int i; message = camel_folder_get_message(queue, uid, ex); if (!message) return; - + camel_medium_set_header (CAMEL_MEDIUM (message), "X-Mailer", "Evolution " VERSION SUB_VERSION " " VERSION_COMMENT); - + + err = g_string_new(""); xev = mail_tool_remove_xevolution_headers (message); - - if (xev->account) { + + tmp = camel_header_raw_find(&xev, "X-Evolution-Account", NULL); + if (tmp) { char *name; - name = g_strstrip (g_strdup (xev->account)); - account = mail_config_get_account_by_name (name); - g_free (name); - - if (account) { + name = g_strstrip(g_strdup(tmp)); + if ((account = mail_config_get_account_by_uid(name)) + /* 'old' x-evolution-account stored the name, how silly */ + || (account = mail_config_get_account_by_name(name))) { if (account->transport && account->transport->url) transport_url = g_strdup (account->transport->url); sent_folder_uri = g_strdup (account->sent_folder_uri); } + g_free(name); } if (!account) { /* default back to these headers */ - if (xev->transport) - transport_url = g_strstrip (g_strdup (xev->transport)); + tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL); + if (tmp) + transport_url = g_strstrip(g_strdup(tmp)); - if (xev->fcc) - sent_folder_uri = g_strstrip (g_strdup (xev->fcc)); - } - - xport = camel_session_get_transport (session, transport_url ? transport_url : destination, ex); - g_free (transport_url); - if (!xport) { - mail_tool_restore_xevolution_headers (message, xev); - mail_tool_destroy_xevolution (xev); - g_free (sent_folder_uri); - return; + tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL); + if (tmp) + sent_folder_uri = g_strstrip(g_strdup(tmp)); } - + + /* Check for email sending */ from = (CamelAddress *) camel_internet_address_new (); resent_from = camel_medium_get_header (CAMEL_MEDIUM (message), "Resent-From"); if (resent_from) { @@ -517,24 +513,42 @@ mail_send_message(CamelFolder *queue, const char *uid, const char *destination, iaddr = camel_mime_message_get_recipients (message, type); camel_address_cat (recipients, CAMEL_ADDRESS (iaddr)); } - - camel_transport_send_to (xport, message, from, recipients, ex); - camel_object_unref (recipients); - camel_object_unref (from); - - mail_tool_restore_xevolution_headers (message, xev); - mail_tool_destroy_xevolution (xev); - - camel_object_unref (xport); - if (camel_exception_is_set (ex)) { - g_free (sent_folder_uri); - return; + + if (camel_address_length(recipients) > 0) { + xport = camel_session_get_transport (session, transport_url ? transport_url : destination, ex); + if (camel_exception_is_set(ex)) + goto exit; + + camel_transport_send_to(xport, message, from, recipients, ex); + if (camel_exception_is_set(ex)) + goto exit; } - - /* post-process */ - err = g_string_new(""); + + /* Now check for posting, failures are ignored */ info = camel_message_info_new(NULL); camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0); + camel_mime_message_set_date(message, CAMEL_MESSAGE_DATE_CURRENT, 0); + + for (header = xev;header;header=header->next) { + char *uri; + + if (strcmp(header->name, "X-Evolution-PostTo") != 0) + continue; + + /* TODO: don't lose errors */ + + uri = g_strstrip(g_strdup(header->value)); + folder = mail_tool_uri_to_folder(uri, 0, NULL); + if (folder) { + camel_folder_append_message(folder, message, info, NULL, NULL); + camel_object_unref(folder); + folder = NULL; + } + g_free(uri); + } + + /* post process */ + mail_tool_restore_xevolution_headers (message, xev); if (sent_folder_uri) { folder = mail_tool_uri_to_folder (sent_folder_uri, 0, ex); @@ -544,7 +558,6 @@ mail_send_message(CamelFolder *queue, const char *uid, const char *destination, sent_folder_uri, camel_exception_get_description (ex)); camel_exception_clear (ex); } - g_free (sent_folder_uri); } if (!folder) { @@ -612,12 +625,24 @@ mail_send_message(CamelFolder *queue, const char *uid, const char *destination, camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, err->str); } - exit: - g_string_free (err, TRUE); - camel_folder_sync (folder, FALSE, NULL); - camel_message_info_free (info); - camel_object_unref (folder); +exit: + if (folder) { + camel_folder_sync(folder, FALSE, NULL); + camel_object_unref(folder); + } + if (info) + camel_message_info_free(info); + camel_object_unref(recipients); + camel_object_unref(from); + if (xport) + camel_object_unref(xport); + g_free(sent_folder_uri); + g_free(transport_url); + camel_header_raw_clear(&xev); + g_string_free(err, TRUE); camel_object_unref(message); + + return; } /* ** SEND MAIL QUEUE ***************************************************** */ diff --git a/mail/mail-tools.c b/mail/mail-tools.c index b49fb38a43..858c7f018f 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -206,62 +206,26 @@ mail_tool_generate_forward_subject (CamelMimeMessage *msg) return fwd_subj; } -XEvolution * +struct _camel_header_raw * mail_tool_remove_xevolution_headers (CamelMimeMessage *message) { - XEvolution *xev; - - xev = g_new (XEvolution, 1); - xev->flags = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution")); - xev->source = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Source")); - xev->transport = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Transport")); - xev->account = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Account")); - xev->fcc = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc")); - xev->format = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Format")); - xev->postto = g_strdup (camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-PostTo")); - - /* rip off the X-Evolution* headers */ - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Source"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Account"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Format"); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-PostTo"); - - return xev; -} + struct _camel_header_raw *scan, *list = NULL; -void -mail_tool_restore_xevolution_headers (CamelMimeMessage *message, XEvolution *xev) -{ - if (xev->flags) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution", xev->flags); - if (xev->source) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Source", xev->source); - if (xev->transport) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Transport", xev->transport); - if (xev->account) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Account", xev->account); - if (xev->fcc) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc", xev->fcc); - if (xev->format) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Format", xev->format); - if (xev->postto) - camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-PostTo", xev->postto); + for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next) + if (!strncmp(scan->name, "X-Evolution", 11)) + camel_header_raw_append(&list, scan->name, scan->value, scan->offset); + + for (scan=list;scan;scan=scan->next) + camel_medium_remove_header((CamelMedium *)message, scan->name); + + return list; } void -mail_tool_destroy_xevolution (XEvolution *xev) +mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *xev) { - g_free (xev->flags); - g_free (xev->source); - g_free (xev->transport); - g_free (xev->account); - g_free (xev->format); - g_free (xev->fcc); - g_free (xev->postto); - g_free (xev); + for (;xev;xev=xev->next) + camel_medium_add_header((CamelMedium *)message, xev->name, xev->value); } CamelMimePart * @@ -269,7 +233,7 @@ mail_tool_make_message_attachment (CamelMimeMessage *message) { CamelMimePart *part; const char *subject; - XEvolution *xev; + struct _camel_header_raw *xev; char *desc; subject = camel_mime_message_get_subject (message); @@ -280,11 +244,10 @@ mail_tool_make_message_attachment (CamelMimeMessage *message) /* rip off the X-Evolution headers */ xev = mail_tool_remove_xevolution_headers (message); - mail_tool_destroy_xevolution (xev); + camel_header_raw_clear(&xev); /* remove Bcc headers */ - while (camel_medium_get_header (CAMEL_MEDIUM (message), "Bcc")) - camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc"); + camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc"); part = camel_mime_part_new (); camel_mime_part_set_disposition (part, "inline"); diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 295a30d832..914a02c522 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -29,16 +29,7 @@ struct _CamelFolder; struct _CamelException; struct _CamelMimeMessage; struct _CamelMimePart; - -typedef struct _xevolution { - char *flags; - char *source; - char *transport; - char *account; - char *fcc; - char *format; - char *postto; -} XEvolution; +struct _camel_header_raw; /* Get the "inbox" for a url (uses global session) */ struct _CamelFolder *mail_tool_get_inbox (const char *url, struct _CamelException *ex); @@ -50,9 +41,8 @@ struct _CamelFolder *mail_tool_get_trash (const char *url, int connect, struct _ * and returns the path to the new movemail folder that was created. which shoudl be freed later */ char *mail_tool_do_movemail (const char *source_url, struct _CamelException *ex); -XEvolution *mail_tool_remove_xevolution_headers (struct _CamelMimeMessage *message); -void mail_tool_restore_xevolution_headers (struct _CamelMimeMessage *message, XEvolution *xev); -void mail_tool_destroy_xevolution (XEvolution *xev); +struct _camel_header_raw *mail_tool_remove_xevolution_headers (struct _CamelMimeMessage *message); +void mail_tool_restore_xevolution_headers (struct _CamelMimeMessage *message, struct _camel_header_raw *); /* Generates the subject for a message forwarding @msg */ gchar *mail_tool_generate_forward_subject (struct _CamelMimeMessage *msg); |