Search in sources :

Example 1 with RPException

use of com.biglybt.pifimpl.remote.RPException in project BiglyBT by BiglySoftware.

the class RPTorrentDownloader method download.

@Override
public Torrent download(String encoding) throws TorrentException {
    try {
        RPTorrent resp = (RPTorrent) _dispatcher.dispatch(new RPRequest(this, "download[String]", new Object[] { encoding })).getResponse();
        resp._setRemote(_dispatcher);
        return (resp);
    } catch (RPException e) {
        if (e.getCause() instanceof TorrentException) {
            throw ((TorrentException) e.getCause());
        }
        throw (e);
    }
}
Also used : RPRequest(com.biglybt.pifimpl.remote.RPRequest) RPException(com.biglybt.pifimpl.remote.RPException) RPObject(com.biglybt.pifimpl.remote.RPObject) TorrentException(com.biglybt.pif.torrent.TorrentException)

Example 2 with RPException

use of com.biglybt.pifimpl.remote.RPException 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));
}
Also used : Torrent(com.biglybt.pif.torrent.Torrent) RPException(com.biglybt.pifimpl.remote.RPException) RPReply(com.biglybt.pifimpl.remote.RPReply) TorrentException(com.biglybt.pif.torrent.TorrentException)

Example 3 with RPException

use of com.biglybt.pifimpl.remote.RPException in project BiglyBT by BiglySoftware.

the class RPTorrentManager method getURLDownloader.

@Override
public TorrentDownloader getURLDownloader(URL url, String user_name, String password) throws TorrentException {
    try {
        RPTorrentDownloader resp = (RPTorrentDownloader) _dispatcher.dispatch(new RPRequest(this, "getURLDownloader[URL,String,String]", new Object[] { url, user_name, password })).getResponse();
        resp._setRemote(_dispatcher);
        return (resp);
    } catch (RPException e) {
        if (e.getCause() instanceof TorrentException) {
            throw ((TorrentException) e.getCause());
        }
        throw (e);
    }
}
Also used : RPRequest(com.biglybt.pifimpl.remote.RPRequest) RPException(com.biglybt.pifimpl.remote.RPException) RPObject(com.biglybt.pifimpl.remote.RPObject)

Example 4 with RPException

use of com.biglybt.pifimpl.remote.RPException in project BiglyBT by BiglySoftware.

the class RPTorrentManager method createFromBEncodedData.

@Override
public Torrent createFromBEncodedData(byte[] data) throws TorrentException {
    try {
        RPTorrent res = (RPTorrent) _dispatcher.dispatch(new RPRequest(this, "createFromBEncodedData[byte[]]", new Object[] { data })).getResponse();
        res._setRemote(_dispatcher);
        return (res);
    } catch (RPException e) {
        if (e.getCause() instanceof TorrentException) {
            throw ((TorrentException) e.getCause());
        }
        throw (e);
    }
}
Also used : RPRequest(com.biglybt.pifimpl.remote.RPRequest) RPException(com.biglybt.pifimpl.remote.RPException) RPObject(com.biglybt.pifimpl.remote.RPObject)

Example 5 with RPException

use of com.biglybt.pifimpl.remote.RPException 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));
}
Also used : RPException(com.biglybt.pifimpl.remote.RPException) RPReply(com.biglybt.pifimpl.remote.RPReply) RPObject(com.biglybt.pifimpl.remote.RPObject) URL(java.net.URL)

Aggregations

RPException (com.biglybt.pifimpl.remote.RPException)13 RPObject (com.biglybt.pifimpl.remote.RPObject)11 RPRequest (com.biglybt.pifimpl.remote.RPRequest)8 RPReply (com.biglybt.pifimpl.remote.RPReply)5 Torrent (com.biglybt.pif.torrent.Torrent)3 TorrentException (com.biglybt.pif.torrent.TorrentException)3 TrackerException (com.biglybt.pif.tracker.TrackerException)2 RPTorrent (com.biglybt.pifimpl.remote.torrent.RPTorrent)2 TrackerTorrent (com.biglybt.pif.tracker.TrackerTorrent)1 File (java.io.File)1 URL (java.net.URL)1