Update xdg-util dependency to 0.4.0
parent
54b2066f73
commit
98c1ece28d
|
@ -2174,9 +2174,9 @@ checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xdg-utils"
|
name = "xdg-utils"
|
||||||
version = "0.3.1"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6c275db8f4249f393a5c4de777ebeba37a5859bc2209a30fb66dc566dddd3ce"
|
checksum = "db9fefe62d5969721e2cfc529e6a760901cc0da422b6d67e7bfd18e69490dba6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
|
|
|
@ -47,7 +47,7 @@ smol = "1.0.0"
|
||||||
async-stream = "0.2.1"
|
async-stream = "0.2.1"
|
||||||
base64 = { version = "0.12.3", optional = true }
|
base64 = { version = "0.12.3", optional = true }
|
||||||
flate2 = { version = "1.0.16", optional = true }
|
flate2 = { version = "1.0.16", optional = true }
|
||||||
xdg-utils = "0.3.0"
|
xdg-utils = "^0.4.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["unicode_algorithms", "imap_backend", "maildir_backend", "mbox_backend", "vcard", "sqlite3", "smtp", "deflate_compression"]
|
default = ["unicode_algorithms", "imap_backend", "maildir_backend", "mbox_backend", "vcard", "sqlite3", "smtp", "deflate_compression"]
|
||||||
|
|
|
@ -1910,17 +1910,21 @@ impl Component for MailView {
|
||||||
}
|
}
|
||||||
ContentType::Other { .. } => {
|
ContentType::Other { .. } => {
|
||||||
let attachment_type = attachment.mime_type();
|
let attachment_type = attachment.mime_type();
|
||||||
let binary = query_default_app(&attachment_type);
|
|
||||||
let filename = attachment.filename();
|
let filename = attachment.filename();
|
||||||
if let Ok(binary) = binary {
|
if let Ok(command) = query_default_app(&attachment_type) {
|
||||||
let p = create_temp_file(
|
let p = create_temp_file(
|
||||||
&decode(attachment, None),
|
&decode(attachment, None),
|
||||||
filename.as_ref().map(|s| s.as_str()),
|
filename.as_ref().map(|s| s.as_str()),
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
match Command::new(&binary)
|
let (exec_cmd, argument) = desktop_exec_to_command(
|
||||||
.arg(p.path())
|
&command,
|
||||||
|
p.path.display().to_string(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
match Command::new(&exec_cmd)
|
||||||
|
.arg(&argument)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
|
@ -1932,9 +1936,8 @@ impl Component for MailView {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
StatusEvent::DisplayMessage(format!(
|
StatusEvent::DisplayMessage(format!(
|
||||||
"Failed to start {}: {}",
|
"Failed to start `{} {}`: {}",
|
||||||
binary.display(),
|
&exec_cmd, &argument, err
|
||||||
err
|
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -2508,3 +2511,50 @@ fn save_attachment(path: &std::path::Path, bytes: &[u8]) -> Result<()> {
|
||||||
f.flush()?;
|
f.flush()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn desktop_exec_to_command(command: &str, path: String, is_url: bool) -> (String, String) {
|
||||||
|
/* Purge unused field codes */
|
||||||
|
let command = command
|
||||||
|
.replace("%i", "")
|
||||||
|
.replace("%c", "")
|
||||||
|
.replace("%k", "");
|
||||||
|
if let Some(pos) = command.find("%f").or_else(|| command.find("%F")) {
|
||||||
|
(command[0..pos].trim().to_string(), path)
|
||||||
|
} else if let Some(pos) = command.find("%u").or_else(|| command.find("%U")) {
|
||||||
|
if is_url {
|
||||||
|
(command[0..pos].trim().to_string(), path)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
command[0..pos].trim().to_string(),
|
||||||
|
format!("file://{}", path),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(command, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#[test]
|
||||||
|
fn test_desktop_exec() {
|
||||||
|
for cmd in [
|
||||||
|
"ristretto %F",
|
||||||
|
"/usr/lib/firefox-esr/firefox-esr %u",
|
||||||
|
"/usr/bin/vlc --started-from-file %U",
|
||||||
|
"zathura %U",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
{
|
||||||
|
println!(
|
||||||
|
"cmd = {} output = {:?}, is_url = false",
|
||||||
|
cmd,
|
||||||
|
desktop_exec_to_command(cmd, "/tmp/file".to_string(), false)
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"cmd = {} output = {:?}, is_url = true",
|
||||||
|
cmd,
|
||||||
|
desktop_exec_to_command(cmd, "www.example.com".to_string(), true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -433,43 +433,55 @@ impl Component for EnvelopeView {
|
||||||
));
|
));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ContentType::Other { ref name, .. } => {
|
ContentType::Other { .. } => {
|
||||||
let attachment_type = u.mime_type();
|
let attachment_type = u.mime_type();
|
||||||
let binary = query_default_app(&attachment_type);
|
let filename = u.filename();
|
||||||
if let Ok(binary) = binary {
|
if let Ok(command) = query_default_app(&attachment_type) {
|
||||||
let p = create_temp_file(
|
let p = create_temp_file(
|
||||||
&decode(u, None),
|
&decode(u, None),
|
||||||
name.as_ref().map(String::as_str),
|
filename.as_ref().map(|s| s.as_str()),
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
match Command::new(&binary)
|
let (exec_cmd, argument) = super::desktop_exec_to_command(
|
||||||
.arg(p.path())
|
&command,
|
||||||
|
p.path.display().to_string(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
match Command::new(&exec_cmd)
|
||||||
|
.arg(&argument)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
Ok(child) => {
|
Ok(child) => {
|
||||||
context.children.push(child);
|
|
||||||
context.temp_files.push(p);
|
context.temp_files.push(p);
|
||||||
|
context.children.push(child);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
StatusEvent::DisplayMessage(format!(
|
StatusEvent::DisplayMessage(format!(
|
||||||
"Failed to start {}: {}",
|
"Failed to start `{} {}`: {}",
|
||||||
binary.display(),
|
&exec_cmd, &argument, err
|
||||||
err
|
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
StatusEvent::DisplayMessage(format!(
|
StatusEvent::DisplayMessage(if let Some(filename) = filename.as_ref() {
|
||||||
"Couldn't find a default application for type {}",
|
format!(
|
||||||
attachment_type
|
"Couldn't find a default application for file {} (type {})",
|
||||||
)),
|
filename,
|
||||||
));
|
attachment_type
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"Couldn't find a default application for type {}",
|
||||||
|
attachment_type
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,11 +131,12 @@ impl Component for HtmlView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let UIEvent::Input(Key::Char('v')) = event {
|
if let UIEvent::Input(Key::Char('v')) = event {
|
||||||
let binary = query_default_app("text/html");
|
if let Ok(command) = query_default_app("text/html") {
|
||||||
if let Ok(binary) = binary {
|
|
||||||
let p = create_temp_file(&self.bytes, None, None, true);
|
let p = create_temp_file(&self.bytes, None, None, true);
|
||||||
match Command::new(&binary)
|
let (exec_cmd, argument) =
|
||||||
.arg(p.path())
|
super::desktop_exec_to_command(&command, p.path.display().to_string(), false);
|
||||||
|
match Command::new(&exec_cmd)
|
||||||
|
.arg(&argument)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
|
@ -147,9 +148,8 @@ impl Component for HtmlView {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
StatusEvent::DisplayMessage(format!(
|
StatusEvent::DisplayMessage(format!(
|
||||||
"Failed to start {}: {}",
|
"Failed to start `{} {}`: {}",
|
||||||
binary.display(),
|
&exec_cmd, &argument, err
|
||||||
err
|
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue