IMAP: implement forwarded and answered flags

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@331 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-05 00:18:29 +00:00
parent 88081c9e42
commit f15d9c25e4
2 changed files with 23 additions and 5 deletions

View File

@ -544,7 +544,8 @@ public class ExchangeSession {
} else if ("x0E070003".equals(localName)) { } else if ("x0E070003".equals(localName)) {
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 = "102".equals(prop.getPropertyAsString()) || "103".equals(prop.getPropertyAsString());
message.forwarded = "104".equals(prop.getPropertyAsString());
} else if ("isdeleted".equals(localName)) { } else if ("isdeleted".equals(localName)) {
message.deleted = "1".equals(prop.getPropertyAsString()); message.deleted = "1".equals(prop.getPropertyAsString());
} else if ("message-id".equals(prop.getLocalName())) { } else if ("message-id".equals(prop.getLocalName())) {
@ -583,6 +584,14 @@ public class ExchangeSession {
patchMethod.addPropertyToSet("x10900003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/"); patchMethod.addPropertyToSet("x10900003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/");
} else if ("answered".equals(entry.getKey())) { } else if ("answered".equals(entry.getKey())) {
patchMethod.addPropertyToSet("x10810003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/"); patchMethod.addPropertyToSet("x10810003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/");
if ("102".equals(entry.getValue())) {
patchMethod.addPropertyToSet("x10800003", "261", "f", "http://schemas.microsoft.com/mapi/proptag/");
}
} else if ("forwarded".equals(entry.getKey())) {
patchMethod.addPropertyToSet("x10810003", entry.getValue(), "f", "http://schemas.microsoft.com/mapi/proptag/");
if ("104".equals(entry.getValue())) {
patchMethod.addPropertyToSet("x10800003", "262", "f", "http://schemas.microsoft.com/mapi/proptag/");
}
} else if ("bcc".equals(entry.getKey())) { } else if ("bcc".equals(entry.getKey())) {
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())) {
@ -949,6 +958,7 @@ public class ExchangeSession {
public boolean flagged; public boolean flagged;
public boolean draft; public boolean draft;
public boolean answered; public boolean answered;
public boolean forwarded;
public long getUidAsLong() { public long getUidAsLong() {
byte[] decodedValue = Base64.decode(uid.getBytes()); byte[] decodedValue = Base64.decode(uid.getBytes());
@ -982,6 +992,9 @@ public class ExchangeSession {
if (answered) { if (answered) {
buffer.append("\\Answered "); buffer.append("\\Answered ");
} }
if (forwarded) {
buffer.append("$Forwarded ");
}
return buffer.toString().trim(); return buffer.toString().trim();
} }

View File

@ -155,8 +155,8 @@ public class ImapConnection extends AbstractConnection {
} else { } else {
sendClient("* OK [UIDNEXT " + (messages.get(messages.size() - 1).getUidAsLong() + 1) + "]"); sendClient("* OK [UIDNEXT " + (messages.get(messages.size() - 1).getUidAsLong() + 1) + "]");
} }
sendClient("* FLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen $Forwarded Forwarded Junk)"); sendClient("* FLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen $Forwarded Junk)");
sendClient("* OK [PERMANENTFLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen $Forwarded Forwarded Junk \\*)]"); sendClient("* OK [PERMANENTFLAGS (\\Answered \\Deleted \\Draft \\Flagged \\Seen $Forwarded Junk \\*)]");
//sendClient("* [UNSEEN 1] first unseen message in inbox"); //sendClient("* [UNSEEN 1] first unseen message in inbox");
sendClient(commandId + " OK [READ-WRITE] " + command + " completed"); sendClient(commandId + " OK [READ-WRITE] " + command + " completed");
} else { } else {
@ -296,7 +296,9 @@ public class ImapConnection extends AbstractConnection {
} else if ("\\Flagged".equals(flag)) { } else if ("\\Flagged".equals(flag)) {
properties.put("flagged", "2"); properties.put("flagged", "2");
} else if ("\\Answered".equals(flag)) { } else if ("\\Answered".equals(flag)) {
properties.put("answered", "103"); properties.put("answered", "102");
} else if ("$Forwarded".equals(flag)) {
properties.put("forwarded", "104");
} else if ("\\Draft".equals(flag)) { } else if ("\\Draft".equals(flag)) {
properties.put("draft", "9"); properties.put("draft", "9");
} else if ("Junk".equals(flag)) { } else if ("Junk".equals(flag)) {
@ -420,8 +422,11 @@ public class ImapConnection extends AbstractConnection {
properties.put("flagged", "2"); properties.put("flagged", "2");
message.flagged = true; message.flagged = true;
} else if ("\\Answered".equals(flag)) { } else if ("\\Answered".equals(flag)) {
properties.put("answered", "103"); properties.put("answered", "102");
message.answered = true; message.answered = true;
} else if ("$Forwarded".equals(flag)) {
properties.put("forwarded", "104");
message.forwarded = true;
} else if ("Junk".equals(flag)) { } else if ("Junk".equals(flag)) {
properties.put("junk", "1"); properties.put("junk", "1");
message.junk = true; message.junk = true;