use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.
the class ImapFolderTest method createFetchProfile.
private FetchProfile createFetchProfile(Item... items) {
FetchProfile fetchProfile = new FetchProfile();
Collections.addAll(fetchProfile, items);
return fetchProfile;
}
use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.
the class ImapFolderTest method fetch_withFlagsFetchProfile_shouldIssueRespectiveCommand.
@Test
public void fetch_withFlagsFetchProfile_shouldIssueRespectiveCommand() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RO);
folder.open(OPEN_MODE_RO);
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
List<ImapMessage> messages = createImapMessages("1");
FetchProfile fetchProfile = createFetchProfile(Item.FLAGS);
folder.fetch(messages, fetchProfile, null);
verify(imapConnection).sendCommand("UID FETCH 1 (UID FLAGS)", false);
}
use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.
the class ImapFolderTest method fetch_withEmptyMessageListArgument_shouldDoNothing.
@Test
public void fetch_withEmptyMessageListArgument_shouldDoNothing() throws Exception {
ImapFolder folder = createFolder("Folder");
FetchProfile fetchProfile = createFetchProfile();
folder.fetch(Collections.<ImapMessage>emptyList(), fetchProfile, null);
verifyNoMoreInteractions(imapStore);
}
use of com.fsck.k9.mail.FetchProfile in project k-9 by k9mail.
the class ImapFolderTest method fetch_withBodySaneFetchProfileAndNoMaximumDownloadSize_shouldIssueRespectiveCommand.
@Test
public void fetch_withBodySaneFetchProfileAndNoMaximumDownloadSize_shouldIssueRespectiveCommand() throws Exception {
ImapFolder folder = createFolder("Folder");
prepareImapFolderForOpen(OPEN_MODE_RO);
folder.open(OPEN_MODE_RO);
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
List<ImapMessage> messages = createImapMessages("1");
FetchProfile fetchProfile = createFetchProfile(Item.BODY_SANE);
when(storeConfig.getMaximumAutoDownloadMessageSize()).thenReturn(0);
folder.fetch(messages, fetchProfile, null);
verify(imapConnection).sendCommand("UID FETCH 1 (UID BODY.PEEK[])", false);
}
use of com.fsck.k9.mail.FetchProfile 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!");
}
}
Aggregations