1
0
mirror of https://github.com/etesync/android synced 2024-11-26 18:08:11 +00:00

Don't require capabilities on home sets that MAY not be available on these collections (fixes #289)

This commit is contained in:
rfc2822 2014-07-31 14:00:36 +02:00
parent bdee53b5ab
commit 1235a5e45a
9 changed files with 15 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.resource;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@ -40,7 +40,7 @@ public class DavResourceFinder {
Log.i(TAG, "Found address book home set: " + pathAddressBooks); Log.i(TAG, "Found address book home set: " + pathAddressBooks);
WebDavResource homeSetAddressBooks = new WebDavResource(principal, pathAddressBooks); WebDavResource homeSetAddressBooks = new WebDavResource(principal, pathAddressBooks);
if (checkCapabilities(homeSetAddressBooks, "addressbook")) { if (checkHomesetCapabilities(homeSetAddressBooks, "addressbook")) {
homeSetAddressBooks.propfind(Mode.CARDDAV_COLLECTIONS); homeSetAddressBooks.propfind(Mode.CARDDAV_COLLECTIONS);
List<ServerInfo.ResourceInfo> addressBooks = new LinkedList<ServerInfo.ResourceInfo>(); List<ServerInfo.ResourceInfo> addressBooks = new LinkedList<ServerInfo.ResourceInfo>();
@ -80,7 +80,7 @@ public class DavResourceFinder {
Log.i(TAG, "Found calendar home set: " + pathCalendars); Log.i(TAG, "Found calendar home set: " + pathCalendars);
WebDavResource homeSetCalendars = new WebDavResource(principal, pathCalendars); WebDavResource homeSetCalendars = new WebDavResource(principal, pathCalendars);
if (checkCapabilities(homeSetCalendars, "calendar-access")) { if (checkHomesetCapabilities(homeSetCalendars, "calendar-access")) {
homeSetCalendars.propfind(Mode.CALDAV_COLLECTIONS); homeSetCalendars.propfind(Mode.CALDAV_COLLECTIONS);
List<ServerInfo.ResourceInfo> calendars = new LinkedList<ServerInfo.ResourceInfo>(); List<ServerInfo.ResourceInfo> calendars = new LinkedList<ServerInfo.ResourceInfo>();
@ -147,16 +147,12 @@ public class DavResourceFinder {
return null; return null;
} }
private static boolean checkCapabilities(WebDavResource resource, String davCapability) throws IOException { private static boolean checkHomesetCapabilities(WebDavResource resource, String davCapability) throws IOException {
// check for necessary capabilities // check for necessary capabilities
try { try {
resource.options(); resource.options();
if (resource.supportsDAV(davCapability) && if (resource.supportsDAV(davCapability) &&
resource.supportsMethod("PROPFIND") && resource.supportsMethod("PROPFIND")) // check only for methods that MUST be available for home sets
resource.supportsMethod("GET") &&
resource.supportsMethod("REPORT") &&
resource.supportsMethod("PUT") &&
resource.supportsMethod("DELETE"))
return true; return true;
} catch(HttpException e) { } catch(HttpException e) {
// for instance, 405 Method not allowed // for instance, 405 Method not allowed

View File

@ -60,7 +60,6 @@ import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Reminders; import android.provider.CalendarContract.Reminders;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.syncadapter.ServerInfo;
/** /**
* Represents a locally stored calendar, containing Events. * Represents a locally stored calendar, containing Events.

View File

@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.resource;
import java.io.Serializable; import java.io.Serializable;
import java.util.LinkedList; import java.util.LinkedList;

View File

@ -29,6 +29,7 @@ import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.resource.LocalCalendar; import at.bitfire.davdroid.resource.LocalCalendar;
import at.bitfire.davdroid.resource.LocalStorageException; import at.bitfire.davdroid.resource.LocalStorageException;
import at.bitfire.davdroid.resource.ServerInfo;
public class AccountDetailsFragment extends Fragment implements TextWatcher { public class AccountDetailsFragment extends Fragment implements TextWatcher {
public static final String KEY_SERVER_INFO = "server_info"; public static final String KEY_SERVER_INFO = "server_info";

View File

@ -23,6 +23,7 @@ import android.os.Bundle;
import android.provider.CalendarContract; import android.provider.CalendarContract;
import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Calendars;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.resource.ServerInfo;
import ezvcard.VCardVersion; import ezvcard.VCardVersion;
public class AccountSettings { public class AccountSettings {

View File

@ -23,6 +23,8 @@ import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.resource.DavResourceFinder;
import at.bitfire.davdroid.resource.ServerInfo;
import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavException;
import ch.boye.httpclientandroidlib.HttpException; import ch.boye.httpclientandroidlib.HttpException;

View File

@ -17,6 +17,7 @@ import android.widget.BaseAdapter;
import android.widget.CheckedTextView; import android.widget.CheckedTextView;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.resource.ServerInfo;
public class SelectCollectionsAdapter extends BaseAdapter implements ListAdapter { public class SelectCollectionsAdapter extends BaseAdapter implements ListAdapter {
final static int TYPE_ADDRESS_BOOKS_HEADING = 0, final static int TYPE_ADDRESS_BOOKS_HEADING = 0,

View File

@ -20,6 +20,7 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.resource.ServerInfo;
public class SelectCollectionsFragment extends ListFragment { public class SelectCollectionsFragment extends ListFragment {
public static final String KEY_SERVER_INFO = "server_info"; public static final String KEY_SERVER_INFO = "server_info";

View File

@ -4,7 +4,9 @@ import java.util.List;
import ezvcard.VCardVersion; import ezvcard.VCardVersion;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import at.bitfire.davdroid.syncadapter.ServerInfo.ResourceInfo; import at.bitfire.davdroid.resource.DavResourceFinder;
import at.bitfire.davdroid.resource.ServerInfo;
import at.bitfire.davdroid.resource.ServerInfo.ResourceInfo;
import at.bitfire.davdroid.test.Constants; import at.bitfire.davdroid.test.Constants;
public class DavResourceFinderTest extends InstrumentationTestCase { public class DavResourceFinderTest extends InstrumentationTestCase {