1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-10-31 15:35:05 -04:00

IMAP: use DAV:ishidden as persistent deleted flag

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@329 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-04 23:06:30 +00:00
parent 780a6e457c
commit 70a8286809
2 changed files with 15 additions and 30 deletions

View File

@ -545,6 +545,8 @@ public class ExchangeSession {
message.draft = "9".equals(prop.getPropertyAsString()); message.draft = "9".equals(prop.getPropertyAsString());
} else if ("x10810003".equals(localName)) { } else if ("x10810003".equals(localName)) {
message.answered = prop.getPropertyAsString().length() > 0; message.answered = prop.getPropertyAsString().length() > 0;
} else if ("ishidden".equals(localName)) {
message.deleted = "1".equals(prop.getPropertyAsString());
} else if ("message-id".equals(prop.getLocalName())) { } else if ("message-id".equals(prop.getLocalName())) {
message.messageId = prop.getPropertyAsString(); message.messageId = prop.getPropertyAsString();
if (message.messageId.startsWith("<") && message.messageId.endsWith(">")) { if (message.messageId.startsWith("<") && message.messageId.endsWith(">")) {
@ -585,6 +587,8 @@ public class ExchangeSession {
patchMethod.addPropertyToSet("bcc", entry.getValue(), "b", "urn:schemas:mailheader:"); patchMethod.addPropertyToSet("bcc", entry.getValue(), "b", "urn:schemas:mailheader:");
} else if ("draft".equals(entry.getKey())) { } else if ("draft".equals(entry.getKey())) {
patchMethod.addPropertyToSet("x0E070003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/"); patchMethod.addPropertyToSet("x0E070003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/");
} else if ("deleted".equals(entry.getKey())) {
patchMethod.addPropertyToSet("ishidden", entry.getValue(), "d", "DAV:");
} }
} }
} }
@ -609,9 +613,9 @@ public class ExchangeSession {
String searchRequest = "Select \"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" + String searchRequest = "Select \"DAV:uid\", \"http://schemas.microsoft.com/mapi/proptag/x0e080003\"" +
" ,\"http://schemas.microsoft.com/mapi/proptag/x10830003\", \"http://schemas.microsoft.com/mapi/proptag/x10900003\"" + " ,\"http://schemas.microsoft.com/mapi/proptag/x10830003\", \"http://schemas.microsoft.com/mapi/proptag/x10900003\"" +
" ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" + " ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" +
" ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\"" + " ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\", \"DAV:ishidden\"" +
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" + " FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n" + " WHERE \"DAV:isfolder\" = False\n" +
" ORDER BY \"urn:schemas:httpmail:date\" ASC"; " ORDER BY \"urn:schemas:httpmail:date\" ASC";
Enumeration folderEnum = DavGatewayHttpClientFacade.executeSearchMethod(wdr.retrieveSessionInstance(), folderUrl, searchRequest); Enumeration folderEnum = DavGatewayHttpClientFacade.executeSearchMethod(wdr.retrieveSessionInstance(), folderUrl, searchRequest);

View File

@ -143,8 +143,6 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " BAD missing folder argument"); sendClient(commandId + " BAD missing folder argument");
} }
} else if ("select".equalsIgnoreCase(command) || "examine".equalsIgnoreCase(command)) { } else if ("select".equalsIgnoreCase(command) || "examine".equalsIgnoreCase(command)) {
// first purge previous folder
expunge();
if (tokens.hasMoreTokens()) { if (tokens.hasMoreTokens()) {
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken()); String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
currentFolder = session.getFolder(folderName); currentFolder = session.getFolder(folderName);
@ -164,10 +162,11 @@ public class ImapConnection extends AbstractConnection {
} else { } else {
sendClient(commandId + " BAD command unrecognized"); sendClient(commandId + " BAD command unrecognized");
} }
} else if ("close".equalsIgnoreCase(command)) { } else if ("close".equalsIgnoreCase(command) || "expunge".equalsIgnoreCase(command)) {
expunge();
currentFolder = null; currentFolder = null;
messages = null; messages = null;
sendClient(commandId + " OK CLOSE completed"); sendClient(commandId + " OK "+command+" completed");
} else if ("create".equalsIgnoreCase(command)) { } else if ("create".equalsIgnoreCase(command)) {
if (tokens.hasMoreTokens()) { if (tokens.hasMoreTokens()) {
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken()); String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
@ -208,9 +207,9 @@ public class ImapConnection extends AbstractConnection {
while (rangeIterator.hasNext()) { while (rangeIterator.hasNext()) {
ExchangeSession.Message message = rangeIterator.next(); ExchangeSession.Message message = rangeIterator.next();
if (parameters == null) { if (parameters == null) {
sendClient("* " + (rangeIterator.currentIndex + 1) + " FETCH (UID " + message.getUidAsLong() + " FLAGS (" + (message.getImapFlags()) + "))"); sendClient("* " + (rangeIterator.currentIndex ) + " FETCH (UID " + message.getUidAsLong() + " FLAGS (" + (message.getImapFlags()) + "))");
} else if ("BODYSTRUCTURE".equals(parameters)) { } else if ("BODYSTRUCTURE".equals(parameters)) {
sendClient("* " + (rangeIterator.currentIndex + 1) + " FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"windows-1252\") NIL NIL \"QUOTED-PRINTABLE\" " + message.size + " 50 NIL NIL NIL NIL))"); sendClient("* " + (rangeIterator.currentIndex ) + " FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"windows-1252\") NIL NIL \"QUOTED-PRINTABLE\" " + message.size + " 50 NIL NIL NIL NIL))");
// send full message // send full message
} else if (parameters.indexOf("BODY[]") >= 0) { } else if (parameters.indexOf("BODY[]") >= 0) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -218,7 +217,7 @@ public class ImapConnection extends AbstractConnection {
baos.close(); baos.close();
DavGatewayTray.debug("Messagee size: " + message.size + " actual size:" + baos.size() + " message+headers: " + (message.size + baos.size())); DavGatewayTray.debug("Messagee size: " + message.size + " actual size:" + baos.size() + " message+headers: " + (message.size + baos.size()));
sendClient("* " + (rangeIterator.currentIndex + 1) + " FETCH (UID " + message.getUidAsLong() + " RFC822.SIZE " + baos.size() + " BODY[]<0>" + sendClient("* " + (rangeIterator.currentIndex ) + " FETCH (UID " + message.getUidAsLong() + " RFC822.SIZE " + baos.size() + " BODY[]<0>" +
" {" + baos.size() + "}"); " {" + baos.size() + "}");
os.write(baos.toByteArray()); os.write(baos.toByteArray());
os.flush(); os.flush();
@ -229,7 +228,7 @@ public class ImapConnection extends AbstractConnection {
HeaderOutputStream headerOutputStream = new HeaderOutputStream(baos); HeaderOutputStream headerOutputStream = new HeaderOutputStream(baos);
message.write(headerOutputStream); message.write(headerOutputStream);
baos.close(); baos.close();
sendClient("* " + (rangeIterator.currentIndex + 1) + " FETCH (UID " + message.getUidAsLong() + " RFC822.SIZE " + headerOutputStream.size() + " BODY[HEADER.FIELDS ()" + sendClient("* " + (rangeIterator.currentIndex ) + " FETCH (UID " + message.getUidAsLong() + " RFC822.SIZE " + headerOutputStream.size() + " BODY[HEADER.FIELDS ()" +
"] {" + baos.size() + "}"); "] {" + baos.size() + "}");
os.write(baos.toByteArray()); os.write(baos.toByteArray());
os.flush(); os.flush();
@ -266,7 +265,7 @@ public class ImapConnection extends AbstractConnection {
while (rangeIterator.hasNext()) { while (rangeIterator.hasNext()) {
ExchangeSession.Message message = rangeIterator.next(); ExchangeSession.Message message = rangeIterator.next();
updateFlags(message, action, flags); updateFlags(message, action, flags);
sendClient("* " + (rangeIterator.currentIndex + 1) + " FETCH (UID " + message.getUidAsLong() + " FLAGS (" + (message.getImapFlags()) + "))"); sendClient("* " + (rangeIterator.currentIndex) + " FETCH (UID " + message.getUidAsLong() + " FLAGS (" + (message.getImapFlags()) + "))");
} }
sendClient(commandId + " OK STORE completed"); sendClient(commandId + " OK STORE completed");
} else if ("copy".equalsIgnoreCase(subcommand)) { } else if ("copy".equalsIgnoreCase(subcommand)) {
@ -285,26 +284,8 @@ public class ImapConnection extends AbstractConnection {
} else { } else {
sendClient(commandId + " BAD command unrecognized"); sendClient(commandId + " BAD command unrecognized");
} }
} else if ("fetch".equalsIgnoreCase(command)) {
// TODO : refactor with uid fetch
if (tokens.hasMoreTokens()) {
int messageIndex = Integer.parseInt(tokens.nextToken());
ExchangeSession.Message message = messages.get(messageIndex - 1);
if (tokens.hasMoreTokens()) {
String parameters = tokens.nextToken();
if ("BODYSTRUCTURE".equals(parameters)) {
sendClient("* " + messageIndex + " FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"windows-1252\") NIL NIL \"QUOTED-PRINTABLE\" " + message.size + " 50 NIL NIL NIL NIL))");
sendClient(commandId + " OK FETCH completed");
} else {
sendClient("* " + messageIndex + " 1 FETCH (BODY[TEXT]<0> {" + message.size + "}");
message.write(os);
sendClient(commandId + " OK FETCH completed");
}
}
}
} else if ("append".equalsIgnoreCase(command)) { } else if ("append".equalsIgnoreCase(command)) {
String folderName = BASE64MailboxDecoder.decode(tokens.nextToken()); String folderName = BASE64MailboxDecoder.decode(tokens.nextToken());
// TODO handle flags
String flags = tokens.nextToken(); String flags = tokens.nextToken();
HashMap<String, String> properties = new HashMap<String, String>(); HashMap<String, String> properties = new HashMap<String, String>();
StringTokenizer flagtokenizer = new StringTokenizer(flags); StringTokenizer flagtokenizer = new StringTokenizer(flags);
@ -347,7 +328,6 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " OK APPEND completed"); sendClient(commandId + " OK APPEND completed");
} else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) { } else if ("noop".equalsIgnoreCase(command) || "check".equalsIgnoreCase(command)) {
if (currentFolder != null) { if (currentFolder != null) {
expunge();
currentFolder = session.getFolder(currentFolder.folderName); currentFolder = session.getFolder(currentFolder.folderName);
messages = session.getAllMessages(currentFolder.folderUrl); messages = session.getAllMessages(currentFolder.folderUrl);
sendClient("* " + currentFolder.objectCount + " EXISTS"); sendClient("* " + currentFolder.objectCount + " EXISTS");
@ -435,6 +415,7 @@ public class ImapConnection extends AbstractConnection {
message.read = true; message.read = true;
} else if ("\\Deleted".equals(flag)) { } else if ("\\Deleted".equals(flag)) {
message.deleted = true; message.deleted = true;
properties.put("deleted", "1");
} else if ("\\Flagged".equals(flag)) { } else if ("\\Flagged".equals(flag)) {
properties.put("flagged", "2"); properties.put("flagged", "2");
message.flagged = true; message.flagged = true;