diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 24 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 144 | ||||
-rw-r--r-- | mail/mail-config.c | 21 | ||||
-rw-r--r-- | mail/mail-config.h | 3 |
4 files changed, 161 insertions, 31 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 42fae44eac..644ecd1174 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,27 @@ +2001-09-08 Jon Trowbridge <trow@gnu.org> + + * mail-callbacks.c (ask_confirm_for_unwanted_html_mail): Added. + Shows a (hopefully) informative dialog warning you that some + recipients might not want HTML mail (who are listed), and gives + the option to cancel sending. (FIXME: The wording of this dialog + could use some work.) + (composer_get_message): Check if we are sending HTML to someone + who might not want it, and raise the dialog if we are. Use our + new destination-vector based api when talking to the composer. + Touch our destinations here, boosting their use scores. This is + the right place for this to happen --- closer to the end of the + sending process, where incorrect/artificial use score inflation is + less likely to occur. + + * mail-config.c (config_read): Added + /Mail/Format/confirm_unwanted_html key. This flag determines + whether or not we want to see the warning dialog when we send HTML + mail to contacts who don't want it. Default is TRUE. + (mail_config_write_on_exit): Write out the confirm_unwanted_html + key. + (mail_config_get_confirm_unwanted_html): Added. + (mail_config_set_confirm_unwanted_html): Added. + 2001-09-08 Dan Winship <danw@ximian.com> * mail-display.c (mail_display_destroy): Unref the invisible, diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index dc01bb0f78..18c2126355 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -200,6 +200,56 @@ msgbox_destroyed (GtkWidget *widget, gpointer data) } static gboolean +ask_confirm_for_unwanted_html_mail (EMsgComposer *composer, EDestination **recipients) +{ + gboolean show_again = TRUE; + GString *str; + GtkWidget *mbox; + gint i, button; + + if (! mail_config_get_confirm_unwanted_html ()) { + g_message ("doesn't want to see confirm html messages!"); + return TRUE; + } + + /* FIXME: this wording sucks */ + str = g_string_new (_("You are sending an HTML-formatted mail, but the following recipients' " + "contact records do not indicate that they want to receive such messages:\n")); + for (i = 0; recipients[i] != NULL; ++i) { + if (! e_destination_get_html_mail_pref (recipients[i])) { + gchar *name = g_strdup_printf (" %s\n", e_destination_get_textrep (recipients[i])); + g_string_append (str, name); + g_free (name); + } + } + + g_string_append (str, _("Send anyway?")); + + mbox = e_message_box_new (str->str, + E_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + + g_string_free (str, 0); + + gtk_signal_connect (GTK_OBJECT (mbox), "destroy", + msgbox_destroyed, &show_again); + + button = gnome_dialog_run_and_close (GNOME_DIALOG (mbox)); + + if (! show_again) { + mail_config_set_confirm_unwanted_html (show_again); + g_message ("don't show HTML warning again"); + } + + if (button == 0) + return TRUE; + else + return FALSE; +} + +static gboolean ask_confirm_for_empty_subject (EMsgComposer *composer) { /* FIXME: EMessageBox should really handle this stuff @@ -341,8 +391,9 @@ composer_get_message (EMsgComposer *composer) CamelMimeMessage *message; const char *subject; int num_addrs, i; + EDestination **recipients; - message = e_msg_composer_get_message (composer, TRUE /* yes, we are sending this baby! */ ); + message = e_msg_composer_get_message (composer); if (message == NULL) return NULL; @@ -389,6 +440,29 @@ composer_get_message (EMsgComposer *composer) return NULL; } } + + /* Only show this warning if our default is to send html. If it isn't, we've + manually switched into html mode in the composer and (presumably) had a good + reason for doing this. */ + if (e_msg_composer_get_send_html (composer) + && mail_config_get_send_html () + && mail_config_get_confirm_unwanted_html ()) { + gboolean html_problem = FALSE; + recipients = e_msg_composer_get_recipients (composer); + for (i = 0; recipients[i] != NULL && !html_problem; ++i) { + if (! e_destination_get_html_mail_pref (recipients[i])) + html_problem = TRUE; + } + + if (html_problem) { + html_problem = ! ask_confirm_for_unwanted_html_mail (composer, recipients); + e_destination_freev (recipients); + if (html_problem) { + camel_object_unref (CAMEL_OBJECT (message)); + return NULL; + } + } + } /* Check for no subject */ subject = camel_mime_message_get_subject (message); @@ -406,6 +480,11 @@ composer_get_message (EMsgComposer *composer) 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); } + + /* Get the message recipients and 'touch' them, boosting their use scores */ + recipients = e_msg_composer_get_recipients (composer); + e_destination_touchv (recipients); + e_destination_freev (recipients); return message; } @@ -545,17 +624,11 @@ list_add_addresses (GList *list, const CamelInternetAddress *cia, const GSList * const char *name, *addr; const GSList *l; gboolean notme; - char *full; int i; for (i = 0; camel_internet_address_get (cia, i, &name, &addr); i++) { /* Make sure we don't want to ignore this address */ if (!ignore_addr || g_strcasecmp (ignore_addr, addr)) { - /* now, we format this, as if for display, but does the composer - then use it as a real address? If so, very broken. */ - /* we should probably pass around CamelAddresse's if thats what - we mean */ - full = camel_internet_address_format_address (name, addr); /* Here I'll check to see if the cc:'d address is the address of the sender, and if so, don't add it to the cc: list; this @@ -576,10 +649,12 @@ list_add_addresses (GList *list, const CamelInternetAddress *cia, const GSList * } if (notme && !g_hash_table_lookup (rcpt_hash, addr)) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, addr); + list = g_list_append (list, dest); g_hash_table_insert (rcpt_hash, (char *) addr, GINT_TO_POINTER (1)); - list = g_list_append (list, full); - } else - g_free (full); + } } } @@ -632,16 +707,6 @@ guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, const return NULL; } -static void -free_recipients (GList *list) -{ - GList *l; - - for (l = list; l; l = l->next) - g_free (l->data); - g_list_free (list); -} - static EMsgComposer * mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char *uid, int mode) { @@ -652,6 +717,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char const MailConfigAccount *me = NULL; const GSList *accounts = NULL; GList *to = NULL, *cc = NULL; + EDestination **tov, **ccv; EMsgComposer *composer; time_t date; @@ -700,7 +766,7 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); max = camel_address_length (CAMEL_ADDRESS (to_addrs)); for (i = 0; i < max; i++) { - camel_internet_address_get (to_addrs, i, NULL, &address); + camel_internet_address_get (to_addrs, i, &name, &address); if (!g_strncasecmp (address, mlist, len)) break; } @@ -709,14 +775,18 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char cc_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); max = camel_address_length (CAMEL_ADDRESS (cc_addrs)); for (i = 0; i < max; i++) { - camel_internet_address_get (cc_addrs, i, NULL, &address); + camel_internet_address_get (cc_addrs, i, &name, &address); if (!g_strncasecmp (address, mlist, len)) break; } } - - /* We only want to reply to the list address - if it even exists */ - to = address && i != max ? g_list_append (to, g_strdup (address)) : to; + + if (address && i != max) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, address); + to = g_list_append (to, dest); + } } me = guess_me (to_addrs, cc_addrs, accounts); @@ -730,9 +800,13 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char reply_to = camel_mime_message_get_from (message); if (reply_to) { /* Get the Reply-To address so we can ignore references to it in the Cc: list */ - if (camel_internet_address_get (reply_to, 0, NULL, &reply_addr)) { + if (camel_internet_address_get (reply_to, 0, &name, &reply_addr)) { + EDestination *dest = e_destination_new (); + e_destination_set_name (dest, name); + e_destination_set_email (dest, reply_addr); + g_message (">>>>>>>>>> [%s] [%s]", name, reply_addr); + to = g_list_append (to, dest); g_hash_table_insert (rcpt_hash, (char *) reply_addr, GINT_TO_POINTER (1)); - to = g_list_append (to, camel_address_format (CAMEL_ADDRESS (reply_to))); } } @@ -763,10 +837,18 @@ mail_generate_reply (CamelFolder *folder, CamelMimeMessage *message, const char else subject = g_strdup_printf ("Re: %s", subject); } - - e_msg_composer_set_headers (composer, me ? me->name : NULL, to, cc, NULL, subject); - free_recipients (to); - free_recipients (cc); + + tov = e_destination_list_to_vector (to); + ccv = e_destination_list_to_vector (cc); + + g_list_free (to); + g_list_free (cc); + + e_msg_composer_set_headers (composer, me ? me->name : NULL, tov, ccv, NULL, subject); + + e_destination_freev (tov); + e_destination_freev (ccv); + g_free (subject); /* Add In-Reply-To and References. */ diff --git a/mail/mail-config.c b/mail/mail-config.c index 68b310daa0..fc8290948b 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -62,6 +62,7 @@ typedef struct { gboolean hide_deleted; gint paned_size; gboolean send_html; + gboolean confirm_unwanted_html; gboolean citation_highlight; guint32 citation_color; gboolean prompt_empty_subject; @@ -489,6 +490,10 @@ config_read (void) /* Format */ config->send_html = bonobo_config_get_boolean_with_default (config->db, "/Mail/Format/send_html", FALSE, NULL); + + /* Confirm Sending Unwanted HTML */ + config->confirm_unwanted_html = bonobo_config_get_boolean_with_default (config->db, + "/Mail/Format/confirm_unwanted_html", TRUE, NULL); /* Citation */ config->citation_highlight = bonobo_config_get_boolean_with_default ( @@ -798,6 +803,10 @@ mail_config_write_on_exit (void) /* Format */ bonobo_config_set_boolean (config->db, "/Mail/Format/send_html", config->send_html, NULL); + + /* Confirm Sending Unwanted HTML */ + bonobo_config_set_boolean (config->db, "/Mail/Format/confirm_unwanted_html", + config->confirm_unwanted_html, NULL); /* Citation */ bonobo_config_set_boolean (config->db, @@ -1096,6 +1105,18 @@ mail_config_set_send_html (gboolean send_html) } gboolean +mail_config_get_confirm_unwanted_html (void) +{ + return config->confirm_unwanted_html; +} + +void +mail_config_set_confirm_unwanted_html (gboolean confirm) +{ + config->confirm_unwanted_html = confirm; +} + +gboolean mail_config_get_citation_highlight (void) { return config->citation_highlight; diff --git a/mail/mail-config.h b/mail/mail-config.h index 76aa3b60cd..d223ba1eda 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -130,6 +130,9 @@ void mail_config_set_paned_size (gint size); gboolean mail_config_get_send_html (void); void mail_config_set_send_html (gboolean send_html); +gboolean mail_config_get_confirm_unwanted_html (void); +void mail_config_set_confirm_unwanted_html (gboolean html_warning); + gboolean mail_config_get_citation_highlight (void); void mail_config_set_citation_highlight (gboolean); |