IMAP: additional fix for Exchange 2010 header search, use PR_TRANSPORT_MESSAGE_HEADERS

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1986 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-08-05 11:59:00 +00:00
parent a94826b21f
commit 0238281523
2 changed files with 21 additions and 10 deletions

View File

@ -796,20 +796,17 @@ public class EwsExchangeSession extends ExchangeSession {
}
protected class HeaderCondition extends AttributeCondition {
protected static class HeaderCondition extends AttributeCondition {
protected HeaderCondition(String attributeName, Operator operator, String value) {
super(attributeName, operator, value);
protected HeaderCondition(String attributeName, String value) {
super(attributeName, Operator.Contains, value);
containmentMode = ContainmentMode.Substring;
containmentComparison = ContainmentComparison.IgnoreCase;
}
@Override
protected FieldURI getFieldURI() {
// Exchange 2010 does not support header search
if (serverVersion.startsWith("Exchange2010") && "message-id".equals(attributeName)) {
return new UnindexedFieldURI("message:InternetMessageId");
} else {
return new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.InternetHeaders, attributeName);
}
return new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.InternetHeaders, attributeName);
}
}
@ -865,7 +862,17 @@ public class EwsExchangeSession extends ExchangeSession {
@Override
public Condition headerIsEqualTo(String headerName, String value) {
return new HeaderCondition(headerName, Operator.IsEqualTo, value);
if (serverVersion.startsWith("Exchange2010")) {
if ("message-id".equals(headerName)) {
return new AttributeCondition(headerName, Operator.Contains, value, ContainmentMode.Substring, ContainmentComparison.IgnoreCase);
} else {
// Exchange 2010 does not support header search, use PR_TRANSPORT_MESSAGE_HEADERS instead
return new AttributeCondition("messageheaders", Operator.Contains, headerName+": "+value, ContainmentMode.Substring, ContainmentComparison.IgnoreCase);
}
} else {
return new HeaderCondition(headerName, value);
}
}
@Override

View File

@ -232,6 +232,10 @@ public final class Field {
// attachments
FIELD_MAP.put("attachments", new UnindexedFieldURI("item:Attachments"));
// headers
FIELD_MAP.put("message-id", new UnindexedFieldURI("message:InternetMessageId"));
FIELD_MAP.put("messageheaders", new ExtendedFieldURI(0x007D, ExtendedFieldURI.PropertyType.String));
}
/**