Skip to content

Commit

Permalink
Added swig_dht_storage_constructor type and related API
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Feb 10, 2016
1 parent 38876d0 commit 2e34fbc
Show file tree
Hide file tree
Showing 8 changed files with 593 additions and 76 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/frostwire/jlibtorrent/swig/libtorrent_jni.java
Expand Up @@ -2477,6 +2477,7 @@ public class libtorrent_jni {
public final static native void session_handle_dht_get_item__SWIG_1(long jarg1, session_handle jarg1_, long jarg2, byte_vector jarg2_, long jarg3, byte_vector jarg3_);
public final static native void session_handle_dht_put_item__SWIG_1(long jarg1, session_handle jarg1_, long jarg2, byte_vector jarg2_, long jarg3, byte_vector jarg3_, long jarg4, entry jarg4_, long jarg5, byte_vector jarg5_);
public final static native void session_handle_add_swig_extension(long jarg1, session_handle jarg1_, long jarg2, swig_plugin jarg2_);
public final static native void session_handle_set_swig_dht_storage(long jarg1, session_handle jarg1_, long jarg2, swig_dht_storage_constructor jarg2_);
public final static native void delete_session_handle(long jarg1);
public final static native void min_memory_usage(long jarg1, settings_pack jarg1_);
public final static native void high_performance_seed(long jarg1, settings_pack jarg1_);
Expand Down Expand Up @@ -3085,6 +3086,12 @@ public class libtorrent_jni {
public final static native long new_swig_dht_storage();
public final static native void swig_dht_storage_director_connect(swig_dht_storage obj, long cptr, boolean mem_own, boolean weak_global);
public final static native void swig_dht_storage_change_ownership(swig_dht_storage obj, long cptr, boolean take_or_release);
public final static native void delete_swig_dht_storage_constructor(long jarg1);
public final static native long swig_dht_storage_constructor_create(long jarg1, swig_dht_storage_constructor jarg1_, long jarg2, sha1_hash jarg2_, long jarg3, dht_settings jarg3_);
public final static native long swig_dht_storage_constructor_createSwigExplicitswig_dht_storage_constructor(long jarg1, swig_dht_storage_constructor jarg1_, long jarg2, sha1_hash jarg2_, long jarg3, dht_settings jarg3_);
public final static native long new_swig_dht_storage_constructor();
public final static native void swig_dht_storage_constructor_director_connect(swig_dht_storage_constructor obj, long cptr, boolean mem_own, boolean weak_global);
public final static native void swig_dht_storage_constructor_change_ownership(swig_dht_storage_constructor obj, long cptr, boolean take_or_release);
public final static native void delete_swig_plugin(long jarg1);
public final static native long swig_plugin_new_torrent(long jarg1, swig_plugin jarg1_, long jarg2, torrent_handle jarg2_);
public final static native long swig_plugin_new_torrentSwigExplicitswig_plugin(long jarg1, swig_plugin jarg1_, long jarg2, torrent_handle jarg2_);
Expand Down Expand Up @@ -3392,6 +3399,9 @@ public static long SwigDirector_swig_dht_storage_num_immutable_data(swig_dht_sto
public static long SwigDirector_swig_dht_storage_num_mutable_data(swig_dht_storage jself) {
return jself.num_mutable_data();
}
public static long SwigDirector_swig_dht_storage_constructor_create(swig_dht_storage_constructor jself, long id, long settings) {
return swig_dht_storage.getCPtr(jself.create(new sha1_hash(id, false), new dht_settings(settings, false)));
}
public static long SwigDirector_swig_plugin_new_torrent(swig_plugin jself, long t) {
return swig_torrent_plugin.getCPtr(jself.new_torrent(new torrent_handle(t, false)));
}
Expand Down
Expand Up @@ -256,6 +256,10 @@ public void add_swig_extension(swig_plugin p) {
libtorrent_jni.session_handle_add_swig_extension(swigCPtr, this, swig_plugin.getCPtr(p), p);
}

public void set_swig_dht_storage(swig_dht_storage_constructor sc) {
libtorrent_jni.session_handle_set_swig_dht_storage(swigCPtr, this, swig_dht_storage_constructor.getCPtr(sc), sc);
}

public final static class save_state_flags_t {
public final static session_handle.save_state_flags_t save_settings = new session_handle.save_state_flags_t("save_settings", libtorrent_jni.session_handle_save_settings_get());
public final static session_handle.save_state_flags_t save_dht_settings = new session_handle.save_state_flags_t("save_dht_settings", libtorrent_jni.session_handle_save_dht_settings_get());
Expand Down
@@ -0,0 +1,63 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.8
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package com.frostwire.jlibtorrent.swig;

public class swig_dht_storage_constructor {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;

protected swig_dht_storage_constructor(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(swig_dht_storage_constructor obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
libtorrent_jni.delete_swig_dht_storage_constructor(swigCPtr);
}
swigCPtr = 0;
}
}

protected void swigDirectorDisconnect() {
swigCMemOwn = false;
delete();
}

public void swigReleaseOwnership() {
swigCMemOwn = false;
libtorrent_jni.swig_dht_storage_constructor_change_ownership(this, swigCPtr, false);
}

public void swigTakeOwnership() {
swigCMemOwn = true;
libtorrent_jni.swig_dht_storage_constructor_change_ownership(this, swigCPtr, true);
}

public swig_dht_storage create(sha1_hash id, dht_settings settings) {
long cPtr = (getClass() == swig_dht_storage_constructor.class) ? libtorrent_jni.swig_dht_storage_constructor_create(swigCPtr, this, sha1_hash.getCPtr(id), id, dht_settings.getCPtr(settings), settings) : libtorrent_jni.swig_dht_storage_constructor_createSwigExplicitswig_dht_storage_constructor(swigCPtr, this, sha1_hash.getCPtr(id), id, dht_settings.getCPtr(settings), settings);
return (cPtr == 0) ? null : new swig_dht_storage(cPtr, false);
}

public swig_dht_storage_constructor() {
this(libtorrent_jni.new_swig_dht_storage_constructor(), true);
libtorrent_jni.swig_dht_storage_constructor_director_connect(this, swigCPtr, swigCMemOwn, true);
}

}
16 changes: 16 additions & 0 deletions swig/libtorrent.h
Expand Up @@ -420,6 +420,22 @@ struct swig_dht_storage : dht::dht_storage_interface
virtual ~swig_dht_storage() {}
};

class swig_dht_storage_constructor {
public:
virtual ~swig_dht_storage_constructor() {
}

virtual swig_dht_storage* create(libtorrent::sha1_hash const& id, libtorrent::dht_settings const& settings) {
return NULL;
}
};

dht::dht_storage_interface* swig_dht_storage_constructor_cb(libtorrent::sha1_hash const& id
, libtorrent::dht_settings const& settings
, swig_dht_storage_constructor* sc) {
return sc->create(id, settings);
}

//------------------------------------------------------

void dht_put_item_cb(entry& e, boost::array<char, 64>& sig, boost::uint64_t& seq,
Expand Down
10 changes: 9 additions & 1 deletion swig/libtorrent.i
Expand Up @@ -876,6 +876,10 @@ namespace libtorrent {
void add_swig_extension(swig_plugin *p) {
$self->add_extension(boost::shared_ptr<plugin>(p));
}

void set_swig_dht_storage(swig_dht_storage_constructor *sc) {
$self->set_dht_storage(boost::bind(&swig_dht_storage_constructor_cb, _1, _2, sc));
}
};

%extend entry {
Expand Down Expand Up @@ -1040,6 +1044,7 @@ void set_utp_stream_logging(bool enable);
%ignore swig_storage::set_file_priority;
%ignore swig_storage::readv;
%ignore swig_storage::writev;
%ignore swig_storage_constructor_cb;

%feature("director") swig_storage;
%feature("director") swig_storage_constructor;
Expand All @@ -1051,8 +1056,12 @@ void set_utp_stream_logging(bool enable);
%ignore swig_dht_storage::get_mutable_item_seq;
%ignore swig_dht_storage::put_mutable_item(libtorrent::sha1_hash const&, char const*, int, char const*, boost::int64_t, char const*, char const*, int, libtorrent::address const&);
%ignore swig_dht_storage::counters;
%ignore swig_dht_storage_constructor_cb;

%feature("director") swig_dht_storage;
%feature("director") swig_dht_storage_constructor;

%typemap("javapackage") SwigDhtStorage, SwigDhtStorage *, SwigDhtStorage & "com.frostwire.jlibtorrent.plugins";

// libtorrent plugins
%feature("director") swig_plugin;
Expand All @@ -1071,7 +1080,6 @@ void set_utp_stream_logging(bool enable);
%ignore swig_peer_plugin::on_extended;
%ignore swig_peer_plugin::on_unknown_message;

%ignore swig_storage_constructor_cb;
%ignore dht_put_item_cb;

%feature("director") posix_wrapper;
Expand Down

0 comments on commit 2e34fbc

Please sign in to comment.