add pgp commands support back

This commit is contained in:
Clément DOUIN 2023-08-05 22:53:39 +02:00
parent 0eed8f355d
commit 176da9eeeb
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
3 changed files with 55 additions and 27 deletions

15
Cargo.lock generated
View file

@ -2506,7 +2506,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-email" name = "pimalaya-email"
version = "0.14.1-beta" version = "0.14.1-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"advisory-lock", "advisory-lock",
"ammonia", "ammonia",
@ -2553,7 +2553,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-email-tpl" name = "pimalaya-email-tpl"
version = "0.3.2-beta" version = "0.3.2-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"chumsky 0.9.0", "chumsky 0.9.0",
@ -2564,6 +2564,7 @@ dependencies = [
"nanohtml2text", "nanohtml2text",
"pimalaya-keyring", "pimalaya-keyring",
"pimalaya-pgp", "pimalaya-pgp",
"pimalaya-process",
"pimalaya-secret", "pimalaya-secret",
"shellexpand", "shellexpand",
"thiserror", "thiserror",
@ -2573,7 +2574,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-keyring" name = "pimalaya-keyring"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"keyring", "keyring",
"log", "log",
@ -2583,7 +2584,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-oauth2" name = "pimalaya-oauth2"
version = "0.0.5-beta" version = "0.0.5-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"log", "log",
"oauth2", "oauth2",
@ -2596,7 +2597,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-pgp" name = "pimalaya-pgp"
version = "0.0.1" version = "0.0.1"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"futures", "futures",
@ -2616,7 +2617,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-process" name = "pimalaya-process"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"log", "log",
"thiserror", "thiserror",
@ -2626,7 +2627,7 @@ dependencies = [
[[package]] [[package]]
name = "pimalaya-secret" name = "pimalaya-secret"
version = "0.0.6-beta" version = "0.0.6-beta"
source = "git+https://git.sr.ht/~soywod/pimalaya#5241ece85e1ed8837bec4076664604c566d45bff" source = "git+https://git.sr.ht/~soywod/pimalaya#b979746e0a9b5bce0a5a85a2779f8b8477a1b1c5"
dependencies = [ dependencies = [
"log", "log",
"pimalaya-keyring", "pimalaya-keyring",

View file

@ -15,12 +15,14 @@ repository = "https://github.com/soywod/himalaya"
all-features = true all-features = true
[features] [features]
default = ["imap-backend", "smtp-sender"] default = ["imap-backend", "smtp-sender", "cmds-pgp"]
# backends # backends
imap-backend = ["pimalaya-email/imap-backend"] imap-backend = ["pimalaya-email/imap-backend"]
notmuch-backend = ["pimalaya-email/notmuch-backend"] notmuch-backend = ["pimalaya-email/notmuch-backend"]
cmds-pgp = ["pimalaya-email/cmds-pgp"]
gpg = ["pimalaya-email/gpg"] gpg = ["pimalaya-email/gpg"]
native-pgp = ["pimalaya-email/native-pgp"]
# senders # senders
smtp-sender = ["pimalaya-email/smtp-sender"] smtp-sender = ["pimalaya-email/smtp-sender"]

View file

@ -1,5 +1,9 @@
#[cfg(feature = "cmds-pgp")]
use pimalaya_email::account::CmdsPgpConfig;
#[cfg(feature = "gpg")] #[cfg(feature = "gpg")]
use pimalaya_email::account::GpgConfig; use pimalaya_email::account::GpgConfig;
#[cfg(feature = "native-pgp")]
use pimalaya_email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey};
#[cfg(feature = "notmuch-backend")] #[cfg(feature = "notmuch-backend")]
use pimalaya_email::backend::NotmuchConfig; use pimalaya_email::backend::NotmuchConfig;
#[cfg(feature = "imap-backend")] #[cfg(feature = "imap-backend")]
@ -7,10 +11,7 @@ use pimalaya_email::backend::{ImapAuthConfig, ImapConfig};
#[cfg(feature = "smtp-sender")] #[cfg(feature = "smtp-sender")]
use pimalaya_email::sender::{SmtpAuthConfig, SmtpConfig}; use pimalaya_email::sender::{SmtpAuthConfig, SmtpConfig};
use pimalaya_email::{ use pimalaya_email::{
account::{ account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig, PgpConfig},
OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig, PgpConfig, PgpNativeConfig,
PgpNativeSecretKey, SignedSecretKey,
},
backend::{BackendConfig, MaildirConfig}, backend::{BackendConfig, MaildirConfig},
email::{EmailHooks, EmailTextPlainFormat}, email::{EmailHooks, EmailTextPlainFormat},
folder::sync::FolderSyncStrategy, folder::sync::FolderSyncStrategy,
@ -398,29 +399,58 @@ pub enum FolderSyncStrategyDef {
pub enum PgpConfigDef { pub enum PgpConfigDef {
#[default] #[default]
None, None,
#[serde(with = "PgpNativeConfigDef")] #[cfg(feature = "cmds-pgp")]
Native(PgpNativeConfig), #[serde(with = "CmdsPgpConfigDef", alias = "commands")]
Cmds(CmdsPgpConfig),
#[cfg(feature = "gpg")] #[cfg(feature = "gpg")]
#[serde(with = "GpgConfigDef")] #[serde(with = "GpgConfigDef")]
Gpg(GpgConfig), Gpg(GpgConfig),
#[cfg(feature = "native-pgp")]
#[serde(with = "NativePgpConfigDef")]
Native(NativePgpConfig),
} }
#[cfg(feature = "gpg")]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(remote = "PgpNativeConfig", rename_all = "kebab-case")] #[serde(remote = "GpgConfig", rename_all = "kebab-case")]
pub struct PgpNativeConfigDef { pub struct GpgConfigDef;
#[serde(default, with = "PgpNativeSecretKeyDef")]
secret_key: PgpNativeSecretKey, #[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<Cmd>,
#[serde(default)]
encrypt_recipient_fmt: Option<String>,
#[serde(default)]
encrypt_recipients_sep: Option<String>,
#[serde(default, with = "OptionCmdDef")]
decrypt_cmd: Option<Cmd>,
#[serde(default, with = "OptionCmdDef")]
sign_cmd: Option<Cmd>,
#[serde(default, with = "OptionCmdDef")]
verify_cmd: Option<Cmd>,
}
#[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")] #[serde(default, with = "SecretDef")]
secret_key_passphrase: Secret, secret_key_passphrase: Secret,
#[serde(default = "PgpNativeConfig::default_wkd")] #[serde(default = "NativePgpConfig::default_wkd")]
wkd: bool, wkd: bool,
#[serde(default = "PgpNativeConfig::default_key_servers")] #[serde(default = "NativePgpConfig::default_key_servers")]
key_servers: Vec<String>, key_servers: Vec<String>,
} }
#[cfg(feature = "native-pgp")]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(remote = "PgpNativeSecretKey", rename_all = "kebab-case")] #[serde(remote = "NativePgpSecretKey", rename_all = "kebab-case")]
pub enum PgpNativeSecretKeyDef { pub enum NativePgpSecretKeyDef {
#[default] #[default]
None, None,
#[serde(skip)] #[serde(skip)]
@ -429,8 +459,3 @@ pub enum PgpNativeSecretKeyDef {
#[serde(with = "EntryDef")] #[serde(with = "EntryDef")]
Keyring(Entry), Keyring(Entry),
} }
#[cfg(feature = "gpg")]
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(remote = "GpgConfig", rename_all = "kebab-case")]
pub struct GpgConfigDef;