diff options
author | Srinivasa Ragavan <sragavan@novell.com> | 2006-11-27 02:30:29 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2006-11-27 02:30:29 +0800 |
commit | 0a7017c1a673ec61479db348d7ff7452b19f664e (patch) | |
tree | c5f84ec17098333fb9498ae98a70b3832c2a5f1e /mail | |
parent | d8b4b86497a9b95433b2fe967d3bec62cd6bc69c (diff) | |
download | gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar.gz gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar.bz2 gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar.lz gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar.xz gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.tar.zst gsoc2013-evolution-0a7017c1a673ec61479db348d7ff7452b19f664e.zip |
Fix for bug #337439 DoS attach with large emails
2006-11-26 Srinivasa Ragavan <sragavan@novell.com>
* Fix for bug #337439 DoS attach with large emails
svn path=/trunk/; revision=33024
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 26 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 167 | ||||
-rw-r--r-- | mail/em-format-html.c | 8 | ||||
-rw-r--r-- | mail/em-format-quote.c | 8 | ||||
-rw-r--r-- | mail/em-format.c | 32 | ||||
-rw-r--r-- | mail/em-format.h | 4 | ||||
-rw-r--r-- | mail/em-mailer-prefs.c | 20 | ||||
-rw-r--r-- | mail/em-utils.c | 2 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in.in | 31 | ||||
-rw-r--r-- | mail/mail-config.c | 36 | ||||
-rw-r--r-- | mail/mail-config.glade | 86 | ||||
-rw-r--r-- | mail/mail-config.h | 1 |
12 files changed, 396 insertions, 25 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index df767f0f9a..b4fb5a7f5a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,29 @@ +2006-11-26 Srinivasa Ragavan <sragavan@novell.com> + + * Fix for bug #337439 DoS attach with large emails + + * em-format-html-display.c: (efhd_class_init), + (efhd_attachment_popup), (efhd_format_attachment), + (efhd_optional_button_show), (efhd_resize), + (efhd_attachment_optional), (efhd_format_optional): + * em-format-html.c: (efh_text_plain), (efh_text_enriched), + (efh_write_text_html), (efh_message_deliverystatus): + * em-format-quote.c: (emfq_format_source), (emfq_text_plain), + (emfq_text_enriched), (emfq_text_html): + * em-format.c: (emf_init), (em_format_format_content), + (em_format_format_text), (emf_message_deliverystatus): + * em-format.h: + * em-mailer-prefs.c: (mlimit_count_changed), + (em_mailer_prefs_construct): + * em-mailer-prefs.h: + * em-utils.c: (em_utils_part_to_html), (em_utils_message_to_html): + * evolution-mail.schemas.in.in: + * mail-config.c: (gconf_mlimit_size_changed), + (gconf_mlimit_changed), (mail_config_init), + (mail_config_get_address_count), (mail_config_get_message_limit): + * mail-config.glade: + * mail-config.h: + 2006-11-09 Francisco Javier F. Serrador <serrador@openshine.com> * default/Makefile.am: Added "es" to SUBDIRS diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 7c6c3cf846..9d7a13d787 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -74,6 +74,7 @@ #include <bonobo/bonobo-widget.h> #include <camel/camel-stream.h> +#include <camel/camel-stream-filter.h> #include <camel/camel-stream-mem.h> #include <camel/camel-mime-filter-tohtml.h> #include <camel/camel-mime-part.h> @@ -182,6 +183,9 @@ struct _attach_puri { int fit_height; GtkImage *image; + /* Optional Text Mem Stream */ + CamelStreamMem *mstream; + /* Signed / Encrypted */ camel_cipher_validity_sign_t sign; camel_cipher_validity_encrypt_t encrypt; @@ -199,6 +203,7 @@ static void efhd_format_clone(EMFormat *, CamelFolder *folder, const char *, Cam static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt); static void efhd_format_source(EMFormat *, CamelStream *, CamelMimePart *); static void efhd_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const char *, const EMFormatHandler *); +static void efhd_format_optional(EMFormat *, CamelStream *, CamelMimePart *, CamelStream *); static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); static void efhd_complete(EMFormat *); gboolean efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd); @@ -353,6 +358,7 @@ efhd_class_init(GObjectClass *klass) ((EMFormatClass *)klass)->format_error = efhd_format_error; ((EMFormatClass *)klass)->format_source = efhd_format_source; ((EMFormatClass *)klass)->format_attachment = efhd_format_attachment; + ((EMFormatClass *)klass)->format_optional = efhd_format_optional; ((EMFormatClass *)klass)->format_secure = efhd_format_secure; ((EMFormatClass *)klass)->complete = efhd_complete; @@ -1509,7 +1515,7 @@ efhd_attachment_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri * } e_popup_add_items((EPopup *)emp, menus, NULL, efhd_menu_items_free, info); - + menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)target, 0); if (event) gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time); @@ -2398,7 +2404,6 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, if (handle) { if (info->shown) handle->handler(emf, stream, part, handle); - /*camel_stream_printf(stream, "<iframe src=\"%s\" marginheight=0 marginwidth=0>%s</iframe>\n", classid, _("Attachment content could not be loaded"));*/ } else if (efhd_use_component(mime_type)) { g_free(classid); /* messy */ @@ -2409,3 +2414,161 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, g_free(classid); } + +static void +efhd_optional_button_show (GtkWidget *widget, GtkWidget *w) +{ + GtkWidget *label = g_object_get_data (widget, "text-label"); + + if (GTK_WIDGET_VISIBLE (w)) { + gtk_widget_hide (w); + gtk_label_set_text_with_mnemonic (label, _("View _Unformatted")); + } else { + gtk_label_set_text_with_mnemonic (label, _("Hide _Unformatted")); + gtk_widget_show (w); + } +} + +static void +efhd_resize (GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh) +{ + gtk_widget_set_size_request (w, ((GtkWidget *)efh->html)->allocation.width-48, 250); +} + +/* optional render attachment button callback */ +static gboolean +efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) +{ + EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; + EAttachment *new; + struct _attach_puri *info; + GtkWidget *hbox, *vbox, *w, *button, *mainbox, *scroll, *label, *img; + char *simple_type, *tmp, *new_file = NULL; + const char *file; + GdkPixbuf *pixbuf, *mini; + AtkObject *a11y; + GtkTextView *view; + GtkTextBuffer *buffer; + GtkTargetEntry drag_types[] = { + { NULL, 0, 0 }, + { "text/uri-list", 0, 1 }, + }; + + /* FIXME: handle default shown case */ + d(printf("adding attachment button/content for optional rendering\n")); + + info = (struct _attach_puri *)em_format_find_puri((EMFormat *)efh, pobject->classid); + g_assert(info != NULL); + g_assert(info->forward == NULL); + + scroll = gtk_scrolled_window_new (NULL, NULL); + mainbox = gtk_hbox_new(FALSE, 0); + + button = gtk_button_new(); + hbox = gtk_hbox_new (FALSE, 0); + img = e_icon_factory_get_image ("stock_show-all", E_ICON_SIZE_BUTTON); + label = gtk_label_new_with_mnemonic(_("View _Unformatted")); + g_object_set_data (button, "text-label", (gpointer)label); + gtk_box_pack_start ((GtkBox *)hbox, img, TRUE, TRUE, 2); + gtk_box_pack_start ((GtkBox *)hbox, label, TRUE, TRUE, 2); + gtk_widget_show_all (hbox); + gtk_container_add (button, hbox); + if (info->handle) + g_signal_connect(button, "clicked", G_CALLBACK(efhd_optional_button_show), scroll); + else { + gtk_widget_set_sensitive(button, FALSE); + GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); + } + + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start((GtkBox *)mainbox, button, FALSE, FALSE, 6); + + button = gtk_button_new(); + hbox = gtk_hbox_new (FALSE, 0); + img = e_icon_factory_get_image ("stock_open", E_ICON_SIZE_BUTTON); + label = gtk_label_new_with_mnemonic(_("O_pen With")); + gtk_box_pack_start ((GtkBox *)hbox, img, TRUE, TRUE, 2); + gtk_box_pack_start ((GtkBox *)hbox, label, TRUE, TRUE, 2); + gtk_box_pack_start ((GtkBox *)hbox, gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE), TRUE, TRUE, 2); + gtk_widget_show_all (hbox); + gtk_container_add (button, hbox); + + a11y = gtk_widget_get_accessible (button); + atk_object_set_name (a11y, _("Attachment")); + + g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); + g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); + g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); + gtk_box_pack_start((GtkBox *)mainbox, button, FALSE, FALSE, 6); + + gtk_widget_show_all(mainbox); + + gtk_box_pack_start((GtkBox *)vbox, mainbox, FALSE, FALSE, 6); + + view = gtk_text_view_new (); + gtk_text_view_set_editable (view, FALSE); + gtk_text_view_set_cursor_visible (view, FALSE); + buffer = gtk_text_view_get_buffer(view); + gtk_text_buffer_set_text (buffer, info->mstream->buffer->data, info->mstream->buffer->len); + camel_object_unref(info->mstream); + info->mstream = NULL; + gtk_scrolled_window_set_policy (scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); + gtk_container_add (scroll, view); + gtk_box_pack_start((GtkBox *)vbox, scroll, TRUE, TRUE, 6); + gtk_widget_show (view); + gtk_widget_set_size_request (scroll, ((GtkWidget *)efh->html)->allocation.width-48, 250); + g_signal_connect (scroll, "size_allocate", G_CALLBACK(efhd_resize), efh); + gtk_widget_show (scroll); + + if (!info->shown) + gtk_widget_hide (scroll); + + gtk_widget_show (vbox); + gtk_container_add((GtkContainer *)eb, vbox); + info->handle = NULL; + + return TRUE; +} + +static void +efhd_format_optional(EMFormat *emf, CamelStream *fstream, CamelMimePart *part, CamelStream *mstream) +{ + char *classid, *text, *html; + struct _attach_puri *info; + CamelStream *stream = ((CamelStreamFilter *) fstream)->source; + + classid = g_strdup_printf("optional%s", emf->part_id->str); + info = (struct _attach_puri *)em_format_add_puri(emf, sizeof(*info), classid, part, efhd_attachment_frame); + em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_attachment_optional); + info->handle = em_format_find_handler(emf, "text/plain");; + info->shown = FALSE; + info->snoop_mime_type = g_strdup("text/plain"); + info->attachment = e_attachment_new_from_mime_part (info->puri.part); + info->mstream = mstream; + if (emf->valid) { + info->sign = emf->valid->sign.status; + info->encrypt = emf->valid->encrypt.status; + } + + camel_stream_write_string(stream, + EM_FORMAT_HTML_VPAD + "<table cellspacing=0 cellpadding=0><tr><td><h3><font size=-1 color=red>"); + + html = camel_text_to_html(_("Evolution cannot render this email as it is too large to handle. You can view it unformatted or with an external text editor."), ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + camel_stream_write_string(stream, html); + camel_stream_write_string(stream, + "</font></h3></td></tr></table>\n"); + camel_stream_write_string(stream, + "<table cellspacing=0 cellpadding=0>" + "<tr>"); + camel_stream_printf(stream, "<td><object classid=\"%s\"></object></td></tr></table>", classid); + + g_free(html); + + camel_stream_write_string(stream, +/* "</font></h2></td></tr></table>\n" */ + EM_FORMAT_HTML_VPAD); + + g_free(classid); +} diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 8c0cb16e97..dc55d03134 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -767,7 +767,7 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo "<div style=\"border: solid #%06x 1px; background-color: #%06x; padding: 10px;\">\n", efh->frame_colour & 0xffffff, efh->content_colour & 0xffffff); camel_stream_write_string(stream, "<tt>\n"); - em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, camel_medium_get_content_object((CamelMedium *)newpart)); + em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, newpart); camel_stream_flush((CamelStream *)filtered_stream); camel_stream_write_string(stream, "</tt>\n"); camel_stream_write_string(stream, "</div>\n"); @@ -807,7 +807,7 @@ efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, E "<div style=\"border: solid #%06x 1px; background-color: #%06x; padding: 10px;\">\n", efh->frame_colour & 0xffffff, efh->content_colour & 0xffffff); - em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, dw); + em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, part); camel_object_unref(filtered_stream); camel_stream_write_string(stream, "</div>"); @@ -829,7 +829,7 @@ efh_write_text_html(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) camel_data_wrapper_write_to_stream(dw, out); camel_object_unref(out); #endif - em_format_format_text(emf, stream, camel_medium_get_content_object((CamelMedium *)puri->part)); + em_format_format_text(emf, stream, puri->part); } static void @@ -985,7 +985,7 @@ efh_message_deliverystatus(EMFormatHTML *efh, CamelStream *stream, CamelMimePart camel_object_unref(html_filter); camel_stream_write_string(stream, "<tt>\n"); - em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, camel_medium_get_content_object((CamelMedium *)part)); + em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, part); camel_stream_flush((CamelStream *)filtered_stream); camel_stream_write_string(stream, "</tt>\n"); diff --git a/mail/em-format-quote.c b/mail/em-format-quote.c index 87f9fb96fc..b3de8a33ba 100644 --- a/mail/em-format-quote.c +++ b/mail/em-format-quote.c @@ -411,7 +411,7 @@ emfq_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part) camel_stream_filter_add(filtered_stream, html_filter); camel_object_unref(html_filter); - em_format_format_text(emf, (CamelStream *)filtered_stream, dw); + em_format_format_text(emf, (CamelStream *)filtered_stream, part); camel_object_unref(filtered_stream); } @@ -473,7 +473,7 @@ emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, E camel_stream_filter_add(filtered_stream, html_filter); camel_object_unref(html_filter); - em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, camel_medium_get_content_object((CamelMedium *)part)); + em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, part); camel_stream_flush((CamelStream *)filtered_stream); camel_object_unref(filtered_stream); } @@ -501,7 +501,7 @@ emfq_text_enriched(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part camel_object_unref(enriched); camel_stream_write_string(stream, "<br><hr><br>"); - em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, dw); + em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, part); camel_object_unref(filtered_stream); } @@ -509,7 +509,7 @@ static void emfq_text_html(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) { camel_stream_write_string(stream, "\n<!-- text/html -->\n"); - em_format_format_text(emf, stream, camel_medium_get_content_object((CamelMedium *)part)); + em_format_format_text(emf, stream, part); } static void diff --git a/mail/em-format.c b/mail/em-format.c index b89d1e0423..e1f1893a0a 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -47,6 +47,7 @@ #include <camel/camel-string-utils.h> #include <camel/camel-stream-filter.h> #include <camel/camel-stream-null.h> +#include <camel/camel-stream-mem.h> #include <camel/camel-mime-filter-charset.h> #include <camel/camel-mime-filter-windows.h> #include <camel/camel-mime-filter-pgp.h> @@ -80,7 +81,6 @@ static const EMFormatHandler *emf_find_handler(EMFormat *emf, const char *mime_t static void emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *emfsource); static void emf_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); static gboolean emf_busy(EMFormat *emf); - enum { EMF_COMPLETE, EMF_LAST_SIGNAL, @@ -117,8 +117,10 @@ static void emf_init(GObject *o) { EMFormat *emf = (EMFormat *)o; - + char * asize; + emf->inline_table = g_hash_table_new(g_str_hash, g_str_equal); + emf->composer = FALSE; e_dlist_init(&emf->header_list); em_format_default_headers(emf); emf->part_id = g_string_new(""); @@ -469,6 +471,7 @@ em_format_find_visible_puri(EMFormat *emf, const char *uri) * Return value: **/ EMFormatPURI * + em_format_find_puri(EMFormat *emf, const char *uri) { return g_hash_table_lookup(emf->pending_uri_table, uri); @@ -1016,7 +1019,7 @@ em_format_format_content(EMFormat *emf, CamelStream *stream, CamelMimePart *part CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)part); if (camel_content_type_is (dw->mime_type, "text", "*")) - em_format_format_text(emf, stream, dw); + em_format_format_text(emf, stream, part); else camel_data_wrapper_decode_to_stream(dw, stream); } @@ -1036,6 +1039,9 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) CamelMimeFilterCharset *filter; const char *charset = NULL; CamelMimeFilterWindows *windows = NULL; + CamelStream *mem_stream = NULL; + size_t size; + size_t max; if (emf->charset) { charset = emf->charset; @@ -1064,17 +1070,27 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) } else if (charset == NULL) { charset = emf->default_charset; } - - filter_stream = camel_stream_filter_new_with_stream(stream); + + mem_stream = (CamelStreamMem *)camel_stream_mem_new (); + filter_stream = camel_stream_filter_new_with_stream(mem_stream); if ((filter = camel_mime_filter_charset_new_convert(charset, "UTF-8"))) { camel_stream_filter_add(filter_stream, (CamelMimeFilter *) filter); camel_object_unref(filter); } - - camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filter_stream); + + max = mail_config_get_message_limit(); + size = camel_data_wrapper_decode_to_stream(emf->mode == EM_FORMAT_SOURCE ? (CamelDataWrapper *)dw: camel_medium_get_content_object((CamelMedium *)dw), (CamelStream *)filter_stream); camel_stream_flush((CamelStream *)filter_stream); camel_object_unref(filter_stream); + camel_stream_reset (mem_stream); + + if (max == -1 || size < (max * 1024) || emf->composer) { + camel_stream_write_to_stream(mem_stream, (CamelStream *)stream); + camel_stream_flush((CamelStream *)stream); + } else { + ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_optional(emf, stream, (CamelMimePart *)dw, mem_stream); + } if (windows) camel_object_unref(windows); @@ -1495,7 +1511,7 @@ emf_message_rfc822(EMFormat *emf, CamelStream *stream, CamelMimePart *part, cons static void emf_message_deliverystatus(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) { - em_format_format_text(emf, stream, camel_medium_get_content_object((CamelMedium *)part)); + em_format_format_text(emf, stream, part); } static void diff --git a/mail/em-format.h b/mail/em-format.h index 8800019a9f..68b067559e 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -226,6 +226,7 @@ struct _EMFormat { em_format_mode_t mode; /* source/headers/etc */ char *charset; /* charset override */ char *default_charset; /* charset fallback */ + gboolean composer; /* Formatting from composer ?*/ }; struct _EMFormatClass { @@ -257,6 +258,9 @@ struct _EMFormatClass { /* returns true if the formatter is still busy with pending stuff */ gboolean (*busy)(EMFormat *); + /* Shows optional way to open messages */ + void (*format_optional)(EMFormat *, struct _CamelStream *, struct _CamelMimePart *, struct _CamelStream* ); + /* signals */ /* complete, alternative to polling busy, for asynchronous work */ void (*complete)(EMFormat *); diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index d665ba4913..4b944fccb6 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -459,6 +459,16 @@ address_compress_count_changed (GtkSpinButton *spin, EMMailerPrefs *prefs) } static void +mlimit_count_changed (GtkSpinButton *spin, EMMailerPrefs *prefs) +{ + int count; + + count = (int) gtk_spin_button_get_value (prefs->mlimit_count); + + gconf_client_set_int (prefs->gconf, "/apps/evolution/mail/display/message_text_part_limit", count, NULL); +} + +static void spin_button_init (EMMailerPrefs *prefs, GtkSpinButton *spin, const char *key, float div, GCallback value_changed) { GError *err = NULL; @@ -772,6 +782,16 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) "/apps/evolution/mail/display/mark_seen_timeout", 1000.0, G_CALLBACK (mark_seen_timeout_changed)); + prefs->mlimit_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "mlimit_checkbutton")); + toggle_button_init (prefs, prefs->mlimit_toggle, FALSE, + "/apps/evolution/mail/display/force_message_limit", + G_CALLBACK (toggle_button_toggled)); + + prefs->mlimit_count = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "mlimit_spin")); + spin_button_init (prefs, prefs->mlimit_count, + "/apps/evolution/mail/display/message_text_part_limit", + 1, G_CALLBACK (mlimit_count_changed)); + prefs->address_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "address_checkbox")); toggle_button_init (prefs, prefs->address_toggle, FALSE, "/apps/evolution/mail/display/address_compress", diff --git a/mail/em-utils.c b/mail/em-utils.c index b8669b2c7f..d8d0109fa7 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1605,6 +1605,7 @@ em_utils_part_to_html(CamelMimePart *part, ssize_t *len, EMFormat *source) camel_stream_mem_set_byte_array (mem, buf); emfq = em_format_quote_new(NULL, (CamelStream *)mem, 0); + ((EMFormat *) emfq)->composer = TRUE; em_format_set_session((EMFormat *)emfq, session); if (source) { /* copy over things we can, other things are internal, perhaps need different api than 'clone' */ @@ -1653,6 +1654,7 @@ em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 camel_stream_mem_set_byte_array (mem, buf); emfq = em_format_quote_new(credits, (CamelStream *)mem, flags); + ((EMFormat *) emfq)->composer = TRUE; em_format_set_session((EMFormat *)emfq, session); if (!source) { diff --git a/mail/evolution-mail.schemas.in.in b/mail/evolution-mail.schemas.in.in index d869554de9..692a190ee4 100644 --- a/mail/evolution-mail.schemas.in.in +++ b/mail/evolution-mail.schemas.in.in @@ -485,7 +485,36 @@ </long> </locale> </schema> - + + <schema> + <key>/schemas/apps/evolution/mail/display/force_message_limit</key> + <applyto>/apps/evolution/mail/display/force_message_limit</applyto> + <owner>evolution-mail</owner> + <type>bool</type> + <default>true</default> + <locale name="C"> + <short>Allows evolution to display text part of limited size</short> + <long> + Enable to render message text part of limited size. + </long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/evolution/mail/display/message_text_part_limit</key> + <applyto>/apps/evolution/mail/display/message_text_part_limit</applyto> + <owner>evolution-mail</owner> + <type>int</type> + <default>4096</default> + <locale name="C"> + <short>Text message part limit</short> + <long> + This decides the max size of the text part that can be formatted under + evolution. The default is 4MB / 4096 KB and is specified interms of KB. + </long> + </locale> + </schema> + <schema> <key>/schemas/apps/evolution/mail/display/address_count</key> <applyto>/apps/evolution/mail/display/address_count</applyto> diff --git a/mail/mail-config.c b/mail/mail-config.c index fb06f9e17f..d8ca32e0bd 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -110,6 +110,11 @@ typedef struct { guint address_compress_notify_id; gboolean address_compress; gint address_count; + guint mlimit_size_notify_id; + guint mlimit_notify_id; + gboolean mlimit; + gint mlimit_size; + GPtrArray *mime_types; guint mime_types_notify_id; @@ -339,6 +344,20 @@ gconf_address_compress_changed (GConfClient *client, guint cnxn_id, } static void +gconf_mlimit_size_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->mlimit_size = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", NULL); +} + +static void +gconf_mlimit_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + config->mlimit = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/force_message_limit", NULL); +} + +static void gconf_mime_types_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) { @@ -373,7 +392,11 @@ mail_config_init (void) config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_compress", gconf_address_compress_changed, NULL, NULL, NULL); config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_count", - gconf_address_count_changed, NULL, NULL, NULL); + gconf_address_count_changed, NULL, NULL, NULL); + config->mlimit_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/force_message_limit", + gconf_mlimit_changed, NULL, NULL, NULL); + config->mlimit_size_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", + gconf_mlimit_size_changed, NULL, NULL, NULL); config->spell_notify_id = gconf_client_notify_add (config->gconf, "/GNOME/Spell", gconf_style_changed, NULL, NULL, NULL); config->mark_citations__notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/mark_citations", @@ -397,6 +420,8 @@ mail_config_init (void) config_cache_mime_types (); config->address_compress = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/address_compress", NULL); config->address_count = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/address_count", NULL); + config->mlimit = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/force_message_limit", NULL); + config->mlimit_size = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", NULL); config->accounts = e_account_list_new (config->gconf); config->signatures = e_signature_list_new (config->gconf); } @@ -538,6 +563,15 @@ mail_config_get_address_count (void) return config->address_count; } +int +mail_config_get_message_limit (void) +{ + if (!config->mlimit) + return -1; + + return config->mlimit_size; +} + const char * mail_config_get_label_color_by_name (const char *name) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 8fed40ad48..637c6b2a30 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -3342,7 +3342,7 @@ For example: "Work" or "Personal"</property> <child> <widget class="GtkLabel" id="label583"> <property name="visible">True</property> - <property name="label" translatable="yes">S_end message receipts:</property> + <property name="label" translatable="yes">S_end message receipts:</property> <property name="use_underline">True</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -3352,8 +3352,8 @@ For example: "Work" or "Personal"</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="mnemonic_widget">receipt_policy_dropdown</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="width_chars">-1</property> <property name="single_line_mode">False</property> <property name="angle">0</property> @@ -4962,6 +4962,82 @@ For example: "Work" or "Personal"</property> </child> <child> + <widget class="GtkHBox" id="hbox234"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">4</property> + + <child> + <widget class="GtkCheckButton" id="mlimit_checkbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Do not format text contents in mails if the text si_ze exceeds</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="mlimit_spin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">False</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">0 0 30000 1 10 10</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label585"> + <property name="visible">True</property> + <property name="label" translatable="yes">KB</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkHBox" id="hbox233"> <property name="visible">True</property> <property name="homogeneous">False</property> @@ -6572,7 +6648,7 @@ For example: "Work" or "Personal"</property> <child> <widget class="GtkLabel" id="label571"> <property name="visible">True</property> - <property name="label" translatable="no"> </property> + <property name="label"> </property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -6675,7 +6751,7 @@ For example: "Work" or "Personal"</property> <child> <widget class="GtkLabel" id="label572"> <property name="visible">True</property> - <property name="label" translatable="no"> </property> + <property name="label"> </property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -6731,7 +6807,7 @@ For example: "Work" or "Personal"</property> <child> <widget class="GtkLabel" id="label575"> <property name="visible">True</property> - <property name="label" translatable="no"> </property> + <property name="label"> </property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> diff --git a/mail/mail-config.h b/mail/mail-config.h index 9d6e82879b..7a436b2ca1 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -134,6 +134,7 @@ void mail_config_add_account (struct _EAccount *account); void mail_config_remove_account (struct _EAccount *account); void mail_config_set_default_account (struct _EAccount *account); int mail_config_get_address_count (void); +int mail_config_get_message_limit (void); void mail_config_remove_account_proxies (struct _EAccount *account); void mail_config_prune_proxies (void); |