Browse Source

Added tracker list and error messages to qBittorrent (issue 345).

(ALso removed BTJunkie enum value.)
pull/11/head
Eric Kok 13 years ago
parent
commit
e68e84960b
  1. 5
      android/src/org/transdroid/preferences/Preferences.java
  2. 2
      lib/src/org/transdroid/daemon/Daemon.java
  3. 33
      lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

5
android/src/org/transdroid/preferences/Preferences.java

@ -543,7 +543,6 @@ public class Preferences { @@ -543,7 +543,6 @@ public class Preferences {
*/
public static List<SiteSettings> getSupportedSiteSettings() {
List<SiteSettings> settings = new ArrayList<SiteSettings>();
settings.add(new SiteSettings("site_btjunkie", "BTJunkie"));
settings.add(new SiteSettings("site_extratorrent", "ExtraTorrent"));
settings.add(new SiteSettings("site_ezrss", "EzRss"));
settings.add(new SiteSettings("site_isohunt", "isoHunt"));
@ -564,9 +563,7 @@ public class Preferences { @@ -564,9 +563,7 @@ public class Preferences {
* @return The Transdroid Torrent Search site key, f.e. 'Mininova'
*/
public static String getCursorKeyForPreferencesKey(String preferencesKey) {
if (preferencesKey.equals("site_btjunkie")) {
return "Btjunkie";
} else if (preferencesKey.equals("site_extratorrent")) {
if (preferencesKey.equals("site_extratorrent")) {
return "ExtraTorrent";
} else if (preferencesKey.equals("site_ezrss")) {
return "EzRss";

2
lib/src/org/transdroid/daemon/Daemon.java

@ -192,7 +192,7 @@ public enum Daemon { @@ -192,7 +192,7 @@ public enum Daemon {
}
public static boolean supportsFineDetails(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Daemon.Transmission || type == Deluge || type == rTorrent;
return type == uTorrent || type == BitTorrent || type == Daemon.Transmission || type == Deluge || type == rTorrent || type == qBittorrent;
}
public static boolean needsManualPathSpecified(Daemon type) {

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

@ -42,6 +42,7 @@ import org.transdroid.daemon.DaemonSettings; @@ -42,6 +42,7 @@ import org.transdroid.daemon.DaemonSettings;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentDetails;
import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.TorrentStatus;
import org.transdroid.daemon.DaemonException.ExceptionType;
@ -54,6 +55,8 @@ import org.transdroid.daemon.task.DaemonTaskResult; @@ -54,6 +55,8 @@ import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetTorrentDetailsTask;
import org.transdroid.daemon.task.GetTorrentDetailsTaskSuccessResult;
import org.transdroid.daemon.task.RemoveTask;
import org.transdroid.daemon.task.RetrieveTask;
import org.transdroid.daemon.task.RetrieveTaskSuccessResult;
@ -92,7 +95,14 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -92,7 +95,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Request all torrents from server
JSONArray result = new JSONArray(makeRequest("/json/events"));
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseJsonTorrents(result));
case GetTorrentDetails:
// Request tracker and error details for a specific teacher
String mhash = ((GetTorrentDetailsTask)task).getTargetTorrent().getUniqueID();
JSONArray messages = new JSONArray(makeRequest("/json/propertiesTrackers/" + mhash));
return new GetTorrentDetailsTaskSuccessResult((GetTorrentDetailsTask) task, parseJsonTorrentDetails(messages));
case GetFileList:
// Request files listing for a specific torrent
@ -296,6 +306,27 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -296,6 +306,27 @@ public class QbittorrentAdapter implements IDaemonAdapter {
private String buildWebUIUrl(String path) {
return (settings.getSsl() ? "https://" : "http://") + settings.getAddress() + ":" + settings.getPort() + path;
}
private TorrentDetails parseJsonTorrentDetails(JSONArray messages) throws JSONException {
ArrayList<String> trackers = new ArrayList<String>();
ArrayList<String> errors = new ArrayList<String>();
// Parse response
if (messages.length() > 0) {
for (int i = 0; i < messages.length(); i++) {
JSONObject tor = messages.getJSONObject(i);
trackers.add(tor.getString("url"));
String msg = tor.getString("msg");
if (msg != null && !msg.equals(""))
errors.add(msg);
}
}
// Return the list
return new TorrentDetails(trackers, errors);
}
private ArrayList<Torrent> parseJsonTorrents(JSONArray response) throws JSONException {

Loading…
Cancel
Save