use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class SqlQueryBuilder method getFolderId.
private static long getFolderId(Account account, String folderName) {
long folderId = 0;
try {
LocalStore localStore = account.getLocalStore();
LocalFolder folder = localStore.getFolder(folderName);
folder.open(Folder.OPEN_MODE_RO);
folderId = folder.getId();
} catch (MessagingException e) {
//FIXME
e.printStackTrace();
}
return folderId;
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingController method actOnMessageGroup.
private void actOnMessageGroup(Account account, long folderId, List<MessageReference> messageReferences, MessageActor actor) {
try {
LocalFolder messageFolder = localStoreProvider.getInstance(account).getFolder(folderId);
List<LocalMessage> localMessages = messageFolder.getMessagesByReference(messageReferences);
actor.act(account, messageFolder, localMessages);
} catch (MessagingException e) {
Timber.e(e, "Error loading account?!");
}
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingController method loadMessageMetadata.
public LocalMessage loadMessageMetadata(Account account, long folderId, String uid) throws MessagingException {
LocalStore localStore = localStoreProvider.getInstance(account);
LocalFolder localFolder = localStore.getFolder(folderId);
localFolder.open();
LocalMessage message = localFolder.getMessage(uid);
if (message == null || message.getDatabaseId() == 0) {
String folderName = localFolder.getName();
throw new IllegalArgumentException("Message not found: folder=" + folderName + ", uid=" + uid);
}
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
localFolder.fetch(Collections.singletonList(message), fp, null);
return message;
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingController method clearFolderSynchronous.
@VisibleForTesting
protected void clearFolderSynchronous(Account account, long folderId) {
try {
LocalFolder localFolder = localStoreProvider.getInstance(account).getFolder(folderId);
localFolder.open();
localFolder.clearAllMessages();
} catch (Exception e) {
Timber.e(e, "clearFolder failed");
}
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingController method deleteDraft.
public void deleteDraft(final Account account, long id) {
try {
Long folderId = account.getDraftsFolderId();
if (folderId == null) {
Timber.w("No Drafts folder configured. Can't delete draft.");
return;
}
LocalStore localStore = localStoreProvider.getInstance(account);
LocalFolder localFolder = localStore.getFolder(folderId);
localFolder.open();
String uid = localFolder.getMessageUidById(id);
if (uid != null) {
MessageReference messageReference = new MessageReference(account.getUuid(), folderId, uid);
deleteMessage(messageReference);
}
} catch (MessagingException me) {
Timber.e(me, "Error deleting draft");
}
}
Aggregations