mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-12 00:42:58 +00:00
Refactor parameter user_agent out of RemoteOperation and children
This commit is contained in:
@@ -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) {
|
||||
@@ -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);
|
||||
@@ -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());
|
||||
|
||||
@@ -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.
|
||||
@@ -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);
|
||||
@@ -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(
|
||||
@@ -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));
|
||||
@@ -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(
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ public class OwnCloudClientManagerFactory {
|
||||
|
||||
private static OwnCloudClientManager sDefaultSingleton;
|
||||
|
||||
private static String sUserAgent;
|
||||
|
||||
public static OwnCloudClientManager newDefaultOwnCloudClientManager() {
|
||||
return newOwnCloudClientManager(sDefaultPolicy);
|
||||
}
|
||||
@@ -71,7 +73,15 @@ 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;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SimpleFactoryManager implements OwnCloudClientManager {
|
||||
private static final String TAG = SimpleFactoryManager.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context, String userAgent)
|
||||
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
|
||||
throws AccountNotFoundException, OperationCanceledException, AuthenticatorException,
|
||||
IOException {
|
||||
|
||||
@@ -49,8 +49,7 @@ public class SimpleFactoryManager implements OwnCloudClientManager {
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
|
||||
account.getBaseUri(),
|
||||
context.getApplicationContext(),
|
||||
true,
|
||||
userAgent);
|
||||
true);
|
||||
|
||||
Log_OC.v(TAG, " new client {" +
|
||||
(account.getName() != null ?
|
||||
|
||||
@@ -62,8 +62,7 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized OwnCloudClient getClientFor(OwnCloudAccount account, Context context,
|
||||
String userAgent)
|
||||
public synchronized OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
|
||||
throws AccountNotFoundException, OperationCanceledException, AuthenticatorException,
|
||||
IOException {
|
||||
|
||||
@@ -109,8 +108,7 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(
|
||||
account.getBaseUri(),
|
||||
context.getApplicationContext(),
|
||||
true,
|
||||
userAgent); // TODO remove dependency on OwnCloudClientFactory
|
||||
true); // TODO remove dependency on OwnCloudClientFactory
|
||||
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
|
||||
// enable cookie tracking
|
||||
|
||||
|
||||
@@ -81,9 +81,6 @@ public abstract class RemoteOperation implements Runnable {
|
||||
/** Activity */
|
||||
private Activity mCallerActivity;
|
||||
|
||||
/** User agent */
|
||||
private String mUserAgent;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract method to implement the operation in derived classes.
|
||||
@@ -97,15 +94,14 @@ public abstract class RemoteOperation implements Runnable {
|
||||
* Do not call this method from the main thread.
|
||||
*
|
||||
* This method should be used whenever an ownCloud account is available, instead of
|
||||
* {@link #execute(OwnCloudClient, java.lang.String)}.
|
||||
* {@link #execute(OwnCloudClient)}.
|
||||
*
|
||||
* @param account ownCloud account in remote ownCloud server to reach during the
|
||||
* execution of the operation.
|
||||
* @param context Android context for the component calling the method.
|
||||
* @param userAgent userAgent string
|
||||
* @return Result of the operation.
|
||||
*/
|
||||
public RemoteOperationResult execute(Account account, Context context, String userAgent) {
|
||||
public RemoteOperationResult execute(Account account, Context context) {
|
||||
if (account == null)
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"Account");
|
||||
@@ -114,11 +110,10 @@ public abstract class RemoteOperation implements Runnable {
|
||||
"Context");
|
||||
mAccount = account;
|
||||
mContext = context.getApplicationContext();
|
||||
mUserAgent = userAgent;
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, mContext);
|
||||
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, mContext, mUserAgent);
|
||||
getClientFor(ocAccount, mContext);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error while trying to access to " + mAccount.name, e);
|
||||
return new RemoteOperationResult(e);
|
||||
@@ -134,15 +129,13 @@ public abstract class RemoteOperation implements Runnable {
|
||||
*
|
||||
* @param client Client object to reach an ownCloud server during the execution of
|
||||
* the operation.
|
||||
* @param userAgent userAgent string
|
||||
* @return Result of the operation.
|
||||
*/
|
||||
public RemoteOperationResult execute(OwnCloudClient client, String userAgent) {
|
||||
public RemoteOperationResult execute(OwnCloudClient client) {
|
||||
if (client == null)
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"OwnCloudClient");
|
||||
mClient = client;
|
||||
mUserAgent = userAgent;
|
||||
return run(client);
|
||||
}
|
||||
|
||||
@@ -151,10 +144,10 @@ public abstract class RemoteOperation implements Runnable {
|
||||
* Asynchronously executes the remote operation
|
||||
*
|
||||
* This method should be used whenever an ownCloud account is available, instead of
|
||||
* {@link #execute(OwnCloudClient, java.lang.String)}.
|
||||
* {@link #execute(OwnCloudClient)}.
|
||||
*
|
||||
* @deprecated This method will be removed in version 1.0.
|
||||
* Use {@link #execute(Account, Context, String, OnRemoteOperationListener,
|
||||
* Use {@link #execute(Account, Context, OnRemoteOperationListener,
|
||||
* Handler)} instead.
|
||||
*
|
||||
* @param account ownCloud account in remote ownCloud server to reach during
|
||||
@@ -193,18 +186,17 @@ public abstract class RemoteOperation implements Runnable {
|
||||
* Asynchronously executes the remote operation
|
||||
*
|
||||
* This method should be used whenever an ownCloud account is available,
|
||||
* instead of {@link #execute(OwnCloudClient, String, OnRemoteOperationListener, Handler))}.
|
||||
* instead of {@link #execute(OwnCloudClient, OnRemoteOperationListener, Handler))}.
|
||||
*
|
||||
* @param account ownCloud account in remote ownCloud server to reach during the
|
||||
* execution of the operation.
|
||||
* @param context Android context for the component calling the method.
|
||||
* @param userAgent userAgent string
|
||||
* @param listener Listener to be notified about the execution of the operation.
|
||||
* @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(Account account, Context context, String userAgent,
|
||||
public Thread execute(Account account, Context context,
|
||||
OnRemoteOperationListener listener, Handler listenerHandler) {
|
||||
|
||||
if (account == null)
|
||||
@@ -234,20 +226,18 @@ public abstract class RemoteOperation implements Runnable {
|
||||
*
|
||||
* @param client Client object to reach an ownCloud server
|
||||
* during the execution of the operation.
|
||||
* @param userAgent userAgent string
|
||||
* @param listener Listener to be notified about the execution of the operation.
|
||||
* @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(OwnCloudClient client, String userAgent,
|
||||
public Thread execute(OwnCloudClient client,
|
||||
OnRemoteOperationListener listener, Handler listenerHandler) {
|
||||
if (client == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Trying to execute a remote operation with a NULL OwnCloudClient");
|
||||
}
|
||||
mClient = client;
|
||||
mUserAgent = userAgent;
|
||||
|
||||
if (listener == null) {
|
||||
throw new IllegalArgumentException
|
||||
@@ -270,7 +260,7 @@ public abstract class RemoteOperation implements Runnable {
|
||||
|
||||
/**
|
||||
* Asynchronous execution of the operation
|
||||
* started by {@link RemoteOperation#execute(OwnCloudClient, String,
|
||||
* started by {@link RemoteOperation#execute(OwnCloudClient,
|
||||
* OnRemoteOperationListener, Handler)},
|
||||
* and result posting.
|
||||
*
|
||||
@@ -287,12 +277,12 @@ public abstract class RemoteOperation implements Runnable {
|
||||
/** DEPRECATED BLOCK - will be removed at version 1.0 */
|
||||
if (mCallerActivity != null) {
|
||||
mClient = OwnCloudClientFactory.createOwnCloudClient(
|
||||
mAccount, mContext, mCallerActivity, mUserAgent);
|
||||
mAccount, mContext, mCallerActivity);
|
||||
} else {
|
||||
/** EOF DEPRECATED */
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, mContext);
|
||||
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, mContext, mUserAgent);
|
||||
getClientFor(ocAccount, mContext);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -371,13 +361,4 @@ public abstract class RemoteOperation implements Runnable {
|
||||
return mClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user agent string
|
||||
* @return
|
||||
*/
|
||||
public final String getUserAgent() {
|
||||
return mUserAgent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
|
||||
}
|
||||
mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
|
||||
mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
|
||||
mPutMethod.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
((ChunkFromFileChannelRequestEntity)mEntity).setOffset(offset);
|
||||
mPutMethod.setRequestEntity(mEntity);
|
||||
status = client.executeMethod(mPutMethod);
|
||||
|
||||
@@ -78,8 +78,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
result = createFolder(client);
|
||||
if (!result.isSuccess() && mCreateFullPath &&
|
||||
RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) {
|
||||
result = createParentFolder(FileUtils.getParentPath(mRemotePath), client,
|
||||
getUserAgent());
|
||||
result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
|
||||
if (result.isSuccess()) {
|
||||
result = createFolder(client); // second (and last) try
|
||||
}
|
||||
@@ -98,7 +97,6 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
MkColMethod mkcol = null;
|
||||
try {
|
||||
mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
mkcol.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
|
||||
result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
|
||||
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
|
||||
@@ -115,11 +113,10 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
return result;
|
||||
}
|
||||
|
||||
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client,
|
||||
String userAgent) {
|
||||
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) {
|
||||
RemoteOperation operation = new CreateRemoteFolderOperation(parentPath,
|
||||
mCreateFullPath);
|
||||
return operation.execute(client, userAgent);
|
||||
return operation.execute(client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
||||
int status = -1;
|
||||
boolean savedFile = false;
|
||||
mGet = new GetMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
mGet.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
Iterator<OnDatatransferProgressListener> it = null;
|
||||
|
||||
FileOutputStream fos = null;
|
||||
|
||||
@@ -77,7 +77,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
|
||||
HeadMethod head = null;
|
||||
try {
|
||||
head = new HeadMethod(client.getWebdavUri() + WebdavUtils.encodePath(mPath));
|
||||
head.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(head, TIMEOUT, TIMEOUT);
|
||||
client.exhaustResponse(head.getResponseBodyAsStream());
|
||||
boolean success = (status == HttpStatus.SC_OK && !mSuccessIfAbsent) ||
|
||||
|
||||
@@ -113,7 +113,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {
|
||||
client.getWebdavUri() + WebdavUtils.encodePath(mTargetRemotePath),
|
||||
mOverwrite
|
||||
);
|
||||
move.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(move, MOVE_READ_TIMEOUT, MOVE_CONNECTION_TIMEOUT);
|
||||
|
||||
/// process response
|
||||
|
||||
@@ -79,7 +79,6 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
||||
propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||
WebdavUtils.getFilePropSet(), // PropFind Properties
|
||||
DavConstants.DEPTH_0);
|
||||
propfind.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status;
|
||||
status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
|
||||
query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||
WebdavUtils.getAllPropSet(), // PropFind Properties
|
||||
DavConstants.DEPTH_1);
|
||||
query.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(query);
|
||||
|
||||
// check and process response
|
||||
|
||||
@@ -68,7 +68,6 @@ public class RemoveRemoteFileOperation extends RemoteOperation {
|
||||
|
||||
try {
|
||||
delete = new DeleteMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
delete.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT);
|
||||
|
||||
delete.getResponseBodyAsString(); // exhaust the response, although not interesting
|
||||
|
||||
@@ -107,7 +107,6 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
||||
move = new LocalMoveMethod( client.getWebdavUri() +
|
||||
WebdavUtils.encodePath(mOldRemotePath),
|
||||
client.getWebdavUri() + WebdavUtils.encodePath(mNewRemotePath));
|
||||
move.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT);
|
||||
|
||||
move.getResponseBodyAsString(); // exhaust response, although not interesting
|
||||
|
||||
@@ -82,7 +82,6 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
||||
} else {
|
||||
mPutMethod = new PutMethod(client.getWebdavUri() +
|
||||
WebdavUtils.encodePath(mRemotePath));
|
||||
mPutMethod.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
|
||||
post.setRequestHeader( "Content-Type",
|
||||
"application/x-www-form-urlencoded; charset=utf-8"); // necessary for special characters
|
||||
post.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
post.addParameter(PARAM_PATH, mRemoteFilePath);
|
||||
post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue()));
|
||||
|
||||
@@ -86,7 +86,6 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation {
|
||||
try {
|
||||
// Get Method
|
||||
get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
// Add Parameters to Get Method
|
||||
get.setQueryString(new NameValuePair[] {
|
||||
|
||||
@@ -67,7 +67,6 @@ public class GetRemoteSharesOperation extends RemoteOperation {
|
||||
try{
|
||||
get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
status = client.executeMethod(get);
|
||||
if(isSuccess(status)) {
|
||||
String response = get.getResponseBodyAsString();
|
||||
|
||||
@@ -72,7 +72,6 @@ public class RemoveRemoteShareOperation extends RemoteOperation {
|
||||
delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH + id);
|
||||
|
||||
delete.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
delete.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
status = client.executeMethod(delete);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -77,10 +78,10 @@ public class GetRemoteStatusOperation extends RemoteOperation {
|
||||
String baseUrlSt = client.getBaseUri().toString();
|
||||
try {
|
||||
get = new GetMethod(baseUrlSt + AccountUtils.STATUS_PATH);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
HttpParams params = get.getParams().getDefaultParams();
|
||||
params.setParameter(HttpMethodParams.USER_AGENT, getUserAgent());
|
||||
params.setParameter(HttpMethodParams.USER_AGENT,
|
||||
OwnCloudClientManagerFactory.getUserAgent());
|
||||
get.getParams().setDefaults(params);
|
||||
|
||||
client.setFollowRedirects(false);
|
||||
|
||||
@@ -79,7 +79,6 @@ public class GetRemoteUserNameOperation extends RemoteOperation {
|
||||
try {
|
||||
get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
||||
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
status = client.executeMethod(get);
|
||||
if(isSuccess(status)) {
|
||||
String response = get.getResponseBodyAsString();
|
||||
|
||||
Reference in New Issue
Block a user