Browse Source

Support qBittorrent versions 3.0.0 and up (issue 412).

pull/11/head
Eric Kok 12 years ago
parent
commit
c1627c1566
  1. 1
      android/res/values/changelog.xml
  2. 4
      lib/src/org/transdroid/daemon/DaemonSettings.java
  3. 4
      lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
  4. 33
      lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java
  5. 2
      lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java

1
android/res/values/changelog.xml

@ -6,6 +6,7 @@ Transdroid 1.1.6\n @@ -6,6 +6,7 @@ Transdroid 1.1.6\n
- Improved label support, by Alexey Rogovoy\n
- Added GZipped content support in RSS feeds\n
- Allow Deluge users to enter a password for HTTP authentication\n
- Support qBittorrent version 3.0.0 and up\n
\n
Transdroid 1.1.5\n
- AndFTP alias:// support and file-in-root fix\n

4
lib/src/org/transdroid/daemon/DaemonSettings.java

@ -171,11 +171,11 @@ public final class DaemonSettings { @@ -171,11 +171,11 @@ public final class DaemonSettings {
public String getHumanReadableIdentifier() {
if (isAutoGenerated) {
// Hide the 'implementation details'; just give the username and server
return (this.shouldUseAuthentication() && this.getUsername() != null && !this.getUsername().isEmpty() ? this
return (this.shouldUseAuthentication() && this.getUsername() != null && this.getUsername() != "" ? this
.getUsername() + "@" : "") + getAddress();
}
return (this.ssl ? "https://" : "http://")
+ (this.shouldUseAuthentication() && this.getUsername() != null && !this.getUsername().isEmpty() ? this
+ (this.shouldUseAuthentication() && this.getUsername() != null && this.getUsername() != "" ? this
.getUsername() + "@" : "") + getAddress() + ":" + getPort()
+ (Daemon.supportsCustomFolder(getType()) && getFolder() != null ? getFolder() : "");
}

4
lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java

@ -431,7 +431,7 @@ public class DelugeAdapter implements IDaemonAdapter { @@ -431,7 +431,7 @@ public class DelugeAdapter implements IDaemonAdapter {
// Build login object
String extraPass = settings.getExtraPassword();
if (extraPass == null || extraPass.isEmpty()) {
if (extraPass == null || extraPass == "") {
extraPass = settings.getPassword();
}
JSONObject loginRequest = new JSONObject();
@ -524,7 +524,7 @@ public class DelugeAdapter implements IDaemonAdapter { @@ -524,7 +524,7 @@ public class DelugeAdapter implements IDaemonAdapter {
*/
private void initialise() throws DaemonException {
httpclient = HttpHelper.createStandardHttpClient(settings, settings.getUsername() != null && !settings.getUsername().isEmpty());
httpclient = HttpHelper.createStandardHttpClient(settings, settings.getUsername() != null && settings.getUsername() != "");
httpclient.addRequestInterceptor(HttpHelper.gzipRequestInterceptor);
httpclient.addResponseInterceptor(HttpHelper.gzipResponseInterceptor);

33
lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -80,20 +80,51 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -80,20 +80,51 @@ public class QbittorrentAdapter implements IDaemonAdapter {
private DaemonSettings settings;
private DefaultHttpClient httpclient;
private int version = -1;
public QbittorrentAdapter(DaemonSettings settings) {
this.settings = settings;
}
private void ensureVersion() throws DaemonException {
if (version > 0)
return;
// We still need to retrieve the version number from the server
// Do this by getting the web interface about page and trying to parse the version number
// Format is something like 'qBittorrent v2.9.7 (Web UI)'
String about = makeRequest("/about.html");
String aboutStartText = "qBittorrent v";
String aboutEndText = " (Web UI)";
int aboutStart = about.indexOf(aboutStartText);
int aboutEnd = about.indexOf(aboutEndText);
if (aboutStart >= 0 && aboutEnd > aboutStart) {
// String found: now parse a version like 2.9.7 as a number like 20907 (allowing 10 places for each .)
String[] parts = about.substring(aboutStart + aboutStartText.length(), aboutEnd).split("\\.");
if (parts.length > 0) {
version = Integer.parseInt(parts[0]) * 100 * 100;
if (parts.length > 1) {
version += Integer.parseInt(parts[1]) * 100;
if (parts.length > 2) {
version += Integer.parseInt(parts[2]);
return;
}
}
}
}
// Unable to establish version number; assume an old version by setting it to version 1
version = 10000;
}
@Override
public DaemonTaskResult executeTask(DaemonTask task) {
try {
ensureVersion();
switch (task.getMethod()) {
case Retrieve:
// Request all torrents from server
JSONArray result = new JSONArray(makeRequest("/json/events"));
JSONArray result = new JSONArray(makeRequest(version > 30000? "/json/torrents": "/json/events"));
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseJsonTorrents(result),null);
case GetTorrentDetails:

2
lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java

@ -475,7 +475,7 @@ public class TransmissionAdapter implements IDaemonAdapter { @@ -475,7 +475,7 @@ public class TransmissionAdapter implements IDaemonAdapter {
boolean hasError = tor.getInt(RPC_ERROR) == 3;
String errorString = tor.getString(RPC_ERRORSTRING);
String commentString = tor.getString(RPC_COMMENT);
errorString = errorString.isEmpty()? commentString : errorString + "\n" + commentString;
errorString = errorString == ""? commentString : errorString + "\n" + commentString;
torrents.add(new Torrent(
tor.getInt(RPC_ID),
null,

Loading…
Cancel
Save