From 14d93b1e2c83732a0b67c9501bed87473e7f9288 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Thu, 18 Oct 2012 15:50:21 +0200 Subject: [PATCH] Tried to add support for labels with Deluge (issue 417), but it doesn't seem to work. --- .../transdroid/daemon/Deluge/DelugeAdapter.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java b/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java index 430a67f0..ee0ea171 100644 --- a/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java +++ b/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java @@ -64,6 +64,7 @@ import org.transdroid.daemon.task.RetrieveTask; import org.transdroid.daemon.task.RetrieveTaskSuccessResult; import org.transdroid.daemon.task.SetDownloadLocationTask; import org.transdroid.daemon.task.SetFilePriorityTask; +import org.transdroid.daemon.task.SetLabelTask; import org.transdroid.daemon.task.SetTrackersTask; import org.transdroid.daemon.task.SetTransferRatesTask; import org.transdroid.daemon.util.DLog; @@ -115,7 +116,6 @@ public class DelugeAdapter implements IDaemonAdapter { private static final String RPC_NAME = "name"; private static final String RPC_STATUS = "state"; private static final String RPC_MESSAGE = "message"; - private static final String RPC_TRACKERSTATUS = "tracker_status"; private static final String RPC_SAVEPATH = "save_path"; private static final String RPC_MAXDOWNLOAD = "max_download_speed"; private static final String RPC_MAXUPLOAD = "max_upload_speed"; @@ -136,6 +136,7 @@ public class DelugeAdapter implements IDaemonAdapter { private static final String RPC_LABEL = "label"; private static final String RPC_TRACKERS = "trackers"; private static final String RPC_TRACKER_STATUS = "tracker_status"; + private static final String NO_LABEL = "No Label"; private static final String RPC_DETAILS = "files"; private static final String RPC_INDEX = "index"; @@ -150,6 +151,7 @@ public class DelugeAdapter implements IDaemonAdapter { RPC_PEERSKNOWN, RPC_ETA, RPC_DOWNLOADEDEVER, RPC_UPLOADEDEVER, RPC_TOTALSIZE, RPC_PARTDONE, RPC_LABEL, RPC_MESSAGE, RPC_TIMEADDED, RPC_TRACKER_STATUS }; + private DaemonSettings settings; private DefaultHttpClient httpclient; private Cookie sessionCookie; @@ -368,6 +370,17 @@ public class DelugeAdapter implements IDaemonAdapter { makeRequest(buildRequest(RPC_METHOD_SETCONFIG, (new JSONArray()).put(map))); return new DaemonTaskSuccessResult(task); + case SetLabel: + + // TODO: This doesn't seem to work; totally undocumented and also broken in the web UI so won't fix for now + // Request to set the label + SetLabelTask labelTask = (SetLabelTask) task; + JSONObject labelMap = new JSONObject(); + labelMap.put(RPC_LABEL, (labelTask.getNewLabel() == null? NO_LABEL: labelTask.getNewLabel())); + + makeRequest(buildRequest(RPC_METHOD_SETCONFIG, (new JSONArray()).put(labelMap))); + return new DaemonTaskSuccessResult(task); + case SetTrackers: // Set the trackers of some torrent