|
|
@ -95,32 +95,32 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
case Retrieve: |
|
|
|
case Retrieve: |
|
|
|
|
|
|
|
|
|
|
|
// @formatter:off
|
|
|
|
// @formatter:off
|
|
|
|
Object result = makeRtorrentCall(log,"d.multicall", |
|
|
|
Object result = makeRtorrentCall(log,"d.multicall2", |
|
|
|
new String[] { "main", |
|
|
|
new String[] { "", "main", |
|
|
|
"d.get_hash=", |
|
|
|
"d.hash=", |
|
|
|
"d.get_name=", |
|
|
|
"d.name=", |
|
|
|
"d.get_state=", |
|
|
|
"d.state=", |
|
|
|
"d.get_down_rate=", |
|
|
|
"d.down.rate=", |
|
|
|
"d.get_up_rate=", |
|
|
|
"d.up.rate=", |
|
|
|
"d.get_peers_connected=", |
|
|
|
"d.peers_connected=", |
|
|
|
"d.get_peers_not_connected=", |
|
|
|
"d.peers_not_connected=", |
|
|
|
"d.get_peers_accounted=", |
|
|
|
"d.peers_accounted=", |
|
|
|
"d.get_bytes_done=", |
|
|
|
"d.bytes_done=", |
|
|
|
"d.get_up_total=", |
|
|
|
"d.up.total=", |
|
|
|
"d.get_size_bytes=", |
|
|
|
"d.size_bytes=", |
|
|
|
"d.get_creation_date=", |
|
|
|
"d.creation_date=", |
|
|
|
"d.get_left_bytes=", |
|
|
|
"d.left_bytes=", |
|
|
|
"d.get_complete=", |
|
|
|
"d.complete=", |
|
|
|
"d.is_active=", |
|
|
|
"d.is_active=", |
|
|
|
"d.is_hash_checking=", |
|
|
|
"d.is_hash_checking=", |
|
|
|
"d.get_base_path=", |
|
|
|
"d.base_path=", |
|
|
|
"d.get_base_filename=", |
|
|
|
"d.base_filename=", |
|
|
|
"d.get_message=", |
|
|
|
"d.message=", |
|
|
|
"d.get_custom=addtime", |
|
|
|
"d.custom=addtime", |
|
|
|
"d.get_custom=seedingtime", |
|
|
|
"d.custom=seedingtime", |
|
|
|
"d.get_custom1=", |
|
|
|
"d.custom1=", |
|
|
|
"d.get_peers_complete=", |
|
|
|
"d.peers_complete=", |
|
|
|
"d.get_peers_accounted=" }); |
|
|
|
"d.peers_accounted=" }); |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, onTorrentsRetrieved(result), |
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, onTorrentsRetrieved(result), |
|
|
|
lastKnownLabels); |
|
|
|
lastKnownLabels); |
|
|
@ -131,7 +131,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
Object dresult = makeRtorrentCall(log,"t.multicall", new String[] { |
|
|
|
Object dresult = makeRtorrentCall(log,"t.multicall", new String[] { |
|
|
|
task.getTargetTorrent().getUniqueID(), |
|
|
|
task.getTargetTorrent().getUniqueID(), |
|
|
|
"", |
|
|
|
"", |
|
|
|
"t.get_url=" }); |
|
|
|
"t.url=" }); |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
return new GetTorrentDetailsTaskSuccessResult((GetTorrentDetailsTask) task, |
|
|
|
return new GetTorrentDetailsTaskSuccessResult((GetTorrentDetailsTask) task, |
|
|
|
onTorrentDetailsRetrieved(log, dresult)); |
|
|
|
onTorrentDetailsRetrieved(log, dresult)); |
|
|
@ -142,13 +142,13 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
Object fresult = makeRtorrentCall(log,"f.multicall", new String[] { |
|
|
|
Object fresult = makeRtorrentCall(log,"f.multicall", new String[] { |
|
|
|
task.getTargetTorrent().getUniqueID(), |
|
|
|
task.getTargetTorrent().getUniqueID(), |
|
|
|
"", |
|
|
|
"", |
|
|
|
"f.get_path=", |
|
|
|
"f.path=", |
|
|
|
"f.get_size_bytes=", |
|
|
|
"f.size_bytes=", |
|
|
|
"f.get_priority=", |
|
|
|
"f.priority=", |
|
|
|
"f.get_completed_chunks=", |
|
|
|
"f.completed_chunks=", |
|
|
|
"f.get_size_chunks=", |
|
|
|
"f.size_chunks=", |
|
|
|
"f.get_priority=", |
|
|
|
"f.priority=", |
|
|
|
"f.get_frozen_path=" }); |
|
|
|
"f.frozen_path=" }); |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
return new GetFileListTaskSuccessResult((GetFileListTask) task, |
|
|
|
return new GetFileListTaskSuccessResult((GetFileListTask) task, |
|
|
|
onTorrentFilesRetrieved(fresult, task.getTargetTorrent())); |
|
|
|
onTorrentFilesRetrieved(fresult, task.getTargetTorrent())); |
|
|
@ -167,22 +167,22 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
byte[] bytes = baos.toByteArray(); |
|
|
|
byte[] bytes = baos.toByteArray(); |
|
|
|
int size = (int) file.length() * 2; |
|
|
|
int size = (int) file.length() * 2; |
|
|
|
final int XMLRPC_EXTRA_PADDING = 1280; |
|
|
|
final int XMLRPC_EXTRA_PADDING = 1280; |
|
|
|
makeRtorrentCall(log, "set_xmlrpc_size_limit", new Object[]{size + XMLRPC_EXTRA_PADDING}); |
|
|
|
makeRtorrentCall(log, "network.xmlrpc.size_limit.set", new Object[]{size + XMLRPC_EXTRA_PADDING}); |
|
|
|
makeRtorrentCall(log, "load_raw_start", new Object[]{bytes}); |
|
|
|
makeRtorrentCall(log, "load.raw_start", new Object[]{bytes}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case AddByUrl: |
|
|
|
case AddByUrl: |
|
|
|
|
|
|
|
|
|
|
|
// Request to add a torrent by URL
|
|
|
|
// Request to add a torrent by URL
|
|
|
|
String url = ((AddByUrlTask) task).getUrl(); |
|
|
|
String url = ((AddByUrlTask) task).getUrl(); |
|
|
|
makeRtorrentCall(log, "load_start", new String[]{url}); |
|
|
|
makeRtorrentCall(log, "load.start", new String[]{"",url}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case AddByMagnetUrl: |
|
|
|
case AddByMagnetUrl: |
|
|
|
|
|
|
|
|
|
|
|
// Request to add a magnet link by URL
|
|
|
|
// Request to add a magnet link by URL
|
|
|
|
String magnet = ((AddByMagnetUrlTask) task).getUrl(); |
|
|
|
String magnet = ((AddByMagnetUrlTask) task).getUrl(); |
|
|
|
makeRtorrentCall(log, "load_start", new String[]{magnet}); |
|
|
|
makeRtorrentCall(log, "load.start", new String[]{"",magnet}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case Remove: |
|
|
|
case Remove: |
|
|
@ -190,7 +190,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
// Remove a torrent
|
|
|
|
// Remove a torrent
|
|
|
|
RemoveTask removeTask = (RemoveTask) task; |
|
|
|
RemoveTask removeTask = (RemoveTask) task; |
|
|
|
if (removeTask.includingData()) { |
|
|
|
if (removeTask.includingData()) { |
|
|
|
makeRtorrentCall(log, "d.set_custom5", |
|
|
|
makeRtorrentCall(log, "d.custom5.set", |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID(), "1"}); |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID(), "1"}); |
|
|
|
} |
|
|
|
} |
|
|
|
makeRtorrentCall(log, "d.erase", new String[]{task.getTargetTorrent().getUniqueID()}); |
|
|
|
makeRtorrentCall(log, "d.erase", new String[]{task.getTargetTorrent().getUniqueID()}); |
|
|
@ -205,7 +205,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
case PauseAll: |
|
|
|
case PauseAll: |
|
|
|
|
|
|
|
|
|
|
|
// Resume all torrents
|
|
|
|
// Resume all torrents
|
|
|
|
makeRtorrentCall(log, "d.multicall", new String[]{"main", "d.pause="}); |
|
|
|
makeRtorrentCall(log, "d.multicall2", new String[]{"","main", "d.pause="}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case Resume: |
|
|
|
case Resume: |
|
|
@ -217,7 +217,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
case ResumeAll: |
|
|
|
case ResumeAll: |
|
|
|
|
|
|
|
|
|
|
|
// Resume all torrents
|
|
|
|
// Resume all torrents
|
|
|
|
makeRtorrentCall(log, "d.multicall", new String[]{"main", "d.resume="}); |
|
|
|
makeRtorrentCall(log, "d.multicall2", new String[]{"", "main", "d.resume="}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case Stop: |
|
|
|
case Stop: |
|
|
@ -229,7 +229,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
case StopAll: |
|
|
|
case StopAll: |
|
|
|
|
|
|
|
|
|
|
|
// Stop all torrents
|
|
|
|
// Stop all torrents
|
|
|
|
makeRtorrentCall(log, "d.multicall", new String[]{"main", "d.stop="}); |
|
|
|
makeRtorrentCall(log, "d.multicall2", new String[]{"", "main", "d.stop="}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case Start: |
|
|
|
case Start: |
|
|
@ -241,7 +241,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
case StartAll: |
|
|
|
case StartAll: |
|
|
|
|
|
|
|
|
|
|
|
// Start all torrents
|
|
|
|
// Start all torrents
|
|
|
|
makeRtorrentCall(log, "d.multicall", new String[]{"main", "d.start="}); |
|
|
|
makeRtorrentCall(log, "d.multicall2", new String[]{"", "main", "d.start="}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case SetFilePriorities: |
|
|
|
case SetFilePriorities: |
|
|
@ -251,7 +251,7 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
String newPriority = "" + convertPriority(prioTask.getNewPriority()); |
|
|
|
String newPriority = "" + convertPriority(prioTask.getNewPriority()); |
|
|
|
// One at a time; rTorrent doesn't seem to support a multicall on a selective number of files
|
|
|
|
// One at a time; rTorrent doesn't seem to support a multicall on a selective number of files
|
|
|
|
for (TorrentFile forFile : prioTask.getForFiles()) { |
|
|
|
for (TorrentFile forFile : prioTask.getForFiles()) { |
|
|
|
makeRtorrentCall(log, "f.set_priority", |
|
|
|
makeRtorrentCall(log, "f.priority.set", |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID() + ":f" + forFile.getKey(), |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID() + ":f" + forFile.getKey(), |
|
|
|
newPriority}); |
|
|
|
newPriority}); |
|
|
|
} |
|
|
|
} |
|
|
@ -261,16 +261,16 @@ public class RtorrentAdapter implements IDaemonAdapter { |
|
|
|
|
|
|
|
|
|
|
|
// Request to set the maximum transfer rates
|
|
|
|
// Request to set the maximum transfer rates
|
|
|
|
SetTransferRatesTask ratesTask = (SetTransferRatesTask) task; |
|
|
|
SetTransferRatesTask ratesTask = (SetTransferRatesTask) task; |
|
|
|
makeRtorrentCall(log, "set_download_rate", new String[]{(ratesTask.getDownloadRate() == null ? "0" : |
|
|
|
makeRtorrentCall(log, "throttle.global_down.max_rate.set", new String[]{"",(ratesTask.getDownloadRate() == null ? "0" : |
|
|
|
ratesTask.getDownloadRate().toString() + "k")}); |
|
|
|
ratesTask.getDownloadRate().toString() + "k")}); |
|
|
|
makeRtorrentCall(log, "set_upload_rate", new String[]{ |
|
|
|
makeRtorrentCall(log, "throttle.global_up.max_rate.set", new String[]{"", |
|
|
|
(ratesTask.getUploadRate() == null ? "0" : ratesTask.getUploadRate().toString() + "k")}); |
|
|
|
(ratesTask.getUploadRate() == null ? "0" : ratesTask.getUploadRate().toString() + "k")}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|
case SetLabel: |
|
|
|
case SetLabel: |
|
|
|
|
|
|
|
|
|
|
|
SetLabelTask labelTask = (SetLabelTask) task; |
|
|
|
SetLabelTask labelTask = (SetLabelTask) task; |
|
|
|
makeRtorrentCall(log, "d.set_custom1", |
|
|
|
makeRtorrentCall(log, "d.custom1.set", |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID(), labelTask.getNewLabel()}); |
|
|
|
new String[]{task.getTargetTorrent().getUniqueID(), labelTask.getNewLabel()}); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
return new DaemonTaskSuccessResult(task); |
|
|
|
|
|
|
|
|
|
|
|