parent
faa349fadb
commit
a4b8b4fd4e
|
@ -9,7 +9,7 @@ use mime_apps::query_default_app;
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
Normal,
|
Normal,
|
||||||
Url,
|
Url,
|
||||||
Attachment(usize),
|
Attachment(usize),
|
||||||
// Raw,
|
// Raw,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,26 +219,31 @@ impl Component for MailView {
|
||||||
|
|
||||||
let envelope: &Envelope = &mailbox.collection[envelope_idx];
|
let envelope: &Envelope = &mailbox.collection[envelope_idx];
|
||||||
if let Some(u) = envelope.body().attachments().get(lidx) {
|
if let Some(u) = envelope.body().attachments().get(lidx) {
|
||||||
let mut p = create_temp_file(&decode(u), None);
|
|
||||||
match u.content_type().0 {
|
match u.content_type().0 {
|
||||||
ContentType::Text => {
|
ContentType::Text => {
|
||||||
self.mode = ViewMode::Attachment(lidx);
|
self.mode = ViewMode::Attachment(lidx);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
},
|
},
|
||||||
ContentType::Multipart { .. } => {
|
ContentType::Multipart { .. } => {
|
||||||
unimplemented!()
|
context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Multipart attachments are not supported yet.")) });
|
||||||
|
return;
|
||||||
},
|
},
|
||||||
ContentType::Unsupported { .. } => {
|
ContentType::Unsupported { .. } => {
|
||||||
let attachment_type = u.mime_type();
|
let attachment_type = u.mime_type();
|
||||||
eprintln!("attachment type {}", attachment_type);
|
let binary = query_default_app(&attachment_type);
|
||||||
let binary = query_default_app(attachment_type);
|
if let Ok(binary) = binary {
|
||||||
eprintln!("{:?}, binary = {:?}", p, binary);
|
let mut p = create_temp_file(&decode(u), None);
|
||||||
Command::new(binary.unwrap())
|
Command::new(&binary)
|
||||||
.arg(p.path())
|
.arg(p.path())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to start xdg_open");
|
.expect(&format!("Failed to start {}", binary.display()));
|
||||||
|
} else {
|
||||||
|
context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Couldn't find a default application for type {}", attachment_type)) });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue