Refactor parameter user_agent out of RemoteOperation and children

This commit is contained in:
masensio 2015-03-24 14:32:13 +01:00
parent 6d3bbd8bf3
commit 6af93bfdde
27 changed files with 48 additions and 51 deletions

@ -1 +1 @@
Subproject commit 94ac3a93d3da2719c24c4f62c95e5de3e7b5e650
Subproject commit 9990eeb7ff68dd6e3a8056768ddce93b4e04bf99

View file

@ -52,6 +52,7 @@ public class MainApp extends Application {
boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
if (isSamlAuth) {
OwnCloudClientManagerFactory.setDefaultPolicy(Policy.SINGLE_SESSION_PER_ACCOUNT);

View file

@ -61,8 +61,7 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
// Client
Uri uri = Uri.parse(url);
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, mContext, true,
MainApp.getUserAgent());
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, mContext, true);
client.setCredentials(credentials);
@ -72,7 +71,7 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
mContext,
SUCCESS_IF_ABSENT
);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
} else {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR);

View file

@ -172,8 +172,7 @@ public class ThumbnailsCacheManager {
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount,
MainApp.getAppContext());
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext(),
MainApp.getUserAgent());
getClientFor(ocAccount, MainApp.getAppContext());
}
mFile = params[0];

View file

@ -466,14 +466,13 @@ public class FileDownloader extends Service
// of update
OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, this, MainApp.getUserAgent());
getClientFor(ocAccount, this);
/// perform the download
/*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
"Executing download of " + mCurrentDownload.getRemotePath());*/
downloadResult = mCurrentDownload.execute(mDownloadClient,
MainApp.getUserAgent());
downloadResult = mCurrentDownload.execute(mDownloadClient);
if (downloadResult.isSuccess()) {
saveDownloadedFile();
}

View file

