Added PGP subject encryption

This commit is contained in:
M66B
2020-11-18 12:01:19 +01:00
parent eb8c715972
commit fc8ae3efc5
5 changed files with 81 additions and 36 deletions

View File

@@ -2336,9 +2336,33 @@ public class FragmentCompose extends FragmentBase {
}
} else {
// Serialize message
try (OutputStream out = new FileOutputStream(input)) {
imessage.writeTo(out);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean encrypt_subject = prefs.getBoolean("encrypt_subject", false);
if (encrypt_subject) {
imessage.saveChanges();
BodyPart bpContent = new MimeBodyPart() {
@Override
public void setContent(Object content, String type) throws MessagingException {
super.setContent(content, type);
updateHeaders();
ContentType ct = new ContentType(type);
ct.setParameter("protected-headers", "v1");
setHeader("Content-Type", ct.toString());
setHeader("Subject", draft.subject == null ? "" : draft.subject);
}
};
bpContent.setContent(imessage.getContent(), imessage.getContentType());
try (OutputStream out = new FileOutputStream(input)) {
bpContent.writeTo(out);
}
} else
try (OutputStream out = new FileOutputStream(input)) {
imessage.writeTo(out);
}
}
}