From 176da9eeeb679731231da82c70ebf129f41deeb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Sat, 5 Aug 2023 22:53:39 +0200 Subject: [PATCH] add pgp commands support back --- Cargo.lock | 15 ++++++----- Cargo.toml | 4 ++- src/config/prelude.rs | 63 ++++++++++++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0e4b4a..c605026 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2506,7 +2506,7 @@ dependencies = [ [[package]] name = "pimalaya-email" version = "0.14.1-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "advisory-lock", "ammonia", @@ -2553,7 +2553,7 @@ dependencies = [ [[package]] name = "pimalaya-email-tpl" version = "0.3.2-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "async-recursion", "chumsky 0.9.0", @@ -2564,6 +2564,7 @@ dependencies = [ "nanohtml2text", "pimalaya-keyring", "pimalaya-pgp", + "pimalaya-process", "pimalaya-secret", "shellexpand", "thiserror", @@ -2573,7 +2574,7 @@ dependencies = [ [[package]] name = "pimalaya-keyring" version = "0.0.6-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "keyring", "log", @@ -2583,7 +2584,7 @@ dependencies = [ [[package]] name = "pimalaya-oauth2" version = "0.0.5-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "log", "oauth2", @@ -2596,7 +2597,7 @@ dependencies = [ [[package]] name = "pimalaya-pgp" version = "0.0.1" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "async-recursion", "futures", @@ -2616,7 +2617,7 @@ dependencies = [ [[package]] name = "pimalaya-process" version = "0.0.6-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "log", "thiserror", @@ -2626,7 +2627,7 @@ dependencies = [ [[package]] name = "pimalaya-secret" version = "0.0.6-beta" -source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" +source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5" dependencies = [ "log", "pimalaya-keyring", diff --git a/Cargo.toml b/Cargo.toml index a809d96..15c62ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,14 @@ repository = "https://github.com/soywod/himalaya" all-features = true [features] -default = ["imap-backend", "smtp-sender"] +default = ["imap-backend", "smtp-sender", "cmds-pgp"] # backends imap-backend = ["pimalaya-email/imap-backend"] notmuch-backend = ["pimalaya-email/notmuch-backend"] +cmds-pgp = ["pimalaya-email/cmds-pgp"] gpg = ["pimalaya-email/gpg"] +native-pgp = ["pimalaya-email/native-pgp"] # senders smtp-sender = ["pimalaya-email/smtp-sender"] diff --git a/src/config/prelude.rs b/src/config/prelude.rs index 863d69b..cf9c443 100644 --- a/src/config/prelude.rs +++ b/src/config/prelude.rs @@ -1,5 +1,9 @@ +#[cfg(feature = "cmds-pgp")] +use pimalaya_email::account::CmdsPgpConfig; #[cfg(feature = "gpg")] use pimalaya_email::account::GpgConfig; +#[cfg(feature = "native-pgp")] +use pimalaya_email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey}; #[cfg(feature = "notmuch-backend")] use pimalaya_email::backend::NotmuchConfig; #[cfg(feature = "imap-backend")] @@ -7,10 +11,7 @@ use pimalaya_email::backend::{ImapAuthConfig, ImapConfig}; #[cfg(feature = "smtp-sender")] use pimalaya_email::sender::{SmtpAuthConfig, SmtpConfig}; use pimalaya_email::{ - account::{ - OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig, PgpConfig, PgpNativeConfig, - PgpNativeSecretKey, SignedSecretKey, - }, + account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig, PgpConfig}, backend::{BackendConfig, MaildirConfig}, email::{EmailHooks, EmailTextPlainFormat}, folder::sync::FolderSyncStrategy, @@ -398,29 +399,58 @@ pub enum FolderSyncStrategyDef { pub enum PgpConfigDef { #[default] None, - #[serde(with = "PgpNativeConfigDef")] - Native(PgpNativeConfig), + #[cfg(feature = "cmds-pgp")] + #[serde(with = "CmdsPgpConfigDef", alias = "commands")] + Cmds(CmdsPgpConfig), #[cfg(feature = "gpg")] #[serde(with = "GpgConfigDef")] Gpg(GpgConfig), + #[cfg(feature = "native-pgp")] + #[serde(with = "NativePgpConfigDef")] + Native(NativePgpConfig), } +#[cfg(feature = "gpg")] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] -#[serde(remote = "PgpNativeConfig", rename_all = "kebab-case")] -pub struct PgpNativeConfigDef { - #[serde(default, with = "PgpNativeSecretKeyDef")] - secret_key: PgpNativeSecretKey, +#[serde(remote = "GpgConfig", rename_all = "kebab-case")] +pub struct GpgConfigDef; + +#[cfg(feature = "cmds-pgp")] +#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] +#[serde(remote = "CmdsPgpConfig", rename_all = "kebab-case")] +pub struct CmdsPgpConfigDef { + #[serde(default, with = "OptionCmdDef")] + encrypt_cmd: Option, + #[serde(default)] + encrypt_recipient_fmt: Option, + #[serde(default)] + encrypt_recipients_sep: Option, + #[serde(default, with = "OptionCmdDef")] + decrypt_cmd: Option, + #[serde(default, with = "OptionCmdDef")] + sign_cmd: Option, + #[serde(default, with = "OptionCmdDef")] + verify_cmd: Option, +} + +#[cfg(feature = "native-pgp")] +#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] +#[serde(remote = "NativePgpConfig", rename_all = "kebab-case")] +pub struct NativePgpConfigDef { + #[serde(default, with = "NativePgpSecretKeyDef")] + secret_key: NativePgpSecretKey, #[serde(default, with = "SecretDef")] secret_key_passphrase: Secret, - #[serde(default = "PgpNativeConfig::default_wkd")] + #[serde(default = "NativePgpConfig::default_wkd")] wkd: bool, - #[serde(default = "PgpNativeConfig::default_key_servers")] + #[serde(default = "NativePgpConfig::default_key_servers")] key_servers: Vec, } +#[cfg(feature = "native-pgp")] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] -#[serde(remote = "PgpNativeSecretKey", rename_all = "kebab-case")] -pub enum PgpNativeSecretKeyDef { +#[serde(remote = "NativePgpSecretKey", rename_all = "kebab-case")] +pub enum NativePgpSecretKeyDef { #[default] None, #[serde(skip)] @@ -429,8 +459,3 @@ pub enum PgpNativeSecretKeyDef { #[serde(with = "EntryDef")] Keyring(Entry), } - -#[cfg(feature = "gpg")] -#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] -#[serde(remote = "GpgConfig", rename_all = "kebab-case")] -pub struct GpgConfigDef;