1
0
mirror of https://github.com/etesync/android synced 2024-11-26 01:48:34 +00:00

Use HttpClient HC4 classes whenever possible (instead of stock Android HttpClient 4.0-beta classes); reorganize imports

This commit is contained in:
R Hirner 2014-12-21 02:19:06 +01:00
parent 49f7bbd8da
commit a52e3507e7
37 changed files with 264 additions and 243 deletions

View File

@ -12,8 +12,9 @@ android {
buildTypes { buildTypes {
debug { debug {
minifyEnabled true minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' //minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
} }
release { release {
minifyEnabled true minifyEnabled true

View File

@ -11,8 +11,5 @@ public class Constants {
public static final String public static final String
APP_VERSION = "0.6.9", APP_VERSION = "0.6.9",
ACCOUNT_TYPE = "bitfire.at.davdroid", ACCOUNT_TYPE = "bitfire.at.davdroid",
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app", WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app";
SETTING_DISABLE_COMPRESSION = "disable_compression",
SETTING_NETWORK_LOGGING = "network_logging";
} }

View File

@ -7,11 +7,11 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid; package at.bitfire.davdroid;
import android.util.Log;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import android.util.Log;
public class URIUtils { public class URIUtils {
private static final String TAG = "davdroid.URIUtils"; private static final String TAG = "davdroid.URIUtils";

View File

@ -7,10 +7,11 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import org.apache.http.impl.client.CloseableHttpClient;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import at.bitfire.davdroid.webdav.DavMultiget; import at.bitfire.davdroid.webdav.DavMultiget;
import org.apache.http.impl.client.CloseableHttpClient;
public class CalDavCalendar extends RemoteCollection<Event> { public class CalDavCalendar extends RemoteCollection<Event> {
//private final static String TAG = "davdroid.CalDavCalendar"; //private final static String TAG = "davdroid.CalDavCalendar";

View File

@ -7,10 +7,11 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import org.apache.http.impl.client.CloseableHttpClient;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import at.bitfire.davdroid.webdav.DavMultiget; import at.bitfire.davdroid.webdav.DavMultiget;
import org.apache.http.impl.client.CloseableHttpClient;
public class CardDavAddressBook extends RemoteCollection<Contact> { public class CardDavAddressBook extends RemoteCollection<Contact> {
//private final static String TAG = "davdroid.CardDavAddressBook"; //private final static String TAG = "davdroid.CardDavAddressBook";

View File

@ -7,6 +7,10 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import android.util.Log;
import org.apache.commons.lang.StringUtils;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -14,13 +18,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang.StringUtils;
import android.util.Log;
import at.bitfire.davdroid.Constants; import at.bitfire.davdroid.Constants;
import ezvcard.Ezvcard; import ezvcard.Ezvcard;
import ezvcard.VCard; import ezvcard.VCard;
@ -51,6 +48,9 @@ import ezvcard.property.Telephone;
import ezvcard.property.Title; import ezvcard.property.Title;
import ezvcard.property.Uid; import ezvcard.property.Uid;
import ezvcard.property.Url; import ezvcard.property.Url;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/** /**

View File

@ -7,6 +7,18 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import android.content.Context;
import android.util.Log;
import org.apache.http.HttpException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -15,15 +27,6 @@ import java.net.URISyntaxException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
import android.content.Context;
import android.util.Log;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavException;
import at.bitfire.davdroid.webdav.DavHttpClient; import at.bitfire.davdroid.webdav.DavHttpClient;
@ -31,8 +34,6 @@ import at.bitfire.davdroid.webdav.DavIncapableException;
import at.bitfire.davdroid.webdav.HttpPropfind.Mode; import at.bitfire.davdroid.webdav.HttpPropfind.Mode;
import at.bitfire.davdroid.webdav.NotAuthorizedException; import at.bitfire.davdroid.webdav.NotAuthorizedException;
import at.bitfire.davdroid.webdav.WebDavResource; import at.bitfire.davdroid.webdav.WebDavResource;
import org.apache.http.HttpException;
import org.apache.http.impl.client.CloseableHttpClient;
import ezvcard.VCardVersion; import ezvcard.VCardVersion;
public class DavResourceFinder implements Closeable { public class DavResourceFinder implements Closeable {
@ -46,7 +47,7 @@ public class DavResourceFinder implements Closeable {
this.context = context; this.context = context;
// disable compression and enable network logging for debugging purposes // disable compression and enable network logging for debugging purposes
httpClient = DavHttpClient.create(true, true); httpClient = DavHttpClient.create();
} }
@Override @Override

View File

@ -7,19 +7,9 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import java.io.ByteArrayOutputStream; import android.text.format.Time;
import java.io.IOException; import android.util.Log;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import net.fortuna.ical4j.data.CalendarBuilder; import net.fortuna.ical4j.data.CalendarBuilder;
import net.fortuna.ical4j.data.CalendarOutputter; import net.fortuna.ical4j.data.CalendarOutputter;
import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.data.ParserException;
@ -58,10 +48,22 @@ import net.fortuna.ical4j.model.property.Uid;
import net.fortuna.ical4j.model.property.Version; import net.fortuna.ical4j.model.property.Version;
import net.fortuna.ical4j.util.SimpleHostInfo; import net.fortuna.ical4j.util.SimpleHostInfo;
import net.fortuna.ical4j.util.UidGenerator; import net.fortuna.ical4j.util.UidGenerator;
import android.text.format.Time;
import android.util.Log; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import at.bitfire.davdroid.Constants; import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.syncadapter.DavSyncAdapter; import at.bitfire.davdroid.syncadapter.DavSyncAdapter;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
public class Event extends Resource { public class Event extends Resource {

View File

@ -7,23 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import lombok.Cleanup;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import android.accounts.Account; import android.accounts.Account;
import android.content.ContentProviderClient; import android.content.ContentProviderClient;
import android.content.ContentProviderOperation; import android.content.ContentProviderOperation;
@ -52,6 +35,22 @@ import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Groups; import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.RawContacts;
import android.util.Log; import android.util.Log;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import at.bitfire.davdroid.syncadapter.AccountSettings; import at.bitfire.davdroid.syncadapter.AccountSettings;
import ezvcard.parameter.AddressType; import ezvcard.parameter.AddressType;
import ezvcard.parameter.EmailType; import ezvcard.parameter.EmailType;
@ -63,6 +62,7 @@ import ezvcard.property.Birthday;
import ezvcard.property.DateOrTimeProperty; import ezvcard.property.DateOrTimeProperty;
import ezvcard.property.Impp; import ezvcard.property.Impp;
import ezvcard.property.Telephone; import ezvcard.property.Telephone;
import lombok.Cleanup;
public class LocalAddressBook extends LocalCollection<Contact> { public class LocalAddressBook extends LocalCollection<Contact> {

View File

@ -7,38 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Cleanup;
import lombok.Getter;
import net.fortuna.ical4j.model.Dur;
import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterList;
import net.fortuna.ical4j.model.PropertyList;
import net.fortuna.ical4j.model.component.VAlarm;
import net.fortuna.ical4j.model.parameter.Cn;
import net.fortuna.ical4j.model.parameter.CuType;
import net.fortuna.ical4j.model.parameter.PartStat;
import net.fortuna.ical4j.model.parameter.Role;
import net.fortuna.ical4j.model.property.Action;
import net.fortuna.ical4j.model.property.Attendee;
import net.fortuna.ical4j.model.property.Description;
import net.fortuna.ical4j.model.property.Duration;
import net.fortuna.ical4j.model.property.ExDate;
import net.fortuna.ical4j.model.property.ExRule;
import net.fortuna.ical4j.model.property.Organizer;
import net.fortuna.ical4j.model.property.RDate;
import net.fortuna.ical4j.model.property.RRule;
import net.fortuna.ical4j.model.property.Status;
import org.apache.commons.lang.StringUtils;
import android.accounts.Account; import android.accounts.Account;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -61,6 +29,39 @@ import android.provider.CalendarContract.Reminders;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.util.Log; import android.util.Log;
import net.fortuna.ical4j.model.Dur;
import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterList;
import net.fortuna.ical4j.model.PropertyList;
import net.fortuna.ical4j.model.component.VAlarm;
import net.fortuna.ical4j.model.parameter.Cn;
import net.fortuna.ical4j.model.parameter.CuType;
import net.fortuna.ical4j.model.parameter.PartStat;
import net.fortuna.ical4j.model.parameter.Role;
import net.fortuna.ical4j.model.property.Action;
import net.fortuna.ical4j.model.property.Attendee;
import net.fortuna.ical4j.model.property.Description;
import net.fortuna.ical4j.model.property.Duration;
import net.fortuna.ical4j.model.property.ExDate;
import net.fortuna.ical4j.model.property.ExRule;
import net.fortuna.ical4j.model.property.Organizer;
import net.fortuna.ical4j.model.property.RDate;
import net.fortuna.ical4j.model.property.RRule;
import net.fortuna.ical4j.model.property.Status;
import org.apache.commons.lang.StringUtils;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.Cleanup;
import lombok.Getter;
/** /**
* Represents a locally stored calendar, containing Events. * Represents a locally stored calendar, containing Events.
* Communicates with the Android Contacts Provider which uses an SQLite * Communicates with the Android Contacts Provider which uses an SQLite

View File

@ -7,9 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import java.util.ArrayList;
import lombok.Cleanup;
import android.accounts.Account; import android.accounts.Account;
import android.content.ContentProviderClient; import android.content.ContentProviderClient;
import android.content.ContentProviderOperation; import android.content.ContentProviderOperation;
@ -23,6 +20,10 @@ import android.os.RemoteException;
import android.provider.CalendarContract; import android.provider.CalendarContract;
import android.util.Log; import android.util.Log;
import java.util.ArrayList;
import lombok.Cleanup;
/** /**
* Represents a locally-stored synchronizable collection (for instance, the * Represents a locally-stored synchronizable collection (for instance, the
* address book or a calendar). Manages a CTag that stores the last known * address book or a calendar). Manages a CTag that stores the last known

View File

@ -7,6 +7,12 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.resource; package at.bitfire.davdroid.resource;
import android.util.Log;
import net.fortuna.ical4j.model.ValidationException;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -15,10 +21,6 @@ import java.net.URISyntaxException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import lombok.Cleanup;
import lombok.Getter;
import net.fortuna.ical4j.model.ValidationException;
import android.util.Log;
import at.bitfire.davdroid.URIUtils; import at.bitfire.davdroid.URIUtils;
import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavException;
import at.bitfire.davdroid.webdav.DavMultiget; import at.bitfire.davdroid.webdav.DavMultiget;
@ -27,8 +29,9 @@ import at.bitfire.davdroid.webdav.HttpException;
import at.bitfire.davdroid.webdav.HttpPropfind; import at.bitfire.davdroid.webdav.HttpPropfind;
import at.bitfire.davdroid.webdav.WebDavResource; import at.bitfire.davdroid.webdav.WebDavResource;
import at.bitfire.davdroid.webdav.WebDavResource.PutMode; import at.bitfire.davdroid.webdav.WebDavResource.PutMode;
import org.apache.http.impl.client.CloseableHttpClient;
import ezvcard.io.text.VCardParseException; import ezvcard.io.text.VCardParseException;
import lombok.Cleanup;
import lombok.Getter;
/** /**
* Represents a remotely stored synchronizable collection (collection as in * Represents a remotely stored synchronizable collection (collection as in

View File

@ -25,6 +25,7 @@ import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import at.bitfire.davdroid.Constants; 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;

View File

@ -7,10 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.net.URI;
import java.net.URISyntaxException;
import lombok.Cleanup;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.content.ContentResolver; import android.content.ContentResolver;
@ -23,8 +19,13 @@ 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 java.net.URI;
import java.net.URISyntaxException;
import at.bitfire.davdroid.resource.ServerInfo; import at.bitfire.davdroid.resource.ServerInfo;
import ezvcard.VCardVersion; import ezvcard.VCardVersion;
import lombok.Cleanup;
public class AccountSettings { public class AccountSettings {
private final static String TAG = "davdroid.AccountSettings"; private final static String TAG = "davdroid.AccountSettings";

View File

@ -14,6 +14,7 @@ import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import at.bitfire.davdroid.Constants; import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;

View File

@ -7,10 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import android.accounts.Account; import android.accounts.Account;
import android.app.Service; import android.app.Service;
import android.content.ContentProviderClient; import android.content.ContentProviderClient;
@ -19,6 +15,11 @@ import android.content.Intent;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import at.bitfire.davdroid.resource.CalDavCalendar; import at.bitfire.davdroid.resource.CalDavCalendar;
import at.bitfire.davdroid.resource.LocalCalendar; import at.bitfire.davdroid.resource.LocalCalendar;
import at.bitfire.davdroid.resource.LocalCollection; import at.bitfire.davdroid.resource.LocalCollection;

View File

@ -7,10 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import android.accounts.Account; import android.accounts.Account;
import android.app.Service; import android.app.Service;
import android.content.ContentProviderClient; import android.content.ContentProviderClient;
@ -18,6 +14,11 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log; import android.util.Log;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import at.bitfire.davdroid.resource.CardDavAddressBook; import at.bitfire.davdroid.resource.CardDavAddressBook;
import at.bitfire.davdroid.resource.LocalAddressBook; import at.bitfire.davdroid.resource.LocalAddressBook;
import at.bitfire.davdroid.resource.LocalCollection; import at.bitfire.davdroid.resource.LocalCollection;

View File

@ -7,16 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.io.Closeable;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import lombok.Getter;
import org.apache.http.HttpStatus;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.content.AbstractThreadedSyncAdapter; import android.content.AbstractThreadedSyncAdapter;
@ -30,14 +20,23 @@ import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.Constants;
import org.apache.http.HttpStatus;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.Closeable;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import at.bitfire.davdroid.resource.LocalCollection; import at.bitfire.davdroid.resource.LocalCollection;
import at.bitfire.davdroid.resource.LocalStorageException; import at.bitfire.davdroid.resource.LocalStorageException;
import at.bitfire.davdroid.resource.RemoteCollection; import at.bitfire.davdroid.resource.RemoteCollection;
import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavException;
import at.bitfire.davdroid.webdav.DavHttpClient; import at.bitfire.davdroid.webdav.DavHttpClient;
import at.bitfire.davdroid.webdav.HttpException; import at.bitfire.davdroid.webdav.HttpException;
import org.apache.http.impl.client.CloseableHttpClient; import lombok.Getter;
public abstract class DavSyncAdapter extends AbstractThreadedSyncAdapter implements Closeable { public abstract class DavSyncAdapter extends AbstractThreadedSyncAdapter implements Closeable {
private final static String TAG = "davdroid.DavSyncAdapter"; private final static String TAG = "davdroid.DavSyncAdapter";
@ -108,10 +107,7 @@ public abstract class DavSyncAdapter extends AbstractThreadedSyncAdapter impleme
if (httpClient == null) { if (httpClient == null) {
Log.d(TAG, "Creating new DavHttpClient"); Log.d(TAG, "Creating new DavHttpClient");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
httpClient = DavHttpClient.create( httpClient = DavHttpClient.create();
settings.getBoolean(Constants.SETTING_DISABLE_COMPRESSION, false),
settings.getBoolean(Constants.SETTING_NETWORK_LOGGING, false)
);
} }
// prevent httpClient shutdown until we're ready by holding a read lock // prevent httpClient shutdown until we're ready by holding a read lock

View File

@ -7,9 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.net.URI;
import java.net.URISyntaxException;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -23,6 +20,10 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import java.net.URI;
import java.net.URISyntaxException;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
public class LoginEmailFragment extends Fragment implements TextWatcher { public class LoginEmailFragment extends Fragment implements TextWatcher {

View File

@ -16,6 +16,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.RadioButton; import android.widget.RadioButton;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
public class LoginTypeFragment extends Fragment { public class LoginTypeFragment extends Fragment {

View File

@ -7,11 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.lang.StringUtils;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -31,6 +26,12 @@ import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.apache.commons.lang.StringUtils;
import java.net.URI;
import java.net.URISyntaxException;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
public class LoginURLFragment extends Fragment implements TextWatcher { public class LoginURLFragment extends Fragment implements TextWatcher {

View File

@ -7,11 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import lombok.Cleanup;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.LoaderManager.LoaderCallbacks; import android.app.LoaderManager.LoaderCallbacks;
import android.content.AsyncTaskLoader; import android.content.AsyncTaskLoader;
@ -24,11 +19,18 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
import org.apache.http.HttpException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.resource.DavResourceFinder; import at.bitfire.davdroid.resource.DavResourceFinder;
import at.bitfire.davdroid.resource.ServerInfo; import at.bitfire.davdroid.resource.ServerInfo;
import at.bitfire.davdroid.webdav.DavException; import at.bitfire.davdroid.webdav.DavException;
import org.apache.http.HttpException; import lombok.Cleanup;
public class QueryServerDialogFragment extends DialogFragment implements LoaderCallbacks<ServerInfo> { public class QueryServerDialogFragment extends DialogFragment implements LoaderCallbacks<ServerInfo> {
private static final String TAG = "davdroid.QueryServerDialogFragment"; private static final String TAG = "davdroid.QueryServerDialogFragment";

View File

@ -7,7 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import lombok.Getter;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.text.Html; import android.text.Html;
@ -17,9 +16,11 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter; 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; import at.bitfire.davdroid.resource.ServerInfo;
import at.bitfire.davdroid.resource.ServerInfo.ResourceInfo.Type; import at.bitfire.davdroid.resource.ServerInfo.ResourceInfo.Type;
import lombok.Getter;
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

@ -19,6 +19,7 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; 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; import at.bitfire.davdroid.resource.ServerInfo;

View File

@ -7,14 +7,16 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import android.content.SyncResult;
import android.util.Log;
import net.fortuna.ical4j.model.ValidationException;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import net.fortuna.ical4j.model.ValidationException;
import android.content.SyncResult;
import android.util.Log;
import at.bitfire.davdroid.ArrayUtils; import at.bitfire.davdroid.ArrayUtils;
import at.bitfire.davdroid.resource.LocalCollection; import at.bitfire.davdroid.resource.LocalCollection;
import at.bitfire.davdroid.resource.LocalStorageException; import at.bitfire.davdroid.resource.LocalStorageException;

View File

@ -7,14 +7,15 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.syncadapter; package at.bitfire.davdroid.syncadapter;
import java.util.List;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.TextView; import android.widget.TextView;
import java.util.List;
import at.bitfire.davdroid.webdav.WebDavResource; import at.bitfire.davdroid.webdav.WebDavResource;
public class WebDavResourceAdapter extends BaseAdapter { public class WebDavResourceAdapter extends BaseAdapter {

View File

@ -8,7 +8,7 @@
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.Constants;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.Registry; import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder; import org.apache.http.config.RegistryBuilder;
@ -17,10 +17,9 @@ import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import java.lang.reflect.Method; import at.bitfire.davdroid.Constants;
public class DavHttpClient { public class DavHttpClient {
@ -44,7 +43,7 @@ public class DavHttpClient {
} }
public static CloseableHttpClient create(boolean disableCompression, boolean logTraffic) { public static CloseableHttpClient create() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
// limits per DavHttpClient (= per DavSyncAdapter extends AbstractThreadedSyncAdapter) // limits per DavHttpClient (= per DavSyncAdapter extends AbstractThreadedSyncAdapter)
connectionManager.setMaxTotal(3); // max. 3 connections in total connectionManager.setMaxTotal(3); // max. 3 connections in total

View File

@ -7,14 +7,13 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import org.apache.commons.lang.ArrayUtils;
import org.apache.http.HttpRequest;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandlerHC4;
import java.util.Locale; import java.util.Locale;
import org.apache.commons.lang.ArrayUtils; public class DavHttpRequestRetryHandler extends DefaultHttpRequestRetryHandlerHC4 {
import org.apache.http.HttpRequest;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
public class DavHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
final static DavHttpRequestRetryHandler INSTANCE = new DavHttpRequestRetryHandler(); final static DavHttpRequestRetryHandler INSTANCE = new DavHttpRequestRetryHandler();
// see http://www.iana.org/assignments/http-methods/http-methods.xhtml // see http://www.iana.org/assignments/http-methods/http-methods.xhtml
@ -27,7 +26,7 @@ public class DavHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
super(/* retry count */ 3, /* retry already sent requests? */ false); super(/* retry count */ 3, /* retry already sent requests? */ false);
} }
//@Override @Override
protected boolean handleAsIdempotent(final HttpRequest request) { protected boolean handleAsIdempotent(final HttpRequest request) {
final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT); final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
return ArrayUtils.contains(idempotentMethods, method); return ArrayUtils.contains(idempotentMethods, method);

View File

@ -7,13 +7,13 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.Element; import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList; import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Order; import org.simpleframework.xml.Order;
import java.util.ArrayList;
import java.util.List;
@Order(elements={"prop","href"}) @Order(elements={"prop","href"})
public class DavMultiget { public class DavMultiget {
public enum Type { public enum Type {

View File

@ -7,12 +7,12 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import java.util.List;
import org.simpleframework.xml.ElementList; 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 java.util.List;
@Namespace(reference="DAV:") @Namespace(reference="DAV:")
@Root(strict=false) @Root(strict=false)
public class DavMultistatus { public class DavMultistatus {

View File

@ -7,10 +7,6 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import java.util.List;
import lombok.Getter;
import org.simpleframework.xml.Attribute; import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element; import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList; import org.simpleframework.xml.ElementList;
@ -18,6 +14,10 @@ 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;
import java.util.List;
import lombok.Getter;
@Namespace(prefix="D",reference="DAV:") @Namespace(prefix="D",reference="DAV:")
@Root(strict=false) @Root(strict=false)
public class DavProp { public class DavProp {

View File

@ -7,11 +7,8 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import java.net.URI;
import java.net.URISyntaxException;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.URIUtils;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
@ -24,6 +21,11 @@ import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import java.net.URI;
import java.net.URISyntaxException;
import at.bitfire.davdroid.URIUtils;
/** /**
* Custom Redirect Strategy that handles 30x for CalDAV/CardDAV-specific requests correctly * Custom Redirect Strategy that handles 30x for CalDAV/CardDAV-specific requests correctly
*/ */
@ -89,7 +91,7 @@ public class DavRedirectStrategy implements RedirectStrategy {
if (!originalURI.isAbsolute()) { if (!originalURI.isAbsolute()) {
final HttpHost target = HttpClientContext.adapt(context).getTargetHost(); final HttpHost target = HttpClientContext.adapt(context).getTargetHost();
if (target != null) if (target != null)
originalURI = org.apache.http.client.utils.URIUtils.rewriteURI(originalURI, target); originalURI = org.apache.http.client.utils.URIUtilsHC4.rewriteURI(originalURI, target);
else else
return null; return null;
} }

View File

@ -7,14 +7,14 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import java.util.List;
import lombok.Getter;
import org.simpleframework.xml.Element; import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList; import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root; import org.simpleframework.xml.Root;
import java.util.List;
import lombok.Getter;
@Root(strict=false) @Root(strict=false)
public class DavResponse { public class DavResponse {
@Element @Element

View File

@ -7,18 +7,18 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import android.util.Log;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBaseHC4;
import org.apache.http.entity.StringEntity;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URI; import java.net.URI;
import java.util.LinkedList; import java.util.LinkedList;
import org.simpleframework.xml.Serializer; public class HttpPropfind extends HttpEntityEnclosingRequestBaseHC4 {
import org.simpleframework.xml.core.Persister;
import android.util.Log;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.entity.StringEntity;
public class HttpPropfind extends HttpEntityEnclosingRequestBase {
private static final String TAG = "davdroid.HttpPropfind"; private static final String TAG = "davdroid.HttpPropfind";
public final static String METHOD_NAME = "PROPFIND"; public final static String METHOD_NAME = "PROPFIND";

View File

@ -9,13 +9,13 @@ package at.bitfire.davdroid.webdav;
import android.util.Log; import android.util.Log;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBaseHC4;
import org.apache.http.entity.StringEntity;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; public class HttpReport extends HttpEntityEnclosingRequestBaseHC4 {
import org.apache.http.entity.StringEntity;
public class HttpReport extends HttpEntityEnclosingRequestBase {
private static final String TAG = "davdroid.HttpEntityEncloseRequestBase"; private static final String TAG = "davdroid.HttpEntityEncloseRequestBase";
public final static String METHOD_NAME = "REPORT"; public final static String METHOD_NAME = "REPORT";

View File

@ -7,6 +7,18 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.net.SSLCertificateSocketFactory;
import android.os.Build;
import android.util.Log;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifierHC4;
import org.apache.http.protocol.HttpContext;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
@ -15,20 +27,11 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import org.apache.commons.lang.StringUtils;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.net.SSLCertificateSocketFactory;
import android.os.Build;
import android.util.Log;
import org.apache.http.HttpHost;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
import org.apache.http.protocol.HttpContext;
public class TlsSniSocketFactory implements LayeredConnectionSocketFactory { public class TlsSniSocketFactory implements LayeredConnectionSocketFactory {
private static final String TAG = "davdroid.SNISocketFactory"; private static final String TAG = "davdroid.SNISocketFactory";
@ -37,7 +40,7 @@ public class TlsSniSocketFactory implements LayeredConnectionSocketFactory {
private final static SSLCertificateSocketFactory sslSocketFactory = private final static SSLCertificateSocketFactory sslSocketFactory =
(SSLCertificateSocketFactory)SSLCertificateSocketFactory.getDefault(0); (SSLCertificateSocketFactory)SSLCertificateSocketFactory.getDefault(0);
private final static HostnameVerifier hostnameVerifier = new BrowserCompatHostnameVerifier(); private final static HostnameVerifier hostnameVerifier = new BrowserCompatHostnameVerifierHC4();
/* /*

View File

@ -7,6 +7,34 @@
******************************************************************************/ ******************************************************************************/
package at.bitfire.davdroid.webdav; package at.bitfire.davdroid.webdav;
import android.util.Log;
import org.apache.commons.lang.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDeleteHC4;
import org.apache.http.client.methods.HttpGetHC4;
import org.apache.http.client.methods.HttpOptionsHC4;
import org.apache.http.client.methods.HttpPutHC4;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.ByteArrayEntityHC4;
import org.apache.http.impl.auth.BasicSchemeHC4;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProviderHC4;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicLineParserHC4;
import org.apache.http.util.EntityUtilsHC4;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringWriter; import java.io.StringWriter;
@ -19,42 +47,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import lombok.Cleanup;
import lombok.Getter;
import lombok.ToString;
import org.apache.commons.lang.StringUtils;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
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.Comp; import at.bitfire.davdroid.webdav.DavProp.Comp;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicLineParser;
import org.apache.http.util.EntityUtils;
import ezvcard.VCardVersion; import ezvcard.VCardVersion;
import lombok.Cleanup;
import lombok.Getter;
import lombok.ToString;
/** /**
@ -105,21 +104,21 @@ public class WebDavResource {
location = baseURI; location = baseURI;
context = HttpClientContext.create(); context = HttpClientContext.create();
context.setCredentialsProvider(new BasicCredentialsProvider()); context.setCredentialsProvider(new BasicCredentialsProviderHC4());
} }
public WebDavResource(CloseableHttpClient httpClient, URI baseURI, String username, String password, boolean preemptive) { public WebDavResource(CloseableHttpClient httpClient, URI baseURI, String username, String password, boolean preemptive) {
this(httpClient, baseURI); this(httpClient, baseURI);
HttpHost host = new HttpHost(baseURI.getHost(), baseURI.getPort(), baseURI.getScheme());
context.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); context.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
if (preemptive) { if (preemptive) {
HttpHost host = new HttpHost(baseURI.getHost(), baseURI.getPort(), baseURI.getScheme());
Log.d(TAG, "Using preemptive authentication (not compatible with Digest auth)"); Log.d(TAG, "Using preemptive authentication (not compatible with Digest auth)");
AuthCache authCache = context.getAuthCache(); AuthCache authCache = context.getAuthCache();
if (authCache == null) if (authCache == null)
authCache = new BasicAuthCache(); authCache = new BasicAuthCache();
authCache.put(host, new BasicScheme()); authCache.put(host, new BasicSchemeHC4());
context.setAuthCache(authCache); context.setAuthCache(authCache);
} }
} }
@ -150,7 +149,7 @@ public class WebDavResource {
/* feature detection */ /* feature detection */
public void options() throws URISyntaxException, IOException, HttpException { public void options() throws URISyntaxException, IOException, HttpException {
HttpOptions options = new HttpOptions(location); HttpOptionsHC4 options = new HttpOptionsHC4(location);
CloseableHttpResponse response = httpClient.execute(options, context); CloseableHttpResponse response = httpClient.execute(options, context);
try { try {
checkResponse(response); checkResponse(response);
@ -332,7 +331,7 @@ public class WebDavResource {
/* resource operations */ /* resource operations */
public void get(String acceptedType) throws URISyntaxException, IOException, HttpException, DavException { public void get(String acceptedType) throws URISyntaxException, IOException, HttpException, DavException {
HttpGet get = new HttpGet(location); HttpGetHC4 get = new HttpGetHC4(location);
get.addHeader("Accept", acceptedType); get.addHeader("Accept", acceptedType);
CloseableHttpResponse response = httpClient.execute(get, context); CloseableHttpResponse response = httpClient.execute(get, context);
@ -343,7 +342,7 @@ public class WebDavResource {
if (entity == null) if (entity == null)
throw new DavNoContentException(); throw new DavNoContentException();
content = EntityUtils.toByteArray(entity); content = EntityUtilsHC4.toByteArray(entity);
} finally { } finally {
response.close(); response.close();
} }
@ -351,8 +350,8 @@ public class WebDavResource {
// returns the ETag of the created/updated resource, if available (null otherwise) // returns the ETag of the created/updated resource, if available (null otherwise)
public String put(byte[] data, PutMode mode) throws URISyntaxException, IOException, HttpException { public String put(byte[] data, PutMode mode) throws URISyntaxException, IOException, HttpException {
HttpPut put = new HttpPut(location); HttpPutHC4 put = new HttpPutHC4(location);
put.setEntity(new ByteArrayEntity(data)); put.setEntity(new ByteArrayEntityHC4(data));
switch (mode) { switch (mode) {
case ADD_DONT_OVERWRITE: case ADD_DONT_OVERWRITE:
@ -381,7 +380,7 @@ public class WebDavResource {
} }
public void delete() throws URISyntaxException, IOException, HttpException { public void delete() throws URISyntaxException, IOException, HttpException {
HttpDelete delete = new HttpDelete(location); HttpDeleteHC4 delete = new HttpDeleteHC4(location);
if (getETag() != null) if (getETag() != null)
delete.addHeader("If-Match", getETag()); delete.addHeader("If-Match", getETag());
@ -468,7 +467,7 @@ public class WebDavResource {
byte[] data = null; byte[] data = null;
for (DavPropstat singlePropstat : singleResponse.getPropstat()) { for (DavPropstat singlePropstat : singleResponse.getPropstat()) {
StatusLine status = BasicLineParser.parseStatusLine(singlePropstat.status, new BasicLineParser()); StatusLine status = BasicLineParserHC4.parseStatusLine(singlePropstat.status, new BasicLineParserHC4());
// ignore information about missing properties etc. // ignore information about missing properties etc.
if (status.getStatusCode()/100 != 1 && status.getStatusCode()/100 != 2) if (status.getStatusCode()/100 != 1 && status.getStatusCode()/100 != 2)