diff --git a/app/src/main/java/org/transdroid/daemon/Daemon.java b/app/src/main/java/org/transdroid/daemon/Daemon.java index 5b05dcb6..9c468dc7 100644 --- a/app/src/main/java/org/transdroid/daemon/Daemon.java +++ b/app/src/main/java/org/transdroid/daemon/Daemon.java @@ -344,7 +344,7 @@ public enum Daemon { } public static boolean supportsLabels(Daemon type) { - return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == Dummy; + return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == qBittorrent || type == Dummy; } public static boolean supportsSetLabel(Daemon type) { diff --git a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java index 56afbd60..e06a6942 100644 --- a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java @@ -39,6 +39,7 @@ import org.transdroid.daemon.DaemonException; import org.transdroid.daemon.DaemonException.ExceptionType; import org.transdroid.daemon.DaemonSettings; import org.transdroid.daemon.IDaemonAdapter; +import org.transdroid.daemon.Label; import org.transdroid.daemon.Priority; import org.transdroid.daemon.Torrent; import org.transdroid.daemon.TorrentDetails; @@ -61,6 +62,7 @@ import org.transdroid.daemon.task.RemoveTask; import org.transdroid.daemon.task.RetrieveTask; import org.transdroid.daemon.task.RetrieveTaskSuccessResult; import org.transdroid.daemon.task.SetFilePriorityTask; +import org.transdroid.daemon.task.SetLabelTask; import org.transdroid.daemon.task.SetTransferRatesTask; import org.transdroid.daemon.util.HttpHelper; @@ -72,7 +74,9 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * The daemon adapter for the qBittorrent torrent client. @@ -211,7 +215,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { // Request all torrents from server JSONArray result = new JSONArray(makeRequest(log, path)); - return new RetrieveTaskSuccessResult((RetrieveTask) task, parseJsonTorrents(result), null); + return new RetrieveTaskSuccessResult((RetrieveTask) task, parseJsonTorrents(result), parseJsonLabels(result)); case GetTorrentDetails: @@ -307,6 +311,15 @@ public class QbittorrentAdapter implements IDaemonAdapter { makeRequest(log, "/command/recheck", new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID())); return new DaemonTaskSuccessResult(task); + case SetLabel: + + // TODO: This doesn't seem to work yet + SetLabelTask labelTask = (SetLabelTask) task; + makeRequest(log, "/command/setCategory", + new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()), + new BasicNameValuePair("category", labelTask.getNewLabel())); + return new DaemonTaskSuccessResult(task); + case SetTransferRates: // TODO: This doesn't seem to work yet @@ -465,6 +478,24 @@ public class QbittorrentAdapter implements IDaemonAdapter { } + private List