-Subproject commit ba42f934fc861f6d5120690edd46ba2c502dd705
+Subproject commit 1ef3a0176cc870d3cb26a77652b7ae9fd79584ce
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
-import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.notifications.NotificationBuilderWithProgressBar;
import com.owncloud.android.notifications.NotificationDelayer;
-import com.owncloud.android.operations.DownloadFileOperation;
+import com.owncloud.android.lib.common.OwnCloudClientMap;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.operations.DownloadFileOperation;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.preview.PreviewImageActivity;
/// prepare client object to send the request to the ownCloud server
if (mDownloadClient == null || !mLastAccount.equals(mCurrentDownload.getAccount())) {
mLastAccount = mCurrentDownload.getAccount();
- mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver());
- mDownloadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext());
+ mStorageManager =
+ new FileDataStorageManager(mLastAccount, getContentResolver());
+ mDownloadClient = OwnCloudClientMap.getClientFor(mLastAccount, this);
}
/// perform the download
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
-import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientMap;
import com.owncloud.android.ui.activity.FailedUploadActivity;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
/// prepare client object to send requests to the ownCloud server
if (mUploadClient == null || !mLastAccount.equals(mCurrentUpload.getAccount())) {
mLastAccount = mCurrentUpload.getAccount();
- mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver());
- mUploadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext());
+ mStorageManager =
+ new FileDataStorageManager(mLastAccount, getContentResolver());
+ mUploadClient = OwnCloudClientMap.getClientFor(mLastAccount, this);
}
/// check the existence of the parent folder for the file to upload
* @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called.
* @return Thread were the remote operation is executed.
*/
+ /*
public Thread execute(FileDataStorageManager storageManager, Context context, OnRemoteOperationListener listener, Handler listenerHandler, Activity callerActivity) {
if (storageManager == null) {
throw new IllegalArgumentException("Trying to execute a sync operation with a NULL storage manager");
mStorageManager = storageManager;
return super.execute(storageManager.getAccount(), context, listener, listenerHandler, callerActivity);
}
+ */
/**
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientFactory;
+import com.owncloud.android.lib.common.OwnCloudClientMap;
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
if (mLastTarget == null || !mLastTarget.equals(next.first)) {
mLastTarget = next.first;
if (mLastTarget.mAccount != null) {
- mOwnCloudClient = OwnCloudClientFactory.createOwnCloudClient(mLastTarget.mAccount, getApplicationContext());
- mStorageManager = new FileDataStorageManager(mLastTarget.mAccount, getContentResolver());
+ mOwnCloudClient =
+ OwnCloudClientMap.getClientFor(mLastTarget.mAccount, this);
+ mStorageManager =
+ new FileDataStorageManager(
+ mLastTarget.mAccount,
+ getContentResolver());
} else {
mOwnCloudClient = OwnCloudClientFactory.createOwnCloudClient(mLastTarget.mServerUrl, getApplicationContext(),
mLastTarget.mFollowRedirects); // this is not good enough
import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.lib.common.accounts.AccountUtils;\r
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;\r
-import com.owncloud.android.lib.common.OwnCloudClientFactory;\r
import com.owncloud.android.lib.common.OwnCloudClient;\r
+import com.owncloud.android.lib.common.OwnCloudClientMap;\r
\r
\r
import android.accounts.Account;\r
\r
protected void initClientForCurrentAccount() throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {\r
AccountUtils.constructFullURLForAccount(getContext(), account);\r
- mClient = OwnCloudClientFactory.createOwnCloudClient(account, getContext());\r
+ mClient = OwnCloudClientMap.getClientFor(account, getContext());\r
}\r
\r
protected OwnCloudClient getClient() {\r
}
}
- private void requestCredentialsUpdate() {
+ protected void requestCredentialsUpdate() {
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
updateAccountCredentials.putExtra(
package com.owncloud.android.ui.activity;
import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.httpclient.Credentials;
import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.operations.CreateFolderOperation;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientMap;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.lib.common.network.BearerCredentials;
import com.owncloud.android.lib.common.network.CertificateCombinedException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && !SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
+ if (SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
+ equals(event) &&
+ /// TODO refactor and make common
+ synchResult != null && !synchResult.isSuccess() &&
+ (synchResult.getCode() == ResultCode.UNAUTHORIZED ||
+ synchResult.isIdPRedirection() ||
+ (synchResult.isException() && synchResult.getException()
+ instanceof AuthenticatorException))) {
+
+
+ OwnCloudClient client = OwnCloudClientMap.removeClientFor(getAccount());
+ if (client != null) {
+ Credentials cred = client.getCredentials();
+ String ssoSessionCookie = client.getSsoSessionCookie();
+ if (cred != null || ssoSessionCookie != null) {
+ boolean bearerAuthorization = (cred != null && cred instanceof BearerCredentials);
+ boolean samlBasedSsoAuthorization = (cred == null && ssoSessionCookie != null);
+ AccountManager am = AccountManager.get(context);
+
+ if (bearerAuthorization) {
+ am.invalidateAuthToken(getAccount().type,
+ ((BearerCredentials)cred).getAccessToken());
+
+ } else if (samlBasedSsoAuthorization ) {
+ am.invalidateAuthToken(getAccount().type, ssoSessionCookie);
+
+ } else {
+ am.clearPassword(getAccount());
+ }
+ }
+ }
+
+ requestCredentialsUpdate();
+
}
- removeStickyBroadcast(intent);
- Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
+ }
+ removeStickyBroadcast(intent);
+ Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
+ setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
}
getAccount(),
getApplicationContext()
);
- synchFolderOp.execute(getAccount(), this, null, null, this);
+ synchFolderOp.execute(getAccount(), this, null, null);
setSupportProgressBarIndeterminateVisibility(true);
}
public void uploadFiles() {
try {
- //OwnCloudClient webdav = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());
ArrayList<String> local = new ArrayList<String>();
ArrayList<String> remote = new ArrayList<String>();
- /* TODO - mCreateDir can never be true at this moment; we will replace wdc.createDirectory by CreateFolderOperation when that is fixed
- OwnCloudClient wdc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());
- // create last directory in path if necessary
- if (mCreateDir) {
- wdc.createDirectory(mUploadPath);
- }
- */
-
// this checks the mimeType
for (Parcelable mStream : mStreamsToUpload) {