Commit 65307f9d authored by Ricki Hirner's avatar Ricki Hirner 🐑

ical4j update, clean up XML requests

* ical4j update to 2.0-beta1 (fixes #509, fixes #606)
* only run sync adapters in :sync process, set thread context class loaders appropriately
* remove "class" attribute from XML requests (fixes #615)
parent 78b32ee1
......@@ -48,9 +48,9 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-io:commons-io:2.4'
// Lombok for useful @helpers
provided 'org.projectlombok:lombok:1.16.4'
provided 'org.projectlombok:lombok:1.16.6'
// ical4j for parsing/generating iCalendars
compile('org.mnode.ical4j:ical4j:2.0-alpha1') {
compile('org.mnode.ical4j:ical4j:2.0-beta1') {
// we don't need content builders, see https://github.com/ical4j/ical4j/wiki/Groovy
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
......
......@@ -9,7 +9,6 @@ package at.bitfire.davdroid.resource;
import android.content.res.AssetManager;
import android.test.InstrumentationTestCase;
import android.util.Log;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.CharEncoding;
......@@ -19,10 +18,8 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import at.bitfire.davdroid.ArrayUtils;
import at.bitfire.davdroid.webdav.DavException;
import at.bitfire.davdroid.webdav.HttpException;
import ezvcard.VCardVersion;
......
......@@ -33,12 +33,11 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:process=":sync">
android:theme="@style/AppTheme">
<service
android:name=".syncadapter.AccountAuthenticatorService"
android:exported="false" >
android:exported="false">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
......@@ -49,7 +48,8 @@
</service>
<service
android:name=".syncadapter.ContactsSyncAdapterService"
android:exported="true" >
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
......@@ -62,7 +62,8 @@
</service>
<service
android:name=".syncadapter.CalendarsSyncAdapterService"
android:exported="true" >
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
......@@ -72,7 +73,8 @@
</service>
<service
android:name=".syncadapter.TasksSyncAdapterService"
android:exported="true" >
android:exported="true"
android:process=":sync">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
......
......@@ -31,7 +31,7 @@ import java.util.SimpleTimeZone;
public class DateUtils {
private final static String TAG = "davdroid.DateUtils";
public final static TimeZoneRegistry tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry();
public static final TimeZoneRegistry tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry();
static {
// disable automatic time-zone updates (causes unwanted network traffic)
......
......@@ -154,9 +154,14 @@ public abstract class iCalendar extends Resource {
public static class Factory implements ParameterFactory {
@Override
public Parameter createParameter(String name, String value) throws URISyntaxException {
public Parameter createParameter(String value) throws URISyntaxException {
return new Email(value);
}
@Override
public boolean supports(String name) {
return PARAMETER_NAME.equalsIgnoreCase(name);
}
}
}
......
......@@ -109,7 +109,8 @@ public abstract class DavSyncAdapter extends AbstractThreadedSyncAdapter impleme
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
Log.i(TAG, "Performing sync for authority " + authority);
// set class loader for iCal4j ResourceLoader
/* Set class loader for iCal4j ResourceLoader – this is required because the various
* sync adapters (contacts, events, tasks) share the same :sync process (see AndroidManifest */
Thread.currentThread().setContextClassLoader(getContext().getClassLoader());
// create httpClient, if necessary
......
......@@ -12,7 +12,6 @@ import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Order;
import java.util.ArrayList;
import java.util.List;
@Order(elements={"prop","href"})
public class DavMultiget {
......@@ -21,17 +20,17 @@ public class DavMultiget {
ADDRESS_BOOK_V4,
CALENDAR
}
@Element
DavProp prop;
@ElementList(inline=true)
List<DavHref> hrefs;
ArrayList<DavHref> hrefs;
public static DavMultiget newRequest(Type type, String names[]) {
DavMultiget multiget = (type == Type.CALENDAR) ? new DavCalendarMultiget() : new DavAddressbookMultiget();
multiget.prop = new DavProp();
multiget.prop.getetag = new DavProp.GetETag();
......@@ -52,7 +51,7 @@ public class DavMultiget {
multiget.hrefs = new ArrayList<>(names.length);
for (String name : names)
multiget.hrefs.add(new DavHref(name));
return multiget;
}
}
......@@ -11,11 +11,12 @@ import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;
import java.util.ArrayList;
import java.util.List;
@Namespace(reference="DAV:")
@Root(strict=false)
public class DavMultistatus {
@ElementList(inline=true,entry="response",required=false)
List<DavResponse> response;
ArrayList<DavResponse> response;
}
......@@ -14,7 +14,7 @@ import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;
import java.util.List;
import java.util.ArrayList;
import lombok.Getter;
import lombok.Setter;
......@@ -85,7 +85,7 @@ public class DavProp {
/* RFC 3744 WebDAV Access Control Protocol */
@ElementList(required=false,name="current-user-privilege-set",entry="privilege")
List<Privilege> currentUserPrivilegeSet;
ArrayList<Privilege> currentUserPrivilegeSet;
public static class Privilege {
@Element(required=false)
......@@ -125,7 +125,7 @@ public class DavProp {
@Namespace(prefix="CD",reference="urn:ietf:params:xml:ns:carddav")
@ElementList(required=false,name="supported-address-data",entry="address-data-type")
List<AddressDataType> supportedAddressData;
ArrayList<AddressDataType> supportedAddressData;
@Element(required=false,name="calendar-description")
CalendarDescription calendarDescription;
......@@ -138,7 +138,7 @@ public class DavProp {
@Namespace(prefix="C",reference="urn:ietf:params:xml:ns:caldav")
@ElementList(required=false,name="supported-calendar-component-set",entry="comp")
List<Comp> supportedCalendarComponentSet;
ArrayList<Comp> supportedCalendarComponentSet;
@Element(name="address-data",required=false)
AddressData addressData;
......
......@@ -11,7 +11,7 @@ import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
import java.util.List;
import java.util.ArrayList;
@Root(strict=false)
public class DavResponse {
......@@ -22,5 +22,5 @@ public class DavResponse {
String status;
@ElementList(inline=true,required=false)
List<DavPropstat> propstat;
ArrayList<DavPropstat> propstat;
}
......@@ -16,7 +16,7 @@ import org.simpleframework.xml.core.Persister;
import java.io.StringWriter;
import java.net.URI;
import java.util.LinkedList;
import java.util.ArrayList;
public class HttpPropfind extends HttpEntityEnclosingRequestBaseHC4 {
private static final String TAG = "davdroid.HttpPropfind";
......@@ -56,25 +56,25 @@ public class HttpPropfind extends HttpEntityEnclosingRequestBaseHC4 {
depth = 1;
propfind.prop.displayname = new DavProp.DisplayName();
propfind.prop.resourcetype = new DavProp.ResourceType();
propfind.prop.currentUserPrivilegeSet = new LinkedList<>();
propfind.prop.currentUserPrivilegeSet = new ArrayList<>();
propfind.prop.addressbookDescription = new DavProp.AddressbookDescription();
break;
case CALDAV_COLLECTIONS:
depth = 1;
propfind.prop.displayname = new DavProp.DisplayName();
propfind.prop.resourcetype = new DavProp.ResourceType();
propfind.prop.currentUserPrivilegeSet = new LinkedList<>();
propfind.prop.currentUserPrivilegeSet = new ArrayList<>();
propfind.prop.calendarDescription = new DavProp.CalendarDescription();
propfind.prop.calendarColor = new DavProp.CalendarColor();
propfind.prop.calendarTimezone = new DavProp.CalendarTimezone();
propfind.prop.supportedCalendarComponentSet = new LinkedList<>();
propfind.prop.supportedCalendarComponentSet = new ArrayList<>();
break;
case COLLECTION_PROPERTIES:
propfind.prop.getctag = new DavProp.GetCTag();
propfind.prop.resourcetype = new DavProp.ResourceType();
propfind.prop.displayname = new DavProp.DisplayName();
propfind.prop.calendarColor = new DavProp.CalendarColor();
propfind.prop.supportedAddressData = new LinkedList<>();
propfind.prop.supportedAddressData = new ArrayList<>();
break;
case MEMBERS_ETAG:
depth = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment