compiled again, some kinda bug still there
This commit is contained in:
parent
89f9610730
commit
f7313aa2bf
108
ngc_hs1.cpp
108
ngc_hs1.cpp
@ -49,38 +49,42 @@ bool NGC_HS1::Peer::hear(uint32_t msg_id, uint32_t peer_number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handle_HS1_ft_recv_request(
|
void _handle_HS1_ft_recv_request(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
const uint8_t* file_id, size_t file_id_size
|
const uint8_t* file_id, size_t file_id_size,
|
||||||
|
void* user_data
|
||||||
);
|
);
|
||||||
|
|
||||||
bool _handle_HS1_ft_recv_init(
|
bool _handle_HS1_ft_recv_init(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
const uint8_t* file_id, size_t file_id_size,
|
const uint8_t* file_id, size_t file_id_size,
|
||||||
const uint8_t transfer_id,
|
const uint8_t transfer_id,
|
||||||
const size_t file_size
|
const size_t file_size,
|
||||||
|
void* user_data
|
||||||
);
|
);
|
||||||
|
|
||||||
void _handle_HS1_ft_recv_data(
|
void _handle_HS1_ft_recv_data(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
uint8_t transfer_id,
|
uint8_t transfer_id,
|
||||||
size_t data_offset,
|
size_t data_offset,
|
||||||
const uint8_t* data, size_t data_size
|
const uint8_t* data, size_t data_size,
|
||||||
|
void* user_data
|
||||||
);
|
);
|
||||||
|
|
||||||
void _handle_HS1_ft_send_data(
|
void _handle_HS1_ft_send_data(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
uint8_t transfer_id,
|
uint8_t transfer_id,
|
||||||
|
|
||||||
size_t data_offset, uint8_t* data, size_t data_size
|
size_t data_offset, uint8_t* data, size_t data_size,
|
||||||
|
void* user_data
|
||||||
);
|
);
|
||||||
|
|
||||||
NGC_HS1* NGC_HS1_new(const struct NGC_HS1_options* options) {
|
NGC_HS1* NGC_HS1_new(const struct NGC_HS1_options* options) {
|
||||||
@ -100,10 +104,12 @@ bool NGC_HS1_register_ext(NGC_HS1* ngc_hs1_ctx, NGC_EXT_CTX* ngc_ext_ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool NGC_HS1_register_ft1(NGC_HS1* ngc_hs1_ctx, NGC_FT1* ngc_ft1_ctx) {
|
bool NGC_HS1_register_ft1(NGC_HS1* ngc_hs1_ctx, NGC_FT1* ngc_ft1_ctx) {
|
||||||
NGC_FT1_register_callback_recv_request(ngc_ext_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_request);
|
ngc_hs1_ctx->ngc_ft1_ctx = ngc_ft1_ctx;
|
||||||
NGC_FT1_register_callback_recv_init(ngc_ext_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_init);
|
NGC_FT1_register_callback_recv_request(ngc_ft1_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_request, ngc_hs1_ctx);
|
||||||
NGC_FT1_register_callback_recv_data(ngc_ext_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_data);
|
NGC_FT1_register_callback_recv_init(ngc_ft1_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_init, ngc_hs1_ctx);
|
||||||
NGC_FT1_register_callback_send_data(ngc_ext_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_send_data);
|
NGC_FT1_register_callback_recv_data(ngc_ft1_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_recv_data, ngc_hs1_ctx);
|
||||||
|
NGC_FT1_register_callback_send_data(ngc_ft1_ctx, NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID, _handle_HS1_ft_send_data, ngc_hs1_ctx);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -134,9 +140,7 @@ void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _iterate_group(Tox *tox, NGC_HS1* ngc_hs1_ctx, /*NGC_EXT_CTX* ngc_ext_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) {
|
||||||
//NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
|
||||||
|
|
||||||
//fprintf(stderr, "g:%u\n", g_i);
|
//fprintf(stderr, "g:%u\n", g_i);
|
||||||
NGC_EXT::GroupKey g_id{};
|
NGC_EXT::GroupKey g_id{};
|
||||||
{ // TODO: error
|
{ // TODO: error
|
||||||
@ -233,7 +237,7 @@ static void _iterate_group(Tox *tox, NGC_HS1* ngc_hs1_ctx, /*NGC_EXT_CTX* ngc_ex
|
|||||||
|
|
||||||
// send request
|
// send request
|
||||||
NGC_FT1_send_request_private(
|
NGC_FT1_send_request_private(
|
||||||
tox, ngc_ext_ctx,
|
tox, ngc_hs1_ctx->ngc_ft1_ctx,
|
||||||
group_number, remote_peer_number,
|
group_number, remote_peer_number,
|
||||||
NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID,
|
NGC_FT1_file_kind::NGC_HS1_MESSAGE_BY_ID,
|
||||||
file_id.data(), file_id.size()
|
file_id.data(), file_id.size()
|
||||||
@ -250,9 +254,9 @@ static void _iterate_group(Tox *tox, NGC_HS1* ngc_hs1_ctx, /*NGC_EXT_CTX* ngc_ex
|
|||||||
assert(ngc_hs1_ctx->history.count(g_id));
|
assert(ngc_hs1_ctx->history.count(g_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/) {
|
void NGC_HS1_iterate(Tox *tox, NGC_HS1* ngc_hs1_ctx) {
|
||||||
assert(ngc_ext_ctx);
|
//void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/) {
|
||||||
assert(ngc_ext_ctx->ngc_hs1_ctx);
|
assert(ngc_hs1_ctx);
|
||||||
|
|
||||||
//fprintf(stderr, "groups: %u\n", ngc_hs1_ctx->history.size());
|
//fprintf(stderr, "groups: %u\n", ngc_hs1_ctx->history.size());
|
||||||
|
|
||||||
@ -263,7 +267,7 @@ void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/) {
|
|||||||
if (tox_group_is_connected(tox, g_i, &g_err)) {
|
if (tox_group_is_connected(tox, g_i, &g_err)) {
|
||||||
// valid and connected here
|
// valid and connected here
|
||||||
// TODO: delta time, or other timers
|
// TODO: delta time, or other timers
|
||||||
_iterate_group(tox, ngc_ext_ctx->ngc_hs1_ctx, g_i, 0.02f);
|
_iterate_group(tox, ngc_hs1_ctx, g_i, 0.02f);
|
||||||
g_c_done++;
|
g_c_done++;
|
||||||
} else if (g_err != TOX_ERR_GROUP_IS_CONNECTED_GROUP_NOT_FOUND) {
|
} else if (g_err != TOX_ERR_GROUP_IS_CONNECTED_GROUP_NOT_FOUND) {
|
||||||
g_c_done++;
|
g_c_done++;
|
||||||
@ -277,8 +281,7 @@ void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NGC_HS1_peer_online(Tox* tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, bool online) {
|
void NGC_HS1_peer_online(Tox* tox, NGC_HS1* ngc_hs1_ctx, uint32_t group_number, uint32_t peer_number, bool online) {
|
||||||
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
|
||||||
// get group id
|
// get group id
|
||||||
NGC_EXT::GroupKey g_id{};
|
NGC_EXT::GroupKey g_id{};
|
||||||
{ // TODO: error
|
{ // TODO: error
|
||||||
@ -309,7 +312,7 @@ void NGC_HS1_peer_online(Tox* tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_numb
|
|||||||
|
|
||||||
bool NGC_HS1_shim_group_send_message(
|
bool NGC_HS1_shim_group_send_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
|
|
||||||
@ -326,7 +329,7 @@ bool NGC_HS1_shim_group_send_message(
|
|||||||
|
|
||||||
bool ret = tox_group_send_message(tox, group_number, type, message, length, msg_id_ptr, error);
|
bool ret = tox_group_send_message(tox, group_number, type, message, length, msg_id_ptr, error);
|
||||||
|
|
||||||
NGC_HS1_record_own_message(tox, ngc_ext_ctx, group_number, type, message, length, *msg_id_ptr);
|
NGC_HS1_record_own_message(tox, ngc_hs1_ctx, group_number, type, message, length, *msg_id_ptr);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -334,13 +337,12 @@ bool NGC_HS1_shim_group_send_message(
|
|||||||
// record own msg
|
// record own msg
|
||||||
void NGC_HS1_record_own_message(
|
void NGC_HS1_record_own_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
|
|
||||||
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
||||||
) {
|
) {
|
||||||
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
|
||||||
fprintf(stderr, "HS: record_own_message %08X\n", message_id);
|
fprintf(stderr, "HS: record_own_message %08X\n", message_id);
|
||||||
// get group id
|
// get group id
|
||||||
NGC_EXT::GroupKey g_id{};
|
NGC_EXT::GroupKey g_id{};
|
||||||
@ -359,24 +361,22 @@ void NGC_HS1_record_own_message(
|
|||||||
assert(ngc_hs1_ctx->history.count(g_id));
|
assert(ngc_hs1_ctx->history.count(g_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NGC_HS1_register_callback_group_message(NGC_EXT_CTX* ngc_ext_ctx, NGC_HS1_group_message_cb* callback) {
|
void NGC_HS1_register_callback_group_message(NGC_HS1* ngc_hs1_ctx, NGC_HS1_group_message_cb* callback) {
|
||||||
assert(ngc_ext_ctx);
|
assert(ngc_hs1_ctx);
|
||||||
assert(ngc_ext_ctx->ngc_hs1_ctx);
|
|
||||||
|
|
||||||
ngc_ext_ctx->ngc_hs1_ctx->cb_group_message = callback;
|
ngc_hs1_ctx->cb_group_message = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// record others msg
|
// record others msg
|
||||||
void NGC_HS1_record_message(
|
void NGC_HS1_record_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
|
|
||||||
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
||||||
) {
|
) {
|
||||||
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
|
||||||
if (!ngc_hs1_ctx->options.record_others) {
|
if (!ngc_hs1_ctx->options.record_others) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -398,11 +398,13 @@ void NGC_HS1_record_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handle_HS1_ft_recv_request(
|
void _handle_HS1_ft_recv_request(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
const uint8_t* file_id, size_t file_id_size
|
const uint8_t* file_id, size_t file_id_size,
|
||||||
|
void* user_data
|
||||||
) {
|
) {
|
||||||
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
assert(file_id_size == TOX_GROUP_PEER_PUBLIC_KEY_SIZE+sizeof(uint32_t));
|
assert(file_id_size == TOX_GROUP_PEER_PUBLIC_KEY_SIZE+sizeof(uint32_t));
|
||||||
|
|
||||||
// get peer_key from file_id
|
// get peer_key from file_id
|
||||||
@ -423,7 +425,7 @@ void _handle_HS1_ft_recv_request(
|
|||||||
tox_group_get_chat_id(tox, group_number, group_id.data.data(), nullptr);
|
tox_group_get_chat_id(tox, group_number, group_id.data.data(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& peers = ngc_ext_ctx->ngc_hs1_ctx->history[group_id].peers;
|
const auto& peers = ngc_hs1_ctx->history[group_id].peers;
|
||||||
|
|
||||||
// do we have that message
|
// do we have that message
|
||||||
|
|
||||||
@ -452,7 +454,7 @@ void _handle_HS1_ft_recv_request(
|
|||||||
uint8_t transfer_id {0};
|
uint8_t transfer_id {0};
|
||||||
|
|
||||||
NGC_FT1_send_init_private(
|
NGC_FT1_send_init_private(
|
||||||
tox, ngc_ext_ctx,
|
tox, ngc_hs1_ctx->ngc_ft1_ctx,
|
||||||
group_number, peer_number,
|
group_number, peer_number,
|
||||||
NGC_HS1_MESSAGE_BY_ID,
|
NGC_HS1_MESSAGE_BY_ID,
|
||||||
file_id, file_id_size,
|
file_id, file_id_size,
|
||||||
@ -462,17 +464,19 @@ void _handle_HS1_ft_recv_request(
|
|||||||
|
|
||||||
//TODO: can fail
|
//TODO: can fail
|
||||||
|
|
||||||
ngc_ext_ctx->ngc_hs1_ctx->history[group_id].sending[std::make_pair(peer_number, transfer_id)] = {peer_key, msg_id};
|
ngc_hs1_ctx->history[group_id].sending[std::make_pair(peer_number, transfer_id)] = {peer_key, msg_id};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _handle_HS1_ft_recv_init(
|
bool _handle_HS1_ft_recv_init(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
const uint8_t* file_id, size_t file_id_size,
|
const uint8_t* file_id, size_t file_id_size,
|
||||||
const uint8_t transfer_id,
|
const uint8_t transfer_id,
|
||||||
const size_t file_size
|
const size_t file_size,
|
||||||
|
void* user_data
|
||||||
) {
|
) {
|
||||||
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
//fprintf(stderr, "HS: -------hs handle ft init\n");
|
//fprintf(stderr, "HS: -------hs handle ft init\n");
|
||||||
|
|
||||||
// peer id and msg id from file id
|
// peer id and msg id from file id
|
||||||
@ -497,7 +501,7 @@ bool _handle_HS1_ft_recv_init(
|
|||||||
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& group = ngc_ext_ctx->ngc_hs1_ctx->history[g_id];
|
auto& group = ngc_hs1_ctx->history[g_id];
|
||||||
|
|
||||||
auto& pending = group.peers[peer_key].pending;
|
auto& pending = group.peers[peer_key].pending;
|
||||||
|
|
||||||
@ -534,20 +538,22 @@ bool _handle_HS1_ft_recv_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handle_HS1_ft_recv_data(
|
void _handle_HS1_ft_recv_data(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
uint8_t transfer_id,
|
uint8_t transfer_id,
|
||||||
size_t data_offset,
|
size_t data_offset,
|
||||||
const uint8_t* data, size_t data_size
|
const uint8_t* data, size_t data_size,
|
||||||
|
void* user_data
|
||||||
) {
|
) {
|
||||||
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
// get group id
|
// get group id
|
||||||
NGC_EXT::GroupKey g_id{};
|
NGC_EXT::GroupKey g_id{};
|
||||||
{ // TODO: error
|
{ // TODO: error
|
||||||
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& group = ngc_ext_ctx->ngc_hs1_ctx->history[g_id];
|
auto& group = ngc_hs1_ctx->history[g_id];
|
||||||
|
|
||||||
// get based on transfer_id
|
// get based on transfer_id
|
||||||
if (!group.transfers.count(std::make_pair(peer_number, transfer_id))) {
|
if (!group.transfers.count(std::make_pair(peer_number, transfer_id))) {
|
||||||
@ -581,10 +587,10 @@ void _handle_HS1_ft_recv_data(
|
|||||||
peer.pending.erase(transfer.msg_id);
|
peer.pending.erase(transfer.msg_id);
|
||||||
peer.append(transfer.msg_id, static_cast<Tox_Message_Type>(transfer.recv_buffer.front()), std::string(reinterpret_cast<const char*>(transfer.recv_buffer.data()+1)));
|
peer.append(transfer.msg_id, static_cast<Tox_Message_Type>(transfer.recv_buffer.front()), std::string(reinterpret_cast<const char*>(transfer.recv_buffer.data()+1)));
|
||||||
|
|
||||||
assert(ngc_ext_ctx->ngc_hs1_ctx->cb_group_message);
|
assert(ngc_hs1_ctx->cb_group_message);
|
||||||
// we dont notify if we dont know the peer id. this kinda breaks some stuff
|
// we dont notify if we dont know the peer id. this kinda breaks some stuff
|
||||||
if (peer.id.has_value()) {
|
if (peer.id.has_value()) {
|
||||||
ngc_ext_ctx->ngc_hs1_ctx->cb_group_message(
|
ngc_hs1_ctx->cb_group_message(
|
||||||
tox,
|
tox,
|
||||||
group_number, peer.id.value(),
|
group_number, peer.id.value(),
|
||||||
static_cast<Tox_Message_Type>(transfer.recv_buffer.front()),
|
static_cast<Tox_Message_Type>(transfer.recv_buffer.front()),
|
||||||
@ -599,21 +605,23 @@ void _handle_HS1_ft_recv_data(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handle_HS1_ft_send_data(
|
void _handle_HS1_ft_send_data(
|
||||||
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
|
Tox *tox,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
uint8_t transfer_id,
|
uint8_t transfer_id,
|
||||||
|
|
||||||
size_t data_offset, uint8_t* data, size_t data_size
|
size_t data_offset, uint8_t* data, size_t data_size,
|
||||||
|
void* user_data
|
||||||
) {
|
) {
|
||||||
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
// get group id
|
// get group id
|
||||||
NGC_EXT::GroupKey g_id{};
|
NGC_EXT::GroupKey g_id{};
|
||||||
{ // TODO: error
|
{ // TODO: error
|
||||||
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
tox_group_get_chat_id(tox, group_number, g_id.data.data(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& group = ngc_ext_ctx->ngc_hs1_ctx->history[g_id];
|
auto& group = ngc_hs1_ctx->history[g_id];
|
||||||
|
|
||||||
if (!group.sending.count(std::make_pair(peer_number, transfer_id))) {
|
if (!group.sending.count(std::make_pair(peer_number, transfer_id))) {
|
||||||
fprintf(stderr, "HS: error, unknown sending transfer %d:%d\n", peer_number, transfer_id);
|
fprintf(stderr, "HS: error, unknown sending transfer %d:%d\n", peer_number, transfer_id);
|
||||||
@ -657,7 +665,7 @@ void _handle_HS1_REQUEST_LAST_IDS(
|
|||||||
size_t length,
|
size_t length,
|
||||||
void* user_data
|
void* user_data
|
||||||
) {
|
) {
|
||||||
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
size_t curser = 0;
|
size_t curser = 0;
|
||||||
|
|
||||||
NGC_EXT::PeerKey p_key;
|
NGC_EXT::PeerKey p_key;
|
||||||
@ -731,7 +739,7 @@ void _handle_HS1_RESPONSE_LAST_IDS(
|
|||||||
size_t length,
|
size_t length,
|
||||||
void* user_data
|
void* user_data
|
||||||
) {
|
) {
|
||||||
NGC_HS1* ngc_hs1_ctx = ngc_ext_ctx->ngc_hs1_ctx;
|
NGC_HS1* ngc_hs1_ctx = static_cast<NGC_HS1*>(user_data);
|
||||||
size_t curser = 0;
|
size_t curser = 0;
|
||||||
|
|
||||||
NGC_EXT::PeerKey p_key;
|
NGC_EXT::PeerKey p_key;
|
||||||
|
13
ngc_hs1.h
13
ngc_hs1.h
@ -48,11 +48,12 @@ void NGC_HS1_kill(NGC_HS1* ngc_hs1_ctx);
|
|||||||
//void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx);
|
//void NGC_HS1_kill(NGC_EXT_CTX* ngc_ext_ctx);
|
||||||
|
|
||||||
// ========== iterate ==========
|
// ========== iterate ==========
|
||||||
void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/);
|
void NGC_HS1_iterate(Tox *tox, NGC_HS1* ngc_hs1_ctx);
|
||||||
|
//void NGC_HS1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/);
|
||||||
|
|
||||||
// ========== peer online/offline ==========
|
// ========== peer online/offline ==========
|
||||||
|
|
||||||
void NGC_HS1_peer_online(Tox* tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, bool online);
|
void NGC_HS1_peer_online(Tox* tox, NGC_HS1* ngc_hs1_ctx, uint32_t group_number, uint32_t peer_number, bool online);
|
||||||
|
|
||||||
// ========== send ==========
|
// ========== send ==========
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ void NGC_HS1_peer_online(Tox* tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_numb
|
|||||||
// NGC_HS1_record_own_message()
|
// NGC_HS1_record_own_message()
|
||||||
bool NGC_HS1_shim_group_send_message(
|
bool NGC_HS1_shim_group_send_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ bool NGC_HS1_shim_group_send_message(
|
|||||||
// record own msg
|
// record own msg
|
||||||
void NGC_HS1_record_own_message(
|
void NGC_HS1_record_own_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
|
|
||||||
@ -94,12 +95,12 @@ typedef void NGC_HS1_group_message_cb(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// callback for when history sync has a new message
|
// callback for when history sync has a new message
|
||||||
void NGC_HS1_register_callback_group_message(NGC_EXT_CTX* ngc_ext_ctx, NGC_HS1_group_message_cb* callback);
|
void NGC_HS1_register_callback_group_message(NGC_HS1* ngc_hs1_ctx, NGC_HS1_group_message_cb* callback); // TODO: userdata
|
||||||
|
|
||||||
// record others msg
|
// record others msg
|
||||||
void NGC_HS1_record_message(
|
void NGC_HS1_record_message(
|
||||||
const Tox *tox,
|
const Tox *tox,
|
||||||
NGC_EXT_CTX* ngc_ext_ctx,
|
NGC_HS1* ngc_hs1_ctx,
|
||||||
|
|
||||||
uint32_t group_number,
|
uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number,
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
struct NGC_HS1 {
|
struct NGC_HS1 {
|
||||||
NGC_HS1_options options;
|
NGC_HS1_options options;
|
||||||
|
|
||||||
|
NGC_FT1* ngc_ft1_ctx {nullptr};
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
//tox_group_message_cb* client_tox_msg_callback;
|
|
||||||
NGC_HS1_group_message_cb* cb_group_message {nullptr};
|
NGC_HS1_group_message_cb* cb_group_message {nullptr};
|
||||||
|
|
||||||
// key - key - key - value store
|
// key - key - key - value store
|
||||||
|
Reference in New Issue
Block a user