summaryrefslogtreecommitdiffstats
path: root/ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/components/mail/view.rs57
-rw-r--r--ui/src/conf.rs6
-rw-r--r--ui/src/conf/pgp.rs53
3 files changed, 96 insertions, 20 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index 315970aa..cd256f6c 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -195,11 +195,20 @@ impl MailView {
}
} else if a.is_signed() {
v.clear();
- match melib::signatures::verify_signature(a) {
- Ok((bytes, sig)) => {
- let bytes_file = create_temp_file(&bytes, None, None, true);
- let signature_file = create_temp_file(sig, None, None, true);
- if let Ok(gpg) = Command::new("gpg2")
+ if context.settings.pgp.auto_verify_signatures {
+ match melib::signatures::verify_signature(a) {
+ Ok((bytes, sig)) => {
+ let bytes_file = create_temp_file(&bytes, None, None, true);
+ let signature_file = create_temp_file(sig, None, None, true);
+ if let Ok(gpg) = Command::new(
+ context
+ .settings
+ .pgp
+ .gpg_binary
+ .as_ref()
+ .map(String::as_str)
+ .unwrap_or("gpg2"),
+ )
.args(&[
"--output",
"-",
@@ -210,27 +219,35 @@ impl MailView {
.stdin(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
- {
- v.extend(gpg.wait_with_output().unwrap().stderr);
- } else {
- context.replies.push_back(UIEvent::Notification(
- Some(
- "Failed to find an application to verify PGP signature"
+ {
+ v.extend(gpg.wait_with_output().unwrap().stderr);
+ } else {
+ context.replies.push_back(UIEvent::Notification(
+ Some(format!(
+ "Failed to launch {} to verify PGP signature",
+ context
+ .settings
+ .pgp
+ .gpg_binary
+ .as_ref()
+ .map(String::as_str)
+ .unwrap_or("gpg2"),
+ )),
+ "see meli.conf(5) for configuration setting pgp.gpg_binary"
.to_string(),
- ),
+ Some(NotificationType::ERROR),
+ ));
+ return;
+ }
+ }
+ Err(e) => {
+ context.replies.push_back(UIEvent::Notification(
+ Some(e.to_string()),
String::new(),
Some(NotificationType::ERROR),
));
- return;
}
}
- Err(e) => {
- context.replies.push_back(UIEvent::Notification(
- Some(e.to_string()),
- String::new(),
- Some(NotificationType::ERROR),
- ));
- }
}
}
})),
diff --git a/ui/src/conf.rs b/ui/src/conf.rs
index 223c737f..b4ca7967 100644
--- a/ui/src/conf.rs
+++ b/ui/src/conf.rs
@@ -27,11 +27,13 @@ extern crate xdg;
pub mod mailer;
pub mod notifications;
pub mod pager;
+pub mod pgp;
pub mod shortcuts;
pub mod accounts;
pub use self::accounts::Account;
pub use self::mailer::*;
+pub use self::pgp::*;
pub use self::shortcuts::*;
use self::default_vals::*;
@@ -272,6 +274,8 @@ struct FileSettings {
#[serde(default)]
shortcuts: Shortcuts,
mailer: MailerSettings,
+ #[serde(default)]
+ pgp: PGPSettings,
}
#[derive(Debug, Clone, Default)]
@@ -300,6 +304,7 @@ pub struct Settings {
pub notifications: NotificationsSettings,
pub shortcuts: Shortcuts,
pub mailer: MailerSettings,
+ pub pgp: PGPSettings,
}
impl FileSettings {
@@ -387,6 +392,7 @@ impl Settings {
notifications: fs.notifications,
shortcuts: fs.shortcuts,
mailer: fs.mailer,
+ pgp: fs.pgp,
}
}
}
diff --git a/ui/src/conf/pgp.rs b/ui/src/conf/pgp.rs
new file mode 100644
index 00000000..f7c59e1f
--- /dev/null
+++ b/ui/src/conf/pgp.rs
@@ -0,0 +1,53 @@
+/*
+ * meli - configuration module.
+ *
+ * Copyright 2019 Manos Pitsidianakis
+ *
+ * This file is part of meli.
+ *
+ * meli is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * meli is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with meli. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+use super::default_vals::*;
+
+/// Settings for digital signing and encryption
+#[derive(Debug, Deserialize, Clone, Serialize)]
+pub struct PGPSettings {
+ /// auto verify signed e-mail according to RFC3156
+ #[serde(default = "true_val")]
+ pub auto_verify_signatures: bool,
+
+ /// always sign sent messages
+ #[serde(default = "false_val")]
+ pub auto_sign: bool,
+
+ // https://tools.ietf.org/html/rfc4880#section-12.2
+ #[serde(default = "none")]
+ pub key: Option<String>,
+
+ /// gpg binary name or file location to use
+ #[serde(default)]
+ pub gpg_binary: Option<String>,
+}
+
+impl Default for PGPSettings {
+ fn default() -> Self {
+ PGPSettings {
+ auto_verify_signatures: true,
+ auto_sign: false,
+ key: None,
+ gpg_binary: None,
+ }
+ }
+}