1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

Caldav: Experimental, send sub calendar folders on propfind with depth 1

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@710 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-09 21:50:11 +00:00
parent fa83089273
commit bdd5dbca78
2 changed files with 43 additions and 10 deletions

View File

@ -507,6 +507,11 @@ public class CaldavConnection extends AbstractConnection {
List<ExchangeSession.Event> events = session.getAllEvents(folderPath); List<ExchangeSession.Event> events = session.getAllEvents(folderPath);
DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_EVENTS", events.size())); DavGatewayTray.debug(new BundleMessage("LOG_FOUND_CALENDAR_EVENTS", events.size()));
appendEventsResponses(response, request, events); appendEventsResponses(response, request, events);
// TODO append sub calendars
List<ExchangeSession.Folder> folderList = session.getSubCalendarFolders(folderPath, false);
for (ExchangeSession.Folder folder : folderList) {
appendCalendar(response, request, folder.folderPath.substring(folder.folderPath.indexOf('/')+1));
}
} }
response.endMultistatus(); response.endMultistatus();
response.close(); response.close();
@ -1039,6 +1044,7 @@ public class CaldavConnection extends AbstractConnection {
/** /**
* Make sure + sign in URL is encoded. * Make sure + sign in URL is encoded.
*
* @param path URL path * @param path URL path
* @return reencoded path * @return reencoded path
*/ */

View File

@ -750,7 +750,7 @@ public class ExchangeSession {
} }
/** /**
* Search folders under given folder * Search folders under given folder.
* *
* @param folderName Exchange folder name * @param folderName Exchange folder name
* @param recursive deep search if true * @param recursive deep search if true
@ -758,15 +758,42 @@ public class ExchangeSession {
* @throws IOException on error * @throws IOException on error
*/ */
public List<Folder> getSubFolders(String folderName, boolean recursive) throws IOException { public List<Folder> getSubFolders(String folderName, boolean recursive) throws IOException {
return getSubFolders(folderName, "(\"DAV:contentclass\"='urn:content-classes:mailfolder' OR \"DAV:contentclass\"='urn:content-classes:folder')", recursive);
}
/**
* Search calendar folders under given folder.
*
* @param folderName Exchange folder name
* @param recursive deep search if true
* @return list of folders
* @throws IOException on error
*/
public List<Folder> getSubCalendarFolders(String folderName, boolean recursive) throws IOException {
return getSubFolders(folderName, "\"DAV:contentclass\"='urn:content-classes:calendarfolder'", recursive);
}
/**
* Search folders under given folder matching filter.
*
* @param folderName Exchange folder name
* @param filter search filter
* @param recursive deep search if true
* @return list of folders
* @throws IOException on error
*/
public List<Folder> getSubFolders(String folderName, String filter, boolean recursive) throws IOException {
String mode = recursive ? "DEEP" : "SHALLOW"; String mode = recursive ? "DEEP" : "SHALLOW";
List<Folder> folders = new ArrayList<Folder>(); List<Folder> folders = new ArrayList<Folder>();
String searchRequest = "Select \"DAV:nosubs\", \"DAV:hassubs\"," + StringBuilder searchRequest = new StringBuilder();
" \"DAV:hassubs\",\"urn:schemas:httpmail:unreadcount\"" + searchRequest.append("Select \"DAV:nosubs\", \"DAV:hassubs\", \"DAV:hassubs\"," +
" FROM Scope('" + mode + " TRAVERSAL OF \"" + getFolderPath(folderName) + "\"')\n" + "\"urn:schemas:httpmail:unreadcount\" FROM Scope('").append(mode).append(" TRAVERSAL OF \"").append(getFolderPath(folderName)).append("\"')\n" +
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = True \n" + " WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = True \n");
" AND (\"DAV:contentclass\"='urn:content-classes:mailfolder' OR \"DAV:contentclass\"='urn:content-classes:folder')"; if (filter != null && filter.length() > 0) {
searchRequest.append(" AND ").append(filter);
}
MultiStatusResponse[] responses = DavGatewayHttpClientFacade.executeSearchMethod( MultiStatusResponse[] responses = DavGatewayHttpClientFacade.executeSearchMethod(
httpClient, URIUtil.encodePath(getFolderPath(folderName)), searchRequest); httpClient, URIUtil.encodePath(getFolderPath(folderName)), searchRequest.toString());
for (MultiStatusResponse response : responses) { for (MultiStatusResponse response : responses) {
folders.add(buildFolder(response)); folders.add(buildFolder(response));