Skip to content

Commit

Permalink
Merge pull request #126 from nextcloud/e2eUserAgent
Browse files Browse the repository at this point in the history
set user agent / use it correctly
  • Loading branch information
AndyScherzinger authored Feb 26, 2018
2 parents eaaa076 + 107c575 commit 7452598
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/com/owncloud/android/lib/common/OwnCloudClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,17 @@ public void setOwnCloudVersion(OwnCloudVersion version){
public OwnCloudVersion getOwnCloudVersion(){
return mVersion;
}

public void setUseNextcloudUserAgent(boolean nextcloudUserAgent) {
mUseNextcloudUserAgent = nextcloudUserAgent;

String userAgent = nextcloudUserAgent ? OwnCloudClientManagerFactory.getNextcloudUserAgent() :
OwnCloudClientManagerFactory.getUserAgent();

getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
}

public boolean useNextcloudUserAgent() {
return mUseNextcloudUserAgent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;

import org.apache.commons.httpclient.params.HttpMethodParams;

import java.io.IOException;


Expand Down Expand Up @@ -142,11 +140,7 @@ public RemoteOperationResult execute(OwnCloudClient client, boolean useNextcloud
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
"OwnCloudClient");
mClient = client;

if (useNextcloudUserAgent) {
mClient.getParams().setParameter(HttpMethodParams.USER_AGENT,
OwnCloudClientManagerFactory.getNextcloudUserAgent());
}
mClient.setUseNextcloudUserAgent(useNextcloudUserAgent);

return run(client);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

package com.owncloud.android.lib.resources.files;

import org.apache.jackrabbit.webdav.client.methods.MkColMethod;

import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
Expand All @@ -34,6 +32,8 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.apache.jackrabbit.webdav.client.methods.MkColMethod;


/**
* Remote operation performing the creation of a new folder in the ownCloud server.
Expand Down Expand Up @@ -99,6 +99,7 @@ private RemoteOperationResult createFolder(OwnCloudClient client) {
MkColMethod mkcol = null;
try {
mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
client.setUseNextcloudUserAgent(true);
client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
result = new RemoteOperationResult(mkcol.succeeded(), mkcol);
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
Expand Down

0 comments on commit 7452598

Please sign in to comment.