summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-05-12 15:10:08 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:48 +0300
commita0b1a079b83bf7ca755e1a32535801ace2c60b98 (patch)
tree333b275200e3f81f596b1e6e9827b851a2598aa0
parent4c88422d71d60265e05cd41d9034387d15f4d546 (diff)
ui: add "application/pgp-signature" content type
-rw-r--r--melib/src/mailbox/email/attachment_types.rs4
-rw-r--r--melib/src/mailbox/email/attachments.rs17
-rw-r--r--ui/src/components/mail/view.rs11
-rw-r--r--ui/src/components/mail/view/envelope.rs8
4 files changed, 39 insertions, 1 deletions
diff --git a/melib/src/mailbox/email/attachment_types.rs b/melib/src/mailbox/email/attachment_types.rs
index 3a8b8e8c..e6c8d2ff 100644
--- a/melib/src/mailbox/email/attachment_types.rs
+++ b/melib/src/mailbox/email/attachment_types.rs
@@ -80,6 +80,7 @@ pub enum MultipartType {
Mixed,
Alternative,
Digest,
+ Signed,
}
impl Default for MultipartType {
@@ -94,6 +95,7 @@ impl Display for MultipartType {
MultipartType::Mixed => write!(f, "multipart/mixed"),
MultipartType::Alternative => write!(f, "multipart/alternative"),
MultipartType::Digest => write!(f, "multipart/digest"),
+ MultipartType::Signed => write!(f, "multipart/signed"),
}
}
}
@@ -110,6 +112,7 @@ pub enum ContentType {
subattachments: Vec<Attachment>,
},
MessageRfc822,
+ PGPSignature,
Unsupported {
tag: Vec<u8>,
},
@@ -130,6 +133,7 @@ impl Display for ContentType {
ContentType::Text { kind: t, .. } => t.fmt(f),
ContentType::Multipart { kind: k, .. } => k.fmt(f),
ContentType::Unsupported { tag: ref t } => write!(f, "{}", String::from_utf8_lossy(t)),
+ ContentType::PGPSignature => write!(f, "application/pgp-signature"),
ContentType::MessageRfc822 => write!(f, "message/rfc822"),
}
}
diff --git a/melib/src/mailbox/email/attachments.rs b/melib/src/mailbox/email/attachments.rs
index 174a3b1c..3fa9fd17 100644
--- a/melib/src/mailbox/email/attachments.rs
+++ b/melib/src/mailbox/email/attachments.rs
@@ -95,6 +95,8 @@ impl AttachmentBuilder {
MultipartType::Alternative
} else if cst.eq_ignore_ascii_case(b"digest") {
MultipartType::Digest
+ } else if cst.eq_ignore_ascii_case(b"signed") {
+ MultipartType::Signed
} else {
Default::default()
},
@@ -134,6 +136,10 @@ impl AttachmentBuilder {
} else if ct.eq_ignore_ascii_case(b"message") && cst.eq_ignore_ascii_case(b"rfc822")
{
self.content_type = ContentType::MessageRfc822;
+ } else if ct.eq_ignore_ascii_case(b"application")
+ && cst.eq_ignore_ascii_case(b"pgp-signature")
+ {
+ self.content_type = ContentType::PGPSignature;
} else {
let mut tag: Vec<u8> = Vec::with_capacity(ct.len() + cst.len() + 1);
tag.extend(ct);
@@ -260,6 +266,7 @@ impl fmt::Display for Attachment {
),
Err(e) => write!(f, "{}", e),
},
+ ContentType::PGPSignature => write!(f, "pgp signature {}", self.mime_type()),
ContentType::Unsupported { .. } => {
write!(f, "Data attachment of type {}", self.mime_type())
}
@@ -388,6 +395,15 @@ impl Attachment {
return true;
}
ContentType::Multipart {
+ kind: MultipartType::Signed,
+ ref subattachments,
+ ..
+ } => subattachments
+ .iter()
+ .find(|s| s.content_type != ContentType::PGPSignature)
+ .map(|s| s.is_html())
+ .unwrap_or(false),
+ ContentType::Multipart {
ref subattachments, ..
} => subattachments
.iter()
@@ -439,6 +455,7 @@ fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option<Filter<'a>>) ->
let ret = match a.content_type {
ContentType::Unsupported { .. } => Vec::new(),
ContentType::Text { .. } => decode_helper(a, filter),
+ ContentType::PGPSignature => a.content_type.to_string().into_bytes(),
ContentType::MessageRfc822 => decode_rec(&decode_rfc822(&a.raw), None),
ContentType::Multipart {
ref kind,
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index 1b3ae398..1ac321ae 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -200,13 +200,14 @@ impl MailView {
match self.mode {
ViewMode::Normal | ViewMode::Subview => {
let mut t = body_text.to_string();
+ t.push('\n');
if body.count_attachments() > 1 {
t = body
.attachments()
.iter()
.enumerate()
.fold(t, |mut s, (idx, a)| {
- s.push_str(&format!("[{}] {}\n\n", idx, a));
+ s.push_str(&format!("\n[{}] {}\n", idx, a));
s
});
}
@@ -660,6 +661,14 @@ impl Component for MailView {
return true;
}
}
+ ContentType::PGPSignature => {
+ context.replies.push_back(UIEvent::StatusEvent(
+ StatusEvent::DisplayMessage(
+ "Signatures aren't supported yet".to_string(),
+ ),
+ ));
+ return true;
+ }
}
} else {
context.replies.push_back(UIEvent::StatusEvent(
diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs
index f888b33e..62467196 100644
--- a/ui/src/components/mail/view/envelope.rs
+++ b/ui/src/components/mail/view/envelope.rs
@@ -459,6 +459,14 @@ impl Component for EnvelopeView {
return true;
}
}
+ ContentType::PGPSignature => {
+ context.replies.push_back(UIEvent::StatusEvent(
+ StatusEvent::DisplayMessage(
+ "Signatures aren't supported yet".to_string(),
+ ),
+ ));
+ return true;
+ }
}
} else {
context.replies.push_back(UIEvent::StatusEvent(