mirror of
https://github.com/moparisthebest/davmail
synced 2024-11-13 12:55:06 -05:00
CardDav: improve automatic address book setup for OSX
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1073 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
2fca78c9a0
commit
3e5ee6f24d
@ -399,8 +399,8 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
|
|
||||||
if (request.hasProperty("resourcetype")) {
|
if (request.hasProperty("resourcetype")) {
|
||||||
if (folder.isContact()) {
|
if (folder.isContact()) {
|
||||||
response.appendProperty("D:resourcetype", "CD=\"urn:ietf:params:xml:ns:carddav\"", "<D:collection/>" +
|
response.appendProperty("D:resourcetype", "<D:collection/>" +
|
||||||
"<CD:addressbook/>");
|
"<E:addressbook/>");
|
||||||
} else if (folder.isCalendar()) {
|
} else if (folder.isCalendar()) {
|
||||||
response.appendProperty("D:resourcetype", "<D:collection/>" + "<C:calendar/>");
|
response.appendProperty("D:resourcetype", "<D:collection/>" + "<C:calendar/>");
|
||||||
} else {
|
} else {
|
||||||
@ -719,6 +719,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
appendInbox(response, request, "inbox");
|
appendInbox(response, request, "inbox");
|
||||||
appendOutbox(response, request, "outbox");
|
appendOutbox(response, request, "outbox");
|
||||||
appendFolder(response, request, "calendar");
|
appendFolder(response, request, "calendar");
|
||||||
|
appendFolder(response, request, "contacts");
|
||||||
}
|
}
|
||||||
response.endResponse();
|
response.endResponse();
|
||||||
response.endMultistatus();
|
response.endMultistatus();
|
||||||
@ -1398,28 +1399,7 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public String getExchangeFolderPath() throws IOException {
|
public String getExchangeFolderPath() throws IOException {
|
||||||
int endIndex;
|
return getExchangeFolderPath(null);
|
||||||
if (isFolder()) {
|
|
||||||
endIndex = getPathLength();
|
|
||||||
} else {
|
|
||||||
endIndex = getPathLength() - 1;
|
|
||||||
}
|
|
||||||
if ("users".equals(getPathElement(1))) {
|
|
||||||
StringBuilder calendarPath = new StringBuilder();
|
|
||||||
calendarPath.append(getPathElement(3));
|
|
||||||
for (int i = 4; i < endIndex; i++) {
|
|
||||||
calendarPath.append('/').append(getPathElement(i));
|
|
||||||
}
|
|
||||||
return session.buildCalendarPath(getPathElement(2), calendarPath.toString());
|
|
||||||
} else {
|
|
||||||
StringBuilder calendarPath = new StringBuilder();
|
|
||||||
for (int i = 0; i < endIndex; i++) {
|
|
||||||
if (getPathElement(i).length() > 0) {
|
|
||||||
calendarPath.append('/').append(getPathElement(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return calendarPath.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1430,10 +1410,38 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
public String getExchangeFolderPath(String subFolder) throws IOException {
|
public String getExchangeFolderPath(String subFolder) throws IOException {
|
||||||
if (subFolder == null || subFolder.length() == 0) {
|
int endIndex;
|
||||||
return getExchangeFolderPath();
|
if (isFolder()) {
|
||||||
|
endIndex = getPathLength();
|
||||||
} else {
|
} else {
|
||||||
return getExchangeFolderPath() + '/' + subFolder;
|
endIndex = getPathLength() - 1;
|
||||||
|
}
|
||||||
|
if ("users".equals(getPathElement(1))) {
|
||||||
|
StringBuilder calendarPath = new StringBuilder();
|
||||||
|
if (getPathLength() > 3) {
|
||||||
|
calendarPath.append(getPathElement(3));
|
||||||
|
}
|
||||||
|
for (int i = 4; i < endIndex; i++) {
|
||||||
|
calendarPath.append('/').append(getPathElement(i));
|
||||||
|
}
|
||||||
|
if (subFolder != null && subFolder.length() > 0) {
|
||||||
|
if (calendarPath.length() > 0) {
|
||||||
|
calendarPath.append('/');
|
||||||
|
}
|
||||||
|
calendarPath.append(subFolder);
|
||||||
|
}
|
||||||
|
return session.buildCalendarPath(getPathElement(2), calendarPath.toString());
|
||||||
|
} else {
|
||||||
|
StringBuilder calendarPath = new StringBuilder();
|
||||||
|
for (int i = 0; i < endIndex; i++) {
|
||||||
|
if (getPathElement(i).length() > 0) {
|
||||||
|
calendarPath.append('/').append(getPathElement(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subFolder != null && subFolder.length() > 0) {
|
||||||
|
calendarPath.append('/').append(subFolder);
|
||||||
|
}
|
||||||
|
return calendarPath.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,6 +1040,8 @@ public abstract class ExchangeSession {
|
|||||||
folderPath = folderName.replaceFirst("Sent", sentitemsUrl);
|
folderPath = folderName.replaceFirst("Sent", sentitemsUrl);
|
||||||
} else if (folderName.startsWith("calendar")) {
|
} else if (folderName.startsWith("calendar")) {
|
||||||
folderPath = folderName.replaceFirst("calendar", calendarUrl);
|
folderPath = folderName.replaceFirst("calendar", calendarUrl);
|
||||||
|
} else if (folderName.startsWith("contacts")) {
|
||||||
|
folderPath = folderName.replaceFirst("contacts", contactsUrl);
|
||||||
} else if (folderName.startsWith("public")) {
|
} else if (folderName.startsWith("public")) {
|
||||||
folderPath = publicFolderUrl + folderName.substring("public".length());
|
folderPath = publicFolderUrl + folderName.substring("public".length());
|
||||||
// absolute folder path
|
// absolute folder path
|
||||||
@ -3260,9 +3262,16 @@ public abstract class ExchangeSession {
|
|||||||
buffer.append(mailPath);
|
buffer.append(mailPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folderName != null && folderName.startsWith("calendar")) {
|
if (folderName != null && (folderName.startsWith("calendar") || folderName.startsWith("contacts")
|
||||||
// replace 'calendar' folder name with i18n name
|
// OSX address book name
|
||||||
buffer.append(calendarUrl.substring(calendarUrl.lastIndexOf('/') + 1));
|
|| folderName.startsWith("addressbook"))) {
|
||||||
|
if (folderName.startsWith("calendar")) {
|
||||||
|
// replace 'calendar' folder name with i18n name
|
||||||
|
buffer.append(calendarUrl.substring(calendarUrl.lastIndexOf('/') + 1));
|
||||||
|
} else {
|
||||||
|
// replace 'contacts' folder name with i18n name
|
||||||
|
buffer.append(contactsUrl.substring(contactsUrl.lastIndexOf('/') + 1));
|
||||||
|
}
|
||||||
|
|
||||||
// sub calendar folder => append sub folder name
|
// sub calendar folder => append sub folder name
|
||||||
int index = folderName.indexOf('/');
|
int index = folderName.indexOf('/');
|
||||||
|
Loading…
Reference in New Issue
Block a user