Skip to content

Commit

Permalink
Added LogAlert type.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 27, 2015
1 parent 8c98ab8 commit 89cbf7e
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 36 deletions.
Binary file modified libjlibtorrent.dylib
Binary file not shown.
3 changes: 2 additions & 1 deletion src/com/frostwire/jlibtorrent/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ private static Map<Integer, CastAlertFunction> buildCastAlertTable() {
CAST_ALERT_METHOD(peer_blocked_alert.class, map);
CAST_ALERT_METHOD(dht_announce_alert.class, map);
CAST_ALERT_METHOD(dht_get_peers_alert.class, map);
CAST_ALERT_METHOD(dht_outgoing_get_peers_alert.class, map);
CAST_ALERT_METHOD(stats_alert.class, map);
CAST_ALERT_METHOD(cache_flushed_alert.class, map);
CAST_ALERT_METHOD(anonymous_mode_alert.class, map);
Expand All @@ -1026,6 +1025,8 @@ private static Map<Integer, CastAlertFunction> buildCastAlertTable() {
CAST_ALERT_METHOD(dht_mutable_item_alert.class, map);
CAST_ALERT_METHOD(dht_put_alert.class, map);
CAST_ALERT_METHOD(i2p_alert.class, map);
CAST_ALERT_METHOD(dht_outgoing_get_peers_alert.class, map);
CAST_ALERT_METHOD(log_alert.class, map);
CAST_ALERT_METHOD(dht_stats_alert.class, map);

CAST_ALERT_METHOD(dht_get_peers_reply_alert.class, map);
Expand Down
3 changes: 0 additions & 3 deletions src/com/frostwire/jlibtorrent/TorrentAlertAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ public void trackerid(TrackeridAlert alert) {
public void unwantedBlock(UnwantedBlockAlert alert) {
}

public void dhtStats(DhtStatsAlert alert) {
}

public void torrentPrioritize(TorrentPrioritizeAlert alert) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/com/frostwire/jlibtorrent/alerts/AlertType.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public enum AlertType {
DHT_REPLY(dht_reply_alert.alert_type),
DHT_BOOTSTRAP(dht_bootstrap_alert.alert_type),
DHT_GET_PEERS(dht_get_peers_alert.alert_type),
DHT_OUTGOING_GET_PEERS(dht_outgoing_get_peers_alert.alert_type),
EXTERNAL_IP(external_ip_alert.alert_type),
LISTEN_SUCCEEDED(listen_succeeded_alert.alert_type),
STATE_UPDATE(state_update_alert.alert_type),
Expand Down Expand Up @@ -72,7 +71,6 @@ public enum AlertType {
BLOCK_TIMEOUT(block_timeout_alert.alert_type),
CACHE_FLUSHED(cache_flushed_alert.alert_type),
DHT_ANNOUNCE(dht_announce_alert.alert_type),
I2P(i2p_alert.alert_type),
RSS(rss_alert.alert_type),
RSS_ITEM(rss_item_alert.alert_type),
STORAGE_MOVED_FAILED(storage_moved_failed_alert.alert_type),
Expand All @@ -82,6 +80,9 @@ public enum AlertType {
DHT_MUTABLE_ITEM(dht_mutable_item_alert.alert_type),
DHT_IMMUTABLE_ITEM(dht_immutable_item_alert.alert_type),
DHT_STATS(dht_stats_alert.alert_type),
I2P(i2p_alert.alert_type),
DHT_OUTGOING_GET_PEERS(dht_outgoing_get_peers_alert.alert_type),
LOG(log_alert.alert_type),
DHT_GET_PEERS_REPLY_ALERT(dht_get_peers_reply_alert.alert_type),
UNKNOWN(-1),
TORRENT_PRIORITIZE(-2);
Expand Down
28 changes: 28 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/DhtOutgoingGetPeersAlert.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.Sha1Hash;
import com.frostwire.jlibtorrent.UdpEndpoint;
import com.frostwire.jlibtorrent.swig.dht_outgoing_get_peers_alert;

/**
Expand All @@ -15,5 +17,31 @@ public DhtOutgoingGetPeersAlert(dht_outgoing_get_peers_alert alert) {
super(alert);
}

/**
* the info_hash of the torrent we're looking for peers for.
*
* @return
*/
public Sha1Hash getInfoHash() {
return new Sha1Hash(alert.getInfo_hash());
}

/**
* if this was an obfuscated lookup, this is the info-hash target
* actually sent to the node.
*
* @return
*/
public Sha1Hash getObfuscatedInfoHash() {
return new Sha1Hash(alert.getObfuscated_info_hash());
}

/**
* the endpoint we're sending this query to
*
* @return
*/
public UdpEndpoint getIp() {
return new UdpEndpoint(alert.getIp());
}
}
30 changes: 30 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/LogAlert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.swig.log_alert;

/**
* This alert is posted by some session wide event. Its main purpose is
* // trouble shooting and debugging. It's not enabled by the default alert
* // mask and is enabled by the ``alert::session_log_notification`` bit.
* // Furhtermore, it's by default disabled as a build configuration. To
* // enable, build libtorrent with logging support enabled (``logging=on``
* // with bjam or define ``TORRENT_LOGGING``).
*
* @author gubatron
* @author aldenml
*/
public abstract class LogAlert extends AbstractAlert<log_alert> {

public LogAlert(log_alert alert) {
super(alert);
}

/**
* The log message.
*
* @return
*/
public String getMsg() {
return alert.getMsg();
}
}
15 changes: 10 additions & 5 deletions src/com/frostwire/jlibtorrent/swig/alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,6 @@ public static dht_get_peers_alert cast_to_dht_get_peers_alert(alert alert) {
return (cPtr == 0) ? null : new dht_get_peers_alert(cPtr, false);
}

public static dht_outgoing_get_peers_alert cast_to_dht_outgoing_get_peers_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_dht_outgoing_get_peers_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new dht_outgoing_get_peers_alert(cPtr, false);
}

public static stats_alert cast_to_stats_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_stats_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new stats_alert(cPtr, false);
Expand Down Expand Up @@ -449,6 +444,16 @@ public static i2p_alert cast_to_i2p_alert(alert alert) {
return (cPtr == 0) ? null : new i2p_alert(cPtr, false);
}

public static dht_outgoing_get_peers_alert cast_to_dht_outgoing_get_peers_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_dht_outgoing_get_peers_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new dht_outgoing_get_peers_alert(cPtr, false);
}

public static log_alert cast_to_log_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_log_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new log_alert(cPtr, false);
}

public static dht_stats_alert cast_to_dht_stats_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_dht_stats_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new dht_stats_alert(cPtr, false);
Expand Down
3 changes: 2 additions & 1 deletion src/com/frostwire/jlibtorrent/swig/libtorrent_jni.java
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,6 @@ public class libtorrent_jni {
public final static native long alert_cast_to_peer_blocked_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_announce_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_get_peers_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_outgoing_get_peers_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_stats_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_cache_flushed_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_anonymous_mode_alert(long jarg1, alert jarg1_);
Expand All @@ -1561,6 +1560,8 @@ public class libtorrent_jni {
public final static native long alert_cast_to_dht_mutable_item_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_put_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_i2p_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_outgoing_get_peers_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_log_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_stats_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_dht_get_peers_reply_alert(long jarg1, alert jarg1_);
public final static native String operation_name(int jarg1);
Expand Down
3 changes: 2 additions & 1 deletion swig/libtorrent.i
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ namespace libtorrent {
CAST_ALERT_METHOD(peer_blocked_alert)
CAST_ALERT_METHOD(dht_announce_alert)
CAST_ALERT_METHOD(dht_get_peers_alert)
CAST_ALERT_METHOD(dht_outgoing_get_peers_alert)
CAST_ALERT_METHOD(stats_alert)
CAST_ALERT_METHOD(cache_flushed_alert)
CAST_ALERT_METHOD(anonymous_mode_alert)
Expand All @@ -794,6 +793,8 @@ namespace libtorrent {
CAST_ALERT_METHOD(dht_mutable_item_alert)
CAST_ALERT_METHOD(dht_put_alert)
CAST_ALERT_METHOD(i2p_alert)
CAST_ALERT_METHOD(dht_outgoing_get_peers_alert)
CAST_ALERT_METHOD(log_alert)
CAST_ALERT_METHOD(dht_stats_alert)

CAST_ALERT_METHOD(dht_get_peers_reply_alert)
Expand Down
69 changes: 46 additions & 23 deletions swig/libtorrent_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,6 @@ SWIGINTERN libtorrent::fastresume_rejected_alert *libtorrent_alert_cast_to_fastr
SWIGINTERN libtorrent::peer_blocked_alert *libtorrent_alert_cast_to_peer_blocked_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::peer_blocked_alert *>(alert); }
SWIGINTERN libtorrent::dht_announce_alert *libtorrent_alert_cast_to_dht_announce_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_announce_alert *>(alert); }
SWIGINTERN libtorrent::dht_get_peers_alert *libtorrent_alert_cast_to_dht_get_peers_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_get_peers_alert *>(alert); }
SWIGINTERN libtorrent::dht_outgoing_get_peers_alert *libtorrent_alert_cast_to_dht_outgoing_get_peers_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_outgoing_get_peers_alert *>(alert); }
SWIGINTERN libtorrent::stats_alert *libtorrent_alert_cast_to_stats_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::stats_alert *>(alert); }
SWIGINTERN libtorrent::cache_flushed_alert *libtorrent_alert_cast_to_cache_flushed_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::cache_flushed_alert *>(alert); }
SWIGINTERN libtorrent::anonymous_mode_alert *libtorrent_alert_cast_to_anonymous_mode_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::anonymous_mode_alert *>(alert); }
Expand All @@ -1258,6 +1257,8 @@ SWIGINTERN libtorrent::dht_immutable_item_alert *libtorrent_alert_cast_to_dht_im
SWIGINTERN libtorrent::dht_mutable_item_alert *libtorrent_alert_cast_to_dht_mutable_item_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_mutable_item_alert *>(alert); }
SWIGINTERN libtorrent::dht_put_alert *libtorrent_alert_cast_to_dht_put_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_put_alert *>(alert); }
SWIGINTERN libtorrent::i2p_alert *libtorrent_alert_cast_to_i2p_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::i2p_alert *>(alert); }
SWIGINTERN libtorrent::dht_outgoing_get_peers_alert *libtorrent_alert_cast_to_dht_outgoing_get_peers_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_outgoing_get_peers_alert *>(alert); }
SWIGINTERN libtorrent::log_alert *libtorrent_alert_cast_to_log_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::log_alert *>(alert); }
SWIGINTERN libtorrent::dht_stats_alert *libtorrent_alert_cast_to_dht_stats_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_stats_alert *>(alert); }
SWIGINTERN libtorrent::dht_get_peers_reply_alert *libtorrent_alert_cast_to_dht_get_peers_reply_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::dht_get_peers_reply_alert *>(alert); }
SWIGINTERN std::vector< int > libtorrent_stats_alert_transferred_v(libtorrent::stats_alert *self){
Expand Down Expand Up @@ -32972,28 +32973,6 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_ale
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_alert_1cast_1to_1dht_1outgoing_1get_1peers_1alert(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::alert *arg1 = (libtorrent::alert *) 0 ;
libtorrent::dht_outgoing_get_peers_alert *result = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(libtorrent::alert **)&jarg1;
{
try {
result = (libtorrent::dht_outgoing_get_peers_alert *)libtorrent_alert_cast_to_dht_outgoing_get_peers_alert(arg1);
} catch (...) {
translate_cpp_exception(jenv);
return 0;
}
}
*(libtorrent::dht_outgoing_get_peers_alert **)&jresult = result;
return jresult;
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_alert_1cast_1to_1stats_1alert(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::alert *arg1 = (libtorrent::alert *) 0 ;
Expand Down Expand Up @@ -33434,6 +33413,50 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_ale
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_alert_1cast_1to_1dht_1outgoing_1get_1peers_1alert(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::alert *arg1 = (libtorrent::alert *) 0 ;
libtorrent::dht_outgoing_get_peers_alert *result = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(libtorrent::alert **)&jarg1;
{
try {
result = (libtorrent::dht_outgoing_get_peers_alert *)libtorrent_alert_cast_to_dht_outgoing_get_peers_alert(arg1);
} catch (...) {
translate_cpp_exception(jenv);
return 0;
}
}
*(libtorrent::dht_outgoing_get_peers_alert **)&jresult = result;
return jresult;
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_alert_1cast_1to_1log_1alert(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::alert *arg1 = (libtorrent::alert *) 0 ;
libtorrent::log_alert *result = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(libtorrent::alert **)&jarg1;
{
try {
result = (libtorrent::log_alert *)libtorrent_alert_cast_to_log_alert(arg1);
} catch (...) {
translate_cpp_exception(jenv);
return 0;
}
}
*(libtorrent::log_alert **)&jresult = result;
return jresult;
}


SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_alert_1cast_1to_1dht_1stats_1alert(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
libtorrent::alert *arg1 = (libtorrent::alert *) 0 ;
Expand Down

0 comments on commit 89cbf7e

Please sign in to comment.