Skip to content

Commit

Permalink
add pgp commands support back
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Aug 5, 2023
1 parent 0eed8f3 commit 176da9e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 27 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
63 changes: 44 additions & 19 deletions src/config/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#[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")]
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,
Expand Down Expand Up @@ -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 = "GpgConfig", rename_all = "kebab-case")]
pub struct GpgConfigDef;

#[cfg(feature = "cmds-pgp")]
#[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 = "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)]
Expand All @@ -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;

0 comments on commit 176da9e

Please sign in to comment.