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]]
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",

View file

@ -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"]

View file

@ -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<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")]
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<String>,
}
#[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;