use of com.biglybt.pifimpl.remote.RPReply in project BiglyBT by BiglySoftware.
the class RPTorrentDownloader method _process.
@Override
public RPReply _process(RPRequest request) {
String method = request.getMethod();
if (method.equals("download")) {
try {
Torrent to = delegate.download();
RPTorrent res = RPTorrent.create(to);
return (new RPReply(res));
} catch (TorrentException e) {
return (new RPReply(e));
}
} else if (method.equals("download[String]")) {
try {
Torrent to = delegate.download((String) request.getParams()[0]);
RPTorrent res = RPTorrent.create(to);
return (new RPReply(res));
} catch (TorrentException e) {
return (new RPReply(e));
}
}
throw (new RPException("Unknown method: " + method));
}
use of com.biglybt.pifimpl.remote.RPReply in project BiglyBT by BiglySoftware.
the class RPTorrentManager method _process.
@Override
public RPReply _process(RPRequest request) {
String method = request.getMethod();
Object[] params = request.getParams();
if (method.equals("getURLDownloader[URL]")) {
try {
TorrentDownloader dl = delegate.getURLDownloader((URL) params[0]);
RPTorrentDownloader res = RPTorrentDownloader.create(dl);
return (new RPReply(res));
} catch (TorrentException e) {
return (new RPReply(e));
}
} else if (method.equals("getURLDownloader[URL,String,String]")) {
try {
TorrentDownloader dl = delegate.getURLDownloader((URL) params[0], (String) params[1], (String) params[2]);
RPTorrentDownloader res = RPTorrentDownloader.create(dl);
return (new RPReply(res));
} catch (TorrentException e) {
return (new RPReply(e));
}
} else if (method.equals("createFromBEncodedData[byte[]]")) {
try {
return (new RPReply(RPTorrent.create(delegate.createFromBEncodedData((byte[]) params[0]))));
} catch (TorrentException e) {
return (new RPReply(e));
}
}
throw (new RPException("Unknown method: " + method));
}
use of com.biglybt.pifimpl.remote.RPReply in project BiglyBT by BiglySoftware.
the class RPTracker method _process.
@Override
public RPReply _process(RPRequest request) {
String method = request.getMethod();
Object[] params = request.getParams();
if (method.equals("host[Torrent,boolean]")) {
try {
Torrent torrent = params[0] == null ? null : (Torrent) ((RPTorrent) params[0])._setLocal();
if (torrent == null) {
throw (new RPException("Invalid torrent"));
}
TrackerTorrent tt = delegate.host(torrent, ((Boolean) params[1]).booleanValue());
RPTrackerTorrent res = RPTrackerTorrent.create(tt);
return (new RPReply(res));
} catch (TrackerException e) {
return (new RPReply(e));
}
} else if (method.equals("getTorrents")) {
TrackerTorrent[] torrents = delegate.getTorrents();
RPTrackerTorrent[] res = new RPTrackerTorrent[torrents.length];
for (int i = 0; i < res.length; i++) {
res[i] = RPTrackerTorrent.create(torrents[i]);
}
return (new RPReply(res));
}
throw (new RPException("Unknown method: " + method));
}
use of com.biglybt.pifimpl.remote.RPReply in project BiglyBT by BiglySoftware.
the class RPDownloadManager method _process.
@Override
public RPReply _process(RPRequest request) {
String method = request.getMethod();
Object[] params = request.getParams();
if (method.equals("getDownloads")) {
Download[] downloads = delegate.getDownloads();
// unfortunately downloads with broken torrents can exist and have no associated
// Torrent. Easiest fix here is to filter them out.
RPDownload[] res = new RPDownload[downloads.length];
for (int i = 0; i < res.length; i++) {
res[i] = RPDownload.create(downloads[i]);
}
return (new RPReply(res));
} else if (method.equals("getDownloads[boolean]")) {
Download[] downloads = delegate.getDownloads(((Boolean) request.getParams()[0]).booleanValue());
RPDownload[] res = new RPDownload[downloads.length];
for (int i = 0; i < res.length; i++) {
res[i] = RPDownload.create(downloads[i]);
}
return (new RPReply(res));
} else if (method.equals("addDownload[Torrent]")) {
try {
RPTorrent torrent = (RPTorrent) request.getParams()[0];
Download res = delegate.addDownload((Torrent) torrent._setLocal());
return (new RPReply(RPDownload.create(res)));
} catch (DownloadException e) {
throw (new RPException("DownloadManager::addDownload failed", e));
}
} else if (method.equals("addDownload[Torrent,String,String]")) {
try {
RPTorrent torrent = (RPTorrent) request.getParams()[0];
File f1 = params[1] == null ? null : new File((String) params[1]);
File f2 = params[2] == null ? null : new File((String) params[2]);
Download res = delegate.addDownload((Torrent) torrent._setLocal(), f1, f2);
return (new RPReply(RPDownload.create(res)));
} catch (DownloadException e) {
throw (new RPException("DownloadManager::addDownload failed", e));
}
} else if (method.equals("addDownload[URL]")) {
try {
delegate.addDownload((URL) request.getParams()[0]);
} catch (DownloadException e) {
throw (new RPException("DownloadManager::addDownload failed", e));
}
return (new RPReply(null));
} else if (method.equals("pauseDownloads")) {
delegate.pauseDownloads();
return (null);
} else if (method.equals("resumeDownloads")) {
delegate.resumeDownloads();
return (null);
} else if (method.equals("stopAllDownloads")) {
delegate.stopAllDownloads();
return (null);
} else if (method.equals("startAllDownloads")) {
delegate.startAllDownloads();
return (null);
}
throw (new RPException("Unknown method: " + method));
}
use of com.biglybt.pifimpl.remote.RPReply in project BiglyBT by BiglySoftware.
the class RPIPFilter method _process.
@Override
public RPReply _process(RPRequest request) {
String method = request.getMethod();
Object[] params = request.getParams();
if (method.equals("createAndAddRange[String,String,String,boolean]")) {
IPRange range = delegate.createAndAddRange((String) params[0], (String) params[1], (String) params[2], ((Boolean) params[3]).booleanValue());
if (range == null) {
return (new RPReply(null));
} else {
RPIPRange rp_range = RPIPRange.create(range);
return (new RPReply(rp_range));
}
} else if (method.equals("getRanges")) {
IPRange[] ranges = delegate.getRanges();
RPIPRange[] rp_ranges = new RPIPRange[ranges.length];
for (int i = 0; i < ranges.length; i++) {
rp_ranges[i] = RPIPRange.create(ranges[i]);
}
return (new RPReply(rp_ranges));
} else if (method.equals("save")) {
try {
delegate.save();
return (null);
} catch (IPFilterException e) {
return (new RPReply(e));
}
} else if (method.equals("getInRangeAddressesAreAllowed")) {
return (new RPReply(Boolean.valueOf(delegate.getInRangeAddressesAreAllowed())));
} else if (method.equals("setInRangeAddressesAreAllowed[boolean]")) {
delegate.setInRangeAddressesAreAllowed(((Boolean) params[0]).booleanValue());
return (null);
} else if (method.equals("isEnabled")) {
return (new RPReply(Boolean.valueOf(delegate.isEnabled())));
} else if (method.equals("setEnabled[boolean]")) {
delegate.setEnabled(((Boolean) params[0]).booleanValue());
return (null);
} else if (method.equals("isInRange[String]")) {
return (new RPReply(Boolean.valueOf(delegate.isInRange((String) params[0]))));
}
throw (new RPException("Unknown method: " + method));
}
Aggregations