CalDAV: ignore collections without VEVENT support (for instance, VTODO collections)

pull/2/head
rfc2822 11 years ago
parent 8f7b48748b
commit 3cbfcbee9b

@ -182,6 +182,15 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
for (WebDavResource resource : homeSetCalendars.getMembers())
if (resource.isCalendar()) {
Log.i(TAG, "Found calendar: " + resource.getLocation().getRawPath());
if (resource.getSupportedComponents() != null) {
// CALDAV:supported-calendar-component-set available
boolean supportsEvents = false;
for (String supportedComponent : resource.getSupportedComponents())
if (supportedComponent.equalsIgnoreCase("VEVENT"))
supportsEvents = true;
if (!supportsEvents) // ignore collections without VEVENT support
continue;
}
ServerInfo.ResourceInfo info = new ServerInfo.ResourceInfo(
ServerInfo.ResourceInfo.Type.CALENDAR,
resource.getLocation().getRawPath(),

@ -7,9 +7,13 @@
******************************************************************************/
package at.bitfire.davdroid.webdav;
import java.util.List;
import lombok.Getter;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;
@ -44,6 +48,9 @@ public class DavProp {
@Element(required=false,name="calendar-timezone")
DavPropCalendarTimezone calendarTimezone;
@Element(required=false,name="supported-calendar-component-set")
DavPropSupportedCalendarComponentSet supportedCalendarComponentSet;
@Element(required=false)
DavPropGetCTag getctag;
@ -117,6 +124,18 @@ public class DavProp {
@Getter private String timezone;
}
@Namespace(prefix="C",reference="urn:ietf:params:xml:ns:caldav")
public static class DavPropSupportedCalendarComponentSet {
@ElementList(inline=true,entry="comp",required=false)
List<DavPropComp> components;
}
@Namespace(prefix="C",reference="urn:ietf:params:xml:ns:caldav")
public static class DavPropComp {
@Attribute
@Getter String name;
}
@Namespace(prefix="CS",reference="http://calendarserver.org/ns/")
public static class DavPropGetCTag {
@Text(required=false)

@ -55,6 +55,7 @@ public class HttpPropfind extends HttpEntityEnclosingRequestBase {
propfind.prop.calendarDescription = new DavProp.DavPropCalendarDescription();
propfind.prop.calendarColor = new DavProp.DavPropCalendarColor();
propfind.prop.calendarTimezone = new DavProp.DavPropCalendarTimezone();
propfind.prop.supportedCalendarComponentSet = new DavProp.DavPropSupportedCalendarComponentSet();
break;
case COLLECTION_CTAG:
depth = 0;

@ -48,6 +48,7 @@ import org.simpleframework.xml.core.Persister;
import android.util.Log;
import at.bitfire.davdroid.URIUtils;
import at.bitfire.davdroid.resource.Event;
import at.bitfire.davdroid.webdav.DavProp.DavPropComp;
@ToString
@ -57,7 +58,7 @@ public class WebDavResource {
public enum Property {
CURRENT_USER_PRINCIPAL,
DISPLAY_NAME, DESCRIPTION, COLOR,
TIMEZONE,
TIMEZONE, SUPPORTED_COMPONENTS,
ADDRESSBOOK_HOMESET, CALENDAR_HOMESET,
IS_ADDRESSBOOK, IS_CALENDAR,
CTAG, ETAG,
@ -81,6 +82,7 @@ public class WebDavResource {
// DAV properties
protected HashMap<Property, String> properties = new HashMap<Property, String>();
@Getter protected List<String> supportedComponents;
// list of members (only for collections)
@Getter protected List<WebDavResource> members;
@ -415,39 +417,46 @@ public class WebDavResource {
continue;
DavProp prop = singlePropstat.prop;
HashMap<Property, String> properties = referenced.properties;
if (prop.currentUserPrincipal != null && prop.currentUserPrincipal.getHref() != null)
referenced.properties.put(Property.CURRENT_USER_PRINCIPAL, prop.currentUserPrincipal.getHref().href);
properties.put(Property.CURRENT_USER_PRINCIPAL, prop.currentUserPrincipal.getHref().href);
if (prop.addressbookHomeSet != null && prop.addressbookHomeSet.getHref() != null)
referenced.properties.put(Property.ADDRESSBOOK_HOMESET, prop.addressbookHomeSet.getHref().href);
properties.put(Property.ADDRESSBOOK_HOMESET, prop.addressbookHomeSet.getHref().href);
if (singlePropstat.prop.calendarHomeSet != null && prop.calendarHomeSet.getHref() != null)
referenced.properties.put(Property.CALENDAR_HOMESET, prop.calendarHomeSet.getHref().href);
properties.put(Property.CALENDAR_HOMESET, prop.calendarHomeSet.getHref().href);
if (prop.displayname != null)
referenced.properties.put(Property.DISPLAY_NAME, prop.displayname.getDisplayName());
properties.put(Property.DISPLAY_NAME, prop.displayname.getDisplayName());
if (prop.resourcetype != null) {
if (prop.resourcetype.getAddressbook() != null) {
referenced.properties.put(Property.IS_ADDRESSBOOK, "1");
properties.put(Property.IS_ADDRESSBOOK, "1");
if (prop.addressbookDescription != null)
referenced.properties.put(Property.DESCRIPTION, prop.addressbookDescription.getDescription());
properties.put(Property.DESCRIPTION, prop.addressbookDescription.getDescription());
} else
referenced.properties.remove(Property.IS_ADDRESSBOOK);
properties.remove(Property.IS_ADDRESSBOOK);
if (prop.resourcetype.getCalendar() != null) {
referenced.properties.put(Property.IS_CALENDAR, "1");
properties.put(Property.IS_CALENDAR, "1");
if (prop.calendarDescription != null)
referenced.properties.put(Property.DESCRIPTION, prop.calendarDescription.getDescription());
properties.put(Property.DESCRIPTION, prop.calendarDescription.getDescription());
if (prop.calendarColor != null)
referenced.properties.put(Property.COLOR, prop.calendarColor.getColor());
properties.put(Property.COLOR, prop.calendarColor.getColor());
if (prop.calendarTimezone != null)
referenced.properties.put(Property.TIMEZONE, Event.TimezoneDefToTzId(prop.calendarTimezone.getTimezone()));
properties.put(Property.TIMEZONE, Event.TimezoneDefToTzId(prop.calendarTimezone.getTimezone()));
if (prop.supportedCalendarComponentSet != null && prop.supportedCalendarComponentSet.components != null) {
referenced.supportedComponents = new LinkedList<String>();
for (DavPropComp component : prop.supportedCalendarComponentSet.components)
referenced.supportedComponents.add(component.getName());
}
} else
referenced.properties.remove(Property.IS_CALENDAR);
}

Loading…
Cancel
Save