mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-15 22:50:16 -05:00
First working sync of messages
This commit is contained in:
parent
33fd9fa51f
commit
97a70add8d
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
@ -61,6 +62,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
|
||||
// Holds the parser's value for isLooping()
|
||||
boolean mIsLooping = false;
|
||||
private List<Message> newEmails;
|
||||
|
||||
public EmailSyncAdapter(MailboxAdapter mailbox, AccountAdapter account) {
|
||||
super(mailbox, account);
|
||||
@ -72,6 +74,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
boolean res = p.parse();
|
||||
// Hold on to the parser's value for isLooping() to pass back to the service
|
||||
mIsLooping = p.isLooping();
|
||||
newEmails = p.newEmails;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -262,7 +265,7 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
switch (tag) {
|
||||
case Tags.SYNC_SERVER_ID:
|
||||
String serverId = getValue();
|
||||
// msg.mServerId = serverId;
|
||||
msg.setUid(serverId);
|
||||
break;
|
||||
case Tags.SYNC_APPLICATION_DATA:
|
||||
addData(msg);
|
||||
@ -838,4 +841,8 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Message> getMessages() {
|
||||
return newEmails;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.fsck.k9.mail.store.exchange.adapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class GetItemEstimateParser extends Parser {
|
||||
|
||||
private String mCollectionId;
|
||||
private int mEstimate;
|
||||
|
||||
public GetItemEstimateParser(InputStream in) throws IOException {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parse() throws IOException {
|
||||
boolean res = true;
|
||||
if (nextTag(START_DOCUMENT) != Tags.GIE_GET_ITEM_ESTIMATE) {
|
||||
throw new IOException();
|
||||
}
|
||||
while (nextTag(START_DOCUMENT) != END_DOCUMENT) {
|
||||
switch (tag) {
|
||||
case Tags.GIE_RESPONSE:
|
||||
res = parseGIEResponse() && res;
|
||||
break;
|
||||
default:
|
||||
skipTag();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private boolean parseGIEResponse() throws IOException {
|
||||
if (nextTag(Tags.GIE_RESPONSE) == Tags.GIE_STATUS) {
|
||||
int status = getValueInt();
|
||||
if (status != 1)
|
||||
return false;
|
||||
|
||||
if (nextTag(Tags.GIE_RESPONSE) == Tags.GIE_COLLECTION) {
|
||||
String collectionId;
|
||||
int estimate;
|
||||
|
||||
if (nextTag(Tags.GIE_COLLECTION) == Tags.GIE_COLLECTION_ID) {
|
||||
collectionId = getValue();
|
||||
} else return false;
|
||||
|
||||
if (nextTag(Tags.GIE_COLLECTION) == Tags.GIE_ESTIMATE) {
|
||||
estimate = getValueInt();
|
||||
} else return false;
|
||||
|
||||
mCollectionId = collectionId;
|
||||
mEstimate = estimate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getCollectionId() {
|
||||
return mCollectionId;
|
||||
}
|
||||
|
||||
public int getEstimate() {
|
||||
return mEstimate;
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ public class MailboxAdapter {
|
||||
|
||||
static final int CHECK_INTERVAL_PING = 0;
|
||||
|
||||
String mSyncKey;
|
||||
static String mSyncKey;
|
||||
|
||||
int mSyncInterval;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user