diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2018-07-25 19:05:42 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:25 +0300 |
commit | 60494497332d5f16aae02873d351db6a049ec3c3 (patch) | |
tree | d7dfe178a8f0a6f12ca75bde8d34fb5156bece4a /ui/src/components/mail/view.rs | |
parent | b7729243adddfdd5781afe6c059092eb2c80db50 (diff) |
Add attachment view for application/* mime
concerns #2
left:
multipart text and pgp.
Diffstat (limited to 'ui/src/components/mail/view.rs')
-rw-r--r-- | ui/src/components/mail/view.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 0015faa0..1b9e5401 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -2,6 +2,8 @@ use super::*; use linkify::{LinkFinder, Link}; use std::process::{Command, Stdio}; +use mime_apps::query_default_app; + #[derive(PartialEq, Debug)] enum ViewMode { @@ -194,8 +196,17 @@ impl Component for MailView { let envelope: &Envelope = &mailbox.collection[envelope_idx]; if let Some(u) = envelope.body().attachments().get(lidx) { - let p = create_temp_file(&decode(u), None); - eprintln!("{:?}", p); + let mut p = create_temp_file(&decode(u), None); + let attachment_type = u.mime_type(); + eprintln!("attachment type {}", attachment_type); + let binary = query_default_app(attachment_type); + eprintln!("{:?}, binary = {:?}", p, binary); + Command::new(binary.unwrap()) + .arg(p.path()) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .expect("Failed to start xdg_open"); } else { context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Attachment `{}` not found.", lidx)) }); |