1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -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) {
sendClient(commandId + " BAD missing range parameter");
} else {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, ranges);
String parameters = null;
if (tokens.hasMoreTokens()) {
parameters = tokens.nextToken();
}
if (!uidRangeIterator.hasNext() && currentFolder.previousMessages != null) {
// message not found in current list, try to get message
// from previous list to handle recent uid change
uidRangeIterator = new UIDRangeIterator(currentFolder.previousMessages, ranges);
}
UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, ranges);
while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = uidRangeIterator.next();
@ -277,13 +272,13 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " OK SEARCH completed");
} else if ("store".equalsIgnoreCase(subcommand)) {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken());
UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, tokens.nextToken());
String action = tokens.nextToken();
String flags = tokens.nextToken();
handleStore(commandId, uidRangeIterator, action, flags);
} else if ("copy".equalsIgnoreCase(subcommand)) {
try {
UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken());
UIDRangeIterator uidRangeIterator = getUIDRangeIterator(currentFolder, tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (uidRangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
@ -1179,6 +1174,16 @@ public class ImapConnection extends AbstractConnection {
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
*/