|
|
@ -81,6 +81,7 @@ pub struct Composer {
|
|
|
|
embed_area: Area,
|
|
|
|
embed_area: Area,
|
|
|
|
embed: Option<EmbedStatus>,
|
|
|
|
embed: Option<EmbedStatus>,
|
|
|
|
sign_mail: ToggleFlag,
|
|
|
|
sign_mail: ToggleFlag,
|
|
|
|
|
|
|
|
encrypt_mail: ToggleFlag,
|
|
|
|
dirty: bool,
|
|
|
|
dirty: bool,
|
|
|
|
has_changes: bool,
|
|
|
|
has_changes: bool,
|
|
|
|
initialized: bool,
|
|
|
|
initialized: bool,
|
|
|
@ -103,6 +104,7 @@ impl Default for Composer {
|
|
|
|
|
|
|
|
|
|
|
|
mode: ViewMode::Edit,
|
|
|
|
mode: ViewMode::Edit,
|
|
|
|
sign_mail: ToggleFlag::Unset,
|
|
|
|
sign_mail: ToggleFlag::Unset,
|
|
|
|
|
|
|
|
encrypt_mail: ToggleFlag::Unset,
|
|
|
|
dirty: true,
|
|
|
|
dirty: true,
|
|
|
|
has_changes: false,
|
|
|
|
has_changes: false,
|
|
|
|
embed_area: ((0, 0), (0, 0)),
|
|
|
|
embed_area: ((0, 0), (0, 0)),
|
|
|
@ -451,6 +453,33 @@ impl Composer {
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.encrypt_mail.is_true() {
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
&format!(
|
|
|
|
|
|
|
|
"☑ encrypt with {}",
|
|
|
|
|
|
|
|
account_settings!(context[self.account_hash].pgp.encrypt_key)
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.map(|s| s.as_str())
|
|
|
|
|
|
|
|
.unwrap_or("default key")
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
grid,
|
|
|
|
|
|
|
|
theme_default.fg,
|
|
|
|
|
|
|
|
theme_default.bg,
|
|
|
|
|
|
|
|
theme_default.attrs,
|
|
|
|
|
|
|
|
(pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
write_string_to_grid(
|
|
|
|
|
|
|
|
"☐ don't encrypt",
|
|
|
|
|
|
|
|
grid,
|
|
|
|
|
|
|
|
theme_default.fg,
|
|
|
|
|
|
|
|
theme_default.bg,
|
|
|
|
|
|
|
|
theme_default.attrs,
|
|
|
|
|
|
|
|
(pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
if attachments_no == 0 {
|
|
|
|
if attachments_no == 0 {
|
|
|
|
write_string_to_grid(
|
|
|
|
write_string_to_grid(
|
|
|
|
"no attachments",
|
|
|
|
"no attachments",
|
|
|
@ -458,7 +487,7 @@ impl Composer {
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.attrs,
|
|
|
|
theme_default.attrs,
|
|
|
|
(pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)),
|
|
|
|
(pos_inc(upper_left!(area), (0, 3)), bottom_right!(area)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -468,7 +497,7 @@ impl Composer {
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.attrs,
|
|
|
|
theme_default.attrs,
|
|
|
|
(pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)),
|
|
|
|
(pos_inc(upper_left!(area), (0, 3)), bottom_right!(area)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
for (i, a) in self.draft.attachments().iter().enumerate() {
|
|
|
|
for (i, a) in self.draft.attachments().iter().enumerate() {
|
|
|
@ -485,7 +514,7 @@ impl Composer {
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.attrs,
|
|
|
|
theme_default.attrs,
|
|
|
|
(pos_inc(upper_left!(area), (0, 3 + i)), bottom_right!(area)),
|
|
|
|
(pos_inc(upper_left!(area), (0, 4 + i)), bottom_right!(area)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -495,7 +524,7 @@ impl Composer {
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.fg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.bg,
|
|
|
|
theme_default.attrs,
|
|
|
|
theme_default.attrs,
|
|
|
|
(pos_inc(upper_left!(area), (0, 3 + i)), bottom_right!(area)),
|
|
|
|
(pos_inc(upper_left!(area), (0, 4 + i)), bottom_right!(area)),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -523,6 +552,11 @@ impl Component for Composer {
|
|
|
|
context[self.account_hash].pgp.auto_sign
|
|
|
|
context[self.account_hash].pgp.auto_sign
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.encrypt_mail.is_unset() {
|
|
|
|
|
|
|
|
self.encrypt_mail = ToggleFlag::InternalVal(*account_settings!(
|
|
|
|
|
|
|
|
context[self.account_hash].pgp.auto_encrypt
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
if !self.draft.headers().contains_key("From") || self.draft.headers()["From"].is_empty()
|
|
|
|
if !self.draft.headers().contains_key("From") || self.draft.headers()["From"].is_empty()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
self.draft.set_header(
|
|
|
|
self.draft.set_header(
|
|
|
@ -1323,6 +1357,12 @@ impl Component for Composer {
|
|
|
|
self.dirty = true;
|
|
|
|
self.dirty = true;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Action::Compose(ComposeAction::ToggleEncrypt) => {
|
|
|
|
|
|
|
|
let is_true = self.encrypt_mail.is_true();
|
|
|
|
|
|
|
|
self.encrypt_mail = ToggleFlag::from(!is_true);
|
|
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|