mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-06 03:08:02 -05:00
Carddav: implement CLASS (private) flag
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1191 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
09640307dc
commit
f1075c57e7
@ -1751,9 +1751,12 @@ public abstract class ExchangeSession {
|
||||
|
||||
writer.appendProperty("BDAY", get("bday"));
|
||||
|
||||
// categories
|
||||
writer.appendProperty("CATEGORIES", get("keywords"));
|
||||
|
||||
if ("1".equals(get("private"))) {
|
||||
writer.appendProperty("CLASS", "PRIVATE");
|
||||
}
|
||||
|
||||
writer.appendProperty("X-ASSISTANT", get("secretarycn"));
|
||||
writer.appendProperty("X-MANAGER", get("manager"));
|
||||
writer.appendProperty("X-SPOUSE", get("spousecn"));
|
||||
@ -2770,6 +2773,14 @@ public abstract class ExchangeSession {
|
||||
}
|
||||
} else if ("CATEGORIES".equals(property.getKey())) {
|
||||
properties.put("keywords", property.getValue());
|
||||
} else if ("CLASS".equals(property.getKey())) {
|
||||
if ("PUBLIC".equals(property.getValue())) {
|
||||
properties.put("sensitivity", "0");
|
||||
properties.put("private", "0");
|
||||
} else {
|
||||
properties.put("sensitivity", "2");
|
||||
properties.put("private", "1");
|
||||
}
|
||||
} else if ("X-ASSISTANT".equals(property.getKey())) {
|
||||
properties.put("secretarycn", property.getValue());
|
||||
} else if ("X-MANAGER".equals(property.getKey())) {
|
||||
@ -3133,6 +3144,9 @@ public abstract class ExchangeSession {
|
||||
CONTACT_ATTRIBUTES.add("othercity");
|
||||
CONTACT_ATTRIBUTES.add("haspicture");
|
||||
CONTACT_ATTRIBUTES.add("keywords");
|
||||
|
||||
CONTACT_ATTRIBUTES.add("private");
|
||||
CONTACT_ATTRIBUTES.add("sensitivity");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -590,7 +590,7 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
ArrayList<DavConstants> list = new ArrayList<DavConstants>();
|
||||
for (Map.Entry<String, String> entry : entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.startsWith("email")) {
|
||||
if (key.startsWith("email") || key.equals("private")) {
|
||||
key = "write" + key;
|
||||
}
|
||||
if (!"photo".equals(key)) {
|
||||
@ -609,7 +609,12 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
*/
|
||||
public ItemResult createOrUpdate() throws IOException {
|
||||
int status = 0;
|
||||
PropPatchMethod propPatchMethod = new PropPatchMethod(URIUtil.encodePath(getHref()), buildProperties());
|
||||
PropPatchMethod propPatchMethod = new PropPatchMethod(URIUtil.encodePath(getHref()), buildProperties()) {
|
||||
@Override
|
||||
protected void processResponseBody(HttpState httpState, HttpConnection httpConnection) {
|
||||
// ignore response body, sometimes invalid with exchange mapi properties
|
||||
}
|
||||
};
|
||||
propPatchMethod.setRequestHeader("Translate", "f");
|
||||
if (etag != null) {
|
||||
propPatchMethod.setRequestHeader("If-Match", etag);
|
||||
@ -620,22 +625,16 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
try {
|
||||
status = httpClient.executeMethod(propPatchMethod);
|
||||
if (status == HttpStatus.SC_MULTI_STATUS) {
|
||||
MultiStatus responses = propPatchMethod.getResponseBodyAsMultiStatus();
|
||||
if (responses.getResponses().length > 0) {
|
||||
status = responses.getResponses()[0].getStatus()[0].getStatusCode();
|
||||
}
|
||||
|
||||
if (status == HttpStatus.SC_CREATED) {
|
||||
if (etag == null) {
|
||||
status = HttpStatus.SC_CREATED;
|
||||
LOGGER.debug("Created contact " + getHref());
|
||||
} else {
|
||||
status = HttpStatus.SC_OK;
|
||||
LOGGER.debug("Updated contact " + getHref());
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Unable to create or update contact " + status + ' ' + propPatchMethod.getStatusLine());
|
||||
}
|
||||
} catch (DavException e) {
|
||||
LOGGER.error("Error in item create or update", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
} finally {
|
||||
propPatchMethod.releaseConnection();
|
||||
}
|
||||
|
@ -251,7 +251,8 @@ public class Field {
|
||||
|
||||
// contact private flags
|
||||
createField("private", DistinguishedPropertySetType.Common, 0x8506, "private"); // True/False
|
||||
createField("sensitivity", 0x0036, PropertyType.Long); // PR_SENSITIVITY SENSITIVITY_PRIVATE=2, SENSITIVITY_NONE = 0
|
||||
createField("writeprivate", DistinguishedPropertySetType.Common, 0x8506, PropertyType.String10);
|
||||
createField("sensitivity", 0x0036, PropertyType.Long); // PR_SENSITIVITY SENSITIVITY_PRIVATE = 2, SENSITIVITY_PERSONAL = 1, SENSITIVITY_NONE = 0
|
||||
|
||||
createField("haspicture", DistinguishedPropertySetType.Address, 0x8015, "haspicture"); // True/False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user