forked from Green-Sky/tomato
Merge commit '61accfe1846e1f857fcdf84d27fb3d6e78fb46a3'
This commit is contained in:
commit
5effe64474
@ -96,7 +96,7 @@ jobs:
|
|||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake --preset windows-default
|
run: cmake --preset windows-default
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build _build
|
run: cmake --build _build -j $([int]$env:NUMBER_OF_PROCESSORS+2)
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
cd _build
|
cd _build
|
||||||
|
4
external/toxcore/c-toxcore/.gitignore
vendored
4
external/toxcore/c-toxcore/.gitignore
vendored
@ -93,5 +93,9 @@ cscope.files
|
|||||||
# rpm
|
# rpm
|
||||||
tox.spec
|
tox.spec
|
||||||
|
|
||||||
|
# clangd
|
||||||
|
.cache/
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
/infer
|
/infer
|
||||||
.idea/
|
.idea/
|
||||||
|
2
external/toxcore/c-toxcore/CMakeLists.txt
vendored
2
external/toxcore/c-toxcore/CMakeLists.txt
vendored
@ -338,6 +338,8 @@ set(toxcore_SOURCES
|
|||||||
toxcore/tox.h
|
toxcore/tox.h
|
||||||
toxcore/tox_private.c
|
toxcore/tox_private.c
|
||||||
toxcore/tox_private.h
|
toxcore/tox_private.h
|
||||||
|
toxcore/tox_pack.c
|
||||||
|
toxcore/tox_pack.h
|
||||||
toxcore/tox_unpack.c
|
toxcore/tox_unpack.c
|
||||||
toxcore/tox_unpack.h
|
toxcore/tox_unpack.h
|
||||||
toxcore/util.c
|
toxcore/util.c
|
||||||
|
@ -46,8 +46,9 @@ auto_test(crypto)
|
|||||||
#auto_test(dht) # Doesn't work with UNITY_BUILD.
|
#auto_test(dht) # Doesn't work with UNITY_BUILD.
|
||||||
auto_test(dht_getnodes_api)
|
auto_test(dht_getnodes_api)
|
||||||
auto_test(encryptsave)
|
auto_test(encryptsave)
|
||||||
auto_test(file_transfer)
|
|
||||||
auto_test(file_saving)
|
auto_test(file_saving)
|
||||||
|
auto_test(file_streaming)
|
||||||
|
auto_test(file_transfer)
|
||||||
auto_test(forwarding)
|
auto_test(forwarding)
|
||||||
auto_test(friend_connection)
|
auto_test(friend_connection)
|
||||||
auto_test(friend_request)
|
auto_test(friend_request)
|
||||||
|
@ -15,6 +15,7 @@ TESTS = \
|
|||||||
crypto_test \
|
crypto_test \
|
||||||
encryptsave_test \
|
encryptsave_test \
|
||||||
file_saving_test \
|
file_saving_test \
|
||||||
|
file_streaming_test \
|
||||||
file_transfer_test \
|
file_transfer_test \
|
||||||
forwarding_test \
|
forwarding_test \
|
||||||
friend_connection_test \
|
friend_connection_test \
|
||||||
@ -103,6 +104,10 @@ file_saving_test_SOURCES = ../auto_tests/file_saving_test.c
|
|||||||
file_saving_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
file_saving_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
file_saving_test_LDADD = $(AUTOTEST_LDADD)
|
file_saving_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
|
file_streaming_test_SOURCES = ../auto_tests/file_streaming_test.c
|
||||||
|
file_streaming_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
|
file_streaming_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
file_transfer_test_SOURCES = ../auto_tests/file_transfer_test.c
|
file_transfer_test_SOURCES = ../auto_tests/file_transfer_test.c
|
||||||
file_transfer_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
file_transfer_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
file_transfer_test_LDADD = $(AUTOTEST_LDADD)
|
file_transfer_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
#define ABORT_ON_LOG_ERROR true
|
#define ABORT_ON_LOG_ERROR true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_IPV6
|
||||||
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
Run_Auto_Options default_run_auto_options(void)
|
Run_Auto_Options default_run_auto_options(void)
|
||||||
{
|
{
|
||||||
return (Run_Auto_Options) {
|
return (Run_Auto_Options) {
|
||||||
@ -193,6 +197,7 @@ void reload(AutoTox *autotox)
|
|||||||
|
|
||||||
struct Tox_Options *const options = tox_options_new(nullptr);
|
struct Tox_Options *const options = tox_options_new(nullptr);
|
||||||
ck_assert(options != nullptr);
|
ck_assert(options != nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||||
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
||||||
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
||||||
@ -214,6 +219,8 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
|||||||
struct Tox_Options *default_opts = tox_options_new(nullptr);
|
struct Tox_Options *default_opts = tox_options_new(nullptr);
|
||||||
ck_assert(default_opts != nullptr);
|
ck_assert(default_opts != nullptr);
|
||||||
|
|
||||||
|
tox_options_set_ipv6_enabled(default_opts, USE_IPV6);
|
||||||
|
|
||||||
if (options == nullptr) {
|
if (options == nullptr) {
|
||||||
options = default_opts;
|
options = default_opts;
|
||||||
}
|
}
|
||||||
@ -426,6 +433,7 @@ Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_us
|
|||||||
|
|
||||||
assert(log_options != nullptr);
|
assert(log_options != nullptr);
|
||||||
|
|
||||||
|
tox_options_set_ipv6_enabled(log_options, USE_IPV6);
|
||||||
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
||||||
// Use a higher start port for non-LAN-discovery tests so it's more likely for the LAN discovery
|
// Use a higher start port for non-LAN-discovery tests so it's more likely for the LAN discovery
|
||||||
// test to get the default port 33445.
|
// test to get the default port 33445.
|
||||||
|
275
external/toxcore/c-toxcore/auto_tests/file_streaming_test.c
vendored
Normal file
275
external/toxcore/c-toxcore/auto_tests/file_streaming_test.c
vendored
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
/* File transfer test: streaming version (no known size).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "../testing/misc_tools.h"
|
||||||
|
#include "../toxcore/ccompat.h"
|
||||||
|
#include "../toxcore/tox.h"
|
||||||
|
#include "../toxcore/util.h"
|
||||||
|
#include "auto_test_support.h"
|
||||||
|
#include "check_compat.h"
|
||||||
|
|
||||||
|
#ifndef USE_IPV6
|
||||||
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
|
#define TOX_LOCALHOST "::1"
|
||||||
|
#else
|
||||||
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
||||||
|
{
|
||||||
|
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
|
||||||
|
tox_friend_add_norequest(m, public_key, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t size_recv;
|
||||||
|
static uint64_t sending_pos;
|
||||||
|
|
||||||
|
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
|
||||||
|
static uint32_t file_accepted;
|
||||||
|
static uint64_t file_size;
|
||||||
|
static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t filesize,
|
||||||
|
const uint8_t *filename, size_t filename_length, void *userdata)
|
||||||
|
{
|
||||||
|
ck_assert_msg(kind == TOX_FILE_KIND_DATA, "bad kind");
|
||||||
|
|
||||||
|
ck_assert_msg(filename_length == sizeof("Gentoo.exe")
|
||||||
|
&& memcmp(filename, "Gentoo.exe", sizeof("Gentoo.exe")) == 0, "bad filename");
|
||||||
|
|
||||||
|
uint8_t file_id[TOX_FILE_ID_LENGTH];
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_get_file_id(tox, friend_number, file_number, file_id, nullptr), "tox_file_get_file_id error");
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) == 0, "bad file_id");
|
||||||
|
|
||||||
|
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) != 0, "empty file_id");
|
||||||
|
|
||||||
|
file_size = filesize;
|
||||||
|
|
||||||
|
if (filesize) {
|
||||||
|
sending_pos = size_recv = 1337;
|
||||||
|
|
||||||
|
Tox_Err_File_Seek err_s;
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_seek(tox, friend_number, file_number, 1337, &err_s), "tox_file_seek error");
|
||||||
|
|
||||||
|
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_OK, "tox_file_seek wrong error");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sending_pos = size_recv = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tox_Err_File_Control error;
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||||
|
"tox_file_control failed. %i", error);
|
||||||
|
++file_accepted;
|
||||||
|
|
||||||
|
Tox_Err_File_Seek err_s;
|
||||||
|
|
||||||
|
ck_assert_msg(!tox_file_seek(tox, friend_number, file_number, 1234, &err_s), "tox_file_seek no error");
|
||||||
|
|
||||||
|
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_DENIED, "tox_file_seek wrong error");
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t sendf_ok;
|
||||||
|
static void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
|
/* First send file num is 0.*/
|
||||||
|
if (file_number == 0 && control == TOX_FILE_CONTROL_RESUME) {
|
||||||
|
sendf_ok = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t max_sending;
|
||||||
|
static bool m_send_reached;
|
||||||
|
static uint8_t sending_num;
|
||||||
|
static bool file_sending_done;
|
||||||
|
static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
||||||
|
size_t length, void *user_data)
|
||||||
|
{
|
||||||
|
ck_assert_msg(sendf_ok, "didn't get resume control");
|
||||||
|
|
||||||
|
ck_assert_msg(sending_pos == position, "bad position %lu", (unsigned long)position);
|
||||||
|
|
||||||
|
if (length == 0) {
|
||||||
|
ck_assert_msg(!file_sending_done, "file sending already done");
|
||||||
|
|
||||||
|
file_sending_done = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position + length > max_sending) {
|
||||||
|
ck_assert_msg(!m_send_reached, "requested done file transfer");
|
||||||
|
|
||||||
|
length = max_sending - position;
|
||||||
|
m_send_reached = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VLA(uint8_t, f_data, length);
|
||||||
|
memset(f_data, sending_num, length);
|
||||||
|
|
||||||
|
Tox_Err_File_Send_Chunk error;
|
||||||
|
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
|
||||||
|
|
||||||
|
|
||||||
|
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
|
||||||
|
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
|
||||||
|
|
||||||
|
++sending_num;
|
||||||
|
sending_pos += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t num;
|
||||||
|
static bool file_recv;
|
||||||
|
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
||||||
|
size_t length, void *user_data)
|
||||||
|
{
|
||||||
|
ck_assert_msg(size_recv == position, "bad position");
|
||||||
|
|
||||||
|
if (length == 0) {
|
||||||
|
file_recv = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VLA(uint8_t, f_data, length);
|
||||||
|
memset(f_data, num, length);
|
||||||
|
++num;
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(f_data, data, length) == 0, "FILE_CORRUPTED");
|
||||||
|
|
||||||
|
size_recv += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void file_transfer_test(void)
|
||||||
|
{
|
||||||
|
printf("Starting test: few_clients\n");
|
||||||
|
uint32_t index[] = { 1, 2, 3 };
|
||||||
|
long long unsigned int cur_time = time(nullptr);
|
||||||
|
Tox_Err_New t_n_error;
|
||||||
|
Tox *tox1 = tox_new_log(nullptr, &t_n_error, &index[0]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
Tox *tox2 = tox_new_log(nullptr, &t_n_error, &index[1]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
Tox *tox3 = tox_new_log(nullptr, &t_n_error, &index[2]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
|
||||||
|
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||||
|
|
||||||
|
tox_callback_friend_request(tox2, accept_friend_request);
|
||||||
|
uint8_t address[TOX_ADDRESS_SIZE];
|
||||||
|
tox_self_get_address(tox2, address);
|
||||||
|
uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr);
|
||||||
|
ck_assert_msg(test == 0, "Failed to add friend error code: %u", test);
|
||||||
|
|
||||||
|
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
|
||||||
|
tox_self_get_dht_id(tox1, dht_key);
|
||||||
|
uint16_t dht_port = tox_self_get_udp_port(tox1, nullptr);
|
||||||
|
|
||||||
|
tox_bootstrap(tox2, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||||
|
tox_bootstrap(tox3, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||||
|
|
||||||
|
printf("Waiting for toxes to come online\n");
|
||||||
|
|
||||||
|
do {
|
||||||
|
tox_iterate(tox1, nullptr);
|
||||||
|
tox_iterate(tox2, nullptr);
|
||||||
|
tox_iterate(tox3, nullptr);
|
||||||
|
|
||||||
|
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
||||||
|
tox_self_get_connection_status(tox1),
|
||||||
|
tox_self_get_connection_status(tox2),
|
||||||
|
tox_self_get_connection_status(tox3),
|
||||||
|
tox_friend_get_connection_status(tox2, 0, nullptr),
|
||||||
|
tox_friend_get_connection_status(tox3, 0, nullptr));
|
||||||
|
c_sleep(ITERATION_INTERVAL);
|
||||||
|
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_self_get_connection_status(tox3) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_friend_get_connection_status(tox2, 0, nullptr) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_friend_get_connection_status(tox3, 0, nullptr) == TOX_CONNECTION_NONE);
|
||||||
|
|
||||||
|
printf("Starting file transfer test: 100MiB file.\n");
|
||||||
|
|
||||||
|
file_accepted = file_size = sendf_ok = size_recv = 0;
|
||||||
|
file_recv = 0;
|
||||||
|
max_sending = UINT64_MAX;
|
||||||
|
uint64_t totalf_size = 100 * 1024 * 1024;
|
||||||
|
|
||||||
|
printf("Starting file streaming transfer test.\n");
|
||||||
|
|
||||||
|
file_sending_done = 0;
|
||||||
|
file_accepted = 0;
|
||||||
|
file_size = 0;
|
||||||
|
sendf_ok = 0;
|
||||||
|
size_recv = 0;
|
||||||
|
file_recv = 0;
|
||||||
|
tox_callback_file_recv_chunk(tox3, write_file);
|
||||||
|
tox_callback_file_recv_control(tox2, file_print_control);
|
||||||
|
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||||
|
tox_callback_file_recv_control(tox3, file_print_control);
|
||||||
|
tox_callback_file_recv(tox3, tox_file_receive);
|
||||||
|
totalf_size = UINT64_MAX;
|
||||||
|
Tox_File_Number fnum = tox_file_send(
|
||||||
|
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||||
|
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||||
|
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
||||||
|
|
||||||
|
Tox_Err_File_Get gfierr;
|
||||||
|
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
||||||
|
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
||||||
|
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
||||||
|
|
||||||
|
max_sending = 100 * 1024;
|
||||||
|
m_send_reached = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
tox_iterate(tox1, nullptr);
|
||||||
|
tox_iterate(tox2, nullptr);
|
||||||
|
tox_iterate(tox3, nullptr);
|
||||||
|
|
||||||
|
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
||||||
|
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||||
|
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||||
|
|
||||||
|
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
||||||
|
} while (!file_sending_done);
|
||||||
|
|
||||||
|
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
||||||
|
&& sending_pos == size_recv && file_accepted == 1,
|
||||||
|
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
||||||
|
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
||||||
|
(unsigned long)totalf_size, (unsigned long)file_size,
|
||||||
|
(unsigned long)size_recv, (unsigned long)sending_pos);
|
||||||
|
|
||||||
|
printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time);
|
||||||
|
|
||||||
|
tox_kill(tox1);
|
||||||
|
tox_kill(tox2);
|
||||||
|
tox_kill(tox3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
|
file_transfer_test();
|
||||||
|
return 0;
|
||||||
|
}
|
@ -13,9 +13,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
@ -261,53 +266,6 @@ static void file_transfer_test(void)
|
|||||||
|
|
||||||
printf("100MiB file sent in %lu seconds\n", (unsigned long)(time(nullptr) - f_time));
|
printf("100MiB file sent in %lu seconds\n", (unsigned long)(time(nullptr) - f_time));
|
||||||
|
|
||||||
printf("Starting file streaming transfer test.\n");
|
|
||||||
|
|
||||||
file_sending_done = 0;
|
|
||||||
file_accepted = 0;
|
|
||||||
file_size = 0;
|
|
||||||
sendf_ok = 0;
|
|
||||||
size_recv = 0;
|
|
||||||
file_recv = 0;
|
|
||||||
tox_callback_file_recv_chunk(tox3, write_file);
|
|
||||||
tox_callback_file_recv_control(tox2, file_print_control);
|
|
||||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
|
||||||
tox_callback_file_recv_control(tox3, file_print_control);
|
|
||||||
tox_callback_file_recv(tox3, tox_file_receive);
|
|
||||||
totalf_size = UINT64_MAX;
|
|
||||||
fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
|
||||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
|
||||||
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
|
||||||
|
|
||||||
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
|
||||||
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
|
||||||
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
|
||||||
|
|
||||||
max_sending = 100 * 1024;
|
|
||||||
m_send_reached = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
tox_iterate(tox1, nullptr);
|
|
||||||
tox_iterate(tox2, nullptr);
|
|
||||||
tox_iterate(tox3, nullptr);
|
|
||||||
|
|
||||||
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
|
||||||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
|
||||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
|
||||||
|
|
||||||
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
|
||||||
} while (!file_sending_done);
|
|
||||||
|
|
||||||
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
|
||||||
&& sending_pos == size_recv && file_accepted == 1,
|
|
||||||
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
|
||||||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
|
||||||
(unsigned long)totalf_size, (unsigned long)file_size,
|
|
||||||
(unsigned long)size_recv, (unsigned long)sending_pos);
|
|
||||||
|
|
||||||
printf("starting file 0 transfer test.\n");
|
printf("starting file 0 transfer test.\n");
|
||||||
|
|
||||||
file_sending_done = 0;
|
file_sending_done = 0;
|
||||||
|
@ -247,7 +247,7 @@ static void handle_user(State *state, const char *peer_name, size_t peer_name_le
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
||||||
Tox_Group_Mod_Event event, void *user_data)
|
Tox_Group_Mod_Event mod_type, void *user_data)
|
||||||
{
|
{
|
||||||
AutoTox *autotox = (AutoTox *)user_data;
|
AutoTox *autotox = (AutoTox *)user_data;
|
||||||
ck_assert(autotox != nullptr);
|
ck_assert(autotox != nullptr);
|
||||||
@ -275,7 +275,11 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
|||||||
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
||||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||||
|
|
||||||
switch (event) {
|
fprintf(stderr, "tox%u: got moderator event %d (%s), role = %s\n",
|
||||||
|
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
||||||
|
tox_group_role_to_string(role));
|
||||||
|
|
||||||
|
switch (mod_type) {
|
||||||
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
||||||
handle_mod(state, peer_name, peer_name_len, role);
|
handle_mod(state, peer_name, peer_name_len, role);
|
||||||
break;
|
break;
|
||||||
@ -298,7 +302,7 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
ck_assert_msg(0, "Got invalid moderator event %d", event);
|
ck_assert_msg(0, "Got invalid moderator event %d", mod_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TOX_LOCALHOST
|
#ifdef TOX_LOCALHOST
|
||||||
#undef TOX_LOCALHOST
|
#undef TOX_LOCALHOST
|
||||||
#endif
|
#endif
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
@ -74,6 +76,7 @@ static void reload_tox(Tox **tox, struct Tox_Options *const in_opts, void *user_
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Tox_Options *const options = (in_opts == nullptr) ? tox_options_new(nullptr) : in_opts;
|
struct Tox_Options *const options = (in_opts == nullptr) ? tox_options_new(nullptr) : in_opts;
|
||||||
|
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||||
|
|
||||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||||
|
|
||||||
@ -138,6 +141,7 @@ static void test_few_clients(void)
|
|||||||
time_t con_time = 0, cur_time = time(nullptr);
|
time_t con_time = 0, cur_time = time(nullptr);
|
||||||
|
|
||||||
struct Tox_Options *opts1 = tox_options_new(nullptr);
|
struct Tox_Options *opts1 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts1, USE_IPV6);
|
||||||
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
||||||
Tox_Err_New t_n_error;
|
Tox_Err_New t_n_error;
|
||||||
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
||||||
@ -145,12 +149,14 @@ static void test_few_clients(void)
|
|||||||
tox_options_free(opts1);
|
tox_options_free(opts1);
|
||||||
|
|
||||||
struct Tox_Options *opts2 = tox_options_new(nullptr);
|
struct Tox_Options *opts2 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts2, USE_IPV6);
|
||||||
tox_options_set_udp_enabled(opts2, false);
|
tox_options_set_udp_enabled(opts2, false);
|
||||||
tox_options_set_local_discovery_enabled(opts2, false);
|
tox_options_set_local_discovery_enabled(opts2, false);
|
||||||
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||||
|
|
||||||
struct Tox_Options *opts3 = tox_options_new(nullptr);
|
struct Tox_Options *opts3 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts3, USE_IPV6);
|
||||||
tox_options_set_local_discovery_enabled(opts3, false);
|
tox_options_set_local_discovery_enabled(opts3, false);
|
||||||
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||||
|
@ -13,9 +13,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
|
@ -1 +1 @@
|
|||||||
5061f92a95ba45cfa49d78175fa8fb6e4d66a58d86634ea3fd3ae6d80cb0558a /usr/local/bin/tox-bootstrapd
|
0b904988d79b9576bb88c6c7316d107b5a61bd6119a0992ebd7c1fa43db70abf /usr/local/bin/tox-bootstrapd
|
||||||
|
@ -56,15 +56,31 @@ std::string bin_pack_name_from_type(const std::string& type) {
|
|||||||
return "bin_pack_u8";
|
return "bin_pack_u8";
|
||||||
} else if (type == "bool") {
|
} else if (type == "bool") {
|
||||||
return "bin_pack_bool";
|
return "bin_pack_bool";
|
||||||
// only unpack is special TODO(Green-Sky): should we change that?
|
} else if (type == "Tox_User_Status") {
|
||||||
//} else if (type == "Tox_User_Status") {
|
return "tox_user_status_pack";
|
||||||
//return "tox_pack_user_status";
|
} else if (type == "Tox_Conference_Type") {
|
||||||
//} else if (type == "Tox_Conference_Type") {
|
return "tox_conference_type_pack";
|
||||||
//return "tox_pack_conference_type";
|
} else if (type == "Tox_Message_Type") {
|
||||||
|
return "tox_message_type_pack";
|
||||||
|
} else if (type == "Tox_File_Control") {
|
||||||
|
return "tox_file_control_pack";
|
||||||
|
} else if (type == "Tox_Connection") {
|
||||||
|
return "tox_connection_pack";
|
||||||
|
} else if (type == "Tox_Group_Privacy_State") {
|
||||||
|
return "tox_group_privacy_state_pack";
|
||||||
|
} else if (type == "Tox_Group_Voice_State") {
|
||||||
|
return "tox_group_voice_state_pack";
|
||||||
|
} else if (type == "Tox_Group_Topic_Lock") {
|
||||||
|
return "tox_group_topic_lock_pack";
|
||||||
|
} else if (type == "Tox_Group_Join_Fail") {
|
||||||
|
return "tox_group_join_fail_pack";
|
||||||
|
} else if (type == "Tox_Group_Mod_Event") {
|
||||||
|
return "tox_group_mod_event_pack";
|
||||||
|
} else if (type == "Tox_Group_Exit_Type") {
|
||||||
|
return "tox_group_exit_type_pack";
|
||||||
} else {
|
} else {
|
||||||
//std::cerr << "unknown type " << type << "\n";
|
std::cerr << "unknown type " << type << "\n";
|
||||||
//exit(1);
|
exit(1);
|
||||||
// assume enum -> u32
|
|
||||||
return "bin_pack_u32";
|
return "bin_pack_u32";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +180,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
|
|||||||
#include "../tox_events.h")";
|
#include "../tox_events.h")";
|
||||||
if (need_tox_unpack_h) {
|
if (need_tox_unpack_h) {
|
||||||
f << R"(
|
f << R"(
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h")";
|
#include "../tox_unpack.h")";
|
||||||
}
|
}
|
||||||
f << R"(
|
f << R"(
|
||||||
@ -310,20 +327,30 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
|
|||||||
// pack
|
// pack
|
||||||
f << "bool tox_event_" << event_name_l << "_pack(\n";
|
f << "bool tox_event_" << event_name_l << "_pack(\n";
|
||||||
f << " const Tox_Event_" << event_name << " *event, Bin_Pack *bp)\n{\n";
|
f << " const Tox_Event_" << event_name << " *event, Bin_Pack *bp)\n{\n";
|
||||||
f << " assert(event != nullptr);\n";
|
|
||||||
f << " return bin_pack_array(bp, 2)\n";
|
bool return_started = false;
|
||||||
f << " && bin_pack_u32(bp, TOX_EVENT_" << str_toupper(event_name) << ")";
|
|
||||||
if (event_types.size() > 1) {
|
if (event_types.size() > 1) {
|
||||||
f << "\n && bin_pack_array(bp, " << event_types.size() << ")";
|
f << " return bin_pack_array(bp, " << event_types.size() << ")";
|
||||||
|
return_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& t : event_types) {
|
for (const auto& t : event_types) {
|
||||||
|
if (return_started) {
|
||||||
f << "\n && ";
|
f << "\n && ";
|
||||||
|
} else {
|
||||||
|
f << " return ";
|
||||||
|
}
|
||||||
|
|
||||||
std::visit(
|
std::visit(
|
||||||
overloaded{
|
overloaded{
|
||||||
[&](const EventTypeTrivial& t) {
|
[&](const EventTypeTrivial& t) {
|
||||||
f << bin_pack_name_from_type(t.type);
|
f << bin_pack_name_from_type(t.type);
|
||||||
|
if (t.type.rfind("Tox_", 0) == 0) {
|
||||||
|
f << "(event->" << t.name << ", bp)";
|
||||||
|
} else {
|
||||||
f << "(bp, event->" << t.name << ")";
|
f << "(bp, event->" << t.name << ")";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[&](const EventTypeByteRange& t) {
|
[&](const EventTypeByteRange& t) {
|
||||||
f << "bin_pack_bin(bp, event->" << t.name_data << ", event->" << t.name_length << ")";
|
f << "bin_pack_bin(bp, event->" << t.name_data << ", event->" << t.name_length << ")";
|
||||||
@ -354,7 +381,11 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
|
|||||||
overloaded{
|
overloaded{
|
||||||
[&](const EventTypeTrivial& t) {
|
[&](const EventTypeTrivial& t) {
|
||||||
f << bin_unpack_name_from_type(t.type);
|
f << bin_unpack_name_from_type(t.type);
|
||||||
|
if (t.type.rfind("Tox_", 0) == 0) {
|
||||||
|
f << "(&event->" << t.name << ", bu)";
|
||||||
|
} else {
|
||||||
f << "(bu, &event->" << t.name << ")";
|
f << "(bu, &event->" << t.name << ")";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[&](const EventTypeByteRange& t) {
|
[&](const EventTypeByteRange& t) {
|
||||||
f << "bin_unpack_bin(bu, &event->" << t.name_data << ", &event->" << t.name_length << ")";
|
f << "bin_unpack_bin(bu, &event->" << t.name_data << ", &event->" << t.name_length << ")";
|
||||||
|
25
external/toxcore/c-toxcore/toxcore/BUILD.bazel
vendored
25
external/toxcore/c-toxcore/toxcore/BUILD.bazel
vendored
@ -730,17 +730,6 @@ cc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_test(
|
|
||||||
name = "friend_connection_test",
|
|
||||||
size = "small",
|
|
||||||
srcs = ["friend_connection_test.cc"],
|
|
||||||
deps = [
|
|
||||||
":friend_connection",
|
|
||||||
"@com_google_googletest//:gtest",
|
|
||||||
"@com_google_googletest//:gtest_main",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "friend_requests",
|
name = "friend_requests",
|
||||||
srcs = ["friend_requests.c"],
|
srcs = ["friend_requests.c"],
|
||||||
@ -903,6 +892,19 @@ cc_test(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "tox_pack",
|
||||||
|
srcs = ["tox_pack.c"],
|
||||||
|
hdrs = ["tox_pack.h"],
|
||||||
|
visibility = ["//c-toxcore:__subpackages__"],
|
||||||
|
deps = [
|
||||||
|
":attributes",
|
||||||
|
":bin_pack",
|
||||||
|
":ccompat",
|
||||||
|
":tox",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "tox_unpack",
|
name = "tox_unpack",
|
||||||
srcs = ["tox_unpack.c"],
|
srcs = ["tox_unpack.c"],
|
||||||
@ -937,6 +939,7 @@ cc_library(
|
|||||||
":ccompat",
|
":ccompat",
|
||||||
":mem",
|
":mem",
|
||||||
":tox",
|
":tox",
|
||||||
|
":tox_pack",
|
||||||
":tox_unpack",
|
":tox_unpack",
|
||||||
"//c-toxcore/third_party:cmp",
|
"//c-toxcore/third_party:cmp",
|
||||||
],
|
],
|
||||||
|
@ -94,6 +94,8 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
|
|||||||
../toxcore/tox_event.c \
|
../toxcore/tox_event.c \
|
||||||
../toxcore/tox_events.h \
|
../toxcore/tox_events.h \
|
||||||
../toxcore/tox_events.c \
|
../toxcore/tox_events.c \
|
||||||
|
../toxcore/tox_pack.h \
|
||||||
|
../toxcore/tox_pack.c \
|
||||||
../toxcore/tox_unpack.h \
|
../toxcore/tox_unpack.h \
|
||||||
../toxcore/tox_unpack.c \
|
../toxcore/tox_unpack.c \
|
||||||
../toxcore/tox_private.c \
|
../toxcore/tox_private.c \
|
||||||
|
@ -54,10 +54,7 @@ static void tox_event_conference_connected_destruct(Tox_Event_Conference_Connect
|
|||||||
bool tox_event_conference_connected_pack(
|
bool tox_event_conference_connected_pack(
|
||||||
const Tox_Event_Conference_Connected *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Connected *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_u32(bp, event->conference_number);
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_CONNECTED)
|
|
||||||
&& bin_pack_u32(bp, event->conference_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -107,12 +108,9 @@ static void tox_event_conference_invite_destruct(Tox_Event_Conference_Invite *co
|
|||||||
bool tox_event_conference_invite_pack(
|
bool tox_event_conference_invite_pack(
|
||||||
const Tox_Event_Conference_Invite *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Invite *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_INVITE)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->type)
|
&& tox_conference_type_pack(event->type, bp)
|
||||||
&& bin_pack_bin(bp, event->cookie, event->cookie_length);
|
&& bin_pack_bin(bp, event->cookie, event->cookie_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +124,7 @@ static bool tox_event_conference_invite_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->friend_number)
|
return bin_unpack_u32(bu, &event->friend_number)
|
||||||
&& tox_conference_type_unpack(bu, &event->type)
|
&& tox_conference_type_unpack(&event->type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->cookie, &event->cookie_length);
|
&& bin_unpack_bin(bu, &event->cookie, &event->cookie_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -121,13 +122,10 @@ static void tox_event_conference_message_destruct(Tox_Event_Conference_Message *
|
|||||||
bool tox_event_conference_message_pack(
|
bool tox_event_conference_message_pack(
|
||||||
const Tox_Event_Conference_Message *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Message *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 4)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_MESSAGE)
|
|
||||||
&& bin_pack_array(bp, 4)
|
|
||||||
&& bin_pack_u32(bp, event->conference_number)
|
&& bin_pack_u32(bp, event->conference_number)
|
||||||
&& bin_pack_u32(bp, event->peer_number)
|
&& bin_pack_u32(bp, event->peer_number)
|
||||||
&& bin_pack_u32(bp, event->type)
|
&& tox_message_type_pack(event->type, bp)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length);
|
&& bin_pack_bin(bp, event->message, event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +140,7 @@ static bool tox_event_conference_message_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->conference_number)
|
return bin_unpack_u32(bu, &event->conference_number)
|
||||||
&& bin_unpack_u32(bu, &event->peer_number)
|
&& bin_unpack_u32(bu, &event->peer_number)
|
||||||
&& tox_message_type_unpack(bu, &event->type)
|
&& tox_message_type_unpack(&event->type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,7 @@ static void tox_event_conference_peer_list_changed_destruct(Tox_Event_Conference
|
|||||||
bool tox_event_conference_peer_list_changed_pack(
|
bool tox_event_conference_peer_list_changed_pack(
|
||||||
const Tox_Event_Conference_Peer_List_Changed *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Peer_List_Changed *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_u32(bp, event->conference_number);
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED)
|
|
||||||
&& bin_pack_u32(bp, event->conference_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_conference_peer_name_destruct(Tox_Event_Conference_Peer_Na
|
|||||||
bool tox_event_conference_peer_name_pack(
|
bool tox_event_conference_peer_name_pack(
|
||||||
const Tox_Event_Conference_Peer_Name *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Peer_Name *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_PEER_NAME)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->conference_number)
|
&& bin_pack_u32(bp, event->conference_number)
|
||||||
&& bin_pack_u32(bp, event->peer_number)
|
&& bin_pack_u32(bp, event->peer_number)
|
||||||
&& bin_pack_bin(bp, event->name, event->name_length);
|
&& bin_pack_bin(bp, event->name, event->name_length);
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_conference_title_destruct(Tox_Event_Conference_Title *conf
|
|||||||
bool tox_event_conference_title_pack(
|
bool tox_event_conference_title_pack(
|
||||||
const Tox_Event_Conference_Title *event, Bin_Pack *bp)
|
const Tox_Event_Conference_Title *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_TITLE)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->conference_number)
|
&& bin_pack_u32(bp, event->conference_number)
|
||||||
&& bin_pack_u32(bp, event->peer_number)
|
&& bin_pack_u32(bp, event->peer_number)
|
||||||
&& bin_pack_bin(bp, event->title, event->title_length);
|
&& bin_pack_bin(bp, event->title, event->title_length);
|
||||||
|
@ -96,10 +96,7 @@ static void tox_event_file_chunk_request_destruct(Tox_Event_File_Chunk_Request *
|
|||||||
bool tox_event_file_chunk_request_pack(
|
bool tox_event_file_chunk_request_pack(
|
||||||
const Tox_Event_File_Chunk_Request *event, Bin_Pack *bp)
|
const Tox_Event_File_Chunk_Request *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 4)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FILE_CHUNK_REQUEST)
|
|
||||||
&& bin_pack_array(bp, 4)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->file_number)
|
&& bin_pack_u32(bp, event->file_number)
|
||||||
&& bin_pack_u64(bp, event->position)
|
&& bin_pack_u64(bp, event->position)
|
||||||
|
@ -134,10 +134,7 @@ static void tox_event_file_recv_destruct(Tox_Event_File_Recv *file_recv, const M
|
|||||||
bool tox_event_file_recv_pack(
|
bool tox_event_file_recv_pack(
|
||||||
const Tox_Event_File_Recv *event, Bin_Pack *bp)
|
const Tox_Event_File_Recv *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 5)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV)
|
|
||||||
&& bin_pack_array(bp, 5)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->file_number)
|
&& bin_pack_u32(bp, event->file_number)
|
||||||
&& bin_pack_u32(bp, event->kind)
|
&& bin_pack_u32(bp, event->kind)
|
||||||
|
@ -120,10 +120,7 @@ static void tox_event_file_recv_chunk_destruct(Tox_Event_File_Recv_Chunk *file_r
|
|||||||
bool tox_event_file_recv_chunk_pack(
|
bool tox_event_file_recv_chunk_pack(
|
||||||
const Tox_Event_File_Recv_Chunk *event, Bin_Pack *bp)
|
const Tox_Event_File_Recv_Chunk *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 4)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV_CHUNK)
|
|
||||||
&& bin_pack_array(bp, 4)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->file_number)
|
&& bin_pack_u32(bp, event->file_number)
|
||||||
&& bin_pack_u64(bp, event->position)
|
&& bin_pack_u64(bp, event->position)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -83,13 +84,10 @@ static void tox_event_file_recv_control_destruct(Tox_Event_File_Recv_Control *fi
|
|||||||
bool tox_event_file_recv_control_pack(
|
bool tox_event_file_recv_control_pack(
|
||||||
const Tox_Event_File_Recv_Control *event, Bin_Pack *bp)
|
const Tox_Event_File_Recv_Control *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV_CONTROL)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->file_number)
|
&& bin_pack_u32(bp, event->file_number)
|
||||||
&& bin_pack_u32(bp, event->control);
|
&& tox_file_control_pack(event->control, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -103,7 +101,7 @@ static bool tox_event_file_recv_control_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->friend_number)
|
return bin_unpack_u32(bu, &event->friend_number)
|
||||||
&& bin_unpack_u32(bu, &event->file_number)
|
&& bin_unpack_u32(bu, &event->file_number)
|
||||||
&& tox_file_control_unpack(bu, &event->control);
|
&& tox_file_control_unpack(&event->control, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_friend_connection_status_destruct(Tox_Event_Friend_Connect
|
|||||||
bool tox_event_friend_connection_status_pack(
|
bool tox_event_friend_connection_status_pack(
|
||||||
const Tox_Event_Friend_Connection_Status *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Connection_Status *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_CONNECTION_STATUS)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->connection_status);
|
&& tox_connection_pack(event->connection_status, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_friend_connection_status_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->friend_number)
|
return bin_unpack_u32(bu, &event->friend_number)
|
||||||
&& tox_connection_unpack(bu, &event->connection_status);
|
&& tox_connection_unpack(&event->connection_status, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,10 +92,7 @@ static void tox_event_friend_lossless_packet_destruct(Tox_Event_Friend_Lossless_
|
|||||||
bool tox_event_friend_lossless_packet_pack(
|
bool tox_event_friend_lossless_packet_pack(
|
||||||
const Tox_Event_Friend_Lossless_Packet *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Lossless_Packet *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_LOSSLESS_PACKET)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bin(bp, event->data, event->data_length);
|
&& bin_pack_bin(bp, event->data, event->data_length);
|
||||||
}
|
}
|
||||||
|
@ -92,10 +92,7 @@ static void tox_event_friend_lossy_packet_destruct(Tox_Event_Friend_Lossy_Packet
|
|||||||
bool tox_event_friend_lossy_packet_pack(
|
bool tox_event_friend_lossy_packet_pack(
|
||||||
const Tox_Event_Friend_Lossy_Packet *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Lossy_Packet *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_LOSSY_PACKET)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bin(bp, event->data, event->data_length);
|
&& bin_pack_bin(bp, event->data, event->data_length);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -107,12 +108,9 @@ static void tox_event_friend_message_destruct(Tox_Event_Friend_Message *friend_m
|
|||||||
bool tox_event_friend_message_pack(
|
bool tox_event_friend_message_pack(
|
||||||
const Tox_Event_Friend_Message *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Message *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_MESSAGE)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->type)
|
&& tox_message_type_pack(event->type, bp)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length);
|
&& bin_pack_bin(bp, event->message, event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +124,7 @@ static bool tox_event_friend_message_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->friend_number)
|
return bin_unpack_u32(bu, &event->friend_number)
|
||||||
&& tox_message_type_unpack(bu, &event->type)
|
&& tox_message_type_unpack(&event->type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,10 +92,7 @@ static void tox_event_friend_name_destruct(Tox_Event_Friend_Name *friend_name, c
|
|||||||
bool tox_event_friend_name_pack(
|
bool tox_event_friend_name_pack(
|
||||||
const Tox_Event_Friend_Name *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Name *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_NAME)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bin(bp, event->name, event->name_length);
|
&& bin_pack_bin(bp, event->name, event->name_length);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,7 @@ static void tox_event_friend_read_receipt_destruct(Tox_Event_Friend_Read_Receipt
|
|||||||
bool tox_event_friend_read_receipt_pack(
|
bool tox_event_friend_read_receipt_pack(
|
||||||
const Tox_Event_Friend_Read_Receipt *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Read_Receipt *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_READ_RECEIPT)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->message_id);
|
&& bin_pack_u32(bp, event->message_id);
|
||||||
}
|
}
|
||||||
|
@ -93,10 +93,7 @@ static void tox_event_friend_request_destruct(Tox_Event_Friend_Request *friend_r
|
|||||||
bool tox_event_friend_request_pack(
|
bool tox_event_friend_request_pack(
|
||||||
const Tox_Event_Friend_Request *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Request *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_REQUEST)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_bin(bp, event->public_key, TOX_PUBLIC_KEY_SIZE)
|
&& bin_pack_bin(bp, event->public_key, TOX_PUBLIC_KEY_SIZE)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length);
|
&& bin_pack_bin(bp, event->message, event->message_length);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_friend_status_destruct(Tox_Event_Friend_Status *friend_sta
|
|||||||
bool tox_event_friend_status_pack(
|
bool tox_event_friend_status_pack(
|
||||||
const Tox_Event_Friend_Status *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Status *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_STATUS)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_u32(bp, event->status);
|
&& tox_user_status_pack(event->status, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_friend_status_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->friend_number)
|
return bin_unpack_u32(bu, &event->friend_number)
|
||||||
&& tox_user_status_unpack(bu, &event->status);
|
&& tox_user_status_unpack(&event->status, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,10 +92,7 @@ static void tox_event_friend_status_message_destruct(Tox_Event_Friend_Status_Mes
|
|||||||
bool tox_event_friend_status_message_pack(
|
bool tox_event_friend_status_message_pack(
|
||||||
const Tox_Event_Friend_Status_Message *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Status_Message *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_STATUS_MESSAGE)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length);
|
&& bin_pack_bin(bp, event->message, event->message_length);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,7 @@ static void tox_event_friend_typing_destruct(Tox_Event_Friend_Typing *friend_typ
|
|||||||
bool tox_event_friend_typing_pack(
|
bool tox_event_friend_typing_pack(
|
||||||
const Tox_Event_Friend_Typing *event, Bin_Pack *bp)
|
const Tox_Event_Friend_Typing *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_TYPING)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bool(bp, event->typing);
|
&& bin_pack_bool(bp, event->typing);
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_group_custom_packet_destruct(Tox_Event_Group_Custom_Packet
|
|||||||
bool tox_event_group_custom_packet_pack(
|
bool tox_event_group_custom_packet_pack(
|
||||||
const Tox_Event_Group_Custom_Packet *event, Bin_Pack *bp)
|
const Tox_Event_Group_Custom_Packet *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_CUSTOM_PACKET)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_bin(bp, event->data, event->data_length);
|
&& bin_pack_bin(bp, event->data, event->data_length);
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_group_custom_private_packet_destruct(Tox_Event_Group_Custo
|
|||||||
bool tox_event_group_custom_private_packet_pack(
|
bool tox_event_group_custom_private_packet_pack(
|
||||||
const Tox_Event_Group_Custom_Private_Packet *event, Bin_Pack *bp)
|
const Tox_Event_Group_Custom_Private_Packet *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_bin(bp, event->data, event->data_length);
|
&& bin_pack_bin(bp, event->data, event->data_length);
|
||||||
|
@ -129,10 +129,7 @@ static void tox_event_group_invite_destruct(Tox_Event_Group_Invite *group_invite
|
|||||||
bool tox_event_group_invite_pack(
|
bool tox_event_group_invite_pack(
|
||||||
const Tox_Event_Group_Invite *event, Bin_Pack *bp)
|
const Tox_Event_Group_Invite *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_INVITE)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->friend_number)
|
&& bin_pack_u32(bp, event->friend_number)
|
||||||
&& bin_pack_bin(bp, event->invite_data, event->invite_data_length)
|
&& bin_pack_bin(bp, event->invite_data, event->invite_data_length)
|
||||||
&& bin_pack_bin(bp, event->group_name, event->group_name_length);
|
&& bin_pack_bin(bp, event->group_name, event->group_name_length);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_group_join_fail_destruct(Tox_Event_Group_Join_Fail *group_
|
|||||||
bool tox_event_group_join_fail_pack(
|
bool tox_event_group_join_fail_pack(
|
||||||
const Tox_Event_Group_Join_Fail *event, Bin_Pack *bp)
|
const Tox_Event_Group_Join_Fail *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_JOIN_FAIL)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->fail_type);
|
&& tox_group_join_fail_pack(event->fail_type, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_group_join_fail_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& tox_group_join_fail_unpack(bu, &event->fail_type);
|
&& tox_group_join_fail_unpack(&event->fail_type, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -135,13 +136,10 @@ static void tox_event_group_message_destruct(Tox_Event_Group_Message *group_mess
|
|||||||
bool tox_event_group_message_pack(
|
bool tox_event_group_message_pack(
|
||||||
const Tox_Event_Group_Message *event, Bin_Pack *bp)
|
const Tox_Event_Group_Message *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 5)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_MESSAGE)
|
|
||||||
&& bin_pack_array(bp, 5)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_u32(bp, event->type)
|
&& tox_message_type_pack(event->type, bp)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length)
|
&& bin_pack_bin(bp, event->message, event->message_length)
|
||||||
&& bin_pack_u32(bp, event->message_id);
|
&& bin_pack_u32(bp, event->message_id);
|
||||||
}
|
}
|
||||||
@ -157,7 +155,7 @@ static bool tox_event_group_message_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& bin_unpack_u32(bu, &event->peer_id)
|
&& bin_unpack_u32(bu, &event->peer_id)
|
||||||
&& tox_message_type_unpack(bu, &event->type)
|
&& tox_message_type_unpack(&event->type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->message, &event->message_length)
|
&& bin_unpack_bin(bu, &event->message, &event->message_length)
|
||||||
&& bin_unpack_u32(bu, &event->message_id);
|
&& bin_unpack_u32(bu, &event->message_id);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -97,14 +98,11 @@ static void tox_event_group_moderation_destruct(Tox_Event_Group_Moderation *grou
|
|||||||
bool tox_event_group_moderation_pack(
|
bool tox_event_group_moderation_pack(
|
||||||
const Tox_Event_Group_Moderation *event, Bin_Pack *bp)
|
const Tox_Event_Group_Moderation *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 4)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_MODERATION)
|
|
||||||
&& bin_pack_array(bp, 4)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->source_peer_id)
|
&& bin_pack_u32(bp, event->source_peer_id)
|
||||||
&& bin_pack_u32(bp, event->target_peer_id)
|
&& bin_pack_u32(bp, event->target_peer_id)
|
||||||
&& bin_pack_u32(bp, event->mod_type);
|
&& tox_group_mod_event_pack(event->mod_type, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -119,7 +117,7 @@ static bool tox_event_group_moderation_unpack_into(
|
|||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& bin_unpack_u32(bu, &event->source_peer_id)
|
&& bin_unpack_u32(bu, &event->source_peer_id)
|
||||||
&& bin_unpack_u32(bu, &event->target_peer_id)
|
&& bin_unpack_u32(bu, &event->target_peer_id)
|
||||||
&& tox_group_mod_event_unpack(bu, &event->mod_type);
|
&& tox_group_mod_event_unpack(&event->mod_type, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,10 +92,7 @@ static void tox_event_group_password_destruct(Tox_Event_Group_Password *group_pa
|
|||||||
bool tox_event_group_password_pack(
|
bool tox_event_group_password_pack(
|
||||||
const Tox_Event_Group_Password *event, Bin_Pack *bp)
|
const Tox_Event_Group_Password *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PASSWORD)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_bin(bp, event->password, event->password_length);
|
&& bin_pack_bin(bp, event->password, event->password_length);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -158,13 +159,10 @@ static void tox_event_group_peer_exit_destruct(Tox_Event_Group_Peer_Exit *group_
|
|||||||
bool tox_event_group_peer_exit_pack(
|
bool tox_event_group_peer_exit_pack(
|
||||||
const Tox_Event_Group_Peer_Exit *event, Bin_Pack *bp)
|
const Tox_Event_Group_Peer_Exit *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 5)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_EXIT)
|
|
||||||
&& bin_pack_array(bp, 5)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_u32(bp, event->exit_type)
|
&& tox_group_exit_type_pack(event->exit_type, bp)
|
||||||
&& bin_pack_bin(bp, event->name, event->name_length)
|
&& bin_pack_bin(bp, event->name, event->name_length)
|
||||||
&& bin_pack_bin(bp, event->part_message, event->part_message_length);
|
&& bin_pack_bin(bp, event->part_message, event->part_message_length);
|
||||||
}
|
}
|
||||||
@ -180,7 +178,7 @@ static bool tox_event_group_peer_exit_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& bin_unpack_u32(bu, &event->peer_id)
|
&& bin_unpack_u32(bu, &event->peer_id)
|
||||||
&& tox_group_exit_type_unpack(bu, &event->exit_type)
|
&& tox_group_exit_type_unpack(&event->exit_type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->name, &event->name_length)
|
&& bin_unpack_bin(bu, &event->name, &event->name_length)
|
||||||
&& bin_unpack_bin(bu, &event->part_message, &event->part_message_length);
|
&& bin_unpack_bin(bu, &event->part_message, &event->part_message_length);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,7 @@ static void tox_event_group_peer_join_destruct(Tox_Event_Group_Peer_Join *group_
|
|||||||
bool tox_event_group_peer_join_pack(
|
bool tox_event_group_peer_join_pack(
|
||||||
const Tox_Event_Group_Peer_Join *event, Bin_Pack *bp)
|
const Tox_Event_Group_Peer_Join *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_JOIN)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id);
|
&& bin_pack_u32(bp, event->peer_id);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,7 @@ static void tox_event_group_peer_limit_destruct(Tox_Event_Group_Peer_Limit *grou
|
|||||||
bool tox_event_group_peer_limit_pack(
|
bool tox_event_group_peer_limit_pack(
|
||||||
const Tox_Event_Group_Peer_Limit *event, Bin_Pack *bp)
|
const Tox_Event_Group_Peer_Limit *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_LIMIT)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_limit);
|
&& bin_pack_u32(bp, event->peer_limit);
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_group_peer_name_destruct(Tox_Event_Group_Peer_Name *group_
|
|||||||
bool tox_event_group_peer_name_pack(
|
bool tox_event_group_peer_name_pack(
|
||||||
const Tox_Event_Group_Peer_Name *event, Bin_Pack *bp)
|
const Tox_Event_Group_Peer_Name *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_NAME)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_bin(bp, event->name, event->name_length);
|
&& bin_pack_bin(bp, event->name, event->name_length);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -83,13 +84,10 @@ static void tox_event_group_peer_status_destruct(Tox_Event_Group_Peer_Status *gr
|
|||||||
bool tox_event_group_peer_status_pack(
|
bool tox_event_group_peer_status_pack(
|
||||||
const Tox_Event_Group_Peer_Status *event, Bin_Pack *bp)
|
const Tox_Event_Group_Peer_Status *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_STATUS)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_u32(bp, event->status);
|
&& tox_user_status_pack(event->status, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -103,7 +101,7 @@ static bool tox_event_group_peer_status_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& bin_unpack_u32(bu, &event->peer_id)
|
&& bin_unpack_u32(bu, &event->peer_id)
|
||||||
&& tox_user_status_unpack(bu, &event->status);
|
&& tox_user_status_unpack(&event->status, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_group_privacy_state_destruct(Tox_Event_Group_Privacy_State
|
|||||||
bool tox_event_group_privacy_state_pack(
|
bool tox_event_group_privacy_state_pack(
|
||||||
const Tox_Event_Group_Privacy_State *event, Bin_Pack *bp)
|
const Tox_Event_Group_Privacy_State *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PRIVACY_STATE)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->privacy_state);
|
&& tox_group_privacy_state_pack(event->privacy_state, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_group_privacy_state_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& tox_group_privacy_state_unpack(bu, &event->privacy_state);
|
&& tox_group_privacy_state_unpack(&event->privacy_state, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -121,13 +122,10 @@ static void tox_event_group_private_message_destruct(Tox_Event_Group_Private_Mes
|
|||||||
bool tox_event_group_private_message_pack(
|
bool tox_event_group_private_message_pack(
|
||||||
const Tox_Event_Group_Private_Message *event, Bin_Pack *bp)
|
const Tox_Event_Group_Private_Message *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 4)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PRIVATE_MESSAGE)
|
|
||||||
&& bin_pack_array(bp, 4)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_u32(bp, event->type)
|
&& tox_message_type_pack(event->type, bp)
|
||||||
&& bin_pack_bin(bp, event->message, event->message_length);
|
&& bin_pack_bin(bp, event->message, event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +140,7 @@ static bool tox_event_group_private_message_unpack_into(
|
|||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& bin_unpack_u32(bu, &event->peer_id)
|
&& bin_unpack_u32(bu, &event->peer_id)
|
||||||
&& tox_message_type_unpack(bu, &event->type)
|
&& tox_message_type_unpack(&event->type, bu)
|
||||||
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
&& bin_unpack_bin(bu, &event->message, &event->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,7 @@ static void tox_event_group_self_join_destruct(Tox_Event_Group_Self_Join *group_
|
|||||||
bool tox_event_group_self_join_pack(
|
bool tox_event_group_self_join_pack(
|
||||||
const Tox_Event_Group_Self_Join *event, Bin_Pack *bp)
|
const Tox_Event_Group_Self_Join *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_u32(bp, event->group_number);
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_SELF_JOIN)
|
|
||||||
&& bin_pack_u32(bp, event->group_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
|
@ -106,10 +106,7 @@ static void tox_event_group_topic_destruct(Tox_Event_Group_Topic *group_topic, c
|
|||||||
bool tox_event_group_topic_pack(
|
bool tox_event_group_topic_pack(
|
||||||
const Tox_Event_Group_Topic *event, Bin_Pack *bp)
|
const Tox_Event_Group_Topic *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return bin_pack_array(bp, 3)
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_TOPIC)
|
|
||||||
&& bin_pack_array(bp, 3)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->peer_id)
|
&& bin_pack_u32(bp, event->peer_id)
|
||||||
&& bin_pack_bin(bp, event->topic, event->topic_length);
|
&& bin_pack_bin(bp, event->topic, event->topic_length);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_group_topic_lock_destruct(Tox_Event_Group_Topic_Lock *grou
|
|||||||
bool tox_event_group_topic_lock_pack(
|
bool tox_event_group_topic_lock_pack(
|
||||||
const Tox_Event_Group_Topic_Lock *event, Bin_Pack *bp)
|
const Tox_Event_Group_Topic_Lock *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_TOPIC_LOCK)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->topic_lock);
|
&& tox_group_topic_lock_pack(event->topic_lock, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_group_topic_lock_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& tox_group_topic_lock_unpack(bu, &event->topic_lock);
|
&& tox_group_topic_lock_unpack(&event->topic_lock, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -69,12 +70,9 @@ static void tox_event_group_voice_state_destruct(Tox_Event_Group_Voice_State *gr
|
|||||||
bool tox_event_group_voice_state_pack(
|
bool tox_event_group_voice_state_pack(
|
||||||
const Tox_Event_Group_Voice_State *event, Bin_Pack *bp)
|
const Tox_Event_Group_Voice_State *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
|
||||||
return bin_pack_array(bp, 2)
|
return bin_pack_array(bp, 2)
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_GROUP_VOICE_STATE)
|
|
||||||
&& bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, event->group_number)
|
&& bin_pack_u32(bp, event->group_number)
|
||||||
&& bin_pack_u32(bp, event->voice_state);
|
&& tox_group_voice_state_pack(event->voice_state, bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -87,7 +85,7 @@ static bool tox_event_group_voice_state_unpack_into(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return bin_unpack_u32(bu, &event->group_number)
|
return bin_unpack_u32(bu, &event->group_number)
|
||||||
&& tox_group_voice_state_unpack(bu, &event->voice_state);
|
&& tox_group_voice_state_unpack(&event->voice_state, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../mem.h"
|
#include "../mem.h"
|
||||||
#include "../tox.h"
|
#include "../tox.h"
|
||||||
#include "../tox_events.h"
|
#include "../tox_events.h"
|
||||||
|
#include "../tox_pack.h"
|
||||||
#include "../tox_unpack.h"
|
#include "../tox_unpack.h"
|
||||||
|
|
||||||
|
|
||||||
@ -55,10 +56,7 @@ static void tox_event_self_connection_status_destruct(Tox_Event_Self_Connection_
|
|||||||
bool tox_event_self_connection_status_pack(
|
bool tox_event_self_connection_status_pack(
|
||||||
const Tox_Event_Self_Connection_Status *event, Bin_Pack *bp)
|
const Tox_Event_Self_Connection_Status *event, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
return tox_connection_pack(event->connection_status, bp);
|
||||||
return bin_pack_array(bp, 2)
|
|
||||||
&& bin_pack_u32(bp, TOX_EVENT_SELF_CONNECTION_STATUS)
|
|
||||||
&& bin_pack_u32(bp, event->connection_status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
@ -66,7 +64,7 @@ static bool tox_event_self_connection_status_unpack_into(
|
|||||||
Tox_Event_Self_Connection_Status *event, Bin_Unpack *bu)
|
Tox_Event_Self_Connection_Status *event, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
assert(event != nullptr);
|
assert(event != nullptr);
|
||||||
return tox_connection_unpack(bu, &event->connection_status);
|
return tox_connection_unpack(&event->connection_status, bu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include "friend_connection.h"
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// TODO(Jfreegman) make this useful or remove it after NGC is merged
|
|
||||||
TEST(friend_connection, NullTest)
|
|
||||||
{
|
|
||||||
(void)friend_conn_get_onion_friendnum;
|
|
||||||
(void)friend_conn_get_dht_ip_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
5
external/toxcore/c-toxcore/toxcore/network.c
vendored
5
external/toxcore/c-toxcore/toxcore/network.c
vendored
@ -946,8 +946,9 @@ int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packe
|
|||||||
if (net_family_is_ipv4(net->family) && !net_family_is_ipv4(ipp_copy.ip.family)) {
|
if (net_family_is_ipv4(net->family) && !net_family_is_ipv4(ipp_copy.ip.family)) {
|
||||||
// TODO(iphydf): Make this an error. Occasionally we try to send to an
|
// TODO(iphydf): Make this an error. Occasionally we try to send to an
|
||||||
// all-zero ip_port.
|
// all-zero ip_port.
|
||||||
LOGGER_WARNING(net->log, "attempted to send message with network family %d (probably IPv6) on IPv4 socket",
|
Ip_Ntoa ip_str;
|
||||||
ipp_copy.ip.family.value);
|
LOGGER_WARNING(net->log, "attempted to send message with network family %d (probably IPv6) on IPv4 socket (%s)",
|
||||||
|
ipp_copy.ip.family.value, net_ip_ntoa(&ipp_copy.ip, &ip_str));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
external/toxcore/c-toxcore/toxcore/onion.c
vendored
8
external/toxcore/c-toxcore/toxcore/onion.c
vendored
@ -48,7 +48,7 @@ static void change_symmetric_key(Onion *onion)
|
|||||||
|
|
||||||
/** packing and unpacking functions */
|
/** packing and unpacking functions */
|
||||||
non_null()
|
non_null()
|
||||||
static void ip_pack(uint8_t *data, const IP *source)
|
static void ip_pack_to_bytes(uint8_t *data, const IP *source)
|
||||||
{
|
{
|
||||||
data[0] = source->family.value;
|
data[0] = source->family.value;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ static void ip_pack(uint8_t *data, const IP *source)
|
|||||||
|
|
||||||
/** return 0 on success, -1 on failure. */
|
/** return 0 on success, -1 on failure. */
|
||||||
non_null()
|
non_null()
|
||||||
static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_size, bool disable_family_check)
|
static int ip_unpack_from_bytes(IP *target, const uint8_t *data, unsigned int data_size, bool disable_family_check)
|
||||||
{
|
{
|
||||||
if (data_size < (1 + SIZE_IP6)) {
|
if (data_size < (1 + SIZE_IP6)) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -87,7 +87,7 @@ static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_size, bo
|
|||||||
non_null()
|
non_null()
|
||||||
static void ipport_pack(uint8_t *data, const IP_Port *source)
|
static void ipport_pack(uint8_t *data, const IP_Port *source)
|
||||||
{
|
{
|
||||||
ip_pack(data, &source->ip);
|
ip_pack_to_bytes(data, &source->ip);
|
||||||
memcpy(data + SIZE_IP, &source->port, SIZE_PORT);
|
memcpy(data + SIZE_IP, &source->port, SIZE_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ static int ipport_unpack(IP_Port *target, const uint8_t *data, unsigned int data
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip_unpack(&target->ip, data, data_size, disable_family_check) == -1) {
|
if (ip_unpack_from_bytes(&target->ip, data, data_size, disable_family_check) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
external/toxcore/c-toxcore/toxcore/tox.c
vendored
5
external/toxcore/c-toxcore/toxcore/tox.c
vendored
@ -1058,6 +1058,11 @@ bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t publ
|
|||||||
bool udp_success = tox->m->options.udp_disabled;
|
bool udp_success = tox->m->options.udp_disabled;
|
||||||
|
|
||||||
for (int32_t i = 0; i < count; ++i) {
|
for (int32_t i = 0; i < count; ++i) {
|
||||||
|
if (!tox->m->options.ipv6enabled && net_family_is_ipv6(root[i].ip.family)) {
|
||||||
|
// We can't use ipv6 when it's disabled.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
root[i].port = net_htons(port);
|
root[i].port = net_htons(port);
|
||||||
|
|
||||||
if (onion_add_bs_path_node(tox->m->onion_c, &root[i], public_key)) {
|
if (onion_add_bs_path_node(tox->m->onion_c, &root[i], public_key)) {
|
||||||
|
98
external/toxcore/c-toxcore/toxcore/tox_event.c
vendored
98
external/toxcore/c-toxcore/toxcore/tox_event.c
vendored
@ -564,127 +564,132 @@ void tox_event_destruct(Tox_Event *event, const Memory *mem)
|
|||||||
event->data.value = nullptr;
|
event->data.value = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
|
non_null()
|
||||||
|
static bool tox_event_type_pack(Tox_Event_Type type, Bin_Pack *bp)
|
||||||
{
|
{
|
||||||
assert(event->type != TOX_EVENT_INVALID);
|
return bin_pack_u32(bp, (uint32_t)type);
|
||||||
|
}
|
||||||
|
|
||||||
switch (event->type) {
|
non_null()
|
||||||
|
static bool tox_event_data_pack(Tox_Event_Type type, const Tox_Event_Data *data, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
case TOX_EVENT_CONFERENCE_CONNECTED:
|
case TOX_EVENT_CONFERENCE_CONNECTED:
|
||||||
return tox_event_conference_connected_pack(event->data.conference_connected, bp);
|
return tox_event_conference_connected_pack(data->conference_connected, bp);
|
||||||
|
|
||||||
case TOX_EVENT_CONFERENCE_INVITE:
|
case TOX_EVENT_CONFERENCE_INVITE:
|
||||||
return tox_event_conference_invite_pack(event->data.conference_invite, bp);
|
return tox_event_conference_invite_pack(data->conference_invite, bp);
|
||||||
|
|
||||||
case TOX_EVENT_CONFERENCE_MESSAGE:
|
case TOX_EVENT_CONFERENCE_MESSAGE:
|
||||||
return tox_event_conference_message_pack(event->data.conference_message, bp);
|
return tox_event_conference_message_pack(data->conference_message, bp);
|
||||||
|
|
||||||
case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED:
|
case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED:
|
||||||
return tox_event_conference_peer_list_changed_pack(event->data.conference_peer_list_changed, bp);
|
return tox_event_conference_peer_list_changed_pack(data->conference_peer_list_changed, bp);
|
||||||
|
|
||||||
case TOX_EVENT_CONFERENCE_PEER_NAME:
|
case TOX_EVENT_CONFERENCE_PEER_NAME:
|
||||||
return tox_event_conference_peer_name_pack(event->data.conference_peer_name, bp);
|
return tox_event_conference_peer_name_pack(data->conference_peer_name, bp);
|
||||||
|
|
||||||
case TOX_EVENT_CONFERENCE_TITLE:
|
case TOX_EVENT_CONFERENCE_TITLE:
|
||||||
return tox_event_conference_title_pack(event->data.conference_title, bp);
|
return tox_event_conference_title_pack(data->conference_title, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FILE_CHUNK_REQUEST:
|
case TOX_EVENT_FILE_CHUNK_REQUEST:
|
||||||
return tox_event_file_chunk_request_pack(event->data.file_chunk_request, bp);
|
return tox_event_file_chunk_request_pack(data->file_chunk_request, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FILE_RECV_CHUNK:
|
case TOX_EVENT_FILE_RECV_CHUNK:
|
||||||
return tox_event_file_recv_chunk_pack(event->data.file_recv_chunk, bp);
|
return tox_event_file_recv_chunk_pack(data->file_recv_chunk, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FILE_RECV_CONTROL:
|
case TOX_EVENT_FILE_RECV_CONTROL:
|
||||||
return tox_event_file_recv_control_pack(event->data.file_recv_control, bp);
|
return tox_event_file_recv_control_pack(data->file_recv_control, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FILE_RECV:
|
case TOX_EVENT_FILE_RECV:
|
||||||
return tox_event_file_recv_pack(event->data.file_recv, bp);
|
return tox_event_file_recv_pack(data->file_recv, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_CONNECTION_STATUS:
|
case TOX_EVENT_FRIEND_CONNECTION_STATUS:
|
||||||
return tox_event_friend_connection_status_pack(event->data.friend_connection_status, bp);
|
return tox_event_friend_connection_status_pack(data->friend_connection_status, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_LOSSLESS_PACKET:
|
case TOX_EVENT_FRIEND_LOSSLESS_PACKET:
|
||||||
return tox_event_friend_lossless_packet_pack(event->data.friend_lossless_packet, bp);
|
return tox_event_friend_lossless_packet_pack(data->friend_lossless_packet, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_LOSSY_PACKET:
|
case TOX_EVENT_FRIEND_LOSSY_PACKET:
|
||||||
return tox_event_friend_lossy_packet_pack(event->data.friend_lossy_packet, bp);
|
return tox_event_friend_lossy_packet_pack(data->friend_lossy_packet, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_MESSAGE:
|
case TOX_EVENT_FRIEND_MESSAGE:
|
||||||
return tox_event_friend_message_pack(event->data.friend_message, bp);
|
return tox_event_friend_message_pack(data->friend_message, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_NAME:
|
case TOX_EVENT_FRIEND_NAME:
|
||||||
return tox_event_friend_name_pack(event->data.friend_name, bp);
|
return tox_event_friend_name_pack(data->friend_name, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_READ_RECEIPT:
|
case TOX_EVENT_FRIEND_READ_RECEIPT:
|
||||||
return tox_event_friend_read_receipt_pack(event->data.friend_read_receipt, bp);
|
return tox_event_friend_read_receipt_pack(data->friend_read_receipt, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_REQUEST:
|
case TOX_EVENT_FRIEND_REQUEST:
|
||||||
return tox_event_friend_request_pack(event->data.friend_request, bp);
|
return tox_event_friend_request_pack(data->friend_request, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_STATUS:
|
case TOX_EVENT_FRIEND_STATUS:
|
||||||
return tox_event_friend_status_pack(event->data.friend_status, bp);
|
return tox_event_friend_status_pack(data->friend_status, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_STATUS_MESSAGE:
|
case TOX_EVENT_FRIEND_STATUS_MESSAGE:
|
||||||
return tox_event_friend_status_message_pack(event->data.friend_status_message, bp);
|
return tox_event_friend_status_message_pack(data->friend_status_message, bp);
|
||||||
|
|
||||||
case TOX_EVENT_FRIEND_TYPING:
|
case TOX_EVENT_FRIEND_TYPING:
|
||||||
return tox_event_friend_typing_pack(event->data.friend_typing, bp);
|
return tox_event_friend_typing_pack(data->friend_typing, bp);
|
||||||
|
|
||||||
case TOX_EVENT_SELF_CONNECTION_STATUS:
|
case TOX_EVENT_SELF_CONNECTION_STATUS:
|
||||||
return tox_event_self_connection_status_pack(event->data.self_connection_status, bp);
|
return tox_event_self_connection_status_pack(data->self_connection_status, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PEER_NAME:
|
case TOX_EVENT_GROUP_PEER_NAME:
|
||||||
return tox_event_group_peer_name_pack(event->data.group_peer_name, bp);
|
return tox_event_group_peer_name_pack(data->group_peer_name, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PEER_STATUS:
|
case TOX_EVENT_GROUP_PEER_STATUS:
|
||||||
return tox_event_group_peer_status_pack(event->data.group_peer_status, bp);
|
return tox_event_group_peer_status_pack(data->group_peer_status, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_TOPIC:
|
case TOX_EVENT_GROUP_TOPIC:
|
||||||
return tox_event_group_topic_pack(event->data.group_topic, bp);
|
return tox_event_group_topic_pack(data->group_topic, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PRIVACY_STATE:
|
case TOX_EVENT_GROUP_PRIVACY_STATE:
|
||||||
return tox_event_group_privacy_state_pack(event->data.group_privacy_state, bp);
|
return tox_event_group_privacy_state_pack(data->group_privacy_state, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_VOICE_STATE:
|
case TOX_EVENT_GROUP_VOICE_STATE:
|
||||||
return tox_event_group_voice_state_pack(event->data.group_voice_state, bp);
|
return tox_event_group_voice_state_pack(data->group_voice_state, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_TOPIC_LOCK:
|
case TOX_EVENT_GROUP_TOPIC_LOCK:
|
||||||
return tox_event_group_topic_lock_pack(event->data.group_topic_lock, bp);
|
return tox_event_group_topic_lock_pack(data->group_topic_lock, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PEER_LIMIT:
|
case TOX_EVENT_GROUP_PEER_LIMIT:
|
||||||
return tox_event_group_peer_limit_pack(event->data.group_peer_limit, bp);
|
return tox_event_group_peer_limit_pack(data->group_peer_limit, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PASSWORD:
|
case TOX_EVENT_GROUP_PASSWORD:
|
||||||
return tox_event_group_password_pack(event->data.group_password, bp);
|
return tox_event_group_password_pack(data->group_password, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_MESSAGE:
|
case TOX_EVENT_GROUP_MESSAGE:
|
||||||
return tox_event_group_message_pack(event->data.group_message, bp);
|
return tox_event_group_message_pack(data->group_message, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PRIVATE_MESSAGE:
|
case TOX_EVENT_GROUP_PRIVATE_MESSAGE:
|
||||||
return tox_event_group_private_message_pack(event->data.group_private_message, bp);
|
return tox_event_group_private_message_pack(data->group_private_message, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_CUSTOM_PACKET:
|
case TOX_EVENT_GROUP_CUSTOM_PACKET:
|
||||||
return tox_event_group_custom_packet_pack(event->data.group_custom_packet, bp);
|
return tox_event_group_custom_packet_pack(data->group_custom_packet, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET:
|
case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET:
|
||||||
return tox_event_group_custom_private_packet_pack(event->data.group_custom_private_packet, bp);
|
return tox_event_group_custom_private_packet_pack(data->group_custom_private_packet, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_INVITE:
|
case TOX_EVENT_GROUP_INVITE:
|
||||||
return tox_event_group_invite_pack(event->data.group_invite, bp);
|
return tox_event_group_invite_pack(data->group_invite, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PEER_JOIN:
|
case TOX_EVENT_GROUP_PEER_JOIN:
|
||||||
return tox_event_group_peer_join_pack(event->data.group_peer_join, bp);
|
return tox_event_group_peer_join_pack(data->group_peer_join, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_PEER_EXIT:
|
case TOX_EVENT_GROUP_PEER_EXIT:
|
||||||
return tox_event_group_peer_exit_pack(event->data.group_peer_exit, bp);
|
return tox_event_group_peer_exit_pack(data->group_peer_exit, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_SELF_JOIN:
|
case TOX_EVENT_GROUP_SELF_JOIN:
|
||||||
return tox_event_group_self_join_pack(event->data.group_self_join, bp);
|
return tox_event_group_self_join_pack(data->group_self_join, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_JOIN_FAIL:
|
case TOX_EVENT_GROUP_JOIN_FAIL:
|
||||||
return tox_event_group_join_fail_pack(event->data.group_join_fail, bp);
|
return tox_event_group_join_fail_pack(data->group_join_fail, bp);
|
||||||
|
|
||||||
case TOX_EVENT_GROUP_MODERATION:
|
case TOX_EVENT_GROUP_MODERATION:
|
||||||
return tox_event_group_moderation_pack(event->data.group_moderation, bp);
|
return tox_event_group_moderation_pack(data->group_moderation, bp);
|
||||||
|
|
||||||
case TOX_EVENT_INVALID:
|
case TOX_EVENT_INVALID:
|
||||||
return false;
|
return false;
|
||||||
@ -693,6 +698,15 @@ bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
assert(event->type != TOX_EVENT_INVALID);
|
||||||
|
|
||||||
|
return bin_pack_array(bp, 2)
|
||||||
|
&& tox_event_type_pack(event->type, bp)
|
||||||
|
&& tox_event_data_pack(event->type, &event->data, bp);
|
||||||
|
}
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
|
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
|
||||||
{
|
{
|
||||||
|
55
external/toxcore/c-toxcore/toxcore/tox_pack.c
vendored
Normal file
55
external/toxcore/c-toxcore/toxcore/tox_pack.c
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
* Copyright © 2022 The TokTok team.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tox_pack.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "bin_pack.h"
|
||||||
|
#include "tox.h"
|
||||||
|
|
||||||
|
bool tox_conference_type_pack(Tox_Conference_Type val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_connection_pack(Tox_Connection val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_file_control_pack(Tox_File_Control val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_message_type_pack(Tox_Message_Type val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_user_status_pack(Tox_User_Status val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_privacy_state_pack(Tox_Group_Privacy_State val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_voice_state_pack(Tox_Group_Voice_State val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_topic_lock_pack(Tox_Group_Topic_Lock val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_join_fail_pack(Tox_Group_Join_Fail val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
||||||
|
bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp)
|
||||||
|
{
|
||||||
|
return bin_pack_u32(bp, (uint32_t)val);
|
||||||
|
}
|
24
external/toxcore/c-toxcore/toxcore/tox_pack.h
vendored
Normal file
24
external/toxcore/c-toxcore/toxcore/tox_pack.h
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
* Copyright © 2022 The TokTok team.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef C_TOXCORE_TOXCORE_TOX_PACK_H
|
||||||
|
#define C_TOXCORE_TOXCORE_TOX_PACK_H
|
||||||
|
|
||||||
|
#include "attributes.h"
|
||||||
|
#include "bin_pack.h"
|
||||||
|
#include "tox.h"
|
||||||
|
|
||||||
|
non_null() bool tox_conference_type_pack(Tox_Conference_Type val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_connection_pack(Tox_Connection val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_file_control_pack(Tox_File_Control val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_message_type_pack(Tox_Message_Type val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_user_status_pack(Tox_User_Status val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_privacy_state_pack(Tox_Group_Privacy_State val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_voice_state_pack(Tox_Group_Voice_State val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_topic_lock_pack(Tox_Group_Topic_Lock val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_join_fail_pack(Tox_Group_Join_Fail val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp);
|
||||||
|
non_null() bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp);
|
||||||
|
|
||||||
|
#endif // C_TOXCORE_TOXCORE_TOX_PACK_H
|
22
external/toxcore/c-toxcore/toxcore/tox_unpack.c
vendored
22
external/toxcore/c-toxcore/toxcore/tox_unpack.c
vendored
@ -29,7 +29,7 @@ static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_conference_type_unpack(Bin_Unpack *bu, Tox_Conference_Type *val)
|
bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -62,7 +62,7 @@ static bool tox_connection_from_int(uint32_t value, Tox_Connection *out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tox_connection_unpack(Bin_Unpack *bu, Tox_Connection *val)
|
bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -95,7 +95,7 @@ static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tox_file_control_unpack(Bin_Unpack *bu, Tox_File_Control *val)
|
bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -123,7 +123,7 @@ static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tox_message_type_unpack(Bin_Unpack *bu, Tox_Message_Type *val)
|
bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -156,7 +156,7 @@ static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tox_user_status_unpack(Bin_Unpack *bu, Tox_User_Status *val)
|
bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -181,7 +181,7 @@ static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_privacy_state_unpack(Bin_Unpack *bu, Tox_Group_Privacy_State *val)
|
bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -209,7 +209,7 @@ static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_voice_state_unpack(Bin_Unpack *bu, Tox_Group_Voice_State *val)
|
bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -234,7 +234,7 @@ static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_topic_lock_unpack(Bin_Unpack *bu, Tox_Group_Topic_Lock *val)
|
bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -263,7 +263,7 @@ static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_join_fail_unpack(Bin_Unpack *bu, Tox_Group_Join_Fail *val)
|
bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -296,7 +296,7 @@ static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_mod_event_unpack(Bin_Unpack *bu, Tox_Group_Mod_Event *val)
|
bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
@ -337,7 +337,7 @@ static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *ou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool tox_group_exit_type_unpack(Bin_Unpack *bu, Tox_Group_Exit_Type *val)
|
bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu)
|
||||||
{
|
{
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
return bin_unpack_u32(bu, &u32)
|
return bin_unpack_u32(bu, &u32)
|
||||||
|
22
external/toxcore/c-toxcore/toxcore/tox_unpack.h
vendored
22
external/toxcore/c-toxcore/toxcore/tox_unpack.h
vendored
@ -9,16 +9,16 @@
|
|||||||
#include "bin_unpack.h"
|
#include "bin_unpack.h"
|
||||||
#include "tox.h"
|
#include "tox.h"
|
||||||
|
|
||||||
non_null() bool tox_conference_type_unpack(Bin_Unpack *bu, Tox_Conference_Type *val);
|
non_null() bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_connection_unpack(Bin_Unpack *bu, Tox_Connection *val);
|
non_null() bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_file_control_unpack(Bin_Unpack *bu, Tox_File_Control *val);
|
non_null() bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_message_type_unpack(Bin_Unpack *bu, Tox_Message_Type *val);
|
non_null() bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_user_status_unpack(Bin_Unpack *bu, Tox_User_Status *val);
|
non_null() bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_privacy_state_unpack(Bin_Unpack *bu, Tox_Group_Privacy_State *val);
|
non_null() bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_voice_state_unpack(Bin_Unpack *bu, Tox_Group_Voice_State *val);
|
non_null() bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_topic_lock_unpack(Bin_Unpack *bu, Tox_Group_Topic_Lock *val);
|
non_null() bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_join_fail_unpack(Bin_Unpack *bu, Tox_Group_Join_Fail *val);
|
non_null() bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_mod_event_unpack(Bin_Unpack *bu, Tox_Group_Mod_Event *val);
|
non_null() bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu);
|
||||||
non_null() bool tox_group_exit_type_unpack(Bin_Unpack *bu, Tox_Group_Exit_Type *val);
|
non_null() bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu);
|
||||||
|
|
||||||
#endif // C_TOXCORE_TOXCORE_TOX_UNPACK_H
|
#endif // C_TOXCORE_TOXCORE_TOX_UNPACK_H
|
||||||
|
Loading…
Reference in New Issue
Block a user