[Xfce4-commits] <postler:master> Parse content-id field and render embedded media
Christian Dywan
noreply at xfce.org
Tue Feb 8 19:16:01 CET 2011
Updating branch refs/heads/master
to 23084bc1ae577cacf310196a8fcc446d9d1213b2 (commit)
from f1f67c4b925518e384703989a13697d37e6ab808 (commit)
commit 23084bc1ae577cacf310196a8fcc446d9d1213b2
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Feb 7 11:05:40 2011 +0100
Parse content-id field and render embedded media
Attachments rendered embedded don't show as separate icons.
postler/postler-attachments.vala | 16 ++++++++++++++++
postler/postler-content.vala | 6 ++++++
postler/postler-viewer.vala | 10 ++++++++++
3 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/postler/postler-attachments.vala b/postler/postler-attachments.vala
index 7de50de..d1a6555 100644
--- a/postler/postler-attachments.vala
+++ b/postler/postler-attachments.vala
@@ -73,6 +73,22 @@ public class Postler.Attachments : Gtk.IconView {
hide ();
}
+ public void remove_part (MessagePart part) {
+ Gtk.TreeIter iter;
+ if (!model.iter_children (out iter, null))
+ return;
+ do {
+ MessagePart existing_part;
+ model.get (iter, 0, out existing_part);
+ if (existing_part == part) {
+ (model as Gtk.ListStore).remove (iter);
+ if (model.iter_n_children (null) == 0)
+ hide ();
+ break;
+ }
+ } while (model.iter_next (ref iter));
+ }
+
public MessagePart? get_selected_part () {
var paths = get_selected_items ();
var path = paths != null ? paths.nth_data (0) : null;
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 9e5cf1c..ef0c996 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -15,6 +15,7 @@ public class Postler.MessagePart : Object {
public string? charset;
public bool plain_text;
public string? content_disposition;
+ public string? content_id;
public string? filename;
public MessagePart (string mime_type) {
body = new StringBuilder ();
@@ -871,6 +872,11 @@ public class Postler.Content : WebKit.WebView {
else if (content_disposition.has_prefix ("inline"))
message_part.content_disposition = content_disposition;
}
+ else if (field == "content-id") {
+ string content_id = parts[1].strip ();
+ if (content_id[0] == '<' && content_id.has_suffix (">"))
+ message_part.content_id = content_id.slice (1, -1);
+ }
continue;
}
else if (multipart == 1)
diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index 3d3a7de..1decf0d 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -69,6 +69,16 @@ public class Postler.Viewer : Gtk.VBox {
infobar.set_no_show_all (false);
infobar.show_all ();
}
+ if (request.uri.has_prefix ("cid:")) {
+ string content_id = request.uri.substring (4, -1);
+ foreach (var part in content.message_parts) {
+ if (part.content_id == content_id) {
+ request.uri = "data:" + part.mime_type + ";base64," + part.body.str;
+ attachments.remove_part (part);
+ break;
+ }
+ }
+ }
}
void infobar_response (Gtk.InfoBar infobar, int response) {
More information about the Xfce4-commits
mailing list