@ -574,7 +574,7 @@ public class FileUploader extends Service
new FileDataStorageManager(mLastAccount, getContentResolver());
OwnCloudAccount ocAccount = new OwnCloudAccount(mLastAccount, this);
mUploadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, this, MainApp.getUserAgent());
getClientFor(ocAccount, this);
}
/// check the existence of the parent folder for the file to upload
@ -587,8 +587,7 @@ public class FileUploader extends Service
if (grantResult.isSuccess()) {
OCFile parent = mStorageManager.getFileByPath(remoteParentPath);
mCurrentUpload.getFile().setParentId(parent.getFileId());
uploadResult = mCurrentUpload.execute(mUploadClient,
MainApp.getUserAgent());
uploadResult = mCurrentUpload.execute(mUploadClient);
if (uploadResult.isSuccess()) {
saveUploadedFile();
}
@ -647,7 +646,7 @@ public class FileUploader extends Service
*/
private RemoteOperationResult grantFolderExistence(String pathToGrant) {
RemoteOperation operation = new ExistenceCheckRemoteOperation(pathToGrant, this, false);
RemoteOperationResult result = operation.execute(mUploadClient, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(mUploadClient);
if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND &&
mCurrentUpload.isRemoteFolderToBeCreated()) {
SyncOperation syncOp = new CreateFolderOperation( pathToGrant, true);
@ -708,7 +707,7 @@ public class FileUploader extends Service
// in theory, should return the same we already have
ReadRemoteFileOperation operation =
new ReadRemoteFileOperation(mCurrentUpload.getRemotePath());
RemoteOperationResult result = operation.execute(mUploadClient, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(mUploadClient);
if (result.isSuccess()) {
updateOCFile(file, (RemoteFile) result.getData().get(0));
file.setLastSyncDateForProperties(syncDate);

View file

@ -61,7 +61,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
protected RemoteOperationResult run(OwnCloudClient client) {
CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath,
mCreateFullPath);
RemoteOperationResult result = operation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {
saveFolderInDB();

View file

@ -100,12 +100,12 @@ public class CreateShareOperation extends SyncOperation {
// Check if the share link already exists
operation = new GetRemoteSharesForFileOperation(mPath, false, false);
RemoteOperationResult result =
((GetRemoteSharesForFileOperation)operation).execute(client, MainApp.getUserAgent());
((GetRemoteSharesForFileOperation)operation).execute(client);
if (!result.isSuccess() || result.getData().size() <= 0) {
operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload,
mPassword, mPermissions);
result = ((CreateRemoteShareOperation)operation).execute(client, MainApp.getUserAgent());
result = ((CreateRemoteShareOperation)operation).execute(client);
}
if (result.isSuccess()) {

View file

@ -89,12 +89,12 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
client.setFollowRedirects(false);
// try to access the root folder, following redirections but not SAML SSO redirections
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
String redirectedLocation = result.getRedirectedLocation();
while (redirectedLocation != null && redirectedLocation.length() > 0 &&
!result.isIdPRedirection()) {
client.setBaseUri(Uri.parse(result.getRedirectedLocation()));
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
redirectedLocation = result.getRedirectedLocation();
}

View file

@ -150,7 +150,7 @@ public class DownloadFileOperation extends RemoteOperation {
while (listener.hasNext()) {
mDownloadOperation.addDatatransferProgressListener(listener.next());
}
result = mDownloadOperation.execute(client, MainApp.getUserAgent());
result = mDownloadOperation.execute(client);
if (result.isSuccess()) {
mModificationTimestamp = mDownloadOperation.getModificationTimestamp();

View file

@ -79,7 +79,7 @@ public class GetServerInfoOperation extends RemoteOperation {
// first: check the status of the server (including its version)
GetRemoteStatusOperation getStatus = new GetRemoteStatusOperation(mContext);
RemoteOperationResult result = getStatus.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = getStatus.execute(client);
if (result.isSuccess()) {
// second: get authentication method required by the server
@ -107,7 +107,7 @@ public class GetServerInfoOperation extends RemoteOperation {
Log_OC.d(TAG, "Trying empty authorization to detect authentication method");
DetectAuthenticationMethodOperation operation =
new DetectAuthenticationMethodOperation(mContext);
return operation.execute(client, MainApp.getUserAgent());
return operation.execute(client);
}

View file

@ -61,7 +61,7 @@ public class GetSharesForFileOperation extends SyncOperation {
protected RemoteOperationResult run(OwnCloudClient client) {
GetRemoteSharesForFileOperation operation = new GetRemoteSharesForFileOperation(mPath,
mReshares, mSubfiles);
RemoteOperationResult result = operation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {

View file

@ -43,7 +43,7 @@ public class GetSharesOperation extends SyncOperation {
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
GetRemoteSharesOperation operation = new GetRemoteSharesOperation();
RemoteOperationResult result = operation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {

View file

@ -90,7 +90,7 @@ public class MoveFileOperation extends SyncOperation {
targetPath,
false
);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
/// 3. local move
if (result.isSuccess()) {

View file

@ -228,7 +228,7 @@ public class RefreshFolderOperation extends RemoteOperation {
private void updateOCVersion(OwnCloudClient client) {
UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
RemoteOperationResult result = update.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = update.execute(client);
if (result.isSuccess()) {
mIsShareSupported = update.getOCVersion().isSharedSupported();
}
@ -245,7 +245,7 @@ public class RefreshFolderOperation extends RemoteOperation {
// remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess()){
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@ -281,7 +281,7 @@ public class RefreshFolderOperation extends RemoteOperation {
private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
String remotePath = mLocalFolder.getRemotePath();
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
RemoteOperationResult result = operation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(client);
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
if (result.isSuccess()) {
@ -549,7 +549,7 @@ public class RefreshFolderOperation extends RemoteOperation {
// remote request
GetRemoteSharesForFileOperation operation =
new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), false, true);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess()) {
// update local database

View file

@ -79,7 +79,7 @@ public class RemoveFileOperation extends SyncOperation {
boolean localRemovalFailed = false;
if (!mOnlyLocalCopy) {
RemoveRemoteFileOperation operation = new RemoveRemoteFileOperation(mRemotePath);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
localRemovalFailed = !(getStorageManager().removeFile(mFileToRemove, true, true));
}

View file

@ -99,7 +99,7 @@ public class RenameFileOperation extends SyncOperation {
RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(),
mFile.getRemotePath(),
mNewName, mFile.isFolder());
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess()) {
if (mFile.isFolder()) {

View file

@ -197,7 +197,7 @@ public class SynchronizeFileOperation extends SyncOperation {
if (mServerFile == null) {
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess()){
mServerFile = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
mServerFile.setLastSyncDateForProperties(System.currentTimeMillis());

View file

@ -189,7 +189,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
// remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess()){
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@ -228,7 +228,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
}
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(mRemotePath);
RemoteOperationResult result = operation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = operation.execute(client);
Log_OC.d(TAG, "Synchronizing " + mAccount.name + mRemotePath);
if (result.isSuccess()) {

View file

@ -64,7 +64,7 @@ public class UnshareLinkOperation extends SyncOperation {
if (share != null) {
RemoveRemoteShareOperation operation =
new RemoveRemoteShareOperation((int) share.getIdRemoteShared());
result = operation.execute(client, MainApp.getUserAgent());
result = operation.execute(client);
if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) {
Log_OC.d(TAG, "Share id = " + share.getIdRemoteShared() + " deleted");
@ -94,7 +94,7 @@ public class UnshareLinkOperation extends SyncOperation {
private boolean existsFile(OwnCloudClient client, String remotePath){
ExistenceCheckRemoteOperation existsOperation =
new ExistenceCheckRemoteOperation(remotePath, mContext, false);
RemoteOperationResult result = existsOperation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = existsOperation.execute(client);
return result.isSuccess();
}

View file

@ -322,7 +322,7 @@ public class UploadFileOperation extends RemoteOperation {
mUploadOperation.addDatatransferProgressListener(listener.next());
}
if (!mCancellationRequested.get()) {
result = mUploadOperation.execute(client, MainApp.getUserAgent());
result = mUploadOperation.execute(client);
/// move local temporal file or original file to its corresponding
// location in the ownCloud local folder
@ -459,7 +459,7 @@ public class UploadFileOperation extends RemoteOperation {
private boolean existsFile(OwnCloudClient client, String remotePath){
ExistenceCheckRemoteOperation existsOperation =
new ExistenceCheckRemoteOperation(remotePath, mContext, false);
RemoteOperationResult result = existsOperation.execute(client, MainApp.getUserAgent());
RemoteOperationResult result = existsOperation.execute(client);
return result.isSuccess();
}

View file

@ -70,7 +70,7 @@ public abstract class SyncOperation extends RemoteOperation {
"storage manager for a NULL account");
}
mStorageManager = storageManager;
return super.execute(mStorageManager.getAccount(), context, getUserAgent());
return super.execute(mStorageManager.getAccount(), context);
}
@ -90,7 +90,7 @@ public abstract class SyncOperation extends RemoteOperation {
throw new IllegalArgumentException("Trying to execute a sync operation with a " +
"NULL storage manager");
mStorageManager = storageManager;
return super.execute(client, MainApp.getUserAgent());
return super.execute(client);
}
@ -143,7 +143,7 @@ public abstract class SyncOperation extends RemoteOperation {
"with a NULL storage manager");
}
mStorageManager = storageManager;
return super.execute(client, MainApp.getUserAgent(), listener, listenerHandler);
return super.execute(client, listener, listenerHandler);
}

View file

@ -441,7 +441,7 @@ public class OperationsService extends Service {
OwnCloudAccount ocAccount = new OwnCloudAccount(mLastTarget.mAccount,
mService);
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, mService, MainApp.getUserAgent());
getClientFor(ocAccount, mService);
mStorageManager = new FileDataStorageManager(
mLastTarget.mAccount,
mService.getContentResolver()
@ -459,7 +459,7 @@ public class OperationsService extends Service {
OwnCloudAccount ocAccount = new OwnCloudAccount(
mLastTarget.mServerUrl, credentials);
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, mService, MainApp.getUserAgent());
getClientFor(ocAccount, mService);
mStorageManager = null;
}
}
@ -469,7 +469,7 @@ public class OperationsService extends Service {
result = ((SyncOperation)mCurrentOperation).execute(mOwnCloudClient,
mStorageManager);
} else {
result = mCurrentOperation.execute(mOwnCloudClient, MainApp.getUserAgent());
result = mCurrentOperation.execute(mOwnCloudClient);
}
} catch (AccountsException e) {

View file

@ -118,7 +118,7 @@ class SyncFolderHandler extends Handler {
// always get client from client manager, to get fresh credentials in case of update
OwnCloudAccount ocAccount = new OwnCloudAccount(account, mService);
mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, mService, MainApp.getUserAgent());
getClientFor(ocAccount, mService);
result = mCurrentSyncOperation.execute(mOwnCloudClient, mStorageManager);

View file

@ -108,7 +108,7 @@ public abstract class AbstractOwnCloudSyncAdapter extends
AccountUtils.constructFullURLForAccount(getContext(), account);
OwnCloudAccount ocAccount = new OwnCloudAccount(account, getContext());
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, getContext(), MainApp.getUserAgent());
getClientFor(ocAccount, getContext());
}
protected OwnCloudClient getClient() {

View file

@ -228,7 +228,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
* locally saved.
*
* See {@link #onPerformSync(Account, Bundle, String, ContentProviderClient, SyncResult)}
* and {@link #synchronizeFolder(String, long)}.
* and {@link #synchronizeFolder(OCFile)}.
*/
@Override
public void onSyncCanceled() {
@ -243,7 +243,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
*/
private void updateOCVersion() {
UpdateOCVersionOperation update = new UpdateOCVersionOperation(getAccount(), getContext());
RemoteOperationResult result = update.execute(getClient(), MainApp.getUserAgent());
RemoteOperationResult result = update.execute(getClient());
if (!result.isSuccess()) {
mLastFailedResult = result;
} else {
@ -288,7 +288,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
getAccount(),
getContext()
);
RemoteOperationResult result = synchFolderOp.execute(getClient(), MainApp.getUserAgent());
RemoteOperationResult result = synchFolderOp.execute(getClient());
// synchronized folder -> notice to UI - ALWAYS, although !result.isSuccess

View file

@ -220,7 +220,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
getAccount(),
getApplicationContext()
);
synchFolderOp.execute(getAccount(), this, MainApp.getUserAgent(), null, null);
synchFolderOp.execute(getAccount(), this, null, null);
setSupportProgressBarIndeterminateVisibility(true);