introduce constants for message projection column indexes
This commit is contained in:
parent
2fbd6f61a8
commit
472733edcd
2 changed files with 53 additions and 26 deletions
|
@ -54,16 +54,16 @@ public class LocalMessage extends MimeMessage {
|
||||||
|
|
||||||
|
|
||||||
void populateFromGetMessageCursor(Cursor cursor) throws MessagingException {
|
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);
|
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) {
|
if (from.length > 0) {
|
||||||
this.setFrom(from[0]);
|
this.setFrom(from[0]);
|
||||||
}
|
}
|
||||||
this.setInternalSentDate(new Date(cursor.getLong(2)));
|
this.setInternalSentDate(new Date(cursor.getLong(LocalStore.MSG_INDEX_DATE)));
|
||||||
this.setUid(cursor.getString(3));
|
this.setUid(cursor.getString(LocalStore.MSG_INDEX_UID));
|
||||||
String flagList = cursor.getString(4);
|
String flagList = cursor.getString(LocalStore.MSG_INDEX_FLAGS);
|
||||||
if (flagList != null && flagList.length() > 0) {
|
if (flagList != null && flagList.length() > 0) {
|
||||||
String[] flags = flagList.split(",");
|
String[] flags = flagList.split(",");
|
||||||
|
|
||||||
|
@ -79,39 +79,39 @@ public class LocalMessage extends MimeMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.databaseId = cursor.getLong(5);
|
this.databaseId = cursor.getLong(LocalStore.MSG_INDEX_ID);
|
||||||
this.setRecipients(RecipientType.TO, Address.unpack(cursor.getString(6)));
|
this.setRecipients(RecipientType.TO, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_TO)));
|
||||||
this.setRecipients(RecipientType.CC, Address.unpack(cursor.getString(7)));
|
this.setRecipients(RecipientType.CC, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_CC)));
|
||||||
this.setRecipients(RecipientType.BCC, Address.unpack(cursor.getString(8)));
|
this.setRecipients(RecipientType.BCC, Address.unpack(cursor.getString(LocalStore.MSG_INDEX_BCC)));
|
||||||
this.setReplyTo(Address.unpack(cursor.getString(9)));
|
this.setReplyTo(Address.unpack(cursor.getString(LocalStore.MSG_INDEX_REPLY_TO)));
|
||||||
|
|
||||||
this.attachmentCount = cursor.getInt(10);
|
this.attachmentCount = cursor.getInt(LocalStore.MSG_INDEX_ATTACHMENT_COUNT);
|
||||||
this.setInternalDate(new Date(cursor.getLong(11)));
|
this.setInternalDate(new Date(cursor.getLong(LocalStore.MSG_INDEX_INTERNAL_DATE)));
|
||||||
this.setMessageId(cursor.getString(12));
|
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);
|
DatabasePreviewType databasePreviewType = DatabasePreviewType.fromDatabaseValue(previewTypeString);
|
||||||
previewType = databasePreviewType.getPreviewType();
|
previewType = databasePreviewType.getPreviewType();
|
||||||
if (previewType == PreviewType.TEXT) {
|
if (previewType == PreviewType.TEXT) {
|
||||||
preview = cursor.getString(14);
|
preview = cursor.getString(LocalStore.MSG_INDEX_PREVIEW);
|
||||||
} else {
|
} else {
|
||||||
preview = "";
|
preview = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mFolder == null) {
|
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);
|
f.open(LocalFolder.OPEN_MODE_RW);
|
||||||
this.mFolder = f;
|
this.mFolder = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
threadId = (cursor.isNull(15)) ? -1 : cursor.getLong(15);
|
threadId = (cursor.isNull(LocalStore.MSG_INDEX_THREAD_ID)) ? -1 : cursor.getLong(LocalStore.MSG_INDEX_THREAD_ID);
|
||||||
rootId = (cursor.isNull(16)) ? -1 : cursor.getLong(16);
|
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 deleted = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_DELETED) == 1);
|
||||||
boolean read = (cursor.getInt(18) == 1);
|
boolean read = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_READ) == 1);
|
||||||
boolean flagged = (cursor.getInt(19) == 1);
|
boolean flagged = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_FLAGGED) == 1);
|
||||||
boolean answered = (cursor.getInt(20) == 1);
|
boolean answered = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_ANSWERED) == 1);
|
||||||
boolean forwarded = (cursor.getInt(21) == 1);
|
boolean forwarded = (cursor.getInt(LocalStore.MSG_INDEX_FLAG_FORWARDED) == 1);
|
||||||
|
|
||||||
setFlagInternal(Flag.DELETED, deleted);
|
setFlagInternal(Flag.DELETED, deleted);
|
||||||
setFlagInternal(Flag.SEEN, read);
|
setFlagInternal(Flag.SEEN, read);
|
||||||
|
@ -119,10 +119,10 @@ public class LocalMessage extends MimeMessage {
|
||||||
setFlagInternal(Flag.ANSWERED, answered);
|
setFlagInternal(Flag.ANSWERED, answered);
|
||||||
setFlagInternal(Flag.FORWARDED, forwarded);
|
setFlagInternal(Flag.FORWARDED, forwarded);
|
||||||
|
|
||||||
setMessagePartId(cursor.getLong(22));
|
setMessagePartId(cursor.getLong(LocalStore.MSG_INDEX_MESSAGE_PART_ID));
|
||||||
mimeType = cursor.getString(23);
|
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) {
|
if (header != null) {
|
||||||
MessageHeaderParser.parse(this, new ByteArrayInputStream(header));
|
MessageHeaderParser.parse(this, new ByteArrayInputStream(header));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -103,6 +103,33 @@ public class LocalStore extends Store implements Serializable {
|
||||||
"folder_id, preview, threads.id, threads.root, deleted, read, flagged, answered, " +
|
"folder_id, preview, threads.id, threads.root, deleted, read, flagged, answered, " +
|
||||||
"forwarded, message_part_id, messages.mime_type, preview_type, header ";
|
"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 =
|
static final String GET_FOLDER_COLS =
|
||||||
"folders.id, name, visible_limit, last_updated, status, push_state, last_pushed, " +
|
"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";
|
"integrate, top_group, poll_class, push_class, display_class, notify_class, more_messages";
|
||||||
|
|
Loading…
Reference in a new issue