Loading k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java +8 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,14 @@ public class ComposeCryptoStatus { return enablePgpInline; } public boolean isCryptoDisabled() { return cryptoMode == CryptoMode.DISABLE; } public boolean isProviderStateOk() { return cryptoProviderState == CryptoProviderState.OK; } public static class ComposeCryptoStatusBuilder { private CryptoProviderState cryptoProviderState; Loading k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java +1 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public abstract class MessageBuilder { * Build the message to be sent (or saved). If there is another message quoted in this one, it will be baked * into the message here. */ public MimeMessage build() throws MessagingException { protected MimeMessage build() throws MessagingException { //FIXME: check arguments MimeMessage message = new MimeMessage(); Loading k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java +20 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,21 @@ public class PgpMessageBuilder extends MessageBuilder { @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!"); } if (cryptoStatus.isCryptoDisabled()) { throw new AssertionError("PgpMessageBuilder must not be used if crypto is disabled!"); } try { if (!cryptoStatus.isProviderStateOk()) { throw new MessagingException("OpenPGP Provider is not ready!"); } currentProcessedMimeMessage = build(); } catch (MessagingException me) { queueMessageBuildException(me); Loading @@ -62,7 +76,10 @@ public class PgpMessageBuilder extends MessageBuilder { } @Override public void buildMessageOnActivityResult(int requestCode, Intent userInteractionResult) { public void buildMessageOnActivityResult(int requestCode, @NonNull Intent userInteractionResult) { if (currentProcessedMimeMessage == null) { throw new AssertionError("build message from activity result must not be called individually"); } startOrContinueBuildMessage(userInteractionResult); } Loading Loading @@ -119,7 +136,7 @@ public class PgpMessageBuilder extends MessageBuilder { String[] encryptRecipientAddresses = cryptoStatus.getRecipientAddresses(); boolean hasRecipientAddresses = encryptRecipientAddresses != null && encryptRecipientAddresses.length > 0; if (!hasRecipientAddresses) { throw new MessagingException("encryption is enabled, but no encryption key specified!"); throw new MessagingException("encryption is enabled, but no recipient specified!"); } pgpApiIntent.putExtra(OpenPgpApi.EXTRA_USER_IDS, encryptRecipientAddresses); pgpApiIntent.putExtra(OpenPgpApi.EXTRA_ENCRYPT_OPPORTUNISTIC, cryptoStatus.isEncryptionOpportunistic()); Loading Loading @@ -231,7 +248,7 @@ public class PgpMessageBuilder extends MessageBuilder { } private void mimeBuildSignedMessage(@NonNull BodyPart signedBodyPart, Intent result) throws MessagingException { if (!cryptoStatus.isEncryptionEnabled()) { if (!cryptoStatus.isSigningEnabled()) { throw new IllegalStateException("call to mimeBuildSignedMessage while signing isn't enabled!"); } Loading Loading
k9mail/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.java +8 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,14 @@ public class ComposeCryptoStatus { return enablePgpInline; } public boolean isCryptoDisabled() { return cryptoMode == CryptoMode.DISABLE; } public boolean isProviderStateOk() { return cryptoProviderState == CryptoProviderState.OK; } public static class ComposeCryptoStatusBuilder { private CryptoProviderState cryptoProviderState; Loading
k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java +1 −1 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ public abstract class MessageBuilder { * Build the message to be sent (or saved). If there is another message quoted in this one, it will be baked * into the message here. */ public MimeMessage build() throws MessagingException { protected MimeMessage build() throws MessagingException { //FIXME: check arguments MimeMessage message = new MimeMessage(); Loading
k9mail/src/main/java/com/fsck/k9/message/PgpMessageBuilder.java +20 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,21 @@ public class PgpMessageBuilder extends MessageBuilder { @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!"); } if (cryptoStatus.isCryptoDisabled()) { throw new AssertionError("PgpMessageBuilder must not be used if crypto is disabled!"); } try { if (!cryptoStatus.isProviderStateOk()) { throw new MessagingException("OpenPGP Provider is not ready!"); } currentProcessedMimeMessage = build(); } catch (MessagingException me) { queueMessageBuildException(me); Loading @@ -62,7 +76,10 @@ public class PgpMessageBuilder extends MessageBuilder { } @Override public void buildMessageOnActivityResult(int requestCode, Intent userInteractionResult) { public void buildMessageOnActivityResult(int requestCode, @NonNull Intent userInteractionResult) { if (currentProcessedMimeMessage == null) { throw new AssertionError("build message from activity result must not be called individually"); } startOrContinueBuildMessage(userInteractionResult); } Loading Loading @@ -119,7 +136,7 @@ public class PgpMessageBuilder extends MessageBuilder { String[] encryptRecipientAddresses = cryptoStatus.getRecipientAddresses(); boolean hasRecipientAddresses = encryptRecipientAddresses != null && encryptRecipientAddresses.length > 0; if (!hasRecipientAddresses) { throw new MessagingException("encryption is enabled, but no encryption key specified!"); throw new MessagingException("encryption is enabled, but no recipient specified!"); } pgpApiIntent.putExtra(OpenPgpApi.EXTRA_USER_IDS, encryptRecipientAddresses); pgpApiIntent.putExtra(OpenPgpApi.EXTRA_ENCRYPT_OPPORTUNISTIC, cryptoStatus.isEncryptionOpportunistic()); Loading Loading @@ -231,7 +248,7 @@ public class PgpMessageBuilder extends MessageBuilder { } private void mimeBuildSignedMessage(@NonNull BodyPart signedBodyPart, Intent result) throws MessagingException { if (!cryptoStatus.isEncryptionEnabled()) { if (!cryptoStatus.isSigningEnabled()) { throw new IllegalStateException("call to mimeBuildSignedMessage while signing isn't enabled!"); } Loading