use of com.fsck.k9.message.PgpMessageBuilder in project k-9 by k9mail.
the class PgpMessageBuilderTest method createDefaultPgpMessageBuilder.
private static PgpMessageBuilder createDefaultPgpMessageBuilder(OpenPgpApi openPgpApi) {
PgpMessageBuilder builder = new PgpMessageBuilder(RuntimeEnvironment.application, MessageIdGenerator.getInstance(), BoundaryGenerator.getInstance());
builder.setOpenPgpApi(openPgpApi);
Identity identity = new Identity();
identity.setName("tester");
identity.setEmail("test@example.org");
identity.setDescription("test identity");
identity.setSignatureUse(false);
builder.setSubject("subject").setSentDate(new Date()).setHideTimeZone(false).setTo(new ArrayList<Address>()).setCc(new ArrayList<Address>()).setBcc(new ArrayList<Address>()).setInReplyTo("inreplyto").setReferences("references").setRequestReadReceipt(false).setIdentity(identity).setMessageFormat(SimpleMessageFormat.TEXT).setText(TEST_MESSAGE_TEXT).setAttachments(new ArrayList<Attachment>()).setSignature("signature").setQuoteStyle(QuoteStyle.PREFIX).setQuotedTextMode(QuotedTextMode.NONE).setQuotedText("quoted text").setQuotedHtmlContent(new InsertableHtmlContent()).setReplyAfterQuote(false).setSignatureBeforeQuotedText(false).setIdentityChanged(false).setSignatureChanged(false).setCursorPosition(0).setMessageReference(null).setDraft(false);
return builder;
}
use of com.fsck.k9.message.PgpMessageBuilder in project k-9 by k9mail.
the class MessageCompose method onMessageBuildSuccess.
@Override
public void onMessageBuildSuccess(MimeMessage message, boolean isDraft) {
String plaintextSubject = (currentMessageBuilder instanceof PgpMessageBuilder) ? currentMessageBuilder.getSubject() : null;
if (isDraft) {
changesMadeSinceLastSave = false;
currentMessageBuilder = null;
new SaveMessageTask(messagingController, account, internalMessageHandler, message, draftMessageId, plaintextSubject).execute();
if (finishAfterDraftSaved) {
finish();
} else {
setProgressBarIndeterminateVisibility(false);
}
} else {
currentMessageBuilder = null;
new SendMessageTask(messagingController, preferences, account, contacts, message, draftMessageId, plaintextSubject, relatedMessageReference, relatedFlag).execute();
finish();
}
}
use of com.fsck.k9.message.PgpMessageBuilder in project k-9 by k9mail.
the class PgpMessageBuilder method buildMessageInternal.
@Override
protected void buildMessageInternal() {
if (currentProcessedMimeMessage != null) {
throw new IllegalStateException("message can only be built once!");
}
if (cryptoStatus == null) {
throw new IllegalStateException("PgpMessageBuilder must have cryptoStatus set before building!");
}
Long openPgpKeyId = cryptoStatus.getOpenPgpKeyId();
try {
currentProcessedMimeMessage = build();
} catch (MessagingException me) {
queueMessageBuildException(me);
return;
}
if (openPgpKeyId == null) {
queueMessageBuildSuccess(currentProcessedMimeMessage);
return;
}
if (!cryptoStatus.isProviderStateOk()) {
queueMessageBuildException(new MessagingException("OpenPGP Provider is not ready!"));
return;
}
addAutocryptHeaderIfAvailable(openPgpKeyId);
if (isDraft()) {
addDraftStateHeader();
}
startOrContinueBuildMessage(null);
}
use of com.fsck.k9.message.PgpMessageBuilder in project k-9 by k9mail.
the class PgpMessageBuilder method newInstance.
public static PgpMessageBuilder newInstance() {
MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();
AutocryptOperations autocryptOperations = AutocryptOperations.getInstance();
AutocryptOpenPgpApiInteractor autocryptOpenPgpApiInteractor = AutocryptOpenPgpApiInteractor.getInstance();
CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
return new PgpMessageBuilder(messageIdGenerator, boundaryGenerator, autocryptOperations, autocryptOpenPgpApiInteractor, resourceProvider);
}
use of com.fsck.k9.message.PgpMessageBuilder in project k-9 by k9mail.
the class MessageCompose method createMessageBuilder.
@Nullable
private MessageBuilder createMessageBuilder(boolean isDraft) {
MessageBuilder builder;
ComposeCryptoStatus cryptoStatus = recipientPresenter.getCurrentCachedCryptoStatus();
if (cryptoStatus == null) {
return null;
}
boolean shouldUsePgpMessageBuilder = cryptoStatus.isOpenPgpConfigured();
if (shouldUsePgpMessageBuilder) {
SendErrorState maybeSendErrorState = cryptoStatus.getSendErrorStateOrNull();
if (maybeSendErrorState != null) {
recipientPresenter.showPgpSendError(maybeSendErrorState);
return null;
}
PgpMessageBuilder pgpBuilder = PgpMessageBuilder.newInstance();
recipientPresenter.builderSetProperties(pgpBuilder, cryptoStatus);
builder = pgpBuilder;
} else {
builder = SimpleMessageBuilder.newInstance();
recipientPresenter.builderSetProperties(builder);
}
builder.setSubject(Utility.stripNewLines(subjectView.getText().toString())).setSentDate(new Date()).setHideTimeZone(K9.isHideTimeZone()).setInReplyTo(repliedToMessageId).setReferences(referencedMessageIds).setRequestReadReceipt(requestReadReceipt).setIdentity(identity).setReplyTo(replyToPresenter.getAddresses()).setMessageFormat(currentMessageFormat).setText(CrLfConverter.toCrLf(messageContentView.getText())).setAttachments(attachmentPresenter.getAttachments()).setInlineAttachments(attachmentPresenter.getInlineAttachments()).setSignature(CrLfConverter.toCrLf(signatureView.getText())).setSignatureBeforeQuotedText(account.isSignatureBeforeQuotedText()).setIdentityChanged(identityChanged).setSignatureChanged(signatureChanged).setCursorPosition(messageContentView.getSelectionStart()).setMessageReference(relatedMessageReference).setDraft(isDraft).setIsPgpInlineEnabled(cryptoStatus.isPgpInlineModeEnabled());
quotedMessagePresenter.builderSetProperties(builder);
return builder;
}
Aggregations