aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-display.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-07-27 13:49:59 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-28 03:27:09 +0800
commit69837f33cc6701043c9bbef2005c3c8281d5980e (patch)
tree7027303ba875f204a526b4e87702e036b8272662 /mail/e-mail-display.c
parent51b74eee72ecf1323105f9c12942f2fe303ec7e1 (diff)
downloadgsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar.gz
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar.bz2
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar.lz
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar.xz
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.tar.zst
gsoc2013-evolution-69837f33cc6701043c9bbef2005c3c8281d5980e.zip
Add e_web_view_suggest_filename().
Attempts to derive a suggested filename from the given URI for use in a "Save As" dialog. By default the suggested filename is the last path segment of the given URI (the unless the given URI looks like a query), but subclasses can use other mechanisms for custom URI schemes. For example, "cid:" URIs in an email message may refer to a MIME part with a suggested filename in its Content-Disposition header.
Diffstat (limited to 'mail/e-mail-display.c')
-rw-r--r--mail/e-mail-display.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 980fc8f984..46cf48a306 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -1477,6 +1477,45 @@ chainup:
redirect_uri (web_view, uri);
}
+static gchar *
+mail_display_suggest_filename (EWebView *web_view,
+ const gchar *uri)
+{
+ if (g_str_has_prefix (uri, "cid:")) {
+ EMailDisplay *display;
+ EMailPartList *part_list;
+ CamelMimeMessage *message;
+ CamelMimePart *mime_part;
+ const gchar *filename;
+
+ /* Note, this assumes the URI comes
+ * from the currently loaded message. */
+
+ display = E_MAIL_DISPLAY (web_view);
+
+ part_list = e_mail_display_get_part_list (display);
+ if (part_list == NULL)
+ return NULL;
+
+ message = e_mail_part_list_get_message (part_list);
+ if (message == NULL)
+ return NULL;
+
+ mime_part = camel_mime_message_get_part_by_content_id (
+ message, uri + 4);
+ if (mime_part == NULL)
+ return NULL;
+
+ filename = camel_mime_part_get_filename (mime_part);
+
+ return g_strdup (filename);
+ }
+
+ /* Chain up to parent's suggest_filename() method. */
+ return E_WEB_VIEW_CLASS (e_mail_display_parent_class)->
+ suggest_filename (web_view, uri);
+}
+
static void
mail_display_set_fonts (EWebView *web_view,
PangoFontDescription **monospace,
@@ -1531,6 +1570,7 @@ e_mail_display_class_init (EMailDisplayClass *class)
web_view_class = E_WEB_VIEW_CLASS (class);
web_view_class->redirect_uri = mail_display_redirect_uri;
+ web_view_class->suggest_filename = mail_display_suggest_filename;
web_view_class->set_fonts = mail_display_set_fonts;
g_object_class_install_property (