Loading src/com/owncloud/android/lib/common/DynamicSessionManager.java +10 −5 Original line number Diff line number Diff line Loading @@ -26,20 +26,25 @@ public class DynamicSessionManager implements OwnCloudClientManager { @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { return getClientFor(account, context, false); } @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, boolean useNextcloudUserAgent) throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { OwnCloudVersion ownCloudVersion = null; if (account.getSavedAccount() != null) { ownCloudVersion = AccountUtils.getServerVersionForAccount( account.getSavedAccount(), context ); ownCloudVersion = AccountUtils.getServerVersionForAccount(account.getSavedAccount(), context); } if (ownCloudVersion != null && ownCloudVersion.isPreemptiveAuthenticationPreferred()) { return mSingleSessionManager.getClientFor(account, context); return mSingleSessionManager.getClientFor(account, context, useNextcloudUserAgent); } else { return mSimpleFactoryManager.getClientFor(account, context); return mSimpleFactoryManager.getClientFor(account, context, useNextcloudUserAgent); } } Loading src/com/owncloud/android/lib/common/OwnCloudClient.java +23 −12 Original line number Diff line number Diff line Loading @@ -71,31 +71,36 @@ public class OwnCloudClient extends HttpClient { private OwnCloudVersion mVersion = null; private boolean mUseNextcloudUserAgent = false; /** * Constructor */ public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr) { public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr, boolean useNextcloudUserAgent) { super(connectionMgr); if (baseUri == null) { throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL"); } mBaseUri = baseUri; mUseNextcloudUserAgent = useNextcloudUserAgent; mInstanceNumber = sIntanceCounter++; Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter( PARAM_PROTOCOL_VERSION, HttpVersion.HTTP_1_1); String userAgent; getParams().setCookiePolicy( CookiePolicy.IGNORE_COOKIES); getParams().setParameter( PARAM_SINGLE_COOKIE_HEADER, // to avoid problems with some web servers PARAM_SINGLE_COOKIE_HEADER_VALUE); if (useNextcloudUserAgent) { userAgent = OwnCloudClientManagerFactory.getNextcloudUserAgent(); } else { userAgent = OwnCloudClientManagerFactory.getUserAgent(); } getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter(PARAM_PROTOCOL_VERSION, HttpVersion.HTTP_1_1); getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); // to avoid problems with some web servers getParams().setParameter(PARAM_SINGLE_COOKIE_HEADER, PARAM_SINGLE_COOKIE_HEADER_VALUE); applyProxySettings(); Loading Loading @@ -208,7 +213,13 @@ public class OwnCloudClient extends HttpClient { try { // Update User Agent HttpParams params = method.getParams(); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); String userAgent; if (mUseNextcloudUserAgent) { userAgent = OwnCloudClientManagerFactory.getUserAgent(); } else { userAgent = OwnCloudClientManagerFactory.getNextcloudUserAgent(); } params.setParameter(HttpMethodParams.USER_AGENT, userAgent); Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " + Loading src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +8 −5 Original line number Diff line number Diff line Loading @@ -209,8 +209,8 @@ public class OwnCloudClientFactory { * @param context Android context where the OwnCloudClient is being created. * @return A OwnCloudClient object ready to be used */ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects, boolean useNextcloudUserAgent) { try { NetworkUtils.registerAdvancedSslContext(true, context); } catch (GeneralSecurityException e) { Loading @@ -222,12 +222,15 @@ public class OwnCloudClientFactory { " in the system will be used for HTTPS connections", e); } OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager(), useNextcloudUserAgent); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); client.setFollowRedirects(followRedirects); return client; } public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { return createOwnCloudClient(uri, context, followRedirects, false); } } src/com/owncloud/android/lib/common/OwnCloudClientManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -24,14 +24,14 @@ package com.owncloud.android.lib.common; import java.io.IOException; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; import java.io.IOException; /** * Manager to create and reuse OwnCloudClient instances to access remote OC servers. Loading @@ -42,6 +42,10 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce public interface OwnCloudClientManager { public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, boolean useNextcloudUserAgent) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; Loading src/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; private static String sNextcloudUserAgent; public static OwnCloudClientManager newDefaultOwnCloudClientManager() { return newOwnCloudClientManager(sDefaultPolicy); Loading Loading @@ -86,6 +87,14 @@ public class OwnCloudClientManagerFactory { return sUserAgent; } public static void setNextcloudUserAgent(String userAgent) { sNextcloudUserAgent = userAgent; } public static String getNextcloudUserAgent() { return sNextcloudUserAgent; } private static boolean defaultSingletonMustBeUpdated(Policy policy) { if (sDefaultSingleton == null) { return false; Loading Loading
src/com/owncloud/android/lib/common/DynamicSessionManager.java +10 −5 Original line number Diff line number Diff line Loading @@ -26,20 +26,25 @@ public class DynamicSessionManager implements OwnCloudClientManager { @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { return getClientFor(account, context, false); } @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, boolean useNextcloudUserAgent) throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { OwnCloudVersion ownCloudVersion = null; if (account.getSavedAccount() != null) { ownCloudVersion = AccountUtils.getServerVersionForAccount( account.getSavedAccount(), context ); ownCloudVersion = AccountUtils.getServerVersionForAccount(account.getSavedAccount(), context); } if (ownCloudVersion != null && ownCloudVersion.isPreemptiveAuthenticationPreferred()) { return mSingleSessionManager.getClientFor(account, context); return mSingleSessionManager.getClientFor(account, context, useNextcloudUserAgent); } else { return mSimpleFactoryManager.getClientFor(account, context); return mSimpleFactoryManager.getClientFor(account, context, useNextcloudUserAgent); } } Loading
src/com/owncloud/android/lib/common/OwnCloudClient.java +23 −12 Original line number Diff line number Diff line Loading @@ -71,31 +71,36 @@ public class OwnCloudClient extends HttpClient { private OwnCloudVersion mVersion = null; private boolean mUseNextcloudUserAgent = false; /** * Constructor */ public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr) { public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr, boolean useNextcloudUserAgent) { super(connectionMgr); if (baseUri == null) { throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL"); } mBaseUri = baseUri; mUseNextcloudUserAgent = useNextcloudUserAgent; mInstanceNumber = sIntanceCounter++; Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter( PARAM_PROTOCOL_VERSION, HttpVersion.HTTP_1_1); String userAgent; getParams().setCookiePolicy( CookiePolicy.IGNORE_COOKIES); getParams().setParameter( PARAM_SINGLE_COOKIE_HEADER, // to avoid problems with some web servers PARAM_SINGLE_COOKIE_HEADER_VALUE); if (useNextcloudUserAgent) { userAgent = OwnCloudClientManagerFactory.getNextcloudUserAgent(); } else { userAgent = OwnCloudClientManagerFactory.getUserAgent(); } getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter(PARAM_PROTOCOL_VERSION, HttpVersion.HTTP_1_1); getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); // to avoid problems with some web servers getParams().setParameter(PARAM_SINGLE_COOKIE_HEADER, PARAM_SINGLE_COOKIE_HEADER_VALUE); applyProxySettings(); Loading Loading @@ -208,7 +213,13 @@ public class OwnCloudClient extends HttpClient { try { // Update User Agent HttpParams params = method.getParams(); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); String userAgent; if (mUseNextcloudUserAgent) { userAgent = OwnCloudClientManagerFactory.getUserAgent(); } else { userAgent = OwnCloudClientManagerFactory.getNextcloudUserAgent(); } params.setParameter(HttpMethodParams.USER_AGENT, userAgent); Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " + Loading
src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +8 −5 Original line number Diff line number Diff line Loading @@ -209,8 +209,8 @@ public class OwnCloudClientFactory { * @param context Android context where the OwnCloudClient is being created. * @return A OwnCloudClient object ready to be used */ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects, boolean useNextcloudUserAgent) { try { NetworkUtils.registerAdvancedSslContext(true, context); } catch (GeneralSecurityException e) { Loading @@ -222,12 +222,15 @@ public class OwnCloudClientFactory { " in the system will be used for HTTPS connections", e); } OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager(), useNextcloudUserAgent); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); client.setFollowRedirects(followRedirects); return client; } public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { return createOwnCloudClient(uri, context, followRedirects, false); } }
src/com/owncloud/android/lib/common/OwnCloudClientManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -24,14 +24,14 @@ package com.owncloud.android.lib.common; import java.io.IOException; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; import java.io.IOException; /** * Manager to create and reuse OwnCloudClient instances to access remote OC servers. Loading @@ -42,6 +42,10 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce public interface OwnCloudClientManager { public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, boolean useNextcloudUserAgent) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; Loading
src/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; private static String sNextcloudUserAgent; public static OwnCloudClientManager newDefaultOwnCloudClientManager() { return newOwnCloudClientManager(sDefaultPolicy); Loading Loading @@ -86,6 +87,14 @@ public class OwnCloudClientManagerFactory { return sUserAgent; } public static void setNextcloudUserAgent(String userAgent) { sNextcloudUserAgent = userAgent; } public static String getNextcloudUserAgent() { return sNextcloudUserAgent; } private static boolean defaultSingletonMustBeUpdated(Policy policy) { if (sDefaultSingleton == null) { return false; Loading