mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 03:38:05 -05:00
Caldav: improve task support over WebDav, rename .ics to .EML and implement priority (importance)
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1763 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
4bc0773aa7
commit
4d79c262ca
@ -2144,6 +2144,10 @@ public abstract class ExchangeSession {
|
|||||||
super(folderPath, itemName, etag, noneMatch);
|
super(folderPath, itemName, etag, noneMatch);
|
||||||
this.contentClass = contentClass;
|
this.contentClass = contentClass;
|
||||||
fixICS(itemBody.getBytes("UTF-8"), false);
|
fixICS(itemBody.getBytes("UTF-8"), false);
|
||||||
|
// fix task item name
|
||||||
|
if (vCalendar.isTodo() && this.itemName.endsWith(".ics")) {
|
||||||
|
this.itemName = itemName.substring(0, itemName.length() - 3)+".EML";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1370,6 +1370,9 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
davPropertyNameSet.add(Field.getPropertyName("busystatus"));
|
davPropertyNameSet.add(Field.getPropertyName("busystatus"));
|
||||||
davPropertyNameSet.add(Field.getPropertyName("reminderset"));
|
davPropertyNameSet.add(Field.getPropertyName("reminderset"));
|
||||||
davPropertyNameSet.add(Field.getPropertyName("reminderdelta"));
|
davPropertyNameSet.add(Field.getPropertyName("reminderdelta"));
|
||||||
|
// task
|
||||||
|
davPropertyNameSet.add(Field.getPropertyName("importance"));
|
||||||
|
davPropertyNameSet.add(Field.getPropertyName("uid"));
|
||||||
|
|
||||||
PropFindMethod propFindMethod = new PropFindMethod(permanentUrl, davPropertyNameSet, 0);
|
PropFindMethod propFindMethod = new PropFindMethod(permanentUrl, davPropertyNameSet, 0);
|
||||||
try {
|
try {
|
||||||
@ -1386,8 +1389,13 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
vEvent.setPropertyValue("CREATED", convertDateFromExchange(getPropertyIfExists(davPropertySet, "created")));
|
vEvent.setPropertyValue("CREATED", convertDateFromExchange(getPropertyIfExists(davPropertySet, "created")));
|
||||||
vEvent.setPropertyValue("LAST-MODIFIED", convertDateFromExchange(getPropertyIfExists(davPropertySet, "calendarlastmodified")));
|
vEvent.setPropertyValue("LAST-MODIFIED", convertDateFromExchange(getPropertyIfExists(davPropertySet, "calendarlastmodified")));
|
||||||
vEvent.setPropertyValue("DTSTAMP", convertDateFromExchange(getPropertyIfExists(davPropertySet, "dtstamp")));
|
vEvent.setPropertyValue("DTSTAMP", convertDateFromExchange(getPropertyIfExists(davPropertySet, "dtstamp")));
|
||||||
vEvent.setPropertyValue("UID", getPropertyIfExists(davPropertySet, "calendaruid"));
|
String uid = getPropertyIfExists(davPropertySet, "calendaruid");
|
||||||
|
if (uid == null) {
|
||||||
|
uid = getPropertyIfExists(davPropertySet, "uid");
|
||||||
|
}
|
||||||
|
vEvent.setPropertyValue("UID", uid);
|
||||||
vEvent.setPropertyValue("SUMMARY", getPropertyIfExists(davPropertySet, "subject"));
|
vEvent.setPropertyValue("SUMMARY", getPropertyIfExists(davPropertySet, "subject"));
|
||||||
|
vEvent.setPropertyValue("PRIORITY", convertPriorityFromExchange(getPropertyIfExists(davPropertySet, "importance")));
|
||||||
if (instancetype == null) {
|
if (instancetype == null) {
|
||||||
vEvent.type = "VTODO";
|
vEvent.type = "VTODO";
|
||||||
} else {
|
} else {
|
||||||
@ -1536,6 +1544,7 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
}
|
}
|
||||||
propertyValues.add(Field.createPropertyValue("subject", vCalendar.getFirstVeventPropertyValue("SUMMARY")));
|
propertyValues.add(Field.createPropertyValue("subject", vCalendar.getFirstVeventPropertyValue("SUMMARY")));
|
||||||
propertyValues.add(Field.createPropertyValue("description", vCalendar.getFirstVeventPropertyValue("DESCRIPTION")));
|
propertyValues.add(Field.createPropertyValue("description", vCalendar.getFirstVeventPropertyValue("DESCRIPTION")));
|
||||||
|
propertyValues.add(Field.createPropertyValue("importance", convertPriorityToExchange(vCalendar.getFirstVeventPropertyValue("PRIORITY"))));
|
||||||
|
|
||||||
ExchangePropPatchMethod propPatchMethod = new ExchangePropPatchMethod(encodedHref, propertyValues);
|
ExchangePropPatchMethod propPatchMethod = new ExchangePropPatchMethod(encodedHref, propertyValues);
|
||||||
propPatchMethod.setRequestHeader("Translate", "f");
|
propPatchMethod.setRequestHeader("Translate", "f");
|
||||||
@ -2030,6 +2039,9 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
try {
|
try {
|
||||||
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, URIUtil.encodePath(itemPath), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, URIUtil.encodePath(itemPath), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
||||||
if (responses.length == 0 && isMainCalendar(folderPath)) {
|
if (responses.length == 0 && isMainCalendar(folderPath)) {
|
||||||
|
if (itemName.endsWith(".ics")) {
|
||||||
|
itemName = itemName.substring(0, itemName.length() - 3) + "EML";
|
||||||
|
}
|
||||||
// look for item in tasks folder
|
// look for item in tasks folder
|
||||||
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, URIUtil.encodePath(getFolderPath(TASKS) + '/' + emlItemName), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
responses = DavGatewayHttpClientFacade.executePropFindMethod(httpClient, URIUtil.encodePath(getFolderPath(TASKS) + '/' + emlItemName), 0, EVENT_REQUEST_PROPERTIES_NAME_SET);
|
||||||
}
|
}
|
||||||
@ -2771,6 +2783,39 @@ public class DavExchangeSession extends ExchangeSession {
|
|||||||
return zuluDateValue;
|
return zuluDateValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final Map<String, String> importanceToPriorityMap = new HashMap<String, String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
importanceToPriorityMap.put("high", "1");
|
||||||
|
importanceToPriorityMap.put("normal", "5");
|
||||||
|
importanceToPriorityMap.put("low", "9");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static final Map<String, String> priorityToImportanceMap = new HashMap<String, String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
priorityToImportanceMap.put("1", "high");
|
||||||
|
priorityToImportanceMap.put("5", "normal");
|
||||||
|
priorityToImportanceMap.put("9", "low");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String convertPriorityFromExchange(String exchangeImportanceValue) throws DavMailException {
|
||||||
|
String value = null;
|
||||||
|
if (exchangeImportanceValue != null) {
|
||||||
|
value = importanceToPriorityMap.get(exchangeImportanceValue);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String convertPriorityToExchange(String vTodoPriorityValue) throws DavMailException {
|
||||||
|
String value = null;
|
||||||
|
if (vTodoPriorityValue != null) {
|
||||||
|
value = priorityToImportanceMap.get(vTodoPriorityValue);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format date to exchange search format.
|
* Format date to exchange search format.
|
||||||
*
|
*
|
||||||
|
@ -322,6 +322,9 @@ public class Field {
|
|||||||
createField("xmozlastack", DistinguishedPropertySetType.PublicStrings);
|
createField("xmozlastack", DistinguishedPropertySetType.PublicStrings);
|
||||||
createField("xmozsnoozetime", DistinguishedPropertySetType.PublicStrings);
|
createField("xmozsnoozetime", DistinguishedPropertySetType.PublicStrings);
|
||||||
createField("xmozsendinvitations", DistinguishedPropertySetType.PublicStrings);
|
createField("xmozsendinvitations", DistinguishedPropertySetType.PublicStrings);
|
||||||
|
|
||||||
|
// task
|
||||||
|
createField(URN_SCHEMAS_MAILHEADER, "importance");//PS_INTERNET_HEADERS/importance
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String toHexString(int propertyTag) {
|
protected static String toHexString(int propertyTag) {
|
||||||
|
Loading…
Reference in New Issue
Block a user