Search in sources :

Example 1 with CryptoProviderState

use of com.fsck.k9.activity.compose.RecipientPresenter.CryptoProviderState in project k-9 by k9mail.

the class RecipientPresenter method getCurrentCryptoStatus.

public ComposeCryptoStatus getCurrentCryptoStatus() {
    if (cachedCryptoStatus == null) {
        ComposeCryptoStatusBuilder builder = new ComposeCryptoStatusBuilder().setCryptoProviderState(cryptoProviderState).setCryptoMode(currentCryptoMode).setEnablePgpInline(cryptoEnablePgpInline).setRecipients(getAllRecipients());
        long accountCryptoKey = account.getCryptoKey();
        if (accountCryptoKey != Account.NO_OPENPGP_KEY) {
            // TODO split these into individual settings? maybe after key is bound to identity
            builder.setSigningKeyId(accountCryptoKey);
            builder.setSelfEncryptId(accountCryptoKey);
        }
        cachedCryptoStatus = builder.build();
    }
    return cachedCryptoStatus;
}
Also used : ComposeCryptoStatusBuilder(com.fsck.k9.activity.compose.ComposeCryptoStatus.ComposeCryptoStatusBuilder)

Example 2 with CryptoProviderState

use of com.fsck.k9.activity.compose.RecipientPresenter.CryptoProviderState in project k-9 by k9mail.

the class PgpMessageBuilderTest method build__withCryptoProviderNotOk__shouldThrow.

@Test
public void build__withCryptoProviderNotOk__shouldThrow() throws MessagingException {
    cryptoStatusBuilder.setCryptoMode(CryptoMode.SIGN_ONLY);
    CryptoProviderState[] cryptoProviderStates = { CryptoProviderState.LOST_CONNECTION, CryptoProviderState.UNCONFIGURED, CryptoProviderState.UNINITIALIZED, CryptoProviderState.ERROR };
    for (CryptoProviderState state : cryptoProviderStates) {
        cryptoStatusBuilder.setCryptoProviderState(state);
        pgpMessageBuilder.setCryptoStatus(cryptoStatusBuilder.build());
        Callback mockCallback = mock(Callback.class);
        pgpMessageBuilder.buildAsync(mockCallback);
        verify(mockCallback).onMessageBuildException(any(MessagingException.class));
        verifyNoMoreInteractions(mockCallback);
    }
}
Also used : CryptoProviderState(com.fsck.k9.activity.compose.RecipientPresenter.CryptoProviderState) Callback(com.fsck.k9.message.MessageBuilder.Callback) MessagingException(com.fsck.k9.mail.MessagingException) Test(org.junit.Test)

Aggregations

ComposeCryptoStatusBuilder (com.fsck.k9.activity.compose.ComposeCryptoStatus.ComposeCryptoStatusBuilder)1 CryptoProviderState (com.fsck.k9.activity.compose.RecipientPresenter.CryptoProviderState)1 MessagingException (com.fsck.k9.mail.MessagingException)1 Callback (com.fsck.k9.message.MessageBuilder.Callback)1 Test (org.junit.Test)1