1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-12 14:08:38 -05:00

IMAP: implement index (non uid) COPY

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1489 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-10-02 16:16:27 +00:00
parent 0649996caf
commit 7798e535c9
2 changed files with 31 additions and 0 deletions

View File

@ -389,6 +389,19 @@ public class ImapConnection extends AbstractConnection {
String flags = tokens.nextToken();
handleStore(commandId, rangeIterator, action, flags);
} else if ("copy".equalsIgnoreCase(command)) {
try {
RangeIterator rangeIterator = new RangeIterator(currentFolder.messages, tokens.nextToken());
String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
while (rangeIterator.hasNext()) {
DavGatewayTray.switchIcon();
ExchangeSession.Message message = rangeIterator.next();
session.copyMessage(message, targetName);
}
sendClient(commandId + " OK copy completed");
} catch (HttpException e) {
sendClient(commandId + " NO " + e.getMessage());
}
} else if ("append".equalsIgnoreCase(command)) {
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
HashMap<String, String> properties = new HashMap<String, String>();

View File

@ -318,4 +318,22 @@ public class TestImap extends AbstractDavMailTestCase {
clientSocket.close();
Thread.sleep(5000);
}
public void testCopyMessage() throws IOException, InterruptedException, MessagingException {
testCreateFolder();
testCreateMessage();
writeLine(". UID FETCH 1:* (FLAGS)");
String messageLine = readLine();
int uidIndex = messageLine.indexOf("UID ") + 4;
messageUid = messageLine.substring(uidIndex, messageLine.indexOf(' ', uidIndex));
assertEquals(". OK UID FETCH completed", readFullAnswer("."));
writeLine(". UID COPY "+messageUid+" Trash");
assertEquals(". OK copy completed", readFullAnswer("."));
writeLine(". COPY 1 Trash");
assertEquals(". OK copy completed", readFullAnswer("."));
testDeleteFolder();
}
}