Skip to content

Commit

Permalink
Update to master head
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Apr 27, 2016
1 parent f36f8a0 commit 619ca1c
Show file tree
Hide file tree
Showing 30 changed files with 5,260 additions and 1,595 deletions.
51 changes: 2 additions & 49 deletions src/main/java/com/frostwire/jlibtorrent/AddTorrentParams.java
Expand Up @@ -267,8 +267,6 @@ public void trackerId(String value) {
* not be the true info-hash of the .torrent. Instead a placeholder,
* unique, info-hash is used which is later updated once the .torrent
* file has been downloaded.
* <p/>
* Once the info-hash change happens, a {@link com.frostwire.jlibtorrent.alerts.TorrentUpdateAlert} is posted.
*
* @return
*/
Expand All @@ -288,59 +286,13 @@ public String url() {
* not be the true info-hash of the .torrent. Instead a placeholder,
* unique, info-hash is used which is later updated once the .torrent
* file has been downloaded.
* <p/>
* Once the info-hash change happens, a {@link com.frostwire.jlibtorrent.alerts.TorrentUpdateAlert} is posted.
*
* @param value
*/
public void url(String value) {
p.setUrl(value);
}

/**
* If ``uuid`` is specified, it is used to find duplicates. If another
* torrent is already running with the same UUID as the one being added,
* it will be considered a duplicate. This is mainly useful for RSS feed
* items which has UUIDs specified.
*
* @return
*/
public String uuid() {
return p.getUuid();
}

/**
* If ``uuid`` is specified, it is used to find duplicates. If another
* torrent is already running with the same UUID as the one being added,
* it will be considered a duplicate. This is mainly useful for RSS feed
* items which has UUIDs specified.
*
* @param value
*/
public void uuid(String value) {
p.setUuid(value);
}

/**
* Should point to the URL of the RSS feed this torrent comes from, if it
* comes from an RSS feed.
*
* @return
*/
public String sourceFeedUrl() {
return p.getSource_feed_url();
}

/**
* Should point to the URL of the RSS feed this torrent comes from, if it
* comes from an RSS feed.
*
* @param value
*/
public void sourceFeedUrl(String value) {
p.setSource_feed_url(value);
}

/**
* Set this to the info hash of the torrent to add in case the info-hash
* is the only known property of the torrent. i.e. you don't have a
Expand Down Expand Up @@ -435,7 +387,8 @@ public void torrentInfo(TorrentInfo ti) {
* @param data
*/
public void resumeData(byte[] data) {
p.set_resume_data(Vectors.bytes2byte_vector(data));
throw new UnsupportedOperationException();
//p.set_resume_data(Vectors.bytes2byte_vector(data));
}

/**
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/frostwire/jlibtorrent/DhtSettings.java
Expand Up @@ -427,4 +427,26 @@ public int itemLifetime() {
public void itemLifetime(int value) {
s.setItem_lifetime(value);
}

/**
* The number of bytes per second (on average) the DHT is allowed to send.
* If the incoming requests causes to many bytes to be sent in responses,
* incoming requests will be dropped until the quota has been replenished.
*
* @return
*/
public int uploadRateLimit() {
return s.getUpload_rate_limit();
}

/**
* The number of bytes per second (on average) the DHT is allowed to send.
* If the incoming requests causes to many bytes to be sent in responses,
* incoming requests will be dropped until the quota has been replenished.
*
* @param value
*/
public void uploadRateLimit(int value) {
s.setUpload_rate_limit(value);
}
}
19 changes: 10 additions & 9 deletions src/main/java/com/frostwire/jlibtorrent/Session.java
Expand Up @@ -763,16 +763,17 @@ private TorrentHandle addTorrentSupport(TorrentInfo ti, File saveDir, Priority[]

flags &= ~add_torrent_params.flags_t.flag_auto_managed.swigValue();

if (resumeFile != null) {
try {
byte[] data = Files.bytes(resumeFile);
p.set_resume_data(Vectors.bytes2byte_vector(data));

flags |= add_torrent_params.flags_t.flag_use_resume_save_path.swigValue();
} catch (Throwable e) {
LOG.warn("Unable to set resume data", e);
}
if (true) {
throw new UnsupportedOperationException();
}
// if (resumeFile != null) {
// try {
// byte[] data = Files.bytes(resumeFile);
// p.set_resume_data(Vectors.bytes2byte_vector(data));
// } catch (Throwable e) {
// LOG.warn("Unable to set resume data", e);
// }
// }

p.set_flags(flags);

Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/frostwire/jlibtorrent/TorrentAlertAdapter.java
Expand Up @@ -24,7 +24,7 @@ public int[] types() {

@Override
public final void alert(Alert<?> a) {
if (!(a instanceof TorrentAlert<?>)) {
if (!(a instanceof TorrentAlert)) {
return;
}

Expand Down Expand Up @@ -56,9 +56,6 @@ public void torrentFinished(TorrentFinishedAlert alert) {
public void torrentRemoved(TorrentRemovedAlert alert) {
}

public void torrentUpdate(TorrentUpdateAlert alert) {
}

public void torrentDeleted(TorrentDeletedAlert alert) {
}

Expand Down Expand Up @@ -578,12 +575,7 @@ public void invoke(TorrentAlertAdapter l, Alert a) {
arr[68] = null;
arr[69] = null;
arr[70] = null;
arr[71] = new InvokeLambda() {
@Override
public void invoke(TorrentAlertAdapter l, Alert a) {
l.torrentUpdate((TorrentUpdateAlert) a);
}
};
arr[71] = null;
arr[72] = null;
arr[73] = null;
arr[74] = null;
Expand Down
Expand Up @@ -14,7 +14,6 @@ public enum AlertType {
TORRENT_ADDED(torrent_added_alert.alert_type),
TORRENT_FINISHED(torrent_finished_alert.alert_type),
TORRENT_REMOVED(torrent_removed_alert.alert_type),
TORRENT_UPDATE(torrent_update_alert.alert_type),
TORRENT_DELETED(torrent_deleted_alert.alert_type),
TORRENT_PAUSED(torrent_paused_alert.alert_type),
TORRENT_RESUMED(torrent_resumed_alert.alert_type),
Expand Down Expand Up @@ -188,7 +187,7 @@ private static AlertType[] buildTable() {
arr[68] = STATE_UPDATE;
arr[69] = MMAP_CACHE;
arr[70] = SESSION_STATS;
arr[71] = TORRENT_UPDATE;
arr[71] = UNKNOWN;
arr[72] = UNKNOWN;
arr[73] = DHT_ERROR;
arr[74] = DHT_IMMUTABLE_ITEM;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/frostwire/jlibtorrent/alerts/Alerts.java
Expand Up @@ -405,7 +405,7 @@ public Alert cast(alert a) {
arr[63] = new CastLambda() {
@Override
public Alert cast(alert a) {
return new GenericAlert(a);
return handleInvalidAlert(a);
}
};
arr[64] = new CastLambda() {
Expand Down Expand Up @@ -453,13 +453,13 @@ public Alert cast(alert a) {
arr[71] = new CastLambda() {
@Override
public Alert cast(alert a) {
return new TorrentUpdateAlert(cast_to_torrent_update_alert(a));
return handleInvalidAlert(a);
}
};
arr[72] = new CastLambda() {
@Override
public Alert cast(alert a) {
return new GenericAlert(a);
return handleInvalidAlert(a);
}
};
arr[73] = new CastLambda() {
Expand Down Expand Up @@ -568,6 +568,10 @@ public Alert cast(alert a) {
return arr;
}

private static Alert handleInvalidAlert(alert a) {
throw new IllegalArgumentException("alert not know: " + a.type() + " - " + a.message());
}

private interface CastLambda {
Alert cast(alert a);
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/frostwire/jlibtorrent/alerts/GenericAlert.java

This file was deleted.

Expand Up @@ -11,11 +11,11 @@
*/
public final class HashFailedAlert extends TorrentAlert<hash_failed_alert> {

public HashFailedAlert(hash_failed_alert alert) {
HashFailedAlert(hash_failed_alert alert) {
super(alert);
}

public int getPieceIndex() {
public int pieceIndex() {
return alert.getPiece_index();
}
}

0 comments on commit 619ca1c

Please sign in to comment.