1
0
mirror of https://github.com/etesync/android synced 2024-11-29 19:38:23 +00:00

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

This commit is contained in:
rfc2822 2013-11-30 00:06:16 +01:00
parent 8f7b48748b
commit 3cbfcbee9b
4 changed files with 50 additions and 12 deletions

View File

@ -182,6 +182,15 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
for (WebDavResource resource : homeSetCalendars.getMembers()) for (WebDavResource resource : homeSetCalendars.getMembers())
if (resource.isCalendar()) { if (resource.isCalendar()) {
Log.i(TAG, "Found calendar: " + resource.getLocation().getRawPath()); 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 info = new ServerInfo.ResourceInfo(
ServerInfo.ResourceInfo.Type.CALENDAR, ServerInfo.ResourceInfo.Type.CALENDAR,
resource.getLocation().getRawPath(), resource.getLocation().getRawPath(),

View File

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

View File

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

View File

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