1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 11:42:23 -05:00

IMAP: extend thunderbird changed uid workaround to all contexts

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@912 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-01-18 16:04:43 +00:00
parent 1dbb37dbc1
commit 833c2a4d41

View File

@ -245,16 +245,11 @@ public class ImapConnection extends AbstractConnection {
if (ranges == null) { if (ranges == null) {
sendClient(commandId + " BAD missing range parameter"); sendClient(commandId + " BAD missing range parameter");
} else { } else {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, ranges);
String parameters = null; String parameters = null;
if (tokens.hasMoreTokens()) { if (tokens.hasMoreTokens()) {
parameters = tokens.nextToken(); parameters = tokens.nextToken();
} }
if (!uidRangeIterator.hasNext() && currentFolder.previousMessages != null) { UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, ranges);
// message not found in current list, try to get message
// from previous list to handle recent uid change
uidRangeIterator = new UIDRangeIterator(currentFolder.previousMessages, ranges);
}
while (uidRangeIterator.hasNext()) { while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon(); DavGatewayTray.switchIcon();
ExchangeSession.Message message = uidRangeIterator.next(); ExchangeSession.Message message = uidRangeIterator.next();
@ -277,13 +272,13 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " OK SEARCH completed"); sendClient(commandId + " OK SEARCH completed");
} else if ("store".equalsIgnoreCase(subcommand)) { } else if ("store".equalsIgnoreCase(subcommand)) {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken()); UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, tokens.nextToken());
String action = tokens.nextToken(); String action = tokens.nextToken();
String flags = tokens.nextToken(); String flags = tokens.nextToken();
handleStore(commandId, uidRangeIterator, action, flags); handleStore(commandId, uidRangeIterator, action, flags);
} else if ("copy".equalsIgnoreCase(subcommand)) { } else if ("copy".equalsIgnoreCase(subcommand)) {
try { try {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken()); UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken()); String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (uidRangeIterator.hasNext()) { while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon(); DavGatewayTray.switchIcon();
@ -1179,6 +1174,16 @@ public class ImapConnection extends AbstractConnection {
return result; return result;
} }
protected UIDRangeIterator getUIDRangeIterator(ExchangeSession.Folder folder, String ranges) {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(folder.messages, ranges);
if (!uidRangeIterator.hasNext() && folder.previousMessages != null) {
// message not found in current list, try to get message
// from previous list to handle recent uid change
uidRangeIterator = new UIDRangeIterator(folder.previousMessages, ranges);
}
return uidRangeIterator;
}
/** /**
* Filter to output only headers, also count full size * Filter to output only headers, also count full size
*/ */