Merge pull request #2693 from k9mail/cleanup-localstore-classes
Cleanup localstore classes
This commit is contained in:
commit
65dc6d12fd
19 changed files with 345 additions and 341 deletions
|
@ -144,8 +144,6 @@ public abstract class Message implements Part, Body {
|
|||
@Override
|
||||
public abstract void setBody(Body body);
|
||||
|
||||
public abstract long getId();
|
||||
|
||||
public abstract boolean hasAttachments();
|
||||
|
||||
public abstract long getSize();
|
||||
|
|
|
@ -688,11 +688,6 @@ public class MimeMessage extends Message {
|
|||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return Long.parseLong(mUid); //or maybe .mMessageId?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttachments() {
|
||||
return false;
|
||||
|
|
|
@ -126,8 +126,8 @@ public class EmailProviderCache {
|
|||
public void hideMessages(List<LocalMessage> messages) {
|
||||
synchronized (mHiddenMessageCache) {
|
||||
for (LocalMessage message : messages) {
|
||||
long messageId = message.getId();
|
||||
mHiddenMessageCache.put(messageId, message.getFolder().getId());
|
||||
long messageId = message.getDatabaseId();
|
||||
mHiddenMessageCache.put(messageId, message.getFolder().getDatabaseId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,8 +145,8 @@ public class EmailProviderCache {
|
|||
synchronized (mHiddenMessageCache) {
|
||||
for (Message message : messages) {
|
||||
LocalMessage localMessage = (LocalMessage) message;
|
||||
long messageId = localMessage.getId();
|
||||
long folderId = ((LocalFolder) localMessage.getFolder()).getId();
|
||||
long messageId = localMessage.getDatabaseId();
|
||||
long folderId = ((LocalFolder) localMessage.getFolder()).getDatabaseId();
|
||||
Long hiddenInFolder = mHiddenMessageCache.get(messageId);
|
||||
|
||||
if (hiddenInFolder != null && hiddenInFolder.longValue() == folderId) {
|
||||
|
|
|
@ -305,8 +305,8 @@ public class MessagingController {
|
|||
}
|
||||
|
||||
private boolean isMessageSuppressed(LocalMessage message) {
|
||||
long messageId = message.getId();
|
||||
long folderId = message.getFolder().getId();
|
||||
long messageId = message.getDatabaseId();
|
||||
long folderId = message.getFolder().getDatabaseId();
|
||||
|
||||
EmailProviderCache cache = EmailProviderCache.getCache(message.getFolder().getAccountUuid(), context);
|
||||
return cache.isMessageHidden(messageId, folderId);
|
||||
|
@ -2511,7 +2511,7 @@ public class MessagingController {
|
|||
localFolder.open(Folder.OPEN_MODE_RW);
|
||||
|
||||
LocalMessage message = localFolder.getMessage(uid);
|
||||
if (message == null || message.getId() == 0) {
|
||||
if (message == null || message.getDatabaseId() == 0) {
|
||||
throw new IllegalArgumentException("Message not found: folder=" + folderName + ", uid=" + uid);
|
||||
}
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ public class MessagingController {
|
|||
throws MessagingException {
|
||||
|
||||
if (account.isMarkMessageAsReadOnView() && !message.isSet(Flag.SEEN)) {
|
||||
List<Long> messageIds = Collections.singletonList(message.getId());
|
||||
List<Long> messageIds = Collections.singletonList(message.getDatabaseId());
|
||||
setFlag(account, messageIds, Flag.SEEN, true);
|
||||
|
||||
message.setFlagInternal(Flag.SEEN, true);
|
||||
|
@ -2721,7 +2721,7 @@ public class MessagingController {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
|
||||
Timber.i("Scanning folder '%s' (%d) for messages to send",
|
||||
account.getOutboxFolderName(), localFolder.getId());
|
||||
account.getOutboxFolderName(), localFolder.getDatabaseId());
|
||||
|
||||
Transport transport = transportProvider.getTransport(K9.app, account);
|
||||
|
||||
|
@ -2836,11 +2836,11 @@ public class MessagingController {
|
|||
message.setFlag(Flag.DELETED, true);
|
||||
} else {
|
||||
LocalFolder localSentFolder = localStore.getFolder(account.getSentFolderName());
|
||||
Timber.i("Moving sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
|
||||
Timber.i("Moving sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getDatabaseId());
|
||||
|
||||
localFolder.moveMessages(Collections.singletonList(message), localSentFolder);
|
||||
|
||||
Timber.i("Moved sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
|
||||
Timber.i("Moved sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getDatabaseId());
|
||||
|
||||
PendingCommand command = PendingAppend.create(localSentFolder.getName(), message.getUid());
|
||||
queuePendingCommand(account, command);
|
||||
|
@ -3996,7 +3996,7 @@ public class MessagingController {
|
|||
public long getId(Message message) {
|
||||
long id;
|
||||
if (message instanceof LocalMessage) {
|
||||
id = message.getId();
|
||||
id = ((LocalMessage) message).getDatabaseId();
|
||||
} else {
|
||||
Timber.w("MessagingController.getId() called without a LocalMessage");
|
||||
id = INVALID_MESSAGE_ID;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class LocalBodyPart extends MimeBodyPart implements LocalPart {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
public long getPartId() {
|
||||
return messagePartId;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
@ -69,53 +68,57 @@ import org.apache.james.mime4j.util.MimeUtil;
|
|||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1973296520918624767L;
|
||||
public class LocalFolder extends Folder<LocalMessage> {
|
||||
private static final int MAX_BODY_SIZE_FOR_DATABASE = 16 * 1024;
|
||||
static final long INVALID_MESSAGE_PART_ID = -1;
|
||||
private static final long INVALID_MESSAGE_PART_ID = -1;
|
||||
|
||||
|
||||
private final LocalStore localStore;
|
||||
private final AttachmentInfoExtractor attachmentInfoExtractor;
|
||||
|
||||
private String mName = null;
|
||||
private long mFolderId = -1;
|
||||
private int mVisibleLimit = -1;
|
||||
|
||||
private String name = null;
|
||||
private long databaseId = -1;
|
||||
private int visibleLimit = -1;
|
||||
private String prefId = null;
|
||||
private FolderClass mDisplayClass = FolderClass.NO_CLASS;
|
||||
private FolderClass mSyncClass = FolderClass.INHERITED;
|
||||
private FolderClass mPushClass = FolderClass.SECOND_CLASS;
|
||||
private FolderClass mNotifyClass = FolderClass.INHERITED;
|
||||
private boolean mInTopGroup = false;
|
||||
private String mPushState = null;
|
||||
private boolean mIntegrate = false;
|
||||
|
||||
private FolderClass displayClass = FolderClass.NO_CLASS;
|
||||
private FolderClass syncClass = FolderClass.INHERITED;
|
||||
private FolderClass pushClass = FolderClass.SECOND_CLASS;
|
||||
private FolderClass notifyClass = FolderClass.INHERITED;
|
||||
|
||||
private String pushState = null;
|
||||
private boolean isInTopGroup = false;
|
||||
private boolean isIntegrate = false;
|
||||
|
||||
// mLastUid is used during syncs. It holds the highest UID within the local folder so we
|
||||
// know whether or not an unread message added to the local folder is actually "new" or not.
|
||||
private Integer mLastUid = null;
|
||||
private Integer lastUid = null;
|
||||
private MoreMessages moreMessages = MoreMessages.UNKNOWN;
|
||||
|
||||
|
||||
public LocalFolder(LocalStore localStore, String name) {
|
||||
super();
|
||||
this.localStore = localStore;
|
||||
this.mName = name;
|
||||
attachmentInfoExtractor = localStore.attachmentInfoExtractor;
|
||||
this.name = name;
|
||||
attachmentInfoExtractor = localStore.getAttachmentInfoExtractor();
|
||||
|
||||
if (getAccount().getInboxFolderName().equals(getName())) {
|
||||
mSyncClass = FolderClass.FIRST_CLASS;
|
||||
mPushClass = FolderClass.FIRST_CLASS;
|
||||
mInTopGroup = true;
|
||||
syncClass = FolderClass.FIRST_CLASS;
|
||||
pushClass = FolderClass.FIRST_CLASS;
|
||||
isInTopGroup = true;
|
||||
}
|
||||
}
|
||||
|
||||
public LocalFolder(LocalStore localStore, long id) {
|
||||
public LocalFolder(LocalStore localStore, long databaseId) {
|
||||
super();
|
||||
this.localStore = localStore;
|
||||
this.mFolderId = id;
|
||||
attachmentInfoExtractor = localStore.attachmentInfoExtractor;
|
||||
this.databaseId = databaseId;
|
||||
attachmentInfoExtractor = localStore.getAttachmentInfoExtractor();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return mFolderId;
|
||||
public long getDatabaseId() {
|
||||
return databaseId;
|
||||
}
|
||||
|
||||
public String getAccountUuid()
|
||||
|
@ -147,17 +150,18 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String baseQuery = "SELECT " + LocalStore.GET_FOLDER_COLS + " FROM folders ";
|
||||
|
||||
if (mName != null) {
|
||||
cursor = db.rawQuery(baseQuery + "where folders.name = ?", new String[] { mName });
|
||||
if (name != null) {
|
||||
cursor = db.rawQuery(baseQuery + "where folders.name = ?", new String[] { name });
|
||||
} else {
|
||||
cursor = db.rawQuery(baseQuery + "where folders.id = ?", new String[] { Long.toString(mFolderId) });
|
||||
cursor = db.rawQuery(baseQuery + "where folders.id = ?", new String[] { Long.toString(
|
||||
databaseId) });
|
||||
}
|
||||
|
||||
if (cursor.moveToFirst() && !cursor.isNull(LocalStore.FOLDER_ID_INDEX)) {
|
||||
|
@ -166,7 +170,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
open(cursor);
|
||||
}
|
||||
} else {
|
||||
Timber.w("Creating folder %s with existing id %d", getName(), getId());
|
||||
Timber.w("Creating folder %s with existing id %d", getName(), getDatabaseId());
|
||||
create(FolderType.HOLDS_MESSAGES);
|
||||
open(mode);
|
||||
}
|
||||
|
@ -184,33 +188,33 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
void open(Cursor cursor) throws MessagingException {
|
||||
mFolderId = cursor.getInt(LocalStore.FOLDER_ID_INDEX);
|
||||
mName = cursor.getString(LocalStore.FOLDER_NAME_INDEX);
|
||||
mVisibleLimit = cursor.getInt(LocalStore.FOLDER_VISIBLE_LIMIT_INDEX);
|
||||
mPushState = cursor.getString(LocalStore.FOLDER_PUSH_STATE_INDEX);
|
||||
databaseId = cursor.getInt(LocalStore.FOLDER_ID_INDEX);
|
||||
name = cursor.getString(LocalStore.FOLDER_NAME_INDEX);
|
||||
visibleLimit = cursor.getInt(LocalStore.FOLDER_VISIBLE_LIMIT_INDEX);
|
||||
pushState = cursor.getString(LocalStore.FOLDER_PUSH_STATE_INDEX);
|
||||
super.setStatus(cursor.getString(LocalStore.FOLDER_STATUS_INDEX));
|
||||
// Only want to set the local variable stored in the super class. This class
|
||||
// does a DB update on setLastChecked
|
||||
super.setLastChecked(cursor.getLong(LocalStore.FOLDER_LAST_CHECKED_INDEX));
|
||||
super.setLastPush(cursor.getLong(LocalStore.FOLDER_LAST_PUSHED_INDEX));
|
||||
mInTopGroup = cursor.getInt(LocalStore.FOLDER_TOP_GROUP_INDEX) == 1;
|
||||
mIntegrate = cursor.getInt(LocalStore.FOLDER_INTEGRATE_INDEX) == 1;
|
||||
isInTopGroup = cursor.getInt(LocalStore.FOLDER_TOP_GROUP_INDEX) == 1;
|
||||
isIntegrate = cursor.getInt(LocalStore.FOLDER_INTEGRATE_INDEX) == 1;
|
||||
String noClass = FolderClass.NO_CLASS.toString();
|
||||
String displayClass = cursor.getString(LocalStore.FOLDER_DISPLAY_CLASS_INDEX);
|
||||
mDisplayClass = Folder.FolderClass.valueOf((displayClass == null) ? noClass : displayClass);
|
||||
this.displayClass = Folder.FolderClass.valueOf((displayClass == null) ? noClass : displayClass);
|
||||
String notifyClass = cursor.getString(LocalStore.FOLDER_NOTIFY_CLASS_INDEX);
|
||||
mNotifyClass = Folder.FolderClass.valueOf((notifyClass == null) ? noClass : notifyClass);
|
||||
this.notifyClass = Folder.FolderClass.valueOf((notifyClass == null) ? noClass : notifyClass);
|
||||
String pushClass = cursor.getString(LocalStore.FOLDER_PUSH_CLASS_INDEX);
|
||||
mPushClass = Folder.FolderClass.valueOf((pushClass == null) ? noClass : pushClass);
|
||||
this.pushClass = Folder.FolderClass.valueOf((pushClass == null) ? noClass : pushClass);
|
||||
String syncClass = cursor.getString(LocalStore.FOLDER_SYNC_CLASS_INDEX);
|
||||
mSyncClass = Folder.FolderClass.valueOf((syncClass == null) ? noClass : syncClass);
|
||||
this.syncClass = Folder.FolderClass.valueOf((syncClass == null) ? noClass : syncClass);
|
||||
String moreMessagesValue = cursor.getString(LocalStore.MORE_MESSAGES_INDEX);
|
||||
moreMessages = MoreMessages.fromDatabaseName(moreMessagesValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return (mFolderId != -1 && mName != null);
|
||||
return (databaseId != -1 && name != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -220,12 +224,12 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mName;
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() throws MessagingException {
|
||||
return this.localStore.database.execute(false, new DbCallback<Boolean>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
Cursor cursor = null;
|
||||
|
@ -253,7 +257,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
@Override
|
||||
public boolean create(FolderType type, final int visibleLimit) throws MessagingException {
|
||||
if (exists()) {
|
||||
throw new MessagingException("Folder " + mName + " already exists.");
|
||||
throw new MessagingException("Folder " + name + " already exists.");
|
||||
}
|
||||
List<LocalFolder> foldersToCreate = new ArrayList<>(1);
|
||||
foldersToCreate.add(this);
|
||||
|
@ -263,23 +267,23 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
class PreferencesHolder {
|
||||
FolderClass displayClass = mDisplayClass;
|
||||
FolderClass syncClass = mSyncClass;
|
||||
FolderClass notifyClass = mNotifyClass;
|
||||
FolderClass pushClass = mPushClass;
|
||||
boolean inTopGroup = mInTopGroup;
|
||||
boolean integrate = mIntegrate;
|
||||
FolderClass displayClass = LocalFolder.this.displayClass;
|
||||
FolderClass syncClass = LocalFolder.this.syncClass;
|
||||
FolderClass notifyClass = LocalFolder.this.notifyClass;
|
||||
FolderClass pushClass = LocalFolder.this.pushClass;
|
||||
boolean inTopGroup = isInTopGroup;
|
||||
boolean integrate = isIntegrate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mFolderId = -1;
|
||||
databaseId = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageCount() throws MessagingException {
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<Integer>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
try {
|
||||
|
@ -292,7 +296,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
cursor = db.rawQuery(
|
||||
"SELECT COUNT(id) FROM messages " +
|
||||
"WHERE empty = 0 AND deleted = 0 and folder_id = ?",
|
||||
new String[] { Long.toString(mFolderId) });
|
||||
new String[] { Long.toString(databaseId) });
|
||||
cursor.moveToFirst();
|
||||
return cursor.getInt(0); //messagecount
|
||||
} finally {
|
||||
|
@ -307,18 +311,18 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
@Override
|
||||
public int getUnreadMessageCount() throws MessagingException {
|
||||
if (mFolderId == -1) {
|
||||
if (databaseId == -1) {
|
||||
open(OPEN_MODE_RW);
|
||||
}
|
||||
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<Integer>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
int unreadMessageCount = 0;
|
||||
Cursor cursor = db.query("messages", new String[] { "COUNT(id)" },
|
||||
"folder_id = ? AND empty = 0 AND deleted = 0 AND read=0",
|
||||
new String[] { Long.toString(mFolderId) }, null, null, null);
|
||||
new String[] { Long.toString(databaseId) }, null, null, null);
|
||||
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
|
@ -338,18 +342,18 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
@Override
|
||||
public int getFlaggedMessageCount() throws MessagingException {
|
||||
if (mFolderId == -1) {
|
||||
if (databaseId == -1) {
|
||||
open(OPEN_MODE_RW);
|
||||
}
|
||||
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<Integer>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
int flaggedMessageCount = 0;
|
||||
Cursor cursor = db.query("messages", new String[] { "COUNT(id)" },
|
||||
"folder_id = ? AND empty = 0 AND deleted = 0 AND flagged = 1",
|
||||
new String[] { Long.toString(mFolderId) }, null, null, null);
|
||||
new String[] { Long.toString(databaseId) }, null, null, null);
|
||||
|
||||
try {
|
||||
if (cursor.moveToFirst()) {
|
||||
|
@ -391,18 +395,18 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
public int getVisibleLimit() throws MessagingException {
|
||||
open(OPEN_MODE_RW);
|
||||
return mVisibleLimit;
|
||||
return visibleLimit;
|
||||
}
|
||||
|
||||
public void purgeToVisibleLimit(MessageRemovalListener listener) throws MessagingException {
|
||||
//don't purge messages while a Search is active since it might throw away search results
|
||||
if (!Search.isActive()) {
|
||||
if (mVisibleLimit == 0) {
|
||||
if (visibleLimit == 0) {
|
||||
return ;
|
||||
}
|
||||
open(OPEN_MODE_RW);
|
||||
List<? extends Message> messages = getMessages(null, false);
|
||||
for (int i = mVisibleLimit; i < messages.size(); i++) {
|
||||
for (int i = visibleLimit; i < messages.size(); i++) {
|
||||
if (listener != null) {
|
||||
listener.messageRemoved(messages.get(i));
|
||||
}
|
||||
|
@ -413,10 +417,10 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
|
||||
public void setVisibleLimit(final int visibleLimit) throws MessagingException {
|
||||
updateMoreMessagesOnVisibleLimitChange(visibleLimit, mVisibleLimit);
|
||||
updateMoreMessagesOnVisibleLimitChange(visibleLimit, this.visibleLimit);
|
||||
|
||||
mVisibleLimit = visibleLimit;
|
||||
updateFolderColumn("visible_limit", mVisibleLimit);
|
||||
this.visibleLimit = visibleLimit;
|
||||
updateFolderColumn("visible_limit", this.visibleLimit);
|
||||
}
|
||||
|
||||
private void updateMoreMessagesOnVisibleLimitChange(int newVisibleLimit, int oldVisibleLimit)
|
||||
|
@ -437,13 +441,13 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
public void setPushState(final String pushState) throws MessagingException {
|
||||
mPushState = pushState;
|
||||
this.pushState = pushState;
|
||||
updateFolderColumn("push_state", pushState);
|
||||
}
|
||||
|
||||
private void updateFolderColumn(final String column, final Object value) throws MessagingException {
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
try {
|
||||
|
@ -451,7 +455,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
} catch (MessagingException e) {
|
||||
throw new WrappedException(e);
|
||||
}
|
||||
db.execSQL("UPDATE folders SET " + column + " = ? WHERE id = ?", new Object[] { value, mFolderId });
|
||||
db.execSQL("UPDATE folders SET " + column + " = ? WHERE id = ?", new Object[] { value, databaseId });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -461,67 +465,67 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
public String getPushState() {
|
||||
return mPushState;
|
||||
return pushState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderClass getDisplayClass() {
|
||||
return mDisplayClass;
|
||||
return displayClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderClass getSyncClass() {
|
||||
return (FolderClass.INHERITED == mSyncClass) ? getDisplayClass() : mSyncClass;
|
||||
return (FolderClass.INHERITED == syncClass) ? getDisplayClass() : syncClass;
|
||||
}
|
||||
|
||||
public FolderClass getRawSyncClass() {
|
||||
return mSyncClass;
|
||||
return syncClass;
|
||||
}
|
||||
|
||||
public FolderClass getNotifyClass() {
|
||||
return (FolderClass.INHERITED == mNotifyClass) ? getPushClass() : mNotifyClass;
|
||||
return (FolderClass.INHERITED == notifyClass) ? getPushClass() : notifyClass;
|
||||
}
|
||||
|
||||
public FolderClass getRawNotifyClass() {
|
||||
return mNotifyClass;
|
||||
return notifyClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FolderClass getPushClass() {
|
||||
return (FolderClass.INHERITED == mPushClass) ? getSyncClass() : mPushClass;
|
||||
return (FolderClass.INHERITED == pushClass) ? getSyncClass() : pushClass;
|
||||
}
|
||||
|
||||
public FolderClass getRawPushClass() {
|
||||
return mPushClass;
|
||||
return pushClass;
|
||||
}
|
||||
|
||||
public void setDisplayClass(FolderClass displayClass) throws MessagingException {
|
||||
mDisplayClass = displayClass;
|
||||
updateFolderColumn("display_class", mDisplayClass.name());
|
||||
this.displayClass = displayClass;
|
||||
updateFolderColumn("display_class", this.displayClass.name());
|
||||
}
|
||||
|
||||
public void setSyncClass(FolderClass syncClass) throws MessagingException {
|
||||
mSyncClass = syncClass;
|
||||
updateFolderColumn("poll_class", mSyncClass.name());
|
||||
this.syncClass = syncClass;
|
||||
updateFolderColumn("poll_class", this.syncClass.name());
|
||||
}
|
||||
|
||||
public void setPushClass(FolderClass pushClass) throws MessagingException {
|
||||
mPushClass = pushClass;
|
||||
updateFolderColumn("push_class", mPushClass.name());
|
||||
this.pushClass = pushClass;
|
||||
updateFolderColumn("push_class", this.pushClass.name());
|
||||
}
|
||||
|
||||
public void setNotifyClass(FolderClass notifyClass) throws MessagingException {
|
||||
mNotifyClass = notifyClass;
|
||||
updateFolderColumn("notify_class", mNotifyClass.name());
|
||||
this.notifyClass = notifyClass;
|
||||
updateFolderColumn("notify_class", this.notifyClass.name());
|
||||
}
|
||||
|
||||
public boolean isIntegrate() {
|
||||
return mIntegrate;
|
||||
return isIntegrate;
|
||||
}
|
||||
|
||||
public void setIntegrate(boolean integrate) throws MessagingException {
|
||||
mIntegrate = integrate;
|
||||
updateFolderColumn("integrate", mIntegrate ? 1 : 0);
|
||||
isIntegrate = integrate;
|
||||
updateFolderColumn("integrate", isIntegrate ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean hasMoreMessages() {
|
||||
|
@ -539,7 +543,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
private String getPrefId(String name) {
|
||||
if (prefId == null) {
|
||||
prefId = this.localStore.uUid + "." + name;
|
||||
prefId = getAccount().getUuid() + "." + name;
|
||||
}
|
||||
|
||||
return prefId;
|
||||
|
@ -547,7 +551,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
private String getPrefId() throws MessagingException {
|
||||
open(OPEN_MODE_RW);
|
||||
return getPrefId(mName);
|
||||
return getPrefId(name);
|
||||
}
|
||||
|
||||
public void delete() throws MessagingException {
|
||||
|
@ -574,32 +578,32 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
String id = getPrefId();
|
||||
|
||||
// there can be a lot of folders. For the defaults, let's not save prefs, saving space, except for INBOX
|
||||
if (mDisplayClass == FolderClass.NO_CLASS && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
if (displayClass == FolderClass.NO_CLASS && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
editor.remove(id + ".displayMode");
|
||||
} else {
|
||||
editor.putString(id + ".displayMode", mDisplayClass.name());
|
||||
editor.putString(id + ".displayMode", displayClass.name());
|
||||
}
|
||||
|
||||
if (mSyncClass == FolderClass.INHERITED && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
if (syncClass == FolderClass.INHERITED && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
editor.remove(id + ".syncMode");
|
||||
} else {
|
||||
editor.putString(id + ".syncMode", mSyncClass.name());
|
||||
editor.putString(id + ".syncMode", syncClass.name());
|
||||
}
|
||||
|
||||
if (mNotifyClass == FolderClass.INHERITED && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
if (notifyClass == FolderClass.INHERITED && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
editor.remove(id + ".notifyMode");
|
||||
} else {
|
||||
editor.putString(id + ".notifyMode", mNotifyClass.name());
|
||||
editor.putString(id + ".notifyMode", notifyClass.name());
|
||||
}
|
||||
|
||||
if (mPushClass == FolderClass.SECOND_CLASS && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
if (pushClass == FolderClass.SECOND_CLASS && !getAccount().getInboxFolderName().equals(getName())) {
|
||||
editor.remove(id + ".pushMode");
|
||||
} else {
|
||||
editor.putString(id + ".pushMode", mPushClass.name());
|
||||
editor.putString(id + ".pushMode", pushClass.name());
|
||||
}
|
||||
editor.putBoolean(id + ".inTopGroup", mInTopGroup);
|
||||
editor.putBoolean(id + ".inTopGroup", isInTopGroup);
|
||||
|
||||
editor.putBoolean(id + ".integrate", mIntegrate);
|
||||
editor.putBoolean(id + ".integrate", isIntegrate);
|
||||
|
||||
}
|
||||
|
||||
|
@ -656,7 +660,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
public void fetch(final List<LocalMessage> messages, final FetchProfile fp, final MessageRetrievalListener<LocalMessage> listener)
|
||||
throws MessagingException {
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
try {
|
||||
|
@ -800,7 +804,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
public String getMessageUidById(final long id) throws MessagingException {
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<String>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<String>() {
|
||||
@Override
|
||||
public String doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -810,7 +814,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
try {
|
||||
cursor = db.rawQuery(
|
||||
"SELECT uid FROM messages WHERE id = ? AND folder_id = ?",
|
||||
new String[] { Long.toString(id), Long.toString(mFolderId) });
|
||||
new String[] { Long.toString(id), Long.toString(LocalFolder.this.databaseId) });
|
||||
if (!cursor.moveToNext()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -831,7 +835,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
@Override
|
||||
public LocalMessage getMessage(final String uid) throws MessagingException {
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<LocalMessage>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<LocalMessage>() {
|
||||
@Override
|
||||
public LocalMessage doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -847,7 +851,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"LEFT JOIN message_parts ON (message_parts.id = messages.message_part_id) " +
|
||||
"LEFT JOIN threads ON (threads.message_id = messages.id) " +
|
||||
"WHERE uid = ? AND folder_id = ?",
|
||||
new String[] { message.getUid(), Long.toString(mFolderId) });
|
||||
new String[] { message.getUid(), Long.toString(databaseId) });
|
||||
|
||||
if (!cursor.moveToNext()) {
|
||||
return null;
|
||||
|
@ -869,7 +873,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
public Map<String,Long> getAllMessagesAndEffectiveDates() throws MessagingException {
|
||||
try {
|
||||
return localStore.database.execute(false, new DbCallback<Map<String, Long>>() {
|
||||
return localStore.getDatabase().execute(false, new DbCallback<Map<String, Long>>() {
|
||||
@Override
|
||||
public Map<String, Long> doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
Cursor cursor = null;
|
||||
|
@ -883,7 +887,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"FROM messages " +
|
||||
"WHERE empty = 0 AND deleted = 0 AND " +
|
||||
"folder_id = ? ORDER BY date DESC",
|
||||
new String[] { Long.toString(mFolderId) });
|
||||
new String[] { Long.toString(databaseId) });
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
String uid = cursor.getString(0);
|
||||
|
@ -911,7 +915,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
public List<LocalMessage> getMessages(final MessageRetrievalListener<LocalMessage> listener,
|
||||
final boolean includeDeleted) throws MessagingException {
|
||||
try {
|
||||
return localStore.database.execute(false, new DbCallback<List<LocalMessage>>() {
|
||||
return localStore.getDatabase().execute(false, new DbCallback<List<LocalMessage>>() {
|
||||
@Override
|
||||
public List<LocalMessage> doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -924,7 +928,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"WHERE empty = 0 AND " +
|
||||
(includeDeleted ? "" : "deleted = 0 AND ") +
|
||||
"folder_id = ? ORDER BY date DESC",
|
||||
new String[] { Long.toString(mFolderId) });
|
||||
new String[] { Long.toString(databaseId) });
|
||||
} catch (MessagingException e) {
|
||||
throw new WrappedException(e);
|
||||
}
|
||||
|
@ -937,7 +941,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
public List<String> getAllMessageUids() throws MessagingException {
|
||||
try {
|
||||
return localStore.database.execute(false, new DbCallback<List<String>>() {
|
||||
return localStore.getDatabase().execute(false, new DbCallback<List<String>>() {
|
||||
@Override
|
||||
public List<String> doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
Cursor cursor = null;
|
||||
|
@ -951,7 +955,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"FROM messages " +
|
||||
"WHERE empty = 0 AND deleted = 0 AND " +
|
||||
"folder_id = ? ORDER BY date DESC",
|
||||
new String[] { Long.toString(mFolderId) });
|
||||
new String[] { Long.toString(databaseId) });
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
String uid = cursor.getString(0);
|
||||
|
@ -1026,7 +1030,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
final Map<String, String> uidMap = new HashMap<>();
|
||||
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -1038,9 +1042,9 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
Timber.d("Updating folder_id to %s for message with UID %s, " +
|
||||
"id %d currently in folder %s",
|
||||
lDestFolder.getId(),
|
||||
lDestFolder.getDatabaseId(),
|
||||
message.getUid(),
|
||||
lMessage.getId(),
|
||||
lMessage.getDatabaseId(),
|
||||
getName());
|
||||
|
||||
String newUid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
|
||||
|
@ -1054,11 +1058,11 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
/*
|
||||
* "Move" the message into the new folder
|
||||
*/
|
||||
long msgId = lMessage.getId();
|
||||
long msgId = lMessage.getDatabaseId();
|
||||
String[] idArg = new String[] { Long.toString(msgId) };
|
||||
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("folder_id", lDestFolder.getId());
|
||||
cv.put("folder_id", lDestFolder.getDatabaseId());
|
||||
cv.put("uid", newUid);
|
||||
|
||||
db.update("messages", cv, "id = ?", idArg);
|
||||
|
@ -1096,7 +1100,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
cv.putNull("flags");
|
||||
cv.put("read", 1);
|
||||
cv.put("deleted", 1);
|
||||
cv.put("folder_id", mFolderId);
|
||||
cv.put("folder_id", databaseId);
|
||||
cv.put("empty", 0);
|
||||
|
||||
String messageId = message.getMessageId();
|
||||
|
@ -1149,10 +1153,9 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
* @param message Message to store. Never <code>null</code>.
|
||||
* @param runnable What to do before setting {@link Flag#X_DOWNLOADED_FULL}. Never <code>null</code>.
|
||||
* @return The local version of the message. Never <code>null</code>.
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public LocalMessage storeSmallMessage(final Message message, final Runnable runnable) throws MessagingException {
|
||||
return this.localStore.database.execute(true, new DbCallback<LocalMessage>() {
|
||||
return this.localStore.getDatabase().execute(true, new DbCallback<LocalMessage>() {
|
||||
@Override
|
||||
public LocalMessage doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -1188,7 +1191,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
public void destroyMessages(final List<? extends Message> messages) {
|
||||
try {
|
||||
this.localStore.database.execute(true, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
for (Message message : messages) {
|
||||
|
@ -1217,7 +1220,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"WHERE m.folder_id = ? AND m.message_id = ? " +
|
||||
((onlyEmpty) ? "AND m.empty = 1 " : "") +
|
||||
"ORDER BY m.id LIMIT 1";
|
||||
String[] selectionArgs = { Long.toString(mFolderId), messageId };
|
||||
String[] selectionArgs = { Long.toString(databaseId), messageId };
|
||||
Cursor cursor = db.rawQuery(sql, selectionArgs);
|
||||
|
||||
if (cursor != null) {
|
||||
|
@ -1256,7 +1259,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
open(OPEN_MODE_RW);
|
||||
try {
|
||||
final Map<String, String> uidMap = new HashMap<>();
|
||||
this.localStore.database.execute(true, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -1278,7 +1281,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
protected void saveMessage(SQLiteDatabase db, Message message, boolean copy, Map<String, String> uidMap)
|
||||
private void saveMessage(SQLiteDatabase db, Message message, boolean copy, Map<String, String> uidMap)
|
||||
throws MessagingException {
|
||||
if (!(message instanceof MimeMessage)) {
|
||||
throw new Error("LocalStore can only store Messages that extend MimeMessage");
|
||||
|
@ -1304,7 +1307,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
LocalMessage oldMessage = getMessage(uid);
|
||||
|
||||
if (oldMessage != null) {
|
||||
oldMessageId = oldMessage.getId();
|
||||
oldMessageId = oldMessage.getDatabaseId();
|
||||
|
||||
long oldRootMessagePartId = oldMessage.getMessagePartId();
|
||||
deleteMessagePartsAndDataFromDisk(oldRootMessagePartId);
|
||||
|
@ -1344,13 +1347,13 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
cv.put("sender_list", Address.pack(message.getFrom()));
|
||||
cv.put("date", message.getSentDate() == null
|
||||
? System.currentTimeMillis() : message.getSentDate().getTime());
|
||||
cv.put("flags", this.localStore.serializeFlags(message.getFlags()));
|
||||
cv.put("flags", LocalStore.serializeFlags(message.getFlags()));
|
||||
cv.put("deleted", message.isSet(Flag.DELETED) ? 1 : 0);
|
||||
cv.put("read", message.isSet(Flag.SEEN) ? 1 : 0);
|
||||
cv.put("flagged", message.isSet(Flag.FLAGGED) ? 1 : 0);
|
||||
cv.put("answered", message.isSet(Flag.ANSWERED) ? 1 : 0);
|
||||
cv.put("forwarded", message.isSet(Flag.FORWARDED) ? 1 : 0);
|
||||
cv.put("folder_id", mFolderId);
|
||||
cv.put("folder_id", databaseId);
|
||||
cv.put("to_list", Address.pack(message.getRecipients(RecipientType.TO)));
|
||||
cv.put("cc_list", Address.pack(message.getRecipients(RecipientType.CC)));
|
||||
cv.put("bcc_list", Address.pack(message.getRecipients(RecipientType.BCC)));
|
||||
|
@ -1641,7 +1644,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
public void addPartToMessage(final LocalMessage message, final Part part) throws MessagingException {
|
||||
open(OPEN_MODE_RW);
|
||||
|
||||
localStore.database.execute(false, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
long messagePartId;
|
||||
|
@ -1675,17 +1678,16 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
/**
|
||||
* Changes the stored uid of the given message (using it's internal id as a key) to
|
||||
* the uid in the message.
|
||||
* @throws com.fsck.k9.mail.MessagingException
|
||||
*/
|
||||
public void changeUid(final LocalMessage message) throws MessagingException {
|
||||
open(OPEN_MODE_RW);
|
||||
final ContentValues cv = new ContentValues();
|
||||
cv.put("uid", message.getUid());
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
db.update("messages", cv, "id = ?", new String[]
|
||||
{ Long.toString(message.getId()) });
|
||||
{ Long.toString(message.getDatabaseId()) });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -1701,7 +1703,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
// Use one transaction to set all flags
|
||||
try {
|
||||
this.localStore.database.execute(true, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException,
|
||||
UnavailableStorageException {
|
||||
|
@ -1745,7 +1747,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
"LEFT JOIN message_parts ON (message_parts.id = messages.message_part_id) " +
|
||||
"LEFT JOIN threads ON (threads.message_id = messages.id) " +
|
||||
"WHERE empty = 0 AND (folder_id = ? and date < ?)",
|
||||
new String[] { Long.toString(mFolderId), Long.toString(cutoff) });
|
||||
new String[] { Long.toString(databaseId), Long.toString(cutoff) });
|
||||
|
||||
for (Message message : messages) {
|
||||
message.destroy();
|
||||
|
@ -1755,12 +1757,12 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
public void clearAllMessages() throws MessagingException {
|
||||
final String[] folderIdArg = new String[] { Long.toString(mFolderId) };
|
||||
final String[] folderIdArg = new String[] { Long.toString(databaseId) };
|
||||
|
||||
open(OPEN_MODE_RO);
|
||||
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
try {
|
||||
|
@ -1803,7 +1805,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
@Override
|
||||
public void delete(final boolean recurse) throws MessagingException {
|
||||
try {
|
||||
this.localStore.database.execute(false, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -1817,7 +1819,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
throw new WrappedException(e);
|
||||
}
|
||||
db.execSQL("DELETE FROM folders WHERE id = ?", new Object[]
|
||||
{ Long.toString(mFolderId), });
|
||||
{ Long.toString(databaseId), });
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -1829,24 +1831,24 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LocalFolder) {
|
||||
return ((LocalFolder)o).mName.equals(mName);
|
||||
return ((LocalFolder)o).name.equals(name);
|
||||
}
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mName.hashCode();
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
void destroyMessage(LocalMessage localMessage) throws MessagingException {
|
||||
destroyMessage(localMessage.getId(), localMessage.getMessagePartId(), localMessage.getMessageId());
|
||||
destroyMessage(localMessage.getDatabaseId(), localMessage.getMessagePartId(), localMessage.getMessageId());
|
||||
}
|
||||
|
||||
private void destroyMessage(final long messageId, final long messagePartId, final String messageIdHeader)
|
||||
throws MessagingException {
|
||||
try {
|
||||
localStore.database.execute(true, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException,
|
||||
UnavailableStorageException {
|
||||
|
@ -1860,7 +1862,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
// make it an empty message.
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("id", messageId);
|
||||
cv.put("folder_id", getId());
|
||||
cv.put("folder_id", getDatabaseId());
|
||||
cv.put("deleted", 0);
|
||||
cv.put("message_id", messageIdHeader);
|
||||
cv.put("empty", 1);
|
||||
|
@ -1991,7 +1993,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
private void deleteMessageParts(final long rootMessagePartId) throws MessagingException {
|
||||
localStore.database.execute(false, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
db.delete("message_parts", "root = ?", new String[] { Long.toString(rootMessagePartId) });
|
||||
|
@ -2001,7 +2003,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
|
||||
private void deleteMessageDataFromDisk(final long rootMessagePartId) throws MessagingException {
|
||||
localStore.database.execute(false, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
deleteMessagePartsFromDisk(db, rootMessagePartId);
|
||||
|
@ -2031,16 +2033,16 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
@Override
|
||||
public boolean isInTopGroup() {
|
||||
return mInTopGroup;
|
||||
return isInTopGroup;
|
||||
}
|
||||
|
||||
public void setInTopGroup(boolean inTopGroup) throws MessagingException {
|
||||
mInTopGroup = inTopGroup;
|
||||
updateFolderColumn("top_group", mInTopGroup ? 1 : 0);
|
||||
isInTopGroup = inTopGroup;
|
||||
updateFolderColumn("top_group", isInTopGroup ? 1 : 0);
|
||||
}
|
||||
|
||||
public Integer getLastUid() {
|
||||
return mLastUid;
|
||||
return lastUid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2057,16 +2059,16 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
* updated to use internal dates rather than UIDs to determine new-ness. While this doesn't
|
||||
* solve things for POP (which doesn't have internal dates), we can likely use this as a
|
||||
* framework to examine send date in lieu of internal date.</p>
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void updateLastUid() throws MessagingException {
|
||||
Integer lastUid = this.localStore.database.execute(false, new DbCallback<Integer>() {
|
||||
Integer lastUid = this.localStore.getDatabase().execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
open(OPEN_MODE_RO);
|
||||
cursor = db.rawQuery("SELECT MAX(uid) FROM messages WHERE folder_id=?", new String[] { Long.toString(mFolderId) });
|
||||
cursor = db.rawQuery("SELECT MAX(uid) FROM messages WHERE folder_id=?", new String[] { Long.toString(
|
||||
databaseId) });
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
return cursor.getInt(0);
|
||||
|
@ -2080,18 +2082,19 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
}
|
||||
});
|
||||
|
||||
Timber.d("Updated last UID for folder %s to %s", mName, lastUid);
|
||||
mLastUid = lastUid;
|
||||
Timber.d("Updated last UID for folder %s to %s", name, lastUid);
|
||||
this.lastUid = lastUid;
|
||||
}
|
||||
|
||||
public Long getOldestMessageDate() throws MessagingException {
|
||||
return this.localStore.database.execute(false, new DbCallback<Long>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<Long>() {
|
||||
@Override
|
||||
public Long doDbWork(final SQLiteDatabase db) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
open(OPEN_MODE_RO);
|
||||
cursor = db.rawQuery("SELECT MIN(date) FROM messages WHERE folder_id=?", new String[] { Long.toString(mFolderId) });
|
||||
cursor = db.rawQuery("SELECT MIN(date) FROM messages WHERE folder_id=?", new String[] { Long.toString(
|
||||
databaseId) });
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
return cursor.getLong(0);
|
||||
|
@ -2151,7 +2154,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
// Create placeholder message in 'messages' table
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("message_id", reference);
|
||||
cv.put("folder_id", mFolderId);
|
||||
cv.put("folder_id", databaseId);
|
||||
cv.put("empty", 1);
|
||||
|
||||
long newMsgId = db.insert("messages", null, cv);
|
||||
|
@ -2213,7 +2216,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
throws MessagingException {
|
||||
|
||||
try {
|
||||
return this.localStore.database.execute(false, new DbCallback<List<Message>>() {
|
||||
return this.localStore.getDatabase().execute(false, new DbCallback<List<Message>>() {
|
||||
@Override
|
||||
public List<Message> doDbWork(final SQLiteDatabase db) throws WrappedException {
|
||||
try {
|
||||
|
@ -2232,7 +2235,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
StringBuilder selection = new StringBuilder();
|
||||
|
||||
selection.append("folder_id = ? AND UID IN (");
|
||||
selectionArgs.add(Long.toString(mFolderId));
|
||||
selectionArgs.add(Long.toString(databaseId));
|
||||
|
||||
int count = Math.min(messages.size() - start, LocalStore.UID_CHECK_BATCH_SIZE);
|
||||
|
||||
|
@ -2287,7 +2290,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
|
||||
// Note: The contents of the 'message_parts' table depend on these values.
|
||||
// TODO currently unused, might be for caching at a later point
|
||||
static class MessagePartType {
|
||||
private static class MessagePartType {
|
||||
static final int UNKNOWN = 0;
|
||||
static final int ALTERNATIVE_PLAIN = 1;
|
||||
static final int ALTERNATIVE_HTML = 2;
|
||||
|
|
|
@ -27,18 +27,16 @@ import timber.log.Timber;
|
|||
|
||||
|
||||
public class LocalMessage extends MimeMessage {
|
||||
protected MessageReference mReference;
|
||||
private final LocalStore localStore;
|
||||
|
||||
private long mId;
|
||||
private int mAttachmentCount;
|
||||
private String mSubject;
|
||||
|
||||
private String mPreview = "";
|
||||
|
||||
private long mThreadId;
|
||||
private long mRootId;
|
||||
private long databaseId;
|
||||
private long rootId;
|
||||
private long threadId;
|
||||
private long messagePartId;
|
||||
private MessageReference messageReference;
|
||||
private int attachmentCount;
|
||||
private String subject;
|
||||
private String preview = "";
|
||||
private String mimeType;
|
||||
private PreviewType previewType;
|
||||
private boolean headerNeedsUpdating = false;
|
||||
|
@ -56,16 +54,16 @@ public class LocalMessage extends MimeMessage {
|
|||
|
||||
|
||||
void populateFromGetMessageCursor(Cursor cursor) throws MessagingException {
|
||||
final String subject = cursor.getString(0);
|
||||
final String subject = cursor.getString(LocalStore.MSG_INDEX_SUBJECT);
|
||||
this.setSubject(subject == null ? "" : subject);
|
||||
|
||||
Address[] from = Address.unpack(cursor.getString(1));
|
||||
Address[] from = Address.unpack(cursor.getString(LocalStore.MSG_INDEX_SENDER_LIST));
|
||||
if (from.length > 0) {
|
||||
this.setFrom(from[0]);
|
||||
}
|
||||
this.setInternalSentDate(new Date(cursor.getLong(2)));
|
||||
this.setUid(cursor.getString(3));
|
||||
String flagList = cursor.getString(4);
|
||||
this.setInternalSentDate(new Date(cursor.getLong(LocalStore.MSG_INDEX_DATE)));
|
||||
this.setUid(cursor.getString(LocalStore.MSG_INDEX_UID));
|
||||
String flagList = cursor.getString(LocalStore.MSG_INDEX_FLAGS);
|
||||
if (flagList != null && flagList.length() > 0) {
|
||||
String[] flags = flagList.split(",");
|
||||
|
||||
|
@ -81,39 +79,39 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.mId = cursor.getLong(5);
|
||||
this.setRecipients(RecipientType.TO, Address.unpack(cursor.getString(6)));
|
||||
this.setRecipients(RecipientType.CC, Address.unpack(cursor.getString(7)));
|
||||
this.setRecipients(RecipientType.BCC, Address.unpack(cursor.getString(8)));
|
||||
this.setReplyTo(Address.unpack(cursor.getString(9)));
|
||||
this.databaseId = cursor.getLong(LocalStore.MSG_INDEX_ID);
|
||||
this.setRecipients(RecipientType.TO, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_TO)));
|
||||
this.setRecipients(RecipientType.CC, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_CC)));
|
||||
this.setRecipients(RecipientType.BCC, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_BCC)));
|
||||
this.setReplyTo(Address.unpack(cursor.getString(LocalStore.MSG_INDEX_REPLY_TO)));
|
||||
|
||||
this.mAttachmentCount = cursor.getInt(10);
|
||||
this.setInternalDate(new Date(cursor.getLong(11)));
|
||||
this.setMessageId(cursor.getString(12));
|
||||
this.attachmentCount = cursor.getInt(LocalStore.MSG_INDEX_ATTACHMENT_COUNT);
|
||||
this.setInternalDate(new Date(cursor.getLong(LocalStore.MSG_INDEX_INTERNAL_DATE)));
|
||||
this.setMessageId(cursor.getString(LocalStore.MSG_INDEX_MESSAGE_ID_HEADER));
|
||||
|
||||
String previewTypeString = cursor.getString(24);
|
||||
String previewTypeString = cursor.getString(LocalStore.MSG_INDEX_PREVIEW_TYPE);
|
||||
DatabasePreviewType databasePreviewType = DatabasePreviewType.fromDatabaseValue(previewTypeString);
|
||||
previewType = databasePreviewType.getPreviewType();
|
||||
if (previewType == PreviewType.TEXT) {
|
||||
mPreview = cursor.getString(14);
|
||||
preview = cursor.getString(LocalStore.MSG_INDEX_PREVIEW);
|
||||
} else {
|
||||
mPreview = "";
|
||||
preview = "";
|
||||
}
|
||||
|
||||
if (this.mFolder == null) {
|
||||
LocalFolder f = new LocalFolder(this.localStore, cursor.getInt(13));
|
||||
LocalFolder f = new LocalFolder(this.localStore, cursor.getInt(LocalStore.MSG_INDEX_FOLDER_ID));
|
||||
f.open(LocalFolder.OPEN_MODE_RW);
|
||||
this.mFolder = f;
|
||||
}
|
||||
|
||||
mThreadId = (cursor.isNull(15)) ? -1 : cursor.getLong(15);
|
||||
mRootId = (cursor.isNull(16)) ? -1 : cursor.getLong(16);
|
||||
threadId = (cursor.isNull(LocalStore.MSG_INDEX_THREAD_ID)) ? -1 : cursor.getLong(LocalStore.MSG_INDEX_THREAD_ID);
|
||||
rootId = (cursor.isNull(LocalStore.MSG_INDEX_THREAD_ROOT_ID)) ? -1 : cursor.getLong(LocalStore.MSG_INDEX_THREAD_ROOT_ID);
|
||||
|
||||
boolean deleted = (cursor.getInt(17) == 1);
|
||||
boolean read = (cursor.getInt(18) == 1);
|
||||
boolean flagged = (cursor.getInt(19) == 1);
|
||||
boolean answered = (cursor.getInt(20) == 1);
|
||||
boolean forwarded = (cursor.getInt(21) == 1);
|
||||
boolean deleted = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_DELETED) == 1);
|
||||
boolean read = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_READ) == 1);
|
||||
boolean flagged = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_FLAGGED) == 1);
|
||||
boolean answered = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_ANSWERED) == 1);
|
||||
boolean forwarded = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_FORWARDED) == 1);
|
||||
|
||||
setFlagInternal(Flag.DELETED, deleted);
|
||||
setFlagInternal(Flag.SEEN, read);
|
||||
|
@ -121,10 +119,10 @@ public class LocalMessage extends MimeMessage {
|
|||
setFlagInternal(Flag.ANSWERED, answered);
|
||||
setFlagInternal(Flag.FORWARDED, forwarded);
|
||||
|
||||
setMessagePartId(cursor.getLong(22));
|
||||
mimeType = cursor.getString(23);
|
||||
setMessagePartId(cursor.getLong(LocalStore.MSG_INDEX_MESSAGE_PART_ID));
|
||||
mimeType = cursor.getString(LocalStore.MSG_INDEX_MIME_TYPE);
|
||||
|
||||
byte[] header = cursor.getBlob(25);
|
||||
byte[] header = cursor.getBlob(LocalStore.MSG_INDEX_HEADER_DATA);
|
||||
if (header != null) {
|
||||
MessageHeaderParser.parse(this, new ByteArrayInputStream(header));
|
||||
} else {
|
||||
|
@ -157,18 +155,18 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
|
||||
public String getPreview() {
|
||||
return mPreview;
|
||||
return preview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubject() {
|
||||
return mSubject;
|
||||
return subject;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSubject(String subject) {
|
||||
mSubject = subject;
|
||||
this.subject = subject;
|
||||
headerNeedsUpdating = true;
|
||||
}
|
||||
|
||||
|
@ -182,16 +180,16 @@ public class LocalMessage extends MimeMessage {
|
|||
@Override
|
||||
public void setUid(String uid) {
|
||||
super.setUid(uid);
|
||||
this.mReference = null;
|
||||
this.messageReference = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttachments() {
|
||||
return (mAttachmentCount > 0);
|
||||
return (attachmentCount > 0);
|
||||
}
|
||||
|
||||
public int getAttachmentCount() {
|
||||
return mAttachmentCount;
|
||||
int getAttachmentCount() {
|
||||
return attachmentCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -248,16 +246,15 @@ public class LocalMessage extends MimeMessage {
|
|||
super.setFlag(flag, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return mId;
|
||||
public long getDatabaseId() {
|
||||
return databaseId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlag(final Flag flag, final boolean set) throws MessagingException {
|
||||
|
||||
try {
|
||||
this.localStore.database.execute(true, new DbCallback<Void>() {
|
||||
this.localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
|
@ -273,13 +270,13 @@ public class LocalMessage extends MimeMessage {
|
|||
* Set the flags on the message.
|
||||
*/
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("flags", LocalMessage.this.localStore.serializeFlags(getFlags()));
|
||||
cv.put("flags", LocalStore.serializeFlags(getFlags()));
|
||||
cv.put("read", isSet(Flag.SEEN) ? 1 : 0);
|
||||
cv.put("flagged", isSet(Flag.FLAGGED) ? 1 : 0);
|
||||
cv.put("answered", isSet(Flag.ANSWERED) ? 1 : 0);
|
||||
cv.put("forwarded", isSet(Flag.FORWARDED) ? 1 : 0);
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(mId) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -297,7 +294,7 @@ public class LocalMessage extends MimeMessage {
|
|||
*/
|
||||
private void delete() throws MessagingException {
|
||||
try {
|
||||
localStore.database.execute(true, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
ContentValues cv = new ContentValues();
|
||||
|
@ -313,7 +310,7 @@ public class LocalMessage extends MimeMessage {
|
|||
cv.putNull("reply_to_list");
|
||||
cv.putNull("message_part_id");
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(mId) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
try {
|
||||
((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId);
|
||||
|
@ -321,7 +318,7 @@ public class LocalMessage extends MimeMessage {
|
|||
throw new WrappedException(e);
|
||||
}
|
||||
|
||||
getFolder().deleteFulltextIndexEntry(db, mId);
|
||||
getFolder().deleteFulltextIndexEntry(db, databaseId);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -339,13 +336,13 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
|
||||
try {
|
||||
localStore.database.execute(true, new DbCallback<Void>() {
|
||||
localStore.getDatabase().execute(true, new DbCallback<Void>() {
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, MessagingException {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.putNull("message_part_id");
|
||||
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(mId) });
|
||||
db.update("messages", cv, "id = ?", new String[] { Long.toString(databaseId) });
|
||||
|
||||
try {
|
||||
((LocalFolder) mFolder).deleteMessagePartsAndDataFromDisk(messagePartId);
|
||||
|
@ -381,13 +378,13 @@ public class LocalMessage extends MimeMessage {
|
|||
LocalMessage message = new LocalMessage(localStore);
|
||||
super.copy(message);
|
||||
|
||||
message.mReference = mReference;
|
||||
message.mId = mId;
|
||||
message.mAttachmentCount = mAttachmentCount;
|
||||
message.mSubject = mSubject;
|
||||
message.mPreview = mPreview;
|
||||
message.mThreadId = mThreadId;
|
||||
message.mRootId = mRootId;
|
||||
message.messageReference = messageReference;
|
||||
message.databaseId = databaseId;
|
||||
message.attachmentCount = attachmentCount;
|
||||
message.subject = subject;
|
||||
message.preview = preview;
|
||||
message.threadId = threadId;
|
||||
message.rootId = rootId;
|
||||
message.messagePartId = messagePartId;
|
||||
message.mimeType = mimeType;
|
||||
message.previewType = previewType;
|
||||
|
@ -397,11 +394,11 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
|
||||
public long getThreadId() {
|
||||
return mThreadId;
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public long getRootId() {
|
||||
return mRootId;
|
||||
return rootId;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
|
@ -409,10 +406,10 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
|
||||
public MessageReference makeMessageReference() {
|
||||
if (mReference == null) {
|
||||
mReference = new MessageReference(getFolder().getAccountUuid(), getFolder().getName(), mUid, null);
|
||||
if (messageReference == null) {
|
||||
messageReference = new MessageReference(getFolder().getAccountUuid(), getFolder().getName(), mUid, null);
|
||||
}
|
||||
return mReference;
|
||||
return messageReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -434,7 +431,7 @@ public class LocalMessage extends MimeMessage {
|
|||
}
|
||||
|
||||
private void updateHeader() {
|
||||
super.setSubject(mSubject);
|
||||
super.setSubject(subject);
|
||||
super.setReplyTo(mReplyTo);
|
||||
super.setRecipients(RecipientType.TO, mTo);
|
||||
super.setRecipients(RecipientType.CC, mCc);
|
||||
|
@ -479,8 +476,4 @@ public class LocalMessage extends MimeMessage {
|
|||
private String getAccountUuid() {
|
||||
return getAccount().getUuid();
|
||||
}
|
||||
|
||||
public boolean isBodyMissing() {
|
||||
return getBody() == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class LocalMimeMessage extends MimeMessage implements LocalPart {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
public long getPartId() {
|
||||
return messagePartId;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.fsck.k9.mailstore;
|
|||
|
||||
public interface LocalPart {
|
||||
String getAccountUuid();
|
||||
long getId();
|
||||
long getPartId();
|
||||
long getSize();
|
||||
LocalMessage getMessage();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -75,9 +74,7 @@ import org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource;
|
|||
* Implements a SQLite database backed local store for Messages.
|
||||
* </pre>
|
||||
*/
|
||||
public class LocalStore extends Store implements Serializable {
|
||||
private static final long serialVersionUID = -5142141896809423072L;
|
||||
|
||||
public class LocalStore extends Store {
|
||||
static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
||||
|
||||
|
@ -103,6 +100,33 @@ public class LocalStore extends Store implements Serializable {
|
|||
"folder_id, preview, threads.id, threads.root, deleted, read, flagged, answered, " +
|
||||
"forwarded, message_part_id, messages.mime_type, preview_type, header ";
|
||||
|
||||
static final int MSG_INDEX_SUBJECT = 0;
|
||||
static final int MSG_INDEX_SENDER_LIST = 1;
|
||||
static final int MSG_INDEX_DATE = 2;
|
||||
static final int MSG_INDEX_UID = 3;
|
||||
static final int MSG_INDEX_FLAGS = 4;
|
||||
static final int MSG_INDEX_ID = 5;
|
||||
static final int MSG_INDEX_TO = 6;
|
||||
static final int MSG_INDEX_CC = 7;
|
||||
static final int MSG_INDEX_BCC = 8;
|
||||
static final int MSG_INDEX_REPLY_TO = 9;
|
||||
static final int MSG_INDEX_ATTACHMENT_COUNT = 10;
|
||||
static final int MSG_INDEX_INTERNAL_DATE = 11;
|
||||
static final int MSG_INDEX_MESSAGE_ID_HEADER = 12;
|
||||
static final int MSG_INDEX_FOLDER_ID = 13;
|
||||
static final int MSG_INDEX_PREVIEW = 14;
|
||||
static final int MSG_INDEX_THREAD_ID = 15;
|
||||
static final int MSG_INDEX_THREAD_ROOT_ID = 16;
|
||||
static final int MSG_INDEX_FLAG_DELETED = 17;
|
||||
static final int MSG_INDEX_FLAG_READ = 18;
|
||||
static final int MSG_INDEX_FLAG_FLAGGED = 19;
|
||||
static final int MSG_INDEX_FLAG_ANSWERED = 20;
|
||||
static final int MSG_INDEX_FLAG_FORWARDED = 21;
|
||||
static final int MSG_INDEX_MESSAGE_PART_ID = 22;
|
||||
static final int MSG_INDEX_MIME_TYPE = 23;
|
||||
static final int MSG_INDEX_PREVIEW_TYPE = 24;
|
||||
static final int MSG_INDEX_HEADER_DATA = 25;
|
||||
|
||||
static final String GET_FOLDER_COLS =
|
||||
"folders.id, name, visible_limit, last_updated, status, push_state, last_pushed, " +
|
||||
"integrate, top_group, poll_class, push_class, display_class, notify_class, more_messages";
|
||||
|
@ -155,41 +179,16 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
public static final int DB_VERSION = 60;
|
||||
|
||||
|
||||
public static String getColumnNameForFlag(Flag flag) {
|
||||
switch (flag) {
|
||||
case SEEN: {
|
||||
return MessageColumns.READ;
|
||||
}
|
||||
case FLAGGED: {
|
||||
return MessageColumns.FLAGGED;
|
||||
}
|
||||
case ANSWERED: {
|
||||
return MessageColumns.ANSWERED;
|
||||
}
|
||||
case FORWARDED: {
|
||||
return MessageColumns.FORWARDED;
|
||||
}
|
||||
default: {
|
||||
throw new IllegalArgumentException("Flag must be a special column flag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String uUid = null;
|
||||
|
||||
final Context context;
|
||||
|
||||
LockableDatabase database;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private final Account mAccount;
|
||||
private final Context context;
|
||||
private final ContentResolver contentResolver;
|
||||
private final MessagePreviewCreator messagePreviewCreator;
|
||||
private final MessageFulltextCreator messageFulltextCreator;
|
||||
private final AttachmentCounter attachmentCounter;
|
||||
private final PendingCommandSerializer pendingCommandSerializer;
|
||||
final AttachmentInfoExtractor attachmentInfoExtractor;
|
||||
private final AttachmentInfoExtractor attachmentInfoExtractor;
|
||||
|
||||
private final Account account;
|
||||
private final LockableDatabase database;
|
||||
|
||||
/**
|
||||
* local://localhost/path/to/database/uuid.db
|
||||
|
@ -197,13 +196,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
* @throws UnavailableStorageException if not {@link StorageProvider#isReady(Context)}
|
||||
*/
|
||||
private LocalStore(final Account account, final Context context) throws MessagingException {
|
||||
mAccount = account;
|
||||
database = new LockableDatabase(context, account.getUuid(), new StoreSchemaDefinition(this));
|
||||
|
||||
this.context = context;
|
||||
mContentResolver = context.getContentResolver();
|
||||
database.setStorageProviderId(account.getLocalStorageProviderId());
|
||||
uUid = account.getUuid();
|
||||
this.contentResolver = context.getContentResolver();
|
||||
|
||||
messagePreviewCreator = MessagePreviewCreator.newInstance();
|
||||
messageFulltextCreator = MessageFulltextCreator.newInstance();
|
||||
|
@ -211,6 +205,10 @@ public class LocalStore extends Store implements Serializable {
|
|||
pendingCommandSerializer = PendingCommandSerializer.getInstance();
|
||||
attachmentInfoExtractor = AttachmentInfoExtractor.getInstance();
|
||||
|
||||
this.account = account;
|
||||
|
||||
database = new LockableDatabase(context, account.getUuid(), new StoreSchemaDefinition(this));
|
||||
database.setStorageProviderId(account.getLocalStorageProviderId());
|
||||
database.open();
|
||||
}
|
||||
|
||||
|
@ -266,8 +264,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
return context;
|
||||
}
|
||||
|
||||
protected Account getAccount() {
|
||||
return mAccount;
|
||||
Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
protected Storage getStorage() {
|
||||
|
@ -278,7 +276,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
final StorageManager storageManager = StorageManager.getInstance(context);
|
||||
|
||||
final File attachmentDirectory = storageManager.getAttachmentDirectory(uUid,
|
||||
final File attachmentDirectory = storageManager.getAttachmentDirectory(account.getUuid(),
|
||||
database.getStorageProviderId());
|
||||
|
||||
return database.execute(false, new DbCallback<Long>() {
|
||||
|
@ -294,7 +292,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
final File dbFile = storageManager.getDatabase(uUid, database.getStorageProviderId());
|
||||
final File dbFile = storageManager.getDatabase(account.getUuid(), database.getStorageProviderId());
|
||||
return dbFile.length() + attachmentLength;
|
||||
}
|
||||
});
|
||||
|
@ -358,7 +356,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public int getMessageCount() throws MessagingException {
|
||||
private int getMessageCount() throws MessagingException {
|
||||
return database.execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) {
|
||||
|
@ -374,7 +372,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
});
|
||||
}
|
||||
|
||||
public int getFolderCount() throws MessagingException {
|
||||
private int getFolderCount() throws MessagingException {
|
||||
return database.execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doDbWork(final SQLiteDatabase db) {
|
||||
|
@ -464,7 +462,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
private void deleteAllMessagePartsDataFromDisk() {
|
||||
final StorageManager storageManager = StorageManager.getInstance(context);
|
||||
File attachmentDirectory = storageManager.getAttachmentDirectory(uUid, database.getStorageProviderId());
|
||||
File attachmentDirectory = storageManager.getAttachmentDirectory(
|
||||
account.getUuid(), database.getStorageProviderId());
|
||||
File[] files = attachmentDirectory.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
|
@ -568,7 +567,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
StringBuilder query = new StringBuilder();
|
||||
List<String> queryArgs = new ArrayList<>();
|
||||
SqlQueryBuilder.buildWhereClause(mAccount, search.getConditions(), query, queryArgs);
|
||||
SqlQueryBuilder.buildWhereClause(account, search.getConditions(), query, queryArgs);
|
||||
|
||||
// Avoid "ambiguous column name" error by prefixing "id" with the message table name
|
||||
String where = SqlQueryBuilder.addPrefixToSelection(new String[] { "id" },
|
||||
|
@ -776,7 +775,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
if (part instanceof LocalPart) {
|
||||
LocalPart localBodyPart = (LocalPart) part;
|
||||
if (localBodyPart.getId() == partId) {
|
||||
if (localBodyPart.getPartId() == partId) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
|
@ -893,7 +892,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
File getAttachmentFile(String attachmentId) {
|
||||
final StorageManager storageManager = StorageManager.getInstance(context);
|
||||
final File attachmentDirectory = storageManager.getAttachmentDirectory(uUid, database.getStorageProviderId());
|
||||
final File attachmentDirectory = storageManager.getAttachmentDirectory(
|
||||
account.getUuid(), database.getStorageProviderId());
|
||||
return new File(attachmentDirectory, attachmentId);
|
||||
}
|
||||
|
||||
|
@ -914,10 +914,10 @@ public class LocalStore extends Store implements Serializable {
|
|||
// When created, special folders should always be displayed
|
||||
// inbox should be integrated
|
||||
// and the inbox and drafts folders should be syncced by default
|
||||
if (mAccount.isSpecialFolder(name)) {
|
||||
if (account.isSpecialFolder(name)) {
|
||||
prefHolder.inTopGroup = true;
|
||||
prefHolder.displayClass = LocalFolder.FolderClass.FIRST_CLASS;
|
||||
if (name.equalsIgnoreCase(mAccount.getInboxFolderName())) {
|
||||
if (name.equalsIgnoreCase(account.getInboxFolderName())) {
|
||||
prefHolder.integrate = true;
|
||||
prefHolder.notifyClass = LocalFolder.FolderClass.FIRST_CLASS;
|
||||
prefHolder.pushClass = LocalFolder.FolderClass.FIRST_CLASS;
|
||||
|
@ -925,8 +925,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
prefHolder.pushClass = LocalFolder.FolderClass.INHERITED;
|
||||
|
||||
}
|
||||
if (name.equalsIgnoreCase(mAccount.getInboxFolderName()) ||
|
||||
name.equalsIgnoreCase(mAccount.getDraftsFolderName())) {
|
||||
if (name.equalsIgnoreCase(account.getInboxFolderName()) ||
|
||||
name.equalsIgnoreCase(account.getDraftsFolderName())) {
|
||||
prefHolder.syncClass = LocalFolder.FolderClass.FIRST_CLASS;
|
||||
} else {
|
||||
prefHolder.syncClass = LocalFolder.FolderClass.NO_CLASS;
|
||||
|
@ -978,7 +978,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
return database;
|
||||
}
|
||||
|
||||
public MessagePreviewCreator getMessagePreviewCreator() {
|
||||
MessagePreviewCreator getMessagePreviewCreator() {
|
||||
return messagePreviewCreator;
|
||||
}
|
||||
|
||||
|
@ -986,13 +986,17 @@ public class LocalStore extends Store implements Serializable {
|
|||
return messageFulltextCreator;
|
||||
}
|
||||
|
||||
public AttachmentCounter getAttachmentCounter() {
|
||||
AttachmentCounter getAttachmentCounter() {
|
||||
return attachmentCounter;
|
||||
}
|
||||
|
||||
AttachmentInfoExtractor getAttachmentInfoExtractor() {
|
||||
return attachmentInfoExtractor;
|
||||
}
|
||||
|
||||
void notifyChange() {
|
||||
Uri uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + uUid + "/messages");
|
||||
mContentResolver.notifyChange(uri, null);
|
||||
Uri uri = Uri.withAppendedPath(EmailProvider.CONTENT_URI, "account/" + account.getUuid() + "/messages");
|
||||
contentResolver.notifyChange(uri, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1008,10 +1012,8 @@ public class LocalStore extends Store implements Serializable {
|
|||
* Supplies the argument set and the code to query/update the database.
|
||||
* @param batchSize
|
||||
* The maximum size of the selection set in each SQL statement.
|
||||
*
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void doBatchSetSelection(final BatchSetSelection selectionCallback, final int batchSize)
|
||||
private void doBatchSetSelection(final BatchSetSelection selectionCallback, final int batchSize)
|
||||
throws MessagingException {
|
||||
|
||||
final List<String> selectionArgs = new ArrayList<>();
|
||||
|
@ -1063,7 +1065,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
/**
|
||||
* Defines the behavior of {@link LocalStore#doBatchSetSelection(BatchSetSelection, int)}.
|
||||
*/
|
||||
public interface BatchSetSelection {
|
||||
interface BatchSetSelection {
|
||||
/**
|
||||
* @return The size of the argument list.
|
||||
*/
|
||||
|
@ -1089,7 +1091,6 @@ public class LocalStore extends Store implements Serializable {
|
|||
* {@code " IN (?,?,?)"} (starts with a space).
|
||||
* @param selectionArgs
|
||||
* The current subset of the argument list.
|
||||
* @throws UnavailableStorageException
|
||||
*/
|
||||
void doDbWork(SQLiteDatabase db, String selectionSet, String[] selectionArgs)
|
||||
throws UnavailableStorageException;
|
||||
|
@ -1116,7 +1117,6 @@ public class LocalStore extends Store implements Serializable {
|
|||
* @param newState
|
||||
* {@code true}, if the flag should be set. {@code false}, otherwise.
|
||||
*
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void setFlag(final List<Long> messageIds, final Flag flag, final boolean newState)
|
||||
throws MessagingException {
|
||||
|
@ -1165,7 +1165,6 @@ public class LocalStore extends Store implements Serializable {
|
|||
* @param newState
|
||||
* {@code true}, if the flag should be set. {@code false}, otherwise.
|
||||
*
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public void setFlagForThreads(final List<Long> threadRootIds, Flag flag, final boolean newState)
|
||||
throws MessagingException {
|
||||
|
@ -1217,7 +1216,6 @@ public class LocalStore extends Store implements Serializable {
|
|||
*
|
||||
* @return The list of UIDs for the messages grouped by folder name.
|
||||
*
|
||||
* @throws MessagingException
|
||||
*/
|
||||
public Map<String, List<String>> getFoldersAndUids(final List<Long> messageIds,
|
||||
final boolean threadedList) throws MessagingException {
|
||||
|
@ -1289,4 +1287,24 @@ public class LocalStore extends Store implements Serializable {
|
|||
|
||||
return folderMap;
|
||||
}
|
||||
|
||||
public static String getColumnNameForFlag(Flag flag) {
|
||||
switch (flag) {
|
||||
case SEEN: {
|
||||
return MessageColumns.READ;
|
||||
}
|
||||
case FLAGGED: {
|
||||
return MessageColumns.FLAGGED;
|
||||
}
|
||||
case ANSWERED: {
|
||||
return MessageColumns.ANSWERED;
|
||||
}
|
||||
case FORWARDED: {
|
||||
return MessageColumns.FORWARDED;
|
||||
}
|
||||
default: {
|
||||
throw new IllegalArgumentException("Flag must be a special column flag");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.text.TextUtils;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.FetchProfile;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mailstore.LocalFolder;
|
||||
|
@ -38,13 +37,13 @@ class MigrationTo55 {
|
|||
|
||||
String fulltext = fulltextCreator.createFulltext(localMessage);
|
||||
if (!TextUtils.isEmpty(fulltext)) {
|
||||
Timber.d("fulltext for msg id %d is %d chars long", localMessage.getId(), fulltext.length());
|
||||
Timber.d("fulltext for msg id %d is %d chars long", localMessage.getDatabaseId(), fulltext.length());
|
||||
cv.clear();
|
||||
cv.put("docid", localMessage.getId());
|
||||
cv.put("docid", localMessage.getDatabaseId());
|
||||
cv.put("fulltext", fulltext);
|
||||
db.insert("messages_fulltext", null, cv);
|
||||
} else {
|
||||
Timber.d("no fulltext for msg id %d :(", localMessage.getId());
|
||||
Timber.d("no fulltext for msg id %d :(", localMessage.getDatabaseId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import timber.log.Timber;
|
|||
import android.support.annotation.WorkerThread;
|
||||
|
||||
import com.fsck.k9.Globals;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Part;
|
||||
|
@ -64,7 +63,7 @@ public class AttachmentInfoExtractor {
|
|||
if (part instanceof LocalPart) {
|
||||
LocalPart localPart = (LocalPart) part;
|
||||
String accountUuid = localPart.getAccountUuid();
|
||||
long messagePartId = localPart.getId();
|
||||
long messagePartId = localPart.getPartId();
|
||||
size = localPart.getSize();
|
||||
isContentAvailable = part.getBody() != null;
|
||||
uri = AttachmentProvider.getAttachmentUri(accountUuid, messagePartId);
|
||||
|
|
|
@ -358,13 +358,13 @@ public class MessageProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* Extracts the {@link LocalMessage#getId() ID} from the given {@link MessageInfoHolder}. The underlying
|
||||
* Extracts the {@link LocalMessage#getDatabaseId() ID} from the given {@link MessageInfoHolder}. The underlying
|
||||
* {@link Message} is expected to be a {@link LocalMessage}.
|
||||
*/
|
||||
public static class IdExtractor implements FieldExtractor<MessageInfoHolder, Long> {
|
||||
@Override
|
||||
public Long getField(MessageInfoHolder source) {
|
||||
return source.message.getId();
|
||||
return source.message.getDatabaseId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
import timber.log.Timber;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Folder;
|
||||
import com.fsck.k9.mailstore.LocalFolder;
|
||||
|
@ -111,7 +110,7 @@ public class SqlQueryBuilder {
|
|||
LocalStore localStore = account.getLocalStore();
|
||||
LocalFolder folder = localStore.getFolder(folderName);
|
||||
folder.open(Folder.OPEN_MODE_RO);
|
||||
folderId = folder.getId();
|
||||
folderId = folder.getDatabaseId();
|
||||
} catch (MessagingException e) {
|
||||
//FIXME
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -293,7 +293,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
|
|||
|
||||
/* We hide the subject by default for each new message, and MessageTitleView might show
|
||||
* it later by calling showSubjectLine(). */
|
||||
boolean newMessageShown = mMessage == null || mMessage.getId() != message.getId();
|
||||
boolean newMessageShown = mMessage == null || !mMessage.getUid().equals(message.getUid());
|
||||
if (newMessageShown) {
|
||||
mSubjectView.setVisibility(GONE);
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ public class EmailProviderCacheTest {
|
|||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
cache = EmailProviderCache.getCache(UUID.randomUUID().toString(), RuntimeEnvironment.application);
|
||||
when(mockLocalMessage.getId()).thenReturn(localMessageId);
|
||||
when(mockLocalMessage.getDatabaseId()).thenReturn(localMessageId);
|
||||
when(mockLocalMessage.getFolder()).thenReturn(mockLocalMessageFolder);
|
||||
when(mockLocalMessageFolder.getId()).thenReturn(localMessageFolderId);
|
||||
when(mockLocalMessageFolder.getDatabaseId()).thenReturn(localMessageFolderId);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -856,7 +856,7 @@ public class MessagingControllerTest {
|
|||
when(account.hasSentFolder()).thenReturn(true);
|
||||
when(account.getSentFolderName()).thenReturn(SENT_FOLDER_NAME);
|
||||
when(localStore.getFolder(SENT_FOLDER_NAME)).thenReturn(sentFolder);
|
||||
when(sentFolder.getId()).thenReturn(1L);
|
||||
when(sentFolder.getDatabaseId()).thenReturn(1L);
|
||||
when(localFolder.exists()).thenReturn(true);
|
||||
when(transportProvider.getTransport(appContext, account)).thenReturn(transport);
|
||||
when(localFolder.getMessages(null)).thenReturn(Collections.singletonList(localMessageToSend1));
|
||||
|
|
|
@ -163,7 +163,7 @@ public class MigrationTest {
|
|||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getId());
|
||||
Assert.assertEquals(2, msg.getDatabaseId());
|
||||
Assert.assertEquals(13, msg.getHeaderNames().size());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(3, msg.getId());
|
||||
Assert.assertEquals(3, msg.getDatabaseId());
|
||||
Assert.assertEquals(8, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(1, msg.getHeader(MimeHeader.HEADER_CONTENT_TYPE).length);
|
||||
|
@ -301,7 +301,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(4, msg.getId());
|
||||
Assert.assertEquals(4, msg.getDatabaseId());
|
||||
Assert.assertEquals(8, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getAttachmentCount());
|
||||
|
@ -360,7 +360,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(5, msg.getId());
|
||||
Assert.assertEquals(5, msg.getDatabaseId());
|
||||
Assert.assertEquals(13, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/encrypted", msg.getMimeType());
|
||||
Assert.assertEquals(2, msg.getAttachmentCount());
|
||||
|
@ -478,7 +478,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(6, msg.getId());
|
||||
Assert.assertEquals(6, msg.getDatabaseId());
|
||||
Assert.assertEquals(12, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -565,7 +565,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(7, msg.getId());
|
||||
Assert.assertEquals(7, msg.getDatabaseId());
|
||||
Assert.assertEquals(12, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("text/plain", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -623,7 +623,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(8, msg.getId());
|
||||
Assert.assertEquals(8, msg.getDatabaseId());
|
||||
Assert.assertEquals(9, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/alternative", msg.getMimeType());
|
||||
Assert.assertEquals(0, msg.getAttachmentCount());
|
||||
|
@ -688,7 +688,7 @@ public class MigrationTest {
|
|||
fp.add(FetchProfile.Item.BODY);
|
||||
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
|
||||
|
||||
Assert.assertEquals(9, msg.getId());
|
||||
Assert.assertEquals(9, msg.getDatabaseId());
|
||||
Assert.assertEquals(11, msg.getHeaderNames().size());
|
||||
Assert.assertEquals("multipart/mixed", msg.getMimeType());
|
||||
Assert.assertEquals(1, msg.getAttachmentCount());
|
||||
|
|
|
@ -336,7 +336,7 @@ public class StoreSchemaDefinitionTest {
|
|||
LockableDatabase lockableDatabase = createLockableDatabase();
|
||||
|
||||
LocalStore localStore = mock(LocalStore.class);
|
||||
localStore.database = lockableDatabase;
|
||||
when(localStore.getDatabase()).thenReturn(lockableDatabase);
|
||||
when(localStore.getContext()).thenReturn(context);
|
||||
when(localStore.getAccount()).thenReturn(account);
|
||||
|
||||
|
|
Loading…
Reference in a new issue