Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
Conflicts:
	qBittorrentClient/app/build.gradle
  • Loading branch information
lgallard committed May 2, 2015
2 parents 64a5e53 + 3a6836e commit 895f157
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 20 deletions.
58 changes: 58 additions & 0 deletions qBittorrentClient/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "22.0.0"

defaultConfig {
applicationId 'com.lgallardo.qbittorrentclient'
minSdkVersion 14
targetSdkVersion 21
archivesBaseName = "qBittorrentClient_v" + versionName
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

productFlavors {
pro {
applicationId 'com.lgallardo.qbittorrentclientpro'
versionName '3.9.2'
minSdkVersion 14
targetSdkVersion 21
versionCode 392
archivesBaseName = "qBittorrentClient_v" + versionName
}
free {
applicationId "com.lgallardo.qbittorrentclient"
versionName '3.9.2'
minSdkVersion 14
targetSdkVersion 21
versionCode 392
archivesBaseName = "qBittorrentClient_v" + versionName
}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}

dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:7.0.0'
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.5.jar')
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public JSONObject getJSONFromUrl(String url) throws JSONParserStatusCodeExceptio
// Set http parameters
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpProtocolParams.setUserAgent(httpParameters,"qBittorrent for Android");
HttpProtocolParams.setVersion(httpParameters,HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParameters,HTTP.UTF_8);

// Making HTTP request
HttpHost targetHost = new HttpHost(this.hostname, this.port, this.protocol);
Expand All @@ -143,6 +146,8 @@ public JSONObject getJSONFromUrl(String url) throws JSONParserStatusCodeExceptio

// set http parameters

url = protocol + "://" + hostname + ":" + port +"/" +url;

HttpGet httpget = new HttpGet(url);

if (this.cookie != null) {
Expand Down Expand Up @@ -227,12 +232,13 @@ public JSONArray getJSONArrayFromUrl(String url) throws JSONParserStatusCodeExce
// Set http parameters
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpProtocolParams.setUserAgent(httpParameters,"qBittorrent for Android");
HttpProtocolParams.setVersion(httpParameters,HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParameters,HTTP.UTF_8);

// Making HTTP request
HttpHost targetHost = new HttpHost(hostname, port, protocol);

// httpclient = new DefaultHttpClient(httpParameters);
// httpclient = new DefaultHttpClient();
httpclient = getNewHttpClient();

httpclient.setParams(httpParameters);
Expand All @@ -244,13 +250,12 @@ public JSONArray getJSONArrayFromUrl(String url) throws JSONParserStatusCodeExce

httpclient.getCredentialsProvider().setCredentials(authScope, credentials);

HttpGet httpget = new HttpGet(url);
url = protocol + "://" + hostname + ":" + port +"/" +url;

// Log.i("getJSONArrayFromUrl", "Cookie [1]: " + this.cookie);
HttpGet httpget = new HttpGet(url);

if (this.cookie != null) {
httpget.setHeader("Cookie", this.cookie);
// Log.i("getJSONArrayFromUrl", "Cookie: [2]" + this.cookie);
}

httpResponse = httpclient.execute(targetHost, httpget);
Expand Down Expand Up @@ -429,6 +434,24 @@ public void postCommand(String command, String hash) throws JSONParserStatusCode
url = subfolder + "/" + url;
}

HttpParams httpParameters = new BasicHttpParams();

// Set the timeout in milliseconds until a connection is established.
// The default value is zero, that means the timeout is not used.
int timeoutConnection = connection_timeout * 1000;

// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = data_timeout * 1000;

// Set http parameters
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpProtocolParams.setUserAgent(httpParameters,"qBittorrent for Android");
HttpProtocolParams.setVersion(httpParameters,HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParameters,HTTP.UTF_8);


// Making HTTP request
HttpHost targetHost = new HttpHost(this.hostname, this.port, this.protocol);

Expand All @@ -443,6 +466,8 @@ public void postCommand(String command, String hash) throws JSONParserStatusCode

httpclient.getCredentialsProvider().setCredentials(authScope, credentials);

url = protocol + "://" + hostname + ":" + port +"/" +url;

HttpPost httpget = new HttpPost(url);

if ("addTorrent".equals(command)) {
Expand Down Expand Up @@ -552,8 +577,8 @@ public DefaultHttpClient getNewHttpClient() {

HttpParams params = new BasicHttpParams();

HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
// HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
// HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
Expand Down Expand Up @@ -596,6 +621,10 @@ public String getNewCookie() throws JSONParserStatusCodeException {
// Set http parameters
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpProtocolParams.setUserAgent(httpParameters,"qBittorrent for Android");
HttpProtocolParams.setVersion(httpParameters,HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParameters,HTTP.UTF_8);


// Making HTTP request
HttpHost targetHost = new HttpHost(hostname, port, protocol);
Expand All @@ -611,6 +640,8 @@ public String getNewCookie() throws JSONParserStatusCodeException {
//
// httpclient.getCredentialsProvider().setCredentials(authScope, credentials);

url = protocol + "://" + hostname + ":" + port +"/" +url;

HttpPost httpget = new HttpPost(url);

// // In order to pass the username and password we must set the pair name value
Expand Down Expand Up @@ -710,6 +741,10 @@ public String getApiVersion() throws JSONParserStatusCodeException {
// Set http parameters
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpProtocolParams.setUserAgent(httpParameters,"qBittorrent for Android");
HttpProtocolParams.setVersion(httpParameters,HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(httpParameters,HTTP.UTF_8);


// Making HTTP request
HttpHost targetHost = new HttpHost(hostname, port, protocol);
Expand All @@ -719,6 +754,8 @@ public String getApiVersion() throws JSONParserStatusCodeException {

try {

url = protocol + "://" + hostname + ":" + port +"/" +url;

HttpGet httpget = new HttpGet(url);

HttpResponse response = httpclient.execute(targetHost, httpget);
Expand Down
Loading

0 comments on commit 895f157

Please sign in to comment.