mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 11:48: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"));
|
writer.appendProperty("BDAY", get("bday"));
|
||||||
|
|
||||||
// categories
|
|
||||||
writer.appendProperty("CATEGORIES", get("keywords"));
|
writer.appendProperty("CATEGORIES", get("keywords"));
|
||||||
|
|
||||||
|
if ("1".equals(get("private"))) {
|
||||||
|
writer.appendProperty("CLASS", "PRIVATE");
|
||||||
|
}
|
||||||
|
|
||||||
writer.appendProperty("X-ASSISTANT", get("secretarycn"));
|
writer.appendProperty("X-ASSISTANT", get("secretarycn"));
|
||||||
writer.appendProperty("X-MANAGER", get("manager"));
|
writer.appendProperty("X-MANAGER", get("manager"));
|
||||||
writer.appendProperty("X-SPOUSE", get("spousecn"));
|
writer.appendProperty("X-SPOUSE", get("spousecn"));
|
||||||
@ -2770,6 +2773,14 @@ public abstract class ExchangeSession {
|
|||||||
}
|
}
|
||||||
} else if ("CATEGORIES".equals(property.getKey())) {
|
} else if ("CATEGORIES".equals(property.getKey())) {
|
||||||
properties.put("keywords", property.getValue());
|
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())) {
|
} else if ("X-ASSISTANT".equals(property.getKey())) {
|
||||||
properties.put("secretarycn", property.getValue());
|
properties.put("secretarycn", property.getValue());
|
||||||
} else if ("X-MANAGER".equals(property.getKey())) {
|
} else if ("X-MANAGER".equals(property.getKey())) {
|
||||||
@ -3133,6 +3144,9 @@ public abstract class ExchangeSession {
|
|||||||
CONTACT_ATTRIBUTES.add("othercity");
|
CONTACT_ATTRIBUTES.add("othercity");
|
||||||
CONTACT_ATTRIBUTES.add("haspicture");
|
CONTACT_ATTRIBUTES.add("haspicture");
|
||||||
CONTACT_ATTRIBUTES.add("keywords");
|
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>();
|
ArrayList<DavConstants> list = new ArrayList<DavConstants>();
|
||||||
for (Map.Entry<String, String> entry : entrySet()) {
|
for (Map.Entry<String, String> entry : entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
if (key.startsWith("email")) {
|
if (key.startsWith("email") || key.equals("private")) {
|
||||||
key = "write" + key;
|
key = "write" + key;
|
||||||
}
|
}
|
||||||
if (!"photo".equals(key)) {
|
if (!"photo".equals(key)) {
|
||||||
@ -609,7 +609,12 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
*/
|
*/
|
||||||
public ItemResult createOrUpdate() throws IOException {
|
public ItemResult createOrUpdate() throws IOException {
|
||||||
int status = 0;
|
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");
|
propPatchMethod.setRequestHeader("Translate", "f");
|
||||||
if (etag != null) {
|
if (etag != null) {
|
||||||
propPatchMethod.setRequestHeader("If-Match", etag);
|
propPatchMethod.setRequestHeader("If-Match", etag);
|
||||||
@ -620,22 +625,16 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
try {
|
try {
|
||||||
status = httpClient.executeMethod(propPatchMethod);
|
status = httpClient.executeMethod(propPatchMethod);
|
||||||
if (status == HttpStatus.SC_MULTI_STATUS) {
|
if (status == HttpStatus.SC_MULTI_STATUS) {
|
||||||
MultiStatus responses = propPatchMethod.getResponseBodyAsMultiStatus();
|
if (etag == null) {
|
||||||
if (responses.getResponses().length > 0) {
|
status = HttpStatus.SC_CREATED;
|
||||||
status = responses.getResponses()[0].getStatus()[0].getStatusCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == HttpStatus.SC_CREATED) {
|
|
||||||
LOGGER.debug("Created contact " + getHref());
|
LOGGER.debug("Created contact " + getHref());
|
||||||
} else {
|
} else {
|
||||||
|
status = HttpStatus.SC_OK;
|
||||||
LOGGER.debug("Updated contact " + getHref());
|
LOGGER.debug("Updated contact " + getHref());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("Unable to create or update contact " + status + ' ' + propPatchMethod.getStatusLine());
|
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 {
|
} finally {
|
||||||
propPatchMethod.releaseConnection();
|
propPatchMethod.releaseConnection();
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,8 @@ public class Field {
|
|||||||
|
|
||||||
// contact private flags
|
// contact private flags
|
||||||
createField("private", DistinguishedPropertySetType.Common, 0x8506, "private"); // True/False
|
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
|
createField("haspicture", DistinguishedPropertySetType.Address, 0x8015, "haspicture"); // True/False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user