Skip to content

Commit

Permalink
Fixed alert types with new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 26, 2015
1 parent f71569d commit 03ec063
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
10 changes: 10 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/AbstractAlert.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ public String getWhat() {
return alert.what();
}

@Override
public String getMessage() {
return alert.message();
}

@Override
public int getCategory() {
return alert.category();
}

@Override
public boolean isDiscardable() {
return alert.discardable();
}

@Override
public String toString() {
return getType() + " - " + getWhat() + " - " + alert.message();
Expand Down
4 changes: 4 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ public interface Alert<T extends alert> {

public String getWhat();

public String getMessage();

public int getCategory();

public boolean isDiscardable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public BlockDownloadingAlert(block_downloading_alert alert) {
super(alert);
}

public String getPeerSpeedmsg() {
return alert.getPeer_speedmsg();
}

public int getBlockIndex() {
return alert.getBlock_index();
}
Expand Down
21 changes: 11 additions & 10 deletions src/com/frostwire/jlibtorrent/alerts/ListenFailedAlert.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.ErrorCode;
import com.frostwire.jlibtorrent.TcpEndpoint;
import com.frostwire.jlibtorrent.swig.listen_failed_alert;

/**
* This alert is generated when none of the ports, given in the port range, to
* session can be opened for listening. The ``endpoint`` member is the
* interface and port that failed, ``error`` is the error code describing
* session can be opened for listening. The {@link #getInterface()} member is the
* interface and port that failed, {@link #getError()} is the error code describing
* the failure.
* <p/>
* libtorrent may sometimes try to listen on port 0, if all other ports failed.
* Port 0 asks the operating system to pick a port that's free). If that fails
* you may see a listen_failed_alert with port 0 even if you didn't ask to
* you may see a {@link com.frostwire.jlibtorrent.alerts.ListenFailedAlert} with port 0 even if you didn't ask to
* listen on it.
*
* @author gubatron
Expand All @@ -25,16 +24,16 @@ public ListenFailedAlert(listen_failed_alert alert) {
}

/**
* the endpoint libtorrent attempted to listen on.
* The interface libtorrent attempted to listen on.
*
* @return
*/
public TcpEndpoint getEndpoint() {
return new TcpEndpoint(alert.getEndpoint());
public String getInterface() {
return alert.get_interface();
}

/**
* the error the system returned.
* The error the system returned.
*
* @return
*/
Expand All @@ -43,18 +42,20 @@ public ErrorCode getError() {
}

/**
* the specific low level operation that failed. See op_t.
* The specific low level operation that failed.
*
* @return
* @see com.frostwire.jlibtorrent.alerts.ListenFailedAlert.Operation
*/
public Operation getOperation() {
return Operation.fromSwig(alert.getOperation());
}

/**
* the type of listen socket this alert refers to.
* The type of listen socket this alert refers to.
*
* @return
* @see com.frostwire.jlibtorrent.alerts.ListenFailedAlert.SocketType
*/
public SocketType getSocketType() {
return SocketType.fromSwig(alert.getSock_type().swigValue());
Expand Down
16 changes: 10 additions & 6 deletions src/com/frostwire/jlibtorrent/alerts/StatsAlert.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.frostwire.jlibtorrent.swig.stats_alert;

/**
* This alert is posted approximately once every second, and it contains
* byte counters of most statistics that's tracked for torrents. Each active
* torrent posts these alerts regularly.
*
* @author gubatron
* @author aldenml
*/
Expand All @@ -14,7 +18,7 @@ public StatsAlert(stats_alert alert) {
}

/**
* an array of samples. The enum describes what each sample is a
* An array of samples. The enum describes what each sample is a
* measurement of. All of these are raw, and not smoothing is performed.
*
* @return
Expand All @@ -24,7 +28,7 @@ public int[] getTransferred() {
}

/**
* the number of milliseconds during which these stats were collected.
* The number of milliseconds during which these stats were collected.
* This is typically just above 1000, but if CPU is limited, it may be
* higher than that.
*
Expand All @@ -40,11 +44,11 @@ public enum StatsChannel {
DOWNLOAD_PAYLOAD(stats_alert.stats_channel.download_payload.swigValue()),
DOWNLOAD_PROTOCOL(stats_alert.stats_channel.download_protocol.swigValue()),
UPLOAD_IP_PROTOCOL(stats_alert.stats_channel.upload_ip_protocol.swigValue()),
UPLOAD_DHT_PROTOCOL(stats_alert.stats_channel.upload_dht_protocol.swigValue()),
UPLOAD_TRACKER_PROTOCOL(stats_alert.stats_channel.upload_tracker_protocol.swigValue()),
DEPRECATED1(stats_alert.stats_channel.deprecated1.swigValue()),
DEPRECATED2(stats_alert.stats_channel.deprecated2.swigValue()),
DOWNLOAD_IP_PROTOCOL(stats_alert.stats_channel.download_ip_protocol.swigValue()),
DOWNLOAD_DHT_PROTOCOL(stats_alert.stats_channel.download_dht_protocol.swigValue()),
DOWNLOAD_TRACKER_PROTOCOL(stats_alert.stats_channel.download_tracker_protocol.swigValue()),
DEPRECATED3(stats_alert.stats_channel.deprecated3.swigValue()),
DEPRECATED4(stats_alert.stats_channel.deprecated4.swigValue()),
NUM_CHANNELS(stats_alert.stats_channel.num_channels.swigValue());

private StatsChannel(int swigValue) {
Expand Down

0 comments on commit 03ec063

Please sign in to comment.