From b0e603fa0fda57dd9b268b7286259522010a2f48 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 22 Aug 2002 22:04:36 +0000 Subject: Fixes bug #29016 2002-08-22 Jeffrey Stedfast Fixes bug #29016 * e-msg-composer.c (e_msg_composer_new_with_message): If the X-Evolution-PostTo header exists, then treat this message composer as a PostTo composer rather than a mail composer. * e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message_internal): Set the X-Evolution-PostTo header if that is the mdoe we are in. svn path=/trunk/; revision=17843 --- composer/ChangeLog | 11 +++ composer/e-msg-composer-hdrs.c | 8 +- composer/e-msg-composer.c | 188 ++++++++++++++++++++++------------------- 3 files changed, 118 insertions(+), 89 deletions(-) diff --git a/composer/ChangeLog b/composer/ChangeLog index 1dbe0b511b..79e4f81f18 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,14 @@ +2002-08-22 Jeffrey Stedfast + + Fixes bug #29016 + + * e-msg-composer.c (e_msg_composer_new_with_message): If the + X-Evolution-PostTo header exists, then treat this message composer + as a PostTo composer rather than a mail composer. + + * e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message_internal): + Set the X-Evolution-PostTo header if that is the mdoe we are in. + 2002-08-16 Dan Winship * e-msg-composer-hdrs.c (create_headers): Use an diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index f7d4493e76..c26e0e0623 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -785,9 +785,9 @@ e_msg_composer_hdrs_to_message_internal (EMsgComposerHdrs *hdrs, CamelMimeMessage *msg, gboolean redirect) { + EDestination **to_destv, **cc_destv, **bcc_destv; CamelInternetAddress *addr; char *subject, *header; - EDestination **to_destv, **cc_destv, **bcc_destv; g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg)); @@ -825,6 +825,12 @@ e_msg_composer_hdrs_to_message_internal (EMsgComposerHdrs *hdrs, e_destination_freev (cc_destv); e_destination_freev (bcc_destv); } + + if (hdrs->visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO) { + header = e_msg_composer_hdrs_get_post_to (hdrs); + camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-PostTo", header); + g_free (header); + } } diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 5138227383..e04fddafa2 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -390,7 +390,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data) if (composer->send_html) { CORBA_Environment ev; clear_current_images (composer); - + if (save_html_object_data) { CORBA_exception_init (&ev); GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "save-data-on", &ev); @@ -400,7 +400,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data) GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "save-data-off", &ev); CORBA_exception_free (&ev); } - + if (!data) { /* The component has probably died */ camel_object_unref (CAMEL_OBJECT (new)); @@ -492,7 +492,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data) current = CAMEL_DATA_WRAPPER (multipart); } - + camel_exception_init (&ex); if (composer->pgp_sign || composer->pgp_encrypt) { @@ -3382,10 +3382,10 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) const CamelInternetAddress *to, *cc, *bcc; GList *To = NULL, *Cc = NULL, *Bcc = NULL; const MailConfigAccount *account = NULL; + const char *format, *subject, *postto; EDestination **Tov, **Ccv, **Bccv; GHashTable *auto_cc, *auto_bcc; CamelContentType *content_type; - const char *format, *subject; struct _header_raw *headers; CamelDataWrapper *content; char *account_name; @@ -3395,10 +3395,15 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) g_return_val_if_fail (gtk_main_level () > 0, NULL); - new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_MAIL); + postto = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-PostTo"); + + new = create_composer (postto ? E_MSG_COMPOSER_VISIBLE_MASK_POST : E_MSG_COMPOSER_VISIBLE_MASK_MAIL); if (!new) return NULL; + if (postto) + e_msg_composer_hdrs_set_post_to (E_MSG_COMPOSER_HDRS (new->hdrs), postto); + /* Restore the Account preference */ account_name = (char *) camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Account"); if (account_name) { @@ -3408,109 +3413,116 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) account = mail_config_get_account_by_name (account_name); } - auto_cc = g_hash_table_new (g_strcase_hash, g_strcase_equal); - auto_bcc = g_hash_table_new (g_strcase_hash, g_strcase_equal); - - if (account) { - CamelInternetAddress *iaddr; + if (postto == NULL) { + auto_cc = g_hash_table_new (g_strcase_hash, g_strcase_equal); + auto_bcc = g_hash_table_new (g_strcase_hash, g_strcase_equal); - /* hash our auto-recipients for this account */ - if (account->always_cc) { - iaddr = camel_internet_address_new (); - if (camel_address_decode (CAMEL_ADDRESS (iaddr), account->cc_addrs) != -1) { - for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { - const char *name, *addr; - - if (!camel_internet_address_get (iaddr, i, &name, &addr)) - continue; - - g_hash_table_insert (auto_cc, g_strdup (addr), GINT_TO_POINTER (TRUE)); + if (account) { + CamelInternetAddress *iaddr; + + /* hash our auto-recipients for this account */ + if (account->always_cc) { + iaddr = camel_internet_address_new (); + if (camel_address_decode (CAMEL_ADDRESS (iaddr), account->cc_addrs) != -1) { + for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { + const char *name, *addr; + + if (!camel_internet_address_get (iaddr, i, &name, &addr)) + continue; + + g_hash_table_insert (auto_cc, g_strdup (addr), GINT_TO_POINTER (TRUE)); + } } + camel_object_unref (iaddr); } - camel_object_unref (iaddr); - } - - if (account->always_bcc) { - iaddr = camel_internet_address_new (); - if (camel_address_decode (CAMEL_ADDRESS (iaddr), account->bcc_addrs) != -1) { - for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { - const char *name, *addr; - - if (!camel_internet_address_get (iaddr, i, &name, &addr)) - continue; - - g_hash_table_insert (auto_bcc, g_strdup (addr), GINT_TO_POINTER (TRUE)); + + if (account->always_bcc) { + iaddr = camel_internet_address_new (); + if (camel_address_decode (CAMEL_ADDRESS (iaddr), account->bcc_addrs) != -1) { + for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { + const char *name, *addr; + + if (!camel_internet_address_get (iaddr, i, &name, &addr)) + continue; + + g_hash_table_insert (auto_bcc, g_strdup (addr), GINT_TO_POINTER (TRUE)); + } } + camel_object_unref (iaddr); } - camel_object_unref (iaddr); } - } - - subject = camel_mime_message_get_subject (message); - - to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); - cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); - bcc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC); - - len = CAMEL_ADDRESS (to)->addresses->len; - for (i = 0; i < len; i++) { - const char *name, *addr; - if (camel_internet_address_get (to, i, &name, &addr)) { - EDestination *dest = e_destination_new (); - e_destination_set_name (dest, name); - e_destination_set_email (dest, addr); - To = g_list_append (To, dest); - } - } - Tov = e_destination_list_to_vector (To); - g_list_free (To); - - len = CAMEL_ADDRESS (cc)->addresses->len; - for (i = 0; i < len; i++) { - const char *name, *addr; + to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); + cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); + bcc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC); - if (camel_internet_address_get (cc, i, &name, &addr)) { - EDestination *dest = e_destination_new (); - e_destination_set_name (dest, name); - e_destination_set_email (dest, addr); - - if (g_hash_table_lookup (auto_cc, addr)) - e_destination_set_auto_recipient (dest, TRUE); + len = CAMEL_ADDRESS (to)->addresses->len; + for (i = 0; i < len; i++) { + const char *name, *addr; - Cc = g_list_append (Cc, dest); + if (camel_internet_address_get (to, i, &name, &addr)) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, addr); + To = g_list_append (To, dest); + } } - } - - Ccv = e_destination_list_to_vector (Cc); - g_hash_table_foreach (auto_cc, auto_recip_free, NULL); - g_hash_table_destroy (auto_cc); - g_list_free (Cc); - - len = CAMEL_ADDRESS (bcc)->addresses->len; - for (i = 0; i < len; i++) { - const char *name, *addr; + Tov = e_destination_list_to_vector (To); + g_list_free (To); - if (camel_internet_address_get (bcc, i, &name, &addr)) { - EDestination *dest = e_destination_new (); - e_destination_set_name (dest, name); - e_destination_set_email (dest, addr); + len = CAMEL_ADDRESS (cc)->addresses->len; + for (i = 0; i < len; i++) { + const char *name, *addr; - if (g_hash_table_lookup (auto_bcc, addr)) - e_destination_set_auto_recipient (dest, TRUE); + if (camel_internet_address_get (cc, i, &name, &addr)) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, addr); + + if (g_hash_table_lookup (auto_cc, addr)) + e_destination_set_auto_recipient (dest, TRUE); + + Cc = g_list_append (Cc, dest); + } + } + + Ccv = e_destination_list_to_vector (Cc); + g_hash_table_foreach (auto_cc, auto_recip_free, NULL); + g_hash_table_destroy (auto_cc); + g_list_free (Cc); + + len = CAMEL_ADDRESS (bcc)->addresses->len; + for (i = 0; i < len; i++) { + const char *name, *addr; - Bcc = g_list_append (Bcc, dest); + if (camel_internet_address_get (bcc, i, &name, &addr)) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, addr); + + if (g_hash_table_lookup (auto_bcc, addr)) + e_destination_set_auto_recipient (dest, TRUE); + + Bcc = g_list_append (Bcc, dest); + } } + + Bccv = e_destination_list_to_vector (Bcc); + g_hash_table_foreach (auto_bcc, auto_recip_free, NULL); + g_hash_table_destroy (auto_bcc); + g_list_free (Bcc); + } else { + Tov = NULL; + Ccv = NULL; + Bccv = NULL; } - Bccv = e_destination_list_to_vector (Bcc); - g_hash_table_foreach (auto_bcc, auto_recip_free, NULL); - g_hash_table_destroy (auto_bcc); - g_list_free (Bcc); + subject = camel_mime_message_get_subject (message); e_msg_composer_set_headers (new, account_name, Tov, Ccv, Bccv, subject); g_free (account_name); + e_destination_freev (Tov); e_destination_freev (Ccv); e_destination_freev (Bccv); -- cgit v1.2.3