1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#[cfg(feature = "gpgme")]
use super::default_vals::*;
#[cfg(feature = "gpgme")]
use melib::conf::ToggleFlag;
#[cfg(feature = "gpgme")]
#[derive(Debug, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PGPSettings {
#[serde(default = "true_val", alias = "auto-verify-signatures")]
pub auto_verify_signatures: bool,
#[serde(default = "true_val", alias = "auto-decrypt")]
pub auto_decrypt: bool,
#[serde(default = "false_val", alias = "auto-sign")]
pub auto_sign: bool,
#[serde(default = "false_val", alias = "auto-encrypt")]
pub auto_encrypt: bool,
#[serde(default = "none", alias = "sign-key")]
pub sign_key: Option<String>,
#[serde(default = "none", alias = "decrypt-key")]
pub decrypt_key: Option<String>,
#[serde(default = "none", alias = "encrypt-key")]
pub encrypt_key: Option<String>,
#[serde(default = "internal_value_false", alias = "allow-remote-lookups")]
pub allow_remote_lookup: ToggleFlag,
#[serde(
default = "default_lookup_mechanism",
alias = "remote-lookup-mechanisms"
)]
pub remote_lookup_mechanisms: melib::gpgme::LocateKey,
}
#[cfg(feature = "gpgme")]
fn default_lookup_mechanism() -> melib::gpgme::LocateKey {
melib::gpgme::LocateKey::LOCAL | melib::gpgme::LocateKey::WKD
}
#[cfg(feature = "gpgme")]
impl Default for PGPSettings {
fn default() -> Self {
PGPSettings {
auto_verify_signatures: true,
auto_decrypt: true,
auto_sign: false,
auto_encrypt: false,
sign_key: None,
decrypt_key: None,
encrypt_key: None,
allow_remote_lookup: internal_value_false::<ToggleFlag>(),
remote_lookup_mechanisms: default_lookup_mechanism(),
}
}
}
#[cfg(not(feature = "gpgme"))]
#[derive(Debug, Default, Deserialize, Clone, Serialize)]
#[serde(deny_unknown_fields)]
pub struct PGPSettings;