use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class ImapFolderTest method getUnreadMessageCount_connectionThrowsIOException_shouldThrowMessagingException.
@Test
public void getUnreadMessageCount_connectionThrowsIOException_shouldThrowMessagingException() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RW);
when(imapConnection.executeSimpleCommand("SEARCH 1:* UNSEEN NOT DELETED")).thenThrow(new IOException());
folder.open(OPEN_MODE_RW);
try {
folder.getUnreadMessageCount();
fail("Expected exception");
} catch (MessagingException e) {
assertEquals("IO Error", e.getMessage());
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class ImapFolderTest method areMoreMessagesAvailable_withClosedFolder_shouldThrow.
@Test
public void areMoreMessagesAvailable_withClosedFolder_shouldThrow() throws Exception {
ImapFolder folder = createFolder("Folder");
when(imapStore.getConnection()).thenReturn(imapConnection);
try {
folder.areMoreMessagesAvailable(10, new Date());
fail("Expected exception");
} catch (MessagingException e) {
assertCheckOpenErrorMessage("Folder", e);
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class MigrationTo55 method createFtsSearchTable.
static void createFtsSearchTable(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
db.execSQL("CREATE VIRTUAL TABLE messages_fulltext USING fts4 (fulltext)");
LocalStore localStore = migrationsHelper.getLocalStore();
MessageFulltextCreator fulltextCreator = localStore.getMessageFulltextCreator();
try {
List<LocalFolder> folders = localStore.getPersonalNamespaces(true);
ContentValues cv = new ContentValues();
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.BODY);
for (LocalFolder folder : folders) {
List<String> messageUids = folder.getAllMessageUids();
for (String messageUid : messageUids) {
LocalMessage localMessage = folder.getMessage(messageUid);
folder.fetch(Collections.singletonList(localMessage), fp, null);
String fulltext = fulltextCreator.createFulltext(localMessage);
if (!TextUtils.isEmpty(fulltext)) {
Timber.d("fulltext for msg id %d is %d chars long", localMessage.getId(), fulltext.length());
cv.clear();
cv.put("docid", localMessage.getId());
cv.put("fulltext", fulltext);
db.insert("messages_fulltext", null, cv);
} else {
Timber.d("no fulltext for msg id %d :(", localMessage.getId());
}
}
}
} catch (MessagingException e) {
Timber.e(e, "error indexing fulltext - skipping rest, fts index is incomplete!");
}
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class MessageViewInfoExtractor method extractMessageForView.
@WorkerThread
public MessageViewInfo extractMessageForView(Message message, @Nullable MessageCryptoAnnotations annotations) throws MessagingException {
Part rootPart;
CryptoResultAnnotation cryptoResultAnnotation;
List<Part> extraParts;
CryptoMessageParts cryptoMessageParts = MessageCryptoSplitter.split(message, annotations);
if (cryptoMessageParts != null) {
rootPart = cryptoMessageParts.contentPart;
cryptoResultAnnotation = cryptoMessageParts.contentCryptoAnnotation;
extraParts = cryptoMessageParts.extraParts;
} else {
if (annotations != null && !annotations.isEmpty()) {
Timber.e("Got message annotations but no crypto root part!");
}
rootPart = message;
cryptoResultAnnotation = null;
extraParts = null;
}
List<AttachmentViewInfo> attachmentInfos = new ArrayList<>();
ViewableExtractedText viewable = extractViewableAndAttachments(Collections.singletonList(rootPart), attachmentInfos);
List<AttachmentViewInfo> extraAttachmentInfos = new ArrayList<>();
String extraViewableText = null;
if (extraParts != null) {
ViewableExtractedText extraViewable = extractViewableAndAttachments(extraParts, extraAttachmentInfos);
extraViewableText = extraViewable.text;
}
AttachmentResolver attachmentResolver = AttachmentResolver.createFromPart(rootPart);
boolean isMessageIncomplete = !message.isSet(Flag.X_DOWNLOADED_FULL) || MessageExtractor.hasMissingParts(message);
return MessageViewInfo.createWithExtractedContent(message, isMessageIncomplete, rootPart, viewable.html, attachmentInfos, cryptoResultAnnotation, attachmentResolver, extraViewableText, extraAttachmentInfos);
}
use of com.fsck.k9.mail.MessagingException in project k-9 by k9mail.
the class LocalFolder method saveMessagePart.
private long saveMessagePart(SQLiteDatabase db, PartContainer partContainer, long rootMessagePartId, int order) throws IOException, MessagingException {
Part part = partContainer.part;
ContentValues cv = new ContentValues();
if (rootMessagePartId != -1) {
cv.put("root", rootMessagePartId);
}
cv.put("parent", partContainer.parent);
cv.put("seq", order);
cv.put("server_extra", part.getServerExtra());
return updateOrInsertMessagePart(db, cv, part, INVALID_MESSAGE_PART_ID);
}
Aggregations