diff options
author | Dan Winship <danw@src.gnome.org> | 2001-10-23 02:47:59 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-10-23 02:47:59 +0800 |
commit | 9c9f8ebfdf5195ddd34fd4a726bf16941b063957 (patch) | |
tree | 9c1440b9c32ac8b402bd4a03d988a1b5648ded7c /mail/mail-display.c | |
parent | 44faa44bffd7fae58fa58e9eebda4b3244d025f8 (diff) | |
download | gsoc2013-evolution-9c9f8ebfdf5195ddd34fd4a726bf16941b063957.tar.gz gsoc2013-evolution-9c9f8ebfdf5195ddd34fd4a726bf16941b063957.tar.zst gsoc2013-evolution-9c9f8ebfdf5195ddd34fd4a726bf16941b063957.zip |
PGP verification UI changes to make it not HTML spoofable.
* mail-format.c (handle_application_pgp): Remove this unused
hack.
(mail_format_mime_message): Initialize a fourth hash table, used
to keep track of fake MIME parts.
(mail_part_set_default_displayed_inline): New routine to set the
default disposition of a part (doesn't change it if the user has
already overridden it).
(format_mime_part): Wrap a blockquote around the error text (moved
here from mail_error_write since it doesn't apply in other cases).
(write_hr): Write a <hr> with appropriate padding between MIME
parts.
(write_one_text_plain_chunk): Write some plain text with
appropriate margins.
(handle_text_plain): Use write_one_text_plain_chunk. Update for
inline specials handler API change.
(fake_mime_part_from_data): Use the "fake_parts" hash to avoid
recreating the same fake parts again if the message is
redisplayed. Lets you toggle the shown/hiddenness of uudecode
parts, and do the new pgp verification thing for inline pgp
signatures.
(try_inline_pgp): Don't do any actual PGP handling here: Just
rewrite as a multipart/encrypted.
(try_inline_pgp_sig): Likewise, just do a multipart/signed (with
the x-inline-pgp-hack parameter set).
(try_uudecoding, try_inline_binhex): Update for API changes.
(handle_multipart_signed): Exciting and new. Use <object> to
create a button which the user must click to do the
verification. Change the formatting of the gpg output text a bit.
* mail-display.c (on_link_clicked): Remove x-evolution-decode-pgp
hack, which is no longer used.
(pixbuf_gen_idle): Add a hack for the PGP verification button.
(do_attachment_header, do_external_viewer): Split out of
on_object_requeested for clarity.
(do_signature): New routine to do the PGP verification button.
(on_object_requested): Now just dispatches to
do_attachment_header, do_external_viewer, or do_signature.
(mail_error_write): Don't do <blockquote> here. Fixed the problem
that was trying to fix elsewhere.
svn path=/trunk/; revision=13888
Diffstat (limited to 'mail/mail-display.c')
-rw-r--r-- | mail/mail-display.c | 281 |
1 files changed, 149 insertions, 132 deletions
diff --git a/mail/mail-display.c b/mail/mail-display.c index 3dbd12523c..ebe1a5147c 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -218,11 +218,7 @@ on_link_clicked (GtkHTML *html, const char *url, MailDisplay *md) g_warning ("Can't handle news URLs yet."); else if (!g_strncasecmp (url, "mailto:", 7)) send_to_url (url); - else if (!strcmp (url, "x-evolution-decode-pgp:")) { - g_datalist_set_data (md->data, "show_pgp", - GINT_TO_POINTER (1)); - mail_display_queue_redisplay (md); - } else if (*url == '#') + else if (*url == '#') mail_display_jump_to_anchor (md, url); else gnome_url_show (url); @@ -580,9 +576,12 @@ pixbuf_gen_idle (struct _PixbufLoader *pbl) error = TRUE; } - if (error || !pbl->mstream) - pixbuf = pixbuf_for_mime_type (pbl->type); - else + if (error || !pbl->mstream) { + if (pbl->type) + pixbuf = pixbuf_for_mime_type (pbl->type); + else + pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/pgp-signature-nokey.png"); + } else pixbuf = gdk_pixbuf_loader_get_pixbuf (pbl->loader); width = gdk_pixbuf_get_width (pixbuf); @@ -776,138 +775,94 @@ save_url (MailDisplay *md, const char *url) } static gboolean -on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) +do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, + CamelMimePart *part, MailDisplay *md) { - MailDisplay *md = data; - GHashTable *urls; - CamelMedium *medium; - CamelDataWrapper *wrapper; - OAF_ServerInfo *component; - GtkWidget *embedded; - BonoboObjectClient *server; - Bonobo_PersistStream persist; - CORBA_Environment ev; - GByteArray *ba; - CamelStream *cstream; - BonoboStream *bstream; - char *cid; + GtkWidget *button, *mainbox, *hbox, *arrow, *popup; + MailMimeHandler *handler; + struct _PixbufLoader *pbl; - cid = eb->classid; + pbl = g_new0 (struct _PixbufLoader, 1); + if (g_strncasecmp (eb->type, "image/", 6) == 0) { + CamelDataWrapper *content; - if (!strncmp (cid, "popup:", 6)) - cid += 6; - if (strncmp (cid, "cid:", 4) != 0) - return FALSE; + content = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + if (!camel_data_wrapper_is_offline (content)) { + pbl->mstream = camel_stream_mem_new (); + camel_data_wrapper_write_to_stream (content, pbl->mstream); + camel_stream_reset (pbl->mstream); + } + } + pbl->type = g_strdup (eb->type); + pbl->cid = g_strdup (eb->classid + 6); + pbl->pixmap = bonobo_ui_toolbar_icon_new (); + pbl->eb = eb; + pbl->destroy_id = gtk_signal_connect (GTK_OBJECT (eb), "destroy", + embeddable_destroy_cb, pbl); - urls = g_datalist_get_data (md->data, "part_urls"); - g_return_val_if_fail (urls != NULL, FALSE); + g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)pixbuf_gen_idle, + pbl, NULL); - medium = g_hash_table_lookup (urls, cid); - g_return_val_if_fail (CAMEL_IS_MEDIUM (medium), FALSE); + mainbox = gtk_hbox_new (FALSE, 0); - if (cid != eb->classid) { - /* This is a part wrapper */ -#ifdef USE_OLD_DISPLAY_STYLE - GtkWidget *ebox; -#else - GtkWidget *button, *mainbox, *hbox, *arrow, *popup; - MailMimeHandler *handler; -#endif - struct _PixbufLoader *pbl; + button = gtk_button_new (); + gtk_object_set_data (GTK_OBJECT (button), "MailDisplay", md); - pbl = g_new0 (struct _PixbufLoader, 1); - if (g_strncasecmp (eb->type, "image/", 6) == 0) { - CamelDataWrapper *content; + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (button_press), part); - content = camel_medium_get_content_object (medium); - if (!camel_data_wrapper_is_offline (content)) { - pbl->mstream = camel_stream_mem_new (); - camel_data_wrapper_write_to_stream (content, pbl->mstream); - camel_stream_reset (pbl->mstream); - } - } - pbl->type = g_strdup (eb->type); - pbl->cid = g_strdup (cid); - pbl->pixmap = bonobo_ui_toolbar_icon_new (); - pbl->eb = eb; - pbl->destroy_id = gtk_signal_connect (GTK_OBJECT (eb), - "destroy", - embeddable_destroy_cb, - pbl); - - g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)pixbuf_gen_idle, - pbl, NULL); + hbox = gtk_hbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); -#ifdef USE_OLD_DISPLAY_STYLE - ebox = gtk_event_box_new (); - gtk_widget_set_sensitive (GTK_WIDGET (ebox), TRUE); - gtk_widget_add_events (GTK_WIDGET (ebox), - GDK_BUTTON_PRESS_MASK); - gtk_object_set_data (GTK_OBJECT (ebox), "MailDisplay", md); - gtk_object_set_data (GTK_OBJECT (ebox), "CamelMimePart", - medium); - gtk_object_set_data_full (GTK_OBJECT (ebox), "mime_type", - g_strdup (eb->type), - (GDestroyNotify)g_free); - - gtk_signal_connect (GTK_OBJECT (ebox), "button_press_event", - GTK_SIGNAL_FUNC (pixmap_press), md->scroll); - - gtk_container_add (GTK_CONTAINER (ebox), pbl->pixmap); - gtk_widget_show_all (ebox); - gtk_container_add (GTK_CONTAINER (eb), ebox); -#else - mainbox = gtk_hbox_new (FALSE, 0); - - button = gtk_button_new (); - gtk_object_set_data (GTK_OBJECT (button), "MailDisplay", md); - - gtk_signal_connect (GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (button_press), medium); - - hbox = gtk_hbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); - - if (mail_part_is_displayed_inline (CAMEL_MIME_PART (medium), md)) { - arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_DOWN); - } else { - arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_FORWARD); - } - gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), pbl->pixmap, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (button), hbox); - - popup = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (popup), - gtk_arrow_new (GTK_ARROW_DOWN, - GTK_SHADOW_ETCHED_IN)); - - gtk_object_set_data (GTK_OBJECT (popup), "MailDisplay", md); - gtk_object_set_data (GTK_OBJECT (popup), "CamelMimePart", - medium); - gtk_object_set_data_full (GTK_OBJECT (popup), "mime_type", - g_strdup (eb->type), - (GDestroyNotify)g_free); - - gtk_signal_connect (GTK_OBJECT (popup), "button_press_event", - GTK_SIGNAL_FUNC (pixmap_press), md->scroll); - - gtk_box_pack_start (GTK_BOX (mainbox), button, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (mainbox), popup, TRUE, TRUE, 0); - gtk_widget_show_all (mainbox); - - handler = mail_lookup_handler (eb->type); - if (handler && handler->builtin) { - gtk_widget_set_sensitive (button, TRUE); - } else { - gtk_widget_set_sensitive (button, FALSE); - } + if (mail_part_is_displayed_inline (part, md)) + arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_DOWN); + else + arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_FORWARD); + gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), pbl->pixmap, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (button), hbox); + + popup = gtk_button_new (); + gtk_container_add (GTK_CONTAINER (popup), + gtk_arrow_new (GTK_ARROW_DOWN, + GTK_SHADOW_ETCHED_IN)); + + gtk_object_set_data (GTK_OBJECT (popup), "MailDisplay", md); + gtk_object_set_data (GTK_OBJECT (popup), "CamelMimePart", part); + gtk_object_set_data_full (GTK_OBJECT (popup), "mime_type", + g_strdup (eb->type), (GDestroyNotify)g_free); + + gtk_signal_connect (GTK_OBJECT (popup), "button_press_event", + GTK_SIGNAL_FUNC (pixmap_press), md->scroll); + + gtk_box_pack_start (GTK_BOX (mainbox), button, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (mainbox), popup, TRUE, TRUE, 0); + gtk_widget_show_all (mainbox); + + handler = mail_lookup_handler (eb->type); + if (handler && handler->builtin) + gtk_widget_set_sensitive (button, TRUE); + else + gtk_widget_set_sensitive (button, FALSE); - gtk_container_add (GTK_CONTAINER (eb), mainbox); -#endif + gtk_container_add (GTK_CONTAINER (eb), mainbox); - return TRUE; - } + return TRUE; +} + +static gboolean +do_external_viewer (GtkHTML *html, GtkHTMLEmbedded *eb, + CamelMimePart *part, MailDisplay *md) +{ + CamelDataWrapper *wrapper; + OAF_ServerInfo *component; + GtkWidget *embedded; + BonoboObjectClient *server; + Bonobo_PersistStream persist; + CORBA_Environment ev; + GByteArray *ba; + CamelStream *cstream; + BonoboStream *bstream; component = gnome_vfs_mime_get_default_component (eb->type); if (!component) @@ -929,7 +884,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) /* Write the data to a CamelStreamMem... */ ba = g_byte_array_new (); cstream = camel_stream_mem_new_with_byte_array (ba); - wrapper = camel_medium_get_content_object (medium); + wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); camel_data_wrapper_write_to_stream (wrapper, cstream); /* ...convert the CamelStreamMem to a BonoboStreamMem... */ @@ -958,6 +913,66 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) return TRUE; } + +static gboolean +do_signature (GtkHTML *html, GtkHTMLEmbedded *eb, + CamelMimePart *part, MailDisplay *md) +{ + GtkWidget *button; + struct _PixbufLoader *pbl; + + pbl = g_new0 (struct _PixbufLoader, 1); + pbl->type = NULL; + pbl->cid = g_strdup (eb->classid); + pbl->pixmap = bonobo_ui_toolbar_icon_new (); + pbl->eb = eb; + pbl->destroy_id = gtk_signal_connect (GTK_OBJECT (eb), "destroy", + embeddable_destroy_cb, pbl); + + g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)pixbuf_gen_idle, + pbl, NULL); + + button = gtk_button_new (); + gtk_object_set_data (GTK_OBJECT (button), "MailDisplay", md); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (button_press), part); + gtk_container_add (GTK_CONTAINER (button), pbl->pixmap); + gtk_widget_show_all (button); + gtk_container_add (GTK_CONTAINER (eb), button); + + return TRUE; +} + +static gboolean +on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) +{ + MailDisplay *md = data; + GHashTable *urls; + CamelMimePart *part; + + urls = g_datalist_get_data (md->data, "part_urls"); + if (!urls) + return FALSE; + + if (!strncmp (eb->classid, "popup:", 6)) { + part = g_hash_table_lookup (urls, eb->classid + 6); + if (!CAMEL_IS_MIME_PART (part)) + return FALSE; + return do_attachment_header (html, eb, part, md); + } else if (!strncmp (eb->classid, "signature:", 10)) { + part = g_hash_table_lookup (urls, eb->classid); + if (!CAMEL_IS_MIME_PART (part)) + return FALSE; + return do_signature (html, eb, part, md); + } else if (!strncmp (eb->classid, "cid:", 4)) { + part = g_hash_table_lookup (urls, eb->classid); + if (!CAMEL_IS_MIME_PART (part)) + return FALSE; + return do_external_viewer (html, eb, part, md); + } + + return FALSE; +} static void load_http (MailDisplay *md, gpointer data) @@ -1336,9 +1351,9 @@ mail_error_write (GtkHTML *html, GtkHTMLStream *stream, htmltext = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); g_free (buf); - gtk_html_stream_printf (stream, "<blockquote><em><font color=red>"); + gtk_html_stream_printf (stream, "<em><font color=red>"); gtk_html_stream_write (stream, htmltext, strlen (htmltext)); - gtk_html_stream_printf (stream, "</font></em></blockquote>"); + gtk_html_stream_printf (stream, "</font></em>"); g_free (htmltext); } @@ -1540,11 +1555,13 @@ link_open_in_browser (GtkWidget *w, MailDisplay *mail_display) mail_display); } +#if 0 static void link_save_as (GtkWidget *w, MailDisplay *mail_display) { g_print ("FIXME save %s\n", mail_display->html->pointer_url); } +#endif static void link_copy_location (GtkWidget *w, MailDisplay *mail_display) |