Skip to content

Commit

Permalink
Added remaining alert types.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 27, 2015
1 parent 89cbf7e commit 22386af
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 2 deletions.
Binary file modified libjlibtorrent.dylib
Binary file not shown.
4 changes: 4 additions & 0 deletions src/com/frostwire/jlibtorrent/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ private static Map<Integer, CastAlertFunction> buildCastAlertTable() {
CAST_ALERT_METHOD(incoming_connection_alert.class, map);
CAST_ALERT_METHOD(add_torrent_alert.class, map);
CAST_ALERT_METHOD(state_update_alert.class, map);
CAST_ALERT_METHOD(mmap_cache_alert.class, map);
CAST_ALERT_METHOD(session_stats_alert.class, map);
CAST_ALERT_METHOD(torrent_update_alert.class, map);
CAST_ALERT_METHOD(rss_item_alert.class, map);
Expand All @@ -1027,6 +1028,9 @@ private static Map<Integer, CastAlertFunction> buildCastAlertTable() {
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(torrent_log_alert.class, map);
CAST_ALERT_METHOD(peer_log_alert.class, map);
CAST_ALERT_METHOD(lsd_error_alert.class, map);
CAST_ALERT_METHOD(dht_stats_alert.class, map);

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

public void torrentLog(TorrentLogAlert alert) {
}

public void peerLog(PeerLogAlert alert) {
}

public void torrentPrioritize(TorrentPrioritizeAlert alert) {
}

Expand Down
6 changes: 5 additions & 1 deletion src/com/frostwire/jlibtorrent/alerts/AlertType.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public enum AlertType {
EXTERNAL_IP(external_ip_alert.alert_type),
LISTEN_SUCCEEDED(listen_succeeded_alert.alert_type),
STATE_UPDATE(state_update_alert.alert_type),
MMAP_CACHE(mmap_cache_alert.alert_type),
SESSION_STATS(session_stats_alert.alert_type),
SCRAPE_REPLY(scrape_reply_alert.alert_type),
SCRAPE_FAILED(scrape_failed_alert.alert_type),
Expand Down Expand Up @@ -79,10 +80,13 @@ public enum AlertType {
DHT_PUT(dht_put_alert.alert_type),
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),
TORRENT_LOG(torrent_log_alert.alert_type),
PEER_LOG(peer_log_alert.alert_type),
LSD_ERROR(lsd_error_alert.alert_type),
DHT_STATS(dht_stats_alert.alert_type),
DHT_GET_PEERS_REPLY_ALERT(dht_get_peers_reply_alert.alert_type),
UNKNOWN(-1),
TORRENT_PRIORITIZE(-2);
Expand Down
2 changes: 1 addition & 1 deletion src/com/frostwire/jlibtorrent/alerts/LogAlert.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author gubatron
* @author aldenml
*/
public abstract class LogAlert extends AbstractAlert<log_alert> {
public final class LogAlert extends AbstractAlert<log_alert> {

public LogAlert(log_alert alert) {
super(alert);
Expand Down
27 changes: 27 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/LsdErrorAlert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.ErrorCode;
import com.frostwire.jlibtorrent.swig.lsd_error_alert;

/**
* posted if the local service discovery socket fails to start properly.
* it's categorized as ``error_notification``.
*
* @author gubatron
* @author aldenml
*/
public final class LsdErrorAlert extends AbstractAlert<lsd_error_alert> {

public LsdErrorAlert(lsd_error_alert alert) {
super(alert);
}

/**
* The error code.
*
* @return
*/
public ErrorCode getError() {
return new ErrorCode(alert.getError());
}
}
19 changes: 19 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/MmapCacheAlert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.ErrorCode;
import com.frostwire.jlibtorrent.swig.mmap_cache_alert;

/**
* @author gubatron
* @author aldenml
*/
public final class MmapCacheAlert extends AbstractAlert<mmap_cache_alert> {

public MmapCacheAlert(mmap_cache_alert alert) {
super(alert);
}

public ErrorCode getError() {
return new ErrorCode(alert.getError());
}
}
30 changes: 30 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/PeerLogAlert.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.peer_log_alert;

/**
* This alert is posted by events specific to a peer. It's meant to be used
* // for trouble shooting and debugging. It's not enabled by the default alert
* // mask and is enabled by the ``alert::peer_log_notification`` bit. By
* // default it is 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 final class PeerLogAlert extends PeerAlert<peer_log_alert> {

public PeerLogAlert(peer_log_alert alert) {
super(alert);
}

/**
* The log message.
*
* @return
*/
public String getMsg() {
return alert.getMsg();
}
}
30 changes: 30 additions & 0 deletions src/com/frostwire/jlibtorrent/alerts/TorrentLogAlert.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.torrent_log_alert;

/**
* This alert is posted by torrent wide events. It's meant to be used for
* // trouble shooting and debugging. It's not enabled by the default alert
* // mask and is enabled by the ``alert::torrent_log_notification`` bit. By
* // default it is 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 final class TorrentLogAlert extends TorrentAlert<torrent_log_alert> {

public TorrentLogAlert(torrent_log_alert alert) {
super(alert);
}

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

public static mmap_cache_alert cast_to_mmap_cache_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_mmap_cache_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new mmap_cache_alert(cPtr, false);
}

public static session_stats_alert cast_to_session_stats_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_session_stats_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new session_stats_alert(cPtr, false);
Expand Down Expand Up @@ -454,6 +459,21 @@ public static log_alert cast_to_log_alert(alert alert) {
return (cPtr == 0) ? null : new log_alert(cPtr, false);
}

public static torrent_log_alert cast_to_torrent_log_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_torrent_log_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new torrent_log_alert(cPtr, false);
}

public static peer_log_alert cast_to_peer_log_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_peer_log_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new peer_log_alert(cPtr, false);
}

public static lsd_error_alert cast_to_lsd_error_alert(alert alert) {
long cPtr = libtorrent_jni.alert_cast_to_lsd_error_alert(alert.getCPtr(alert), alert);
return (cPtr == 0) ? null : new lsd_error_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
4 changes: 4 additions & 0 deletions src/com/frostwire/jlibtorrent/swig/libtorrent_jni.java
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ public class libtorrent_jni {
public final static native long alert_cast_to_incoming_connection_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_add_torrent_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_state_update_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_mmap_cache_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_session_stats_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_torrent_update_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_rss_item_alert(long jarg1, alert jarg1_);
Expand All @@ -1562,6 +1563,9 @@ public class libtorrent_jni {
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_torrent_log_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_peer_log_alert(long jarg1, alert jarg1_);
public final static native long alert_cast_to_lsd_error_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
4 changes: 4 additions & 0 deletions swig/libtorrent.i
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ namespace libtorrent {
CAST_ALERT_METHOD(incoming_connection_alert)
CAST_ALERT_METHOD(add_torrent_alert)
CAST_ALERT_METHOD(state_update_alert)
CAST_ALERT_METHOD(mmap_cache_alert)
CAST_ALERT_METHOD(session_stats_alert)
CAST_ALERT_METHOD(torrent_update_alert)
CAST_ALERT_METHOD(rss_item_alert)
Expand All @@ -795,6 +796,9 @@ namespace libtorrent {
CAST_ALERT_METHOD(i2p_alert)
CAST_ALERT_METHOD(dht_outgoing_get_peers_alert)
CAST_ALERT_METHOD(log_alert)
CAST_ALERT_METHOD(torrent_log_alert)
CAST_ALERT_METHOD(peer_log_alert)
CAST_ALERT_METHOD(lsd_error_alert)
CAST_ALERT_METHOD(dht_stats_alert)

CAST_ALERT_METHOD(dht_get_peers_reply_alert)
Expand Down
92 changes: 92 additions & 0 deletions swig/libtorrent_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ SWIGINTERN libtorrent::torrent_need_cert_alert *libtorrent_alert_cast_to_torrent
SWIGINTERN libtorrent::incoming_connection_alert *libtorrent_alert_cast_to_incoming_connection_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::incoming_connection_alert *>(alert); }
SWIGINTERN libtorrent::add_torrent_alert *libtorrent_alert_cast_to_add_torrent_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::add_torrent_alert *>(alert); }
SWIGINTERN libtorrent::state_update_alert *libtorrent_alert_cast_to_state_update_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::state_update_alert *>(alert); }
SWIGINTERN libtorrent::mmap_cache_alert *libtorrent_alert_cast_to_mmap_cache_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::mmap_cache_alert *>(alert); }
SWIGINTERN libtorrent::session_stats_alert *libtorrent_alert_cast_to_session_stats_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::session_stats_alert *>(alert); }
SWIGINTERN libtorrent::torrent_update_alert *libtorrent_alert_cast_to_torrent_update_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::torrent_update_alert *>(alert); }
SWIGINTERN libtorrent::rss_item_alert *libtorrent_alert_cast_to_rss_item_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::rss_item_alert *>(alert); }
Expand All @@ -1259,6 +1260,9 @@ SWIGINTERN libtorrent::dht_put_alert *libtorrent_alert_cast_to_dht_put_alert(lib
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::torrent_log_alert *libtorrent_alert_cast_to_torrent_log_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::torrent_log_alert *>(alert); }
SWIGINTERN libtorrent::peer_log_alert *libtorrent_alert_cast_to_peer_log_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::peer_log_alert *>(alert); }
SWIGINTERN libtorrent::lsd_error_alert *libtorrent_alert_cast_to_lsd_error_alert(libtorrent::alert *alert){ return dynamic_cast<libtorrent::lsd_error_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 @@ -33237,6 +33241,28 @@ SWIGEXPORT jlong JNICALL Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_ale
}


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

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


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


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

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


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

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


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

(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(libtorrent::alert **)&jarg1;
{
try {
result = (libtorrent::lsd_error_alert *)libtorrent_alert_cast_to_lsd_error_alert(arg1);
} catch (...) {
translate_cpp_exception(jenv);
return 0;
}
}
*(libtorrent::lsd_error_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 22386af

Please sign in to comment.