Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 316102cc authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Detect VCard/4 support per sync, too

parent 8f933362
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -44,16 +44,13 @@ public class DavResourceFinderTest extends InstrumentationTestCase {
		List<ResourceInfo> collections = info.getAddressBooks();
		// two address books
		assertEquals(2, collections.size());
		// first one
		ResourceInfo collection = collections.get(0);
		assertEquals(TestConstants.roboHydra.resolve("/dav/addressbooks/test/default-v4.vcf/").toString(), collection.getURL());
		assertEquals(TestConstants.roboHydra.resolve("/dav/addressbooks/test/default.vcf/").toString(), collection.getURL());
		assertEquals("Default Address Book", collection.getDescription());
		assertEquals(VCardVersion.V4_0, collection.getVCardVersion());
		// second one
		collection = collections.get(1);
		assertEquals("https://my.server/absolute:uri/my-address-book/", collection.getURL());
		assertEquals("Absolute URI VCard3 Book", collection.getDescription());
		assertEquals(VCardVersion.V3_0, collection.getVCardVersion());
		assertEquals("Absolute URI VCard Book", collection.getDescription());

		/*** CalDAV ***/
		assertTrue(info.isCalDAV());
+4 −6
Original line number Diff line number Diff line
@@ -105,19 +105,17 @@ public class WebDavResourceTest extends InstrumentationTestCase {
		assertEquals("useless-member", ab.getName());
		assertFalse(ab.isAddressBook());

		// the second one is a VCard4-capable address book (referenced by relative URI)
		// the second one is an address book (referenced by relative URI)
		ab = dav.getMembers().get(1);
		assertEquals(TestConstants.roboHydra.resolve("/dav/addressbooks/test/default-v4.vcf/"), ab.getLocation());
		assertEquals("default-v4.vcf", ab.getName());
		assertEquals(TestConstants.roboHydra.resolve("/dav/addressbooks/test/default.vcf/"), ab.getLocation());
		assertEquals("default.vcf", ab.getName());
		assertTrue(ab.isAddressBook());
		assertEquals(VCardVersion.V4_0, ab.getVCardVersion());

		// the third one is a (non-VCard4-capable) address book (referenced by an absolute URI)
		// the third one is an address book (referenced by an absolute URI)
		ab = dav.getMembers().get(2);
		assertEquals(new URI("https://my.server/absolute:uri/my-address-book/"), ab.getLocation());
		assertEquals("my-address-book", ab.getName());
		assertTrue(ab.isAddressBook());
		assertNull(ab.getVCardVersion());
	}
	
	public void testPropfindCalendars() throws Exception {
+2 −6
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ exports.getBodyParts = function(conf) {
									</propstat>\
								</response>\
								<response>\
									<href>/dav/addressbooks/test/default-v4.vcf</href>\
									<href>/dav/addressbooks/test/default.vcf</href>\
									<propstat>\
										<prop xmlns:CARD="urn:ietf:params:xml:ns:carddav">\
											<resourcetype>\
@@ -140,10 +140,6 @@ exports.getBodyParts = function(conf) {
												<CARD:addressbook/>\
											</resourcetype>\
											<CARD:addressbook-description>Default Address Book</CARD:addressbook-description>\
											<CARD:supported-address-data>\
                                                <CARD:address-data-type content-type="text/vcard" version="3.0" />\
                                                <CARD:address-data-type content-type="text/vcard" version="4.0" />\
                                            </CARD:supported-address-data>\
										</prop>\
										<status>HTTP/1.1 200 OK</status>\
									</propstat>\
@@ -156,7 +152,7 @@ exports.getBodyParts = function(conf) {
												<collection/>\
												<CARD:addressbook/>\
											</resourcetype>\
											<CARD:addressbook-description>Absolute URI VCard3 Book</CARD:addressbook-description>\
											<CARD:addressbook-description>Absolute URI VCard Book</CARD:addressbook-description>\
										</prop>\
										<status>HTTP/1.1 200 OK</status>\
									</propstat>\
+0 −5
Original line number Diff line number Diff line
@@ -91,11 +91,6 @@ public class DavResourceFinder implements Closeable {
							resource.getDescription(), resource.getColor()
						);

						VCardVersion version = resource.getVCardVersion();
						if (version == null)
							version = VCardVersion.V3_0;	// VCard 3.0 MUST be supported
						info.setVCardVersion(version);

						addressBooks.add(info);
					}
				serverInfo.setAddressBooks(addressBooks);
+7 −4
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -55,6 +56,8 @@ import java.util.Locale;
import java.util.Set;

import at.bitfire.davdroid.syncadapter.AccountSettings;
import at.bitfire.davdroid.webdav.WebDavResource;
import ezvcard.VCardVersion;
import ezvcard.parameter.AddressType;
import ezvcard.parameter.EmailType;
import ezvcard.parameter.ImppType;
@@ -75,7 +78,6 @@ public class LocalAddressBook extends LocalCollection<Contact> {
	
	protected final static String COLUMN_UNKNOWN_PROPERTIES = RawContacts.SYNC3;

	
	final protected AccountSettings accountSettings;

	
@@ -125,9 +127,10 @@ public class LocalAddressBook extends LocalCollection<Contact> {
	}

	@Override
	public void updateMetaData(String displayName, String color)
	public void updateMetaData(WebDavResource resource)
	{
		// address books don't have a display name or color in Android
		final VCardVersion vCardVersion = resource.getVCardVersion();
		accountSettings.setAddressBookVCardVersion(vCardVersion != null ? vCardVersion : VCardVersion.V3_0);
	}

	
Loading