From 8ffcf0b7552e8b921228a8aa372335a161d262b8 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 12 Mar 2002 22:23:08 +0000 Subject: Handle digest: urls. 2002-03-12 Jeffrey Stedfast * mail-display.c (on_link_clicked): Handle digest: urls. * mail-format.c (setup_mime_tables): Add a handler for multipart/digest. (handle_multipart_digest): Handle multipart/digest parts. svn path=/trunk/; revision=16133 --- mail/ChangeLog | 7 +++++++ mail/mail-display.c | 41 ++++++++++++++++++++++++++++++++++++----- mail/mail-format.c | 21 +++++++++++++++++++++ 3 files changed, 64 insertions(+), 5 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 315d25ba04..1382e4a04f 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2002-03-12 Jeffrey Stedfast + + * mail-display.c (on_link_clicked): Handle digest: urls. + + * mail-format.c (setup_mime_tables): Add a handler for multipart/digest. + (handle_multipart_digest): Handle multipart/digest parts. + 2002-03-12 Jeffrey Stedfast * folder-browser.c (folder_browser_set_folder): Set the folder on diff --git a/mail/mail-display.c b/mail/mail-display.c index 3b82856107..234ecd8db5 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -46,6 +46,8 @@ #include "e-searching-tokenizer.h" #include "folder-browser-factory.h" #include "mail-stream-gtkhtml.h" +#include "folder-browser-window.h" +#include "folder-browser.h" #include "mail-display.h" #include "mail-config.h" #include "mail-ops.h" @@ -216,18 +218,47 @@ mail_display_jump_to_anchor (MailDisplay *md, const char *url) gtk_html_jump_to_anchor (md->html, anchor + 1); } +static void +mail_display_digest_clicked (MailDisplay *md, const char *url) +{ + FolderBrowser *fb, *parent_fb; + CamelFolder *digest; + CamelStore *store; + GtkWidget *window; + + parent_fb = (FolderBrowser *) gtk_widget_get_ancestor (GTK_WIDGET (md), FOLDER_BROWSER_TYPE); + + store = camel_digest_store_new (url); + + digest = camel_digest_folder_new (store, md->current_message); + camel_object_unref (CAMEL_OBJECT (store)); + if (!digest) + return; + + fb = (FolderBrowser *) folder_browser_new (parent_fb->shell, NULL); + folder_browser_set_message_preview (fb, TRUE); + folder_browser_set_folder (fb, digest, url); + camel_object_unref (CAMEL_OBJECT (digest)); + gtk_widget_show (GTK_WIDGET (fb)); + + window = folder_browser_window_new (fb); + gtk_widget_show (window); +} + static void on_link_clicked (GtkHTML *html, const char *url, MailDisplay *md) { - if (!g_strncasecmp (url, "news:", 5) || - !g_strncasecmp (url, "nntp:", 5)) + if (!g_strncasecmp (url, "news:", 5) || !g_strncasecmp (url, "nntp:", 5)) { g_warning ("Can't handle news URLs yet."); - else if (!g_strncasecmp (url, "mailto:", 7)) + } else if (!g_strncasecmp (url, "mailto:", 7)) { send_to_url (url); - else if (*url == '#') + } else if (!g_strncasecmp (url, "digest:", 7)) { + mail_display_digest_clicked (md, url); + } else if (*url == '#') { mail_display_jump_to_anchor (md, url); - else + } else { gnome_url_show (url); + } } static void diff --git a/mail/mail-format.c b/mail/mail-format.c index 1cc5a3d851..d353b0b249 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -92,6 +92,9 @@ static gboolean handle_multipart_encrypted (CamelMimePart *part, static gboolean handle_multipart_signed (CamelMimePart *part, const char *mime_type, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); +static gboolean handle_multipart_digest (CamelMimePart *part, + const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); static gboolean handle_message_rfc822 (CamelMimePart *part, const char *mime_type, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream); @@ -364,6 +367,8 @@ setup_mime_tables (void) handle_multipart_encrypted); g_hash_table_insert (mime_function_table, "multipart/signed", handle_multipart_signed); + g_hash_table_insert (mime_function_table, "multipart/digest", + handle_multipart_digest); /* RFC 2046 says unrecognized text subtypes can be treated * as text/plain (as long as you recognize the character set), @@ -1693,6 +1698,22 @@ handle_multipart_mixed (CamelMimePart *part, const char *mime_type, return TRUE; } +static gboolean +handle_multipart_digest (CamelMimePart *part, const char *mime_type, + MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) +{ + CamelDataWrapper *wrapper = + camel_medium_get_content_object (CAMEL_MEDIUM (part)); + + g_return_val_if_fail (CAMEL_IS_MULTIPART (wrapper), FALSE); + + gtk_html_stream_printf (stream, "    %s", + get_url_for_icon (EVOLUTION_ICONSDIR "/envelope.png", md), + U_("View messages...")); + + return TRUE; +} + static gboolean handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream) -- cgit