use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapStore method checkSettings.
public void checkSettings() throws MessagingException {
try {
ImapConnection connection = createImapConnection();
connection.open();
connection.close();
} catch (IOException ioe) {
throw new MessagingException("Unable to connect", ioe);
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapConnection method executeCommandWithIdSet.
@Override
@NotNull
public synchronized List<ImapResponse> executeCommandWithIdSet(@NotNull String commandPrefix, @NotNull String commandSuffix, @NotNull Set<Long> ids) throws IOException, MessagingException {
GroupedIds groupedIds = IdGrouper.groupIds(ids);
List<String> splitCommands = ImapCommandSplitter.splitCommand(commandPrefix, commandSuffix, groupedIds, getLineLengthLimit());
List<ImapResponse> responses = new ArrayList<>();
for (String splitCommand : splitCommands) {
responses.addAll(executeSimpleCommand(splitCommand));
}
return responses;
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class RealImapConnection method open.
@Override
public synchronized void open() throws IOException, MessagingException {
if (open) {
return;
} else if (stacktraceForClose != null) {
throw new IllegalStateException("open() called after close(). " + "Check wrapped exception to see where close() was called.", stacktraceForClose);
}
open = true;
boolean authSuccess = false;
nextCommandTag = 1;
adjustDNSCacheTTL();
try {
socket = connect();
configureSocket();
setUpStreamsAndParserFromSocket();
readInitialResponse();
requestCapabilitiesIfNecessary();
upgradeToTlsIfNecessary();
List<ImapResponse> responses = authenticate();
authSuccess = true;
extractOrRequestCapabilities(responses);
enableCompressionIfRequested();
retrievePathPrefixIfNecessary();
retrievePathDelimiterIfNecessary();
} catch (SSLException e) {
handleSslException(e);
} catch (ConnectException e) {
handleConnectException(e);
} catch (GeneralSecurityException e) {
throw new MessagingException("Unable to open connection to IMAP server due to security error.", e);
} finally {
if (!authSuccess) {
Timber.e("Failed to login, closing connection for %s", getLogId());
close();
}
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class MessageExtractorTest method getTextFromPart_withExceptionThrownGettingInputStream_shouldReturnNull.
@Test
public void getTextFromPart_withExceptionThrownGettingInputStream_shouldReturnNull() throws Exception {
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/html");
Body body = mock(Body.class);
when(body.getInputStream()).thenThrow(new MessagingException("Test"));
part.setBody(body);
String result = MessageExtractor.getTextFromPart(part);
assertNull(result);
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class AttachmentProvider method getAttachmentDataSource.
@Nullable
private OpenPgpDataSource getAttachmentDataSource(String accountUuid, String attachmentId) throws MessagingException {
final Account account = Preferences.getPreferences(getContext()).getAccount(accountUuid);
LocalStore localStore = DI.get(LocalStoreProvider.class).getInstance(account);
return localStore.getAttachmentDataSource(attachmentId);
}
Aggregations