refactor done, now feature parity with before refactor + ft begins

This commit is contained in:
Green Sky 2022-10-03 03:23:38 +02:00
parent 5d6a5d8c01
commit ad55a345b2
No known key found for this signature in database
3 changed files with 37 additions and 14 deletions

24
ngc_ft1.cpp Normal file
View File

@ -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;
}

View File

@ -5,21 +5,13 @@
#include <tox/tox.h> #include <tox/tox.h>
#include "ngc_ext_common.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// copy from tox.h:
#ifndef TOX_DEFINED
#define TOX_DEFINED
typedef struct Tox Tox;
#endif /* TOX_DEFINED */
// ========== struct / typedef ========== // ========== struct / typedef ==========
typedef struct NGC_FT1 NGC_FT1; typedef struct NGC_FT1 NGC_FT1;

View File

@ -89,7 +89,7 @@ bool NGC_HS1::Peer::hear(uint32_t msg_id, uint32_t peer_number) {
static void _handle_HS1_REQUEST_LAST_IDS( static void _handle_HS1_REQUEST_LAST_IDS(
Tox* tox, Tox* tox,
NGC_HS1* ngc_hs1_ctx, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number, uint32_t group_number,
uint32_t peer_number, uint32_t peer_number,
@ -100,7 +100,7 @@ static void _handle_HS1_REQUEST_LAST_IDS(
static void _handle_HS1_RESPONSE_LAST_IDS( static void _handle_HS1_RESPONSE_LAST_IDS(
Tox* tox, Tox* tox,
NGC_HS1* ngc_hs1_ctx, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number, uint32_t group_number,
uint32_t peer_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) { 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 = new NGC_HS1;
ngc_ext_ctx->ngc_hs1_ctx->options = *options; 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; return true;
} }
void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx) { void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx) {
delete ngc_ext_ctx->ngc_hs1_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) { 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( static void _handle_HS1_REQUEST_LAST_IDS(
Tox* tox, Tox* tox,
NGC_HS1* ngc_hs1_ctx, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number, uint32_t group_number,
uint32_t peer_number, uint32_t peer_number,
@ -322,6 +327,7 @@ static void _handle_HS1_REQUEST_LAST_IDS(
const uint8_t *data, const uint8_t *data,
size_t length size_t length
) { ) {
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
size_t curser = 0; size_t curser = 0;
_PeerKey p_key; _PeerKey p_key;
@ -386,7 +392,7 @@ static void _handle_HS1_REQUEST_LAST_IDS(
static void _handle_HS1_RESPONSE_LAST_IDS( static void _handle_HS1_RESPONSE_LAST_IDS(
Tox* tox, Tox* tox,
NGC_HS1* ngc_hs1_ctx, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number, uint32_t group_number,
uint32_t peer_number, uint32_t peer_number,
@ -394,6 +400,7 @@ static void _handle_HS1_RESPONSE_LAST_IDS(
const uint8_t *data, const uint8_t *data,
size_t length size_t length
) { ) {
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
size_t curser = 0; size_t curser = 0;
_PeerKey p_key; _PeerKey p_key;