Carddav: fix boolean field handling

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1194 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-18 21:33:22 +00:00
parent c4631c5dc4
commit 9a701c6385
3 changed files with 38 additions and 26 deletions

View File

@ -2800,10 +2800,10 @@ public abstract class ExchangeSession {
} else if ("CLASS".equals(property.getKey())) {
if ("PUBLIC".equals(property.getValue())) {
properties.put("sensitivity", "0");
properties.put("private", "0");
properties.put("private", "false");
} else {
properties.put("sensitivity", "2");
properties.put("private", "1");
properties.put("private", "true");
}
} else if ("X-ASSISTANT".equals(property.getKey())) {
properties.put("secretarycn", property.getValue());
@ -2819,7 +2819,8 @@ public abstract class ExchangeSession {
for (String key : CONTACT_ATTRIBUTES) {
if (!"imapUid".equals(key) && !"etag".equals(key) && !"urlcompname".equals(key) &&
!properties.containsKey(key)) {
properties.put(key, null);
// TODO: enable
//properties.put(key, null);
}
}

View File

@ -673,7 +673,7 @@ public class DavExchangeSession extends ExchangeSession {
}
ArrayList<DavConstants> changeList = new ArrayList<DavConstants>();
changeList.add(Field.createDavProperty("attachmentContactPhoto", "1"));
changeList.add(Field.createDavProperty("attachmentContactPhoto", "true"));
changeList.add(Field.createDavProperty("renderingPosition", "-1"));
final PropPatchMethod attachmentPropPatchMethod = new PropPatchMethod(contactPictureUrl, changeList);
@ -1210,7 +1210,8 @@ public class DavExchangeSession extends ExchangeSession {
@Override
public ExchangeSession.ContactPhoto getContactPhoto(ExchangeSession.Contact contact) throws IOException {
ContactPhoto contactPhoto;
final GetMethod method = new GetMethod(getFolderPath(CONTACTS) + '/' + contact.get("urlcompname") + "/ContactPicture.jpg");
final GetMethod method = new GetMethod(contact.getHref() + "/ContactPicture.jpg");
method.setRequestHeader("Translate", "f");
method.setRequestHeader("Accept-Encoding", "gzip");
try {

View File

@ -250,8 +250,8 @@ public class Field {
//createField("keywords", DistinguishedPropertySetType.PublicStrings, "Keywords", ); // PS_PUBLIC_STRINGS Keywords String
// contact private flags
createField("private", DistinguishedPropertySetType.Common, 0x8506, "private"); // True/False
createField("writeprivate", DistinguishedPropertySetType.Common, 0x8506, PropertyType.String10);
createField("private", DistinguishedPropertySetType.Common, 0x8506, "private", PropertyType.Boolean); // True/False
createField("writeprivate", DistinguishedPropertySetType.Common, 0x8506, PropertyType.Boolean);
createField("sensitivity", 0x0036, PropertyType.Long); // PR_SENSITIVITY SENSITIVITY_PRIVATE = 2, SENSITIVITY_PERSONAL = 1, SENSITIVITY_NONE = 0
createField("haspicture", DistinguishedPropertySetType.Address, 0x8015, "haspicture"); // True/False
@ -279,17 +279,18 @@ public class Field {
String name = 'x' + toHexString(propertyTag) + propertyTypeMap.get(propertyType);
Field field;
if (propertyType == PropertyType.Binary) {
field = new Field(alias, SCHEMAS_MAPI_PROPTAG, name, null, "bin.base64");
field = new Field(alias, SCHEMAS_MAPI_PROPTAG, name, null, "bin.base64", propertyType);
} else {
field = new Field(alias, SCHEMAS_MAPI_PROPTAG, name);
}
if (propertyType == PropertyType.Integer || propertyType == PropertyType.Long) {
field.isIntValue = true;
field = new Field(alias, SCHEMAS_MAPI_PROPTAG, name, propertyType);
}
fieldMap.put(field.alias, field);
}
protected static void createField(String alias, DistinguishedPropertySetType propertySetType, int propertyTag, String responseAlias) {
createField(alias, propertySetType, propertyTag, responseAlias, null);
}
protected static void createField(String alias, DistinguishedPropertySetType propertySetType, int propertyTag, String responseAlias, PropertyType propertyType) {
String name;
if (propertySetType == DistinguishedPropertySetType.Address) {
// Address namespace expects integer names
@ -299,15 +300,15 @@ public class Field {
name = "0x" + toHexString(propertyTag);
}
Field field = new Field(alias, Namespace.getNamespace(SCHEMAS_MAPI_ID.getURI() +
'{' + distinguishedPropertySetMap.get(propertySetType) + "}/"), name, responseAlias, null);
'{' + distinguishedPropertySetMap.get(propertySetType) + "}/"), name, responseAlias, null, propertyType);
fieldMap.put(field.alias, field);
}
protected static void createField(String alias, DistinguishedPropertySetType propertySetType, int propertyTag, PropertyType propertyType) {
String name = "_x" + propertyTypeMap.get(propertyType) + "_x" + toHexString(propertyTag);
String name = "_x0030_x" + toHexString(propertyTag);
Field field = new Field(alias, Namespace.getNamespace(SCHEMAS_MAPI_ID.getURI() +
'{' + distinguishedPropertySetMap.get(propertySetType) + "}/"), name);
'{' + distinguishedPropertySetMap.get(propertySetType) + "}/"), name, propertyType);
fieldMap.put(field.alias, field);
}
@ -317,38 +318,41 @@ public class Field {
}
protected static void createField(String alias, Namespace namespace, String name) {
Field field = new Field(alias, namespace, name);
Field field = new Field(alias, namespace, name, null);
fieldMap.put(field.alias, field);
}
protected static void createField(String alias, Namespace namespace, String name, PropertyType propertyType) {
Field field = new Field(alias, namespace, name);
if (propertyType == PropertyType.StringArray) {
field.isMultivalued = true;
}
Field field = new Field(alias, namespace, name, propertyType);
fieldMap.put(field.alias, field);
}
protected final DavPropertyName davPropertyName;
protected final PropertyType propertyType;
protected final String alias;
protected final String uri;
protected final String requestPropertyString;
protected final DavPropertyName responsePropertyName;
protected final String cast;
protected boolean isIntValue;
protected boolean isMultivalued;
protected final boolean isIntValue;
protected final boolean isMultivalued;
protected final boolean isBooleanValue;
public Field(Namespace namespace, String name) {
this(name, namespace, name);
this(name, namespace, name, null);
}
public Field(String alias, Namespace namespace, String name) {
this(alias, namespace, name, null, null);
public Field(String alias, Namespace namespace, String name, PropertyType propertyType) {
this(alias, namespace, name, null, null, propertyType);
}
public Field(String alias, Namespace namespace, String name, String responseAlias, String cast) {
public Field(String alias, Namespace namespace, String name, String responseAlias, String cast, PropertyType propertyType) {
davPropertyName = DavPropertyName.create(name, namespace);
this.propertyType = propertyType;
isMultivalued = propertyType == PropertyType.StringArray;
isIntValue = propertyType == PropertyType.Integer || propertyType == PropertyType.Long;
isBooleanValue = propertyType == PropertyType.Boolean;
this.alias = alias;
this.uri = namespace.getURI() + name;
if (responseAlias == null) {
@ -414,6 +418,12 @@ public class Field {
}
return new DefaultDavProperty(field.davPropertyName, valueList);
} else if (field.isBooleanValue) {
if ("true".equals(value)) {
return new DefaultDavProperty(field.davPropertyName, "1");
} else {
return new DefaultDavProperty(field.davPropertyName, "0");
}
} else {
return new DefaultDavProperty(field.davPropertyName, value);
}