diff --git a/ngc_ft1.cpp b/ngc_ft1.cpp new file mode 100644 index 0000000..2ed1743 --- /dev/null +++ b/ngc_ft1.cpp @@ -0,0 +1,24 @@ +#include "./ngc_ft1.h" + +#include "ngc_ext_common.hpp" + +struct NGC_FT1 { + NGC_FT1_options options; + +}; + +bool NGC_FT1_init(NGC_EXT_CTX* ngc_ext_ctx, const struct NGC_FT1_options* options) { + ngc_ext_ctx->ngc_ft1_ctx = new NGC_FT1; + ngc_ext_ctx->ngc_ft1_ctx->options = *options; + + //ngc_ext_ctx->callbacks[HS1_REQUEST_LAST_IDS] = _handle_HS1_REQUEST_LAST_IDS; + //ngc_ext_ctx->callbacks[HS1_RESPONSE_LAST_IDS] = _handle_HS1_RESPONSE_LAST_IDS; + + return true; +} + +void NGC_FT1_kill(NGC_EXT_CTX* ngc_ext_ctx) { + delete ngc_ext_ctx->ngc_ft1_ctx; + ngc_ext_ctx->ngc_ft1_ctx = nullptr; +} + diff --git a/ngc_ft1.h b/ngc_ft1.h index 7874594..00fc5ae 100644 --- a/ngc_ft1.h +++ b/ngc_ft1.h @@ -5,21 +5,13 @@ #include +#include "ngc_ext_common.h" + #ifdef __cplusplus extern "C" { #endif - -// copy from tox.h: -#ifndef TOX_DEFINED -#define TOX_DEFINED -typedef struct Tox Tox; -#endif /* TOX_DEFINED */ - - - - // ========== struct / typedef ========== typedef struct NGC_FT1 NGC_FT1; diff --git a/ngc_hs1.cpp b/ngc_hs1.cpp index a4b910a..363f875 100644 --- a/ngc_hs1.cpp +++ b/ngc_hs1.cpp @@ -89,7 +89,7 @@ bool NGC_HS1::Peer::hear(uint32_t msg_id, uint32_t peer_number) { static void _handle_HS1_REQUEST_LAST_IDS( Tox* tox, - NGC_HS1* ngc_hs1_ctx, + NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, @@ -100,7 +100,7 @@ static void _handle_HS1_REQUEST_LAST_IDS( static void _handle_HS1_RESPONSE_LAST_IDS( Tox* tox, - NGC_HS1* ngc_hs1_ctx, + NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, @@ -112,11 +112,16 @@ static void _handle_HS1_RESPONSE_LAST_IDS( bool NGC_HS1_init(NGC_EXT_CTX* ngc_ext_ctx, const struct NGC_HS1_options* options) { ngc_ext_ctx->ngc_hs1_ctx = new NGC_HS1; ngc_ext_ctx->ngc_hs1_ctx->options = *options; + + ngc_ext_ctx->callbacks[HS1_REQUEST_LAST_IDS] = _handle_HS1_REQUEST_LAST_IDS; + ngc_ext_ctx->callbacks[HS1_RESPONSE_LAST_IDS] = _handle_HS1_RESPONSE_LAST_IDS; + return true; } void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx) { delete ngc_ext_ctx->ngc_hs1_ctx; + ngc_ext_ctx->ngc_hs1_ctx = nullptr; } static void _iterate_group(Tox *tox, NGC_HS1* ngc_hs1_ctx, uint32_t group_number, float time_delta) { @@ -314,7 +319,7 @@ void NGC_HS1_record_message( static void _handle_HS1_REQUEST_LAST_IDS( Tox* tox, - NGC_HS1* ngc_hs1_ctx, + NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, @@ -322,6 +327,7 @@ static void _handle_HS1_REQUEST_LAST_IDS( const uint8_t *data, size_t length ) { + NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx; size_t curser = 0; _PeerKey p_key; @@ -386,7 +392,7 @@ static void _handle_HS1_REQUEST_LAST_IDS( static void _handle_HS1_RESPONSE_LAST_IDS( Tox* tox, - NGC_HS1* ngc_hs1_ctx, + NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, @@ -394,6 +400,7 @@ static void _handle_HS1_RESPONSE_LAST_IDS( const uint8_t *data, size_t length ) { + NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx; size_t curser = 0; _PeerKey p_key;