diff options
author | Dan Winship <danw@src.gnome.org> | 2000-04-21 13:12:05 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-04-21 13:12:05 +0800 |
commit | 8ff61b81c5771badd0a695b8fab9b27a09570882 (patch) | |
tree | a46550a82e731cfe7ea31fa2b7c4280dae619011 /mail/mail-display.c | |
parent | dc1d13533cb4762c7aa4b6c93b3d8801e2f4919e (diff) | |
download | gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar.gz gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar.bz2 gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar.lz gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar.xz gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.tar.zst gsoc2013-evolution-8ff61b81c5771badd0a695b8fab9b27a09570882.zip |
deal with cid: URLs. (find_cid): helper routine for above. (This could be
* mail-display.c (on_url_requested): deal with cid: URLs.
(find_cid): helper routine for above. (This could be much better.)
(mail_display_init): connect url_requested signal
* mail-format.c (handle_multipart_related): Make this work.
svn path=/trunk/; revision=2542
Diffstat (limited to 'mail/mail-display.c')
-rw-r--r-- | mail/mail-display.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/mail/mail-display.c b/mail/mail-display.c index 5a3b42a319..289b132a2a 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -219,6 +219,73 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, void *unused) g_string_free (camel_stream_gstr, TRUE); } +static CamelMimePart * +find_cid (const char *cid, CamelMimePart *part) +{ + const char *msg_cid; + CamelDataWrapper *content; + CamelMultipart *mp; + int i, nparts; + + msg_cid = camel_mime_part_get_content_id (part); + if (msg_cid && !strcmp (cid, msg_cid)) + return part; + + content = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + if (!content) + return NULL; + + if (CAMEL_IS_MIME_PART (content)) + return find_cid (cid, CAMEL_MIME_PART (content)); + else if (!CAMEL_IS_MULTIPART (content)) + return NULL; + + mp = CAMEL_MULTIPART (content); + nparts = camel_multipart_get_number (mp); + for (i = 0; i < nparts; i++) { + CamelMimePart *found_part; + + part = CAMEL_MIME_PART (camel_multipart_get_part (mp, i)); + found_part = find_cid (cid, part); + if (found_part) + return found_part; + } + + return NULL; +} + +static void +on_url_requested (GtkHTML *html, const char *url, GtkHTMLStreamHandle handle, + gpointer user_data) +{ + char *cid, buf[1024]; + int nread; + CamelMimePart *part; + CamelDataWrapper *data; + CamelStream *output; + + if (strncmp (url, "cid:", 4)) + return; + + part = gtk_object_get_data (GTK_OBJECT (html), "message"); + g_return_if_fail (part != NULL); + + cid = g_strdup_printf ("<%s>", url + 4); + part = find_cid (cid, part); + g_free (cid); + + if (!part) + return; + + data = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + output = camel_data_wrapper_get_output_stream (data); + do { + nread = camel_stream_read (output, buf, sizeof (buf)); + if (nread > 0) + gtk_html_write (html, handle, buf, nread); + } while (!camel_stream_eos (output)); +} + /** * mail_display_set_message: @@ -283,6 +350,8 @@ mail_display_set_message (MailDisplay *mail_display, mail_format_mime_message (CAMEL_MIME_MESSAGE (medium), headers_stream, body_stream); + gtk_object_set_data (GTK_OBJECT (mail_display->body_html_widget), + "message", medium); mail_write_html (headers_stream, "\n</font>\n</body>\n</html>\n"); mail_write_html (body_stream, "\n</body>\n</html>\n"); @@ -313,6 +382,10 @@ mail_display_init (GtkObject *object) "object_requested", GTK_SIGNAL_FUNC (on_object_requested), NULL); + gtk_signal_connect (GTK_OBJECT (mail_display->body_html_widget), + "url_requested", + GTK_SIGNAL_FUNC (on_url_requested), + NULL); gtk_widget_show (GTK_WIDGET (mail_display->body_html_widget)); /* various other initializations */ |