Loading sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java +5 −6 Original line number Diff line number Diff line Loading @@ -79,8 +79,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, mHandler = new Handler(); Uri serverUri = Uri.parse(getString(R.string.server_base_url)); mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true, getString(R.string.user_agent)); mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true); mClient.setCredentials( OwnCloudCredentialsFactory.newBasicCredentials( getString(R.string.username), Loading Loading @@ -150,7 +149,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, private void startRefresh() { ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR); refreshOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); refreshOperation.execute(mClient, this, mHandler); } private void startUpload() { Loading @@ -160,7 +159,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String mimeType = getString(R.string.sample_file_mimetype); UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType); uploadOperation.addDatatransferProgressListener(this); uploadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); uploadOperation.execute(mClient, this, mHandler); } private void startRemoteDeletion() { Loading @@ -168,7 +167,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); removeOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); removeOperation.execute(mClient, this, mHandler); } private void startDownload() { Loading @@ -179,7 +178,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath()); downloadOperation.addDatatransferProgressListener(this); downloadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); downloadOperation.execute(mClient, this, mHandler); } @SuppressWarnings("deprecation") Loading src/com/owncloud/android/lib/common/OwnCloudClient.java +5 −5 Original line number Diff line number Diff line Loading @@ -67,12 +67,11 @@ public class OwnCloudClient extends HttpClient { private int mInstanceNumber = 0; private Uri mBaseUri; private String mUserAgent; /** * Constructor */ public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr, String userAgent) { public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr) { super(connectionMgr); if (baseUri == null) { Loading @@ -83,8 +82,8 @@ public class OwnCloudClient extends HttpClient { mInstanceNumber = sIntanceCounter++; Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); mUserAgent = userAgent; getParams().setParameter(HttpMethodParams.USER_AGENT, mUserAgent); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter( CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); Loading Loading @@ -212,7 +211,8 @@ public class OwnCloudClient extends HttpClient { // Update User Agent HttpParams params = method.getParams(); params.setParameter(HttpMethodParams.USER_AGENT, mUserAgent); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); params.setParameter(HttpMethodParams.USER_AGENT, userAgent); Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " + method.getName() + " " + method.getPath()); Loading src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +6 −10 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ public class OwnCloudClientFactory { * * @param account The ownCloud account * @param appContext Android application context * @param userAgent OwnCloud userAgent string * @return A OwnCloudClient object ready to be used * @throws AuthenticatorException If the authenticator failed to get the authorization * token for the account. Loading @@ -71,8 +70,7 @@ public class OwnCloudClientFactory { * authorization token for the account. * @throws AccountNotFoundException If 'account' is unknown for the AccountManager */ public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, String userAgent) public static OwnCloudClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { //Log_OC.d(TAG, "Creating OwnCloudClient associated to " + account.name); Loading @@ -83,7 +81,7 @@ public class OwnCloudClientFactory { am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null; boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso, userAgent); OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); if (isOauth2) { String accessToken = am.blockingGetAuthToken( Loading Loading @@ -127,7 +125,7 @@ public class OwnCloudClientFactory { public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity, String userAgent) Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); Loading @@ -137,7 +135,7 @@ public class OwnCloudClientFactory { am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null; boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso, userAgent); OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); if (isOauth2) { // TODO avoid a call to getUserData here AccountManagerFuture<Bundle> future = am.getAuthToken( Loading Loading @@ -204,11 +202,10 @@ public class OwnCloudClientFactory { * * @param uri URL to the ownCloud server; BASE ENTRY POINT, not WebDavPATH * @param context Android context where the OwnCloudClient is being created. * @param userAgent OwnCloud userAgent string * @return A OwnCloudClient object ready to be used */ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects, String userAgent) { boolean followRedirects) { try { NetworkUtils.registerAdvancedSslContext(true, context); } catch (GeneralSecurityException e) { Loading @@ -220,8 +217,7 @@ public class OwnCloudClientFactory { " in the system will be used for HTTPS connections", e); } OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager(), userAgent); OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); client.setFollowRedirects(followRedirects); Loading src/com/owncloud/android/lib/common/OwnCloudClientManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce public interface OwnCloudClientManager { public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, String userAgent) public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; Loading src/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +11 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; public static OwnCloudClientManager newDefaultOwnCloudClientManager() { return newOwnCloudClientManager(sDefaultPolicy); } Loading Loading @@ -72,6 +74,14 @@ public class OwnCloudClientManagerFactory { sDefaultPolicy = policy; } public static void setUserAgent(String userAgent){ sUserAgent = userAgent; } public static String getUserAgent() { return sUserAgent; } private static boolean defaultSingletonMustBeUpdated(Policy policy) { if (sDefaultSingleton == null) { return false; Loading Loading
sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java +5 −6 Original line number Diff line number Diff line Loading @@ -79,8 +79,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, mHandler = new Handler(); Uri serverUri = Uri.parse(getString(R.string.server_base_url)); mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true, getString(R.string.user_agent)); mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true); mClient.setCredentials( OwnCloudCredentialsFactory.newBasicCredentials( getString(R.string.username), Loading Loading @@ -150,7 +149,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, private void startRefresh() { ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR); refreshOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); refreshOperation.execute(mClient, this, mHandler); } private void startUpload() { Loading @@ -160,7 +159,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String mimeType = getString(R.string.sample_file_mimetype); UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType); uploadOperation.addDatatransferProgressListener(this); uploadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); uploadOperation.execute(mClient, this, mHandler); } private void startRemoteDeletion() { Loading @@ -168,7 +167,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); removeOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); removeOperation.execute(mClient, this, mHandler); } private void startDownload() { Loading @@ -179,7 +178,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath()); downloadOperation.addDatatransferProgressListener(this); downloadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler); downloadOperation.execute(mClient, this, mHandler); } @SuppressWarnings("deprecation") Loading
src/com/owncloud/android/lib/common/OwnCloudClient.java +5 −5 Original line number Diff line number Diff line Loading @@ -67,12 +67,11 @@ public class OwnCloudClient extends HttpClient { private int mInstanceNumber = 0; private Uri mBaseUri; private String mUserAgent; /** * Constructor */ public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr, String userAgent) { public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr) { super(connectionMgr); if (baseUri == null) { Loading @@ -83,8 +82,8 @@ public class OwnCloudClient extends HttpClient { mInstanceNumber = sIntanceCounter++; Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); mUserAgent = userAgent; getParams().setParameter(HttpMethodParams.USER_AGENT, mUserAgent); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent); getParams().setParameter( CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); Loading Loading @@ -212,7 +211,8 @@ public class OwnCloudClient extends HttpClient { // Update User Agent HttpParams params = method.getParams(); params.setParameter(HttpMethodParams.USER_AGENT, mUserAgent); String userAgent = OwnCloudClientManagerFactory.getUserAgent(); params.setParameter(HttpMethodParams.USER_AGENT, userAgent); Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " + method.getName() + " " + method.getPath()); Loading
src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +6 −10 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ public class OwnCloudClientFactory { * * @param account The ownCloud account * @param appContext Android application context * @param userAgent OwnCloud userAgent string * @return A OwnCloudClient object ready to be used * @throws AuthenticatorException If the authenticator failed to get the authorization * token for the account. Loading @@ -71,8 +70,7 @@ public class OwnCloudClientFactory { * authorization token for the account. * @throws AccountNotFoundException If 'account' is unknown for the AccountManager */ public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, String userAgent) public static OwnCloudClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { //Log_OC.d(TAG, "Creating OwnCloudClient associated to " + account.name); Loading @@ -83,7 +81,7 @@ public class OwnCloudClientFactory { am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null; boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso, userAgent); OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); if (isOauth2) { String accessToken = am.blockingGetAuthToken( Loading Loading @@ -127,7 +125,7 @@ public class OwnCloudClientFactory { public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity, String userAgent) Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); Loading @@ -137,7 +135,7 @@ public class OwnCloudClientFactory { am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null; boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso, userAgent); OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); if (isOauth2) { // TODO avoid a call to getUserData here AccountManagerFuture<Bundle> future = am.getAuthToken( Loading Loading @@ -204,11 +202,10 @@ public class OwnCloudClientFactory { * * @param uri URL to the ownCloud server; BASE ENTRY POINT, not WebDavPATH * @param context Android context where the OwnCloudClient is being created. * @param userAgent OwnCloud userAgent string * @return A OwnCloudClient object ready to be used */ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects, String userAgent) { boolean followRedirects) { try { NetworkUtils.registerAdvancedSslContext(true, context); } catch (GeneralSecurityException e) { Loading @@ -220,8 +217,7 @@ public class OwnCloudClientFactory { " in the system will be used for HTTPS connections", e); } OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager(), userAgent); OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); client.setFollowRedirects(followRedirects); Loading
src/com/owncloud/android/lib/common/OwnCloudClientManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce public interface OwnCloudClientManager { public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, String userAgent) public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException; Loading
src/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +11 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; public static OwnCloudClientManager newDefaultOwnCloudClientManager() { return newOwnCloudClientManager(sDefaultPolicy); } Loading Loading @@ -72,6 +74,14 @@ public class OwnCloudClientManagerFactory { sDefaultPolicy = policy; } public static void setUserAgent(String userAgent){ sUserAgent = userAgent; } public static String getUserAgent() { return sUserAgent; } private static boolean defaultSingletonMustBeUpdated(Policy policy) { if (sDefaultSingleton == null) { return false; Loading