Merge "Delete POP emails when they are removed from the server" into jb-ub-mail-ur10
This commit is contained in:
commit
64690e9452
@ -50,6 +50,7 @@ import com.android.emailcommon.provider.EmailContent.SyncColumns;
|
|||||||
import com.android.emailcommon.provider.Mailbox;
|
import com.android.emailcommon.provider.Mailbox;
|
||||||
import com.android.emailcommon.service.EmailServiceStatus;
|
import com.android.emailcommon.service.EmailServiceStatus;
|
||||||
import com.android.emailcommon.service.IEmailServiceCallback;
|
import com.android.emailcommon.service.IEmailServiceCallback;
|
||||||
|
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||||
import com.android.mail.providers.UIProvider;
|
import com.android.mail.providers.UIProvider;
|
||||||
import com.android.mail.providers.UIProvider.AccountCapabilities;
|
import com.android.mail.providers.UIProvider.AccountCapabilities;
|
||||||
import com.android.mail.providers.UIProvider.AttachmentState;
|
import com.android.mail.providers.UIProvider.AttachmentState;
|
||||||
@ -60,6 +61,7 @@ import org.apache.james.mime4j.EOLConvertingInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class Pop3Service extends Service {
|
public class Pop3Service extends Service {
|
||||||
private static final String TAG = "Pop3Service";
|
private static final String TAG = "Pop3Service";
|
||||||
@ -323,20 +325,6 @@ public class Pop3Service extends Service {
|
|||||||
/*
|
/*
|
||||||
* Get all messageIds in the mailbox.
|
* Get all messageIds in the mailbox.
|
||||||
* We don't necessarily need to sync all of them.
|
* We don't necessarily need to sync all of them.
|
||||||
*
|
|
||||||
* There are four end conditions:
|
|
||||||
* 1. We currently have zero local messages. In this case, we will sync the most recent
|
|
||||||
* DEFAULT_SYNC_COUNT, then stop.
|
|
||||||
* 2. We have some local messages, and after encountering them, we find some older
|
|
||||||
* messages that do not yet exist locally. In this case, we will load whichever came
|
|
||||||
* before the ones we already had locally, and also deltaMessageCount additional
|
|
||||||
* older messages.
|
|
||||||
* 3. We have some local messages, but after examining the most recent
|
|
||||||
* DEFAULT_SYNC_COUNT remote messages, we still have not encountered any that exist
|
|
||||||
* locally. In this case, we'll stop adding new messages to sync, leaving a gap between
|
|
||||||
* the ones we've just loaded and the ones we already had.
|
|
||||||
* 4. We examine all of the remote messages before running into any of our count
|
|
||||||
* limitations.
|
|
||||||
*/
|
*/
|
||||||
remoteMessages = remoteFolder.getMessages(remoteMessageCount, remoteMessageCount);
|
remoteMessages = remoteFolder.getMessages(remoteMessageCount, remoteMessageCount);
|
||||||
LogUtils.d(Logging.LOG_TAG, "remoteMessageCount " + remoteMessageCount);
|
LogUtils.d(Logging.LOG_TAG, "remoteMessageCount " + remoteMessageCount);
|
||||||
@ -355,9 +343,24 @@ public class Pop3Service extends Service {
|
|||||||
remoteUidMap.put(uid, message);
|
remoteUidMap.put(uid, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Figure out which messages we need to sync. Start at the most recent ones, and keep
|
||||||
|
* going until we hit one of four end conditions:
|
||||||
|
* 1. We currently have zero local messages. In this case, we will sync the most recent
|
||||||
|
* DEFAULT_SYNC_COUNT, then stop.
|
||||||
|
* 2. We have some local messages, and after encountering them, we find some older
|
||||||
|
* messages that do not yet exist locally. In this case, we will load whichever came
|
||||||
|
* before the ones we already had locally, and also deltaMessageCount additional
|
||||||
|
* older messages.
|
||||||
|
* 3. We have some local messages, but after examining the most recent
|
||||||
|
* DEFAULT_SYNC_COUNT remote messages, we still have not encountered any that exist
|
||||||
|
* locally. In this case, we'll stop adding new messages to sync, leaving a gap between
|
||||||
|
* the ones we've just loaded and the ones we already had.
|
||||||
|
* 4. We examine all of the remote messages before running into any of our count
|
||||||
|
* limitations.
|
||||||
|
*/
|
||||||
for (final Pop3Message message : remoteMessages) {
|
for (final Pop3Message message : remoteMessages) {
|
||||||
final String uid = message.getUid();
|
final String uid = message.getUid();
|
||||||
|
|
||||||
final LocalMessageInfo localMessage = localMessageMap.get(uid);
|
final LocalMessageInfo localMessage = localMessageMap.get(uid);
|
||||||
if (localMessage == null) {
|
if (localMessage == null) {
|
||||||
count++;
|
count++;
|
||||||
@ -444,10 +447,6 @@ public class Pop3Service extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove any messages that are in the local store but no longer on the remote store.
|
// Remove any messages that are in the local store but no longer on the remote store.
|
||||||
// TODO: This is disabled for now, because it could be that the local copy of the
|
|
||||||
// message is the only one that exists. We should find a way to handle intentional
|
|
||||||
// deletions coming from the server.
|
|
||||||
/*
|
|
||||||
HashSet<String> localUidsToDelete = new HashSet<String>(localMessageMap.keySet());
|
HashSet<String> localUidsToDelete = new HashSet<String>(localMessageMap.keySet());
|
||||||
localUidsToDelete.removeAll(remoteUidMap.keySet());
|
localUidsToDelete.removeAll(remoteUidMap.keySet());
|
||||||
for (String uidToDelete : localUidsToDelete) {
|
for (String uidToDelete : localUidsToDelete) {
|
||||||
@ -472,7 +471,7 @@ public class Pop3Service extends Service {
|
|||||||
Uri deleteRowToDelete = ContentUris.withAppendedId(
|
Uri deleteRowToDelete = ContentUris.withAppendedId(
|
||||||
EmailContent.Message.DELETED_CONTENT_URI, infoToDelete.mId);
|
EmailContent.Message.DELETED_CONTENT_URI, infoToDelete.mId);
|
||||||
resolver.delete(deleteRowToDelete, null, null);
|
resolver.delete(deleteRowToDelete, null, null);
|
||||||
} */
|
}
|
||||||
|
|
||||||
LogUtils.d(TAG, "loadUnsynchedMessages " + unsyncedMessages.size());
|
LogUtils.d(TAG, "loadUnsynchedMessages " + unsyncedMessages.size());
|
||||||
// Load messages we need to sync
|
// Load messages we need to sync
|
||||||
|
Loading…
Reference in New Issue
Block a user