Compare commits
10 Commits
bedbacddde
...
tmp_tox_lo
Author | SHA1 | Date | |
---|---|---|---|
30f96b780b | |||
85a06de59a | |||
6b5f40b4a0 | |||
7495a50723 | |||
1cdde5170b | |||
4248d1d9ab | |||
05d1648209 | |||
4f02c2b55b | |||
fd9d14d00c | |||
4e4f62dd20 |
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: 48fb5f0889...1a036c2321
2
external/solanaceae_util
vendored
2
external/solanaceae_util
vendored
Submodule external/solanaceae_util updated: 92eee153f2...2b20c2d2a4
5
external/toxcore/CMakeLists.txt
vendored
5
external/toxcore/CMakeLists.txt
vendored
@@ -164,9 +164,10 @@ configure_file(
|
|||||||
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
|
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
|
||||||
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
|
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
|
||||||
|
|
||||||
target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
|
#target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
|
||||||
|
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE)
|
||||||
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
|
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
|
||||||
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
|
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
|
||||||
|
|
||||||
find_package(unofficial-sodium CONFIG QUIET)
|
find_package(unofficial-sodium CONFIG QUIET)
|
||||||
find_package(sodium QUIET)
|
find_package(sodium QUIET)
|
||||||
|
1
external/toxcore/c-toxcore/other/BUILD.bazel
vendored
1
external/toxcore/c-toxcore/other/BUILD.bazel
vendored
@@ -16,6 +16,7 @@ cc_binary(
|
|||||||
testonly = 1,
|
testonly = 1,
|
||||||
srcs = ["DHT_bootstrap.c"],
|
srcs = ["DHT_bootstrap.c"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":bootstrap_node_packets",
|
||||||
"//c-toxcore/testing:misc_tools",
|
"//c-toxcore/testing:misc_tools",
|
||||||
"//c-toxcore/toxcore:DHT",
|
"//c-toxcore/toxcore:DHT",
|
||||||
"//c-toxcore/toxcore:LAN_discovery",
|
"//c-toxcore/toxcore:LAN_discovery",
|
||||||
|
11
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
11
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
@@ -31,11 +31,16 @@
|
|||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
|
|
||||||
|
#define DHT_NODE_EXTRA_PACKETS
|
||||||
|
|
||||||
#ifdef DHT_NODE_EXTRA_PACKETS
|
#ifdef DHT_NODE_EXTRA_PACKETS
|
||||||
#include "./bootstrap_node_packets.h"
|
#include "./bootstrap_node_packets.h"
|
||||||
|
|
||||||
#define DHT_VERSION_NUMBER 1
|
#ifndef DAEMON_VERSION_NUMBER
|
||||||
#define DHT_MOTD "This is a test motd"
|
#define DAEMON_VERSION_NUMBER (1000000000UL + TOX_VERSION_MAJOR*1000000UL + TOX_VERSION_MINOR*1000UL + TOX_VERSION_PATCH*1UL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *motd_str = ""; //Change this to anything within 256 bytes(but 96 bytes maximum prefered)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PORT 33445
|
#define PORT 33445
|
||||||
@@ -152,7 +157,7 @@ int main(int argc, char *argv[])
|
|||||||
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
|
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
|
||||||
|
|
||||||
#ifdef DHT_NODE_EXTRA_PACKETS
|
#ifdef DHT_NODE_EXTRA_PACKETS
|
||||||
bootstrap_set_callbacks(dht_get_net(dht), DHT_VERSION_NUMBER, DHT_MOTD, sizeof(DHT_MOTD));
|
bootstrap_set_callbacks(dht_get_net(dht), (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str)+1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(onion && forwarding && onion_a)) {
|
if (!(onion && forwarding && onion_a)) {
|
||||||
|
@@ -1 +1 @@
|
|||||||
9bec65f2a3093ebb49c3751dfad267482bc80d4b29ef9171f11d5ba53058d713 /usr/local/bin/tox-bootstrapd
|
b2996d73cab7c7453dc10ccf7ad733622558de3b1ad0db824a379cf96f500379 /usr/local/bin/tox-bootstrapd
|
||||||
|
30
external/toxcore/c-toxcore/toxcore/group_chats.c
vendored
30
external/toxcore/c-toxcore/toxcore/group_chats.c
vendored
@@ -108,10 +108,19 @@ static_assert(GCC_BUFFER_SIZE <= UINT16_MAX,
|
|||||||
static_assert(MAX_GC_PACKET_CHUNK_SIZE < MAX_GC_PACKET_SIZE,
|
static_assert(MAX_GC_PACKET_CHUNK_SIZE < MAX_GC_PACKET_SIZE,
|
||||||
"MAX_GC_PACKET_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE");
|
"MAX_GC_PACKET_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE");
|
||||||
|
|
||||||
|
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE < MAX_GC_PACKET_SIZE,
|
||||||
|
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be < MAX_GC_PACKET_SIZE");
|
||||||
|
|
||||||
|
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= MAX_GC_PACKET_CHUNK_SIZE,
|
||||||
|
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= MAX_GC_PACKET_CHUNK_SIZE");
|
||||||
|
|
||||||
// size of a lossless handshake packet - lossless packets can't/shouldn't be split up
|
// size of a lossless handshake packet - lossless packets can't/shouldn't be split up
|
||||||
static_assert(MAX_GC_PACKET_CHUNK_SIZE >= 171,
|
static_assert(MAX_GC_PACKET_CHUNK_SIZE >= 171,
|
||||||
"MAX_GC_PACKET_CHUNK_SIZE must be >= 171");
|
"MAX_GC_PACKET_CHUNK_SIZE must be >= 171");
|
||||||
|
|
||||||
|
static_assert(MAX_GC_PACKET_INCOMING_CHUNK_SIZE >= 171,
|
||||||
|
"MAX_GC_PACKET_INCOMING_CHUNK_SIZE must be >= 171");
|
||||||
|
|
||||||
// group_moderation constants assume this is the max packet size.
|
// group_moderation constants assume this is the max packet size.
|
||||||
static_assert(MAX_GC_PACKET_SIZE >= 50000,
|
static_assert(MAX_GC_PACKET_SIZE >= 50000,
|
||||||
"MAX_GC_PACKET_SIZE doesn't match constants in group_moderation.h");
|
"MAX_GC_PACKET_SIZE doesn't match constants in group_moderation.h");
|
||||||
@@ -119,6 +128,9 @@ static_assert(MAX_GC_PACKET_SIZE >= 50000,
|
|||||||
static_assert(MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE,
|
static_assert(MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE,
|
||||||
"MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE");
|
"MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_CHUNK_SIZE");
|
||||||
|
|
||||||
|
static_assert(MAX_GC_PACKET_SIZE <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE,
|
||||||
|
"MAX_GC_PACKET_SIZE must be <= UINT16_MAX - MAX_GC_PACKET_INCOMING_CHUNK_SIZE");
|
||||||
|
|
||||||
/** Types of broadcast messages. */
|
/** Types of broadcast messages. */
|
||||||
typedef enum Group_Message_Type {
|
typedef enum Group_Message_Type {
|
||||||
GC_MESSAGE_TYPE_NORMAL = 0x00,
|
GC_MESSAGE_TYPE_NORMAL = 0x00,
|
||||||
@@ -6255,13 +6267,13 @@ static int handle_gc_tcp_packet(void *object, int id, const uint8_t *packet, uin
|
|||||||
|
|
||||||
if (length <= MIN_TCP_PACKET_SIZE) {
|
if (length <= MIN_TCP_PACKET_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got tcp packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_TCP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_TCP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6336,13 +6348,13 @@ static int handle_gc_tcp_oob_packet(void *object, const uint8_t *public_key, uns
|
|||||||
|
|
||||||
if (length <= GC_MIN_HS_PACKET_PAYLOAD_SIZE) {
|
if (length <= GC_MIN_HS_PACKET_PAYLOAD_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
|
||||||
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
|
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE) {
|
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got tcp oob packet with invalid length: %u (expected %u to %u)", length,
|
||||||
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
|
GC_MIN_HS_PACKET_PAYLOAD_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + CRYPTO_MAC_SIZE + CRYPTO_NONCE_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6392,13 +6404,13 @@ static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t
|
|||||||
|
|
||||||
if (length <= MIN_UDP_PACKET_SIZE) {
|
if (length <= MIN_UDP_PACKET_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
if (length > MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_INCOMING_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
* For an explanation on why this value was chosen, see the following link: https://archive.ph/vsCOG
|
* For an explanation on why this value was chosen, see the following link: https://archive.ph/vsCOG
|
||||||
*/
|
*/
|
||||||
#define MAX_GC_PACKET_CHUNK_SIZE 500
|
#define MAX_GC_PACKET_CHUNK_SIZE 500
|
||||||
|
/* Max size of an incoming packet chunk that is allowed */
|
||||||
|
#define MAX_GC_PACKET_INCOMING_CHUNK_SIZE 1372
|
||||||
|
|
||||||
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
||||||
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
||||||
|
@@ -366,7 +366,7 @@ static uint16_t reassemble_packet(const Logger *log, GC_Connection *gconn, uint8
|
|||||||
// search backwards in recv array until we find an empty slot or a non-fragment packet type
|
// search backwards in recv array until we find an empty slot or a non-fragment packet type
|
||||||
while (!array_entry_is_empty(entry) && entry->packet_type == GP_FRAGMENT) {
|
while (!array_entry_is_empty(entry) && entry->packet_type == GP_FRAGMENT) {
|
||||||
assert(entry->data != nullptr);
|
assert(entry->data != nullptr);
|
||||||
assert(entry->data_length <= MAX_GC_PACKET_CHUNK_SIZE);
|
assert(entry->data_length <= MAX_GC_PACKET_INCOMING_CHUNK_SIZE);
|
||||||
|
|
||||||
const uint16_t diff = packet_length + entry->data_length;
|
const uint16_t diff = packet_length + entry->data_length;
|
||||||
|
|
||||||
|
25
external/toxcore/c-toxcore/toxcore/tox.c
vendored
25
external/toxcore/c-toxcore/toxcore/tox.c
vendored
@@ -858,12 +858,26 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
|
|||||||
|
|
||||||
if (load_savedata_tox
|
if (load_savedata_tox
|
||||||
&& tox_load(tox, tox_options_get_savedata_data(opts), tox_options_get_savedata_length(opts)) == -1) {
|
&& tox_load(tox, tox_options_get_savedata_data(opts), tox_options_get_savedata_length(opts)) == -1) {
|
||||||
|
kill_groupchats(tox->m->conferences_object);
|
||||||
|
kill_messenger(tox->m);
|
||||||
|
|
||||||
|
mono_time_free(tox->sys.mem, tox->mono_time);
|
||||||
|
tox_options_free(default_options);
|
||||||
|
tox_unlock(tox);
|
||||||
|
|
||||||
|
if (tox->mutex != nullptr) {
|
||||||
|
pthread_mutex_destroy(tox->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
mem_delete(sys->mem, tox->mutex);
|
||||||
|
mem_delete(sys->mem, tox);
|
||||||
|
|
||||||
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
|
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT);
|
||||||
} else if (load_savedata_sk) {
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (load_savedata_sk) {
|
||||||
load_secret_key(tox->m->net_crypto, tox_options_get_savedata_data(opts));
|
load_secret_key(tox->m->net_crypto, tox_options_get_savedata_data(opts));
|
||||||
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
|
|
||||||
} else {
|
|
||||||
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_callback_namechange(tox->m, tox_friend_name_handler);
|
m_callback_namechange(tox->m, tox_friend_name_handler);
|
||||||
@@ -913,6 +927,9 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
|
|||||||
tox_options_free(default_options);
|
tox_options_free(default_options);
|
||||||
|
|
||||||
tox_unlock(tox);
|
tox_unlock(tox);
|
||||||
|
|
||||||
|
SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK);
|
||||||
|
|
||||||
return tox;
|
return tox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
external/toxcore/c-toxcore/toxcore/tox.h
vendored
3
external/toxcore/c-toxcore/toxcore/tox.h
vendored
@@ -890,9 +890,6 @@ typedef enum Tox_Err_New {
|
|||||||
* This function will bring the instance into a valid state. Running the event
|
* This function will bring the instance into a valid state. Running the event
|
||||||
* loop with a new instance will operate correctly.
|
* loop with a new instance will operate correctly.
|
||||||
*
|
*
|
||||||
* If loading failed or succeeded only partially, the new or partially loaded
|
|
||||||
* instance is returned and an error code is set.
|
|
||||||
*
|
|
||||||
* @param options An options object as described above. If this parameter is
|
* @param options An options object as described above. If this parameter is
|
||||||
* NULL, the default options are used.
|
* NULL, the default options are used.
|
||||||
*
|
*
|
||||||
|
@@ -58,6 +58,9 @@ add_executable(tomato
|
|||||||
./tox_ui_utils.hpp
|
./tox_ui_utils.hpp
|
||||||
./tox_ui_utils.cpp
|
./tox_ui_utils.cpp
|
||||||
|
|
||||||
|
./tox_dht_cap_histo.hpp
|
||||||
|
./tox_dht_cap_histo.cpp
|
||||||
|
|
||||||
./chat_gui4.hpp
|
./chat_gui4.hpp
|
||||||
./chat_gui4.cpp
|
./chat_gui4.cpp
|
||||||
)
|
)
|
||||||
|
@@ -6,6 +6,9 @@
|
|||||||
#include <solanaceae/tox_messages/components.hpp>
|
#include <solanaceae/tox_messages/components.hpp>
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
|
|
||||||
|
// HACK: remove them
|
||||||
|
#include <solanaceae/tox_contacts/components.hpp>
|
||||||
|
#include <solanaceae/toxcore/utils.hpp>
|
||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
@@ -158,6 +161,16 @@ void ChatGui4::render(void) {
|
|||||||
ImGui::Checkbox("show extra info", &_show_chat_extra_info);
|
ImGui::Checkbox("show extra info", &_show_chat_extra_info);
|
||||||
ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf);
|
ImGui::Checkbox("show avatar transfers", &_show_chat_avatar_tf);
|
||||||
|
|
||||||
|
ImGui::SeparatorText("tox");
|
||||||
|
|
||||||
|
if (_cr.all_of<Contact::Components::ToxGroupPersistent>(*_selected_contact)) {
|
||||||
|
if (ImGui::MenuItem("copy ngc chatid")) {
|
||||||
|
const auto& chat_id = _cr.get<Contact::Components::ToxGroupPersistent>(*_selected_contact).chat_id.data;
|
||||||
|
const auto chat_id_str = bin2hex(std::vector<uint8_t>{chat_id.begin(), chat_id.end()});
|
||||||
|
ImGui::SetClipboardText(chat_id_str.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
@@ -171,6 +184,8 @@ void ChatGui4::render(void) {
|
|||||||
if (const auto* unread_storage = mm.storage<Message::Components::TagUnread>(); unread_storage != nullptr && !unread_storage->empty()) {
|
if (const auto* unread_storage = mm.storage<Message::Components::TagUnread>(); unread_storage != nullptr && !unread_storage->empty()) {
|
||||||
//assert(unread_storage->size() == 0);
|
//assert(unread_storage->size() == 0);
|
||||||
//assert(unread_storage.cbegin() == unread_storage.cend());
|
//assert(unread_storage.cbegin() == unread_storage.cend());
|
||||||
|
|
||||||
|
#if 0
|
||||||
std::cout << "UNREAD ";
|
std::cout << "UNREAD ";
|
||||||
Message3 prev_ent = entt::null;
|
Message3 prev_ent = entt::null;
|
||||||
for (const Message3 e : mm.view<Message::Components::TagUnread>()) {
|
for (const Message3 e : mm.view<Message::Components::TagUnread>()) {
|
||||||
@@ -181,6 +196,7 @@ void ChatGui4::render(void) {
|
|||||||
prev_ent = e;
|
prev_ent = e;
|
||||||
}
|
}
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
rmm(cr),
|
rmm(cr),
|
||||||
mts(rmm),
|
mts(rmm),
|
||||||
tc(save_path, save_password),
|
tc(save_path, save_password),
|
||||||
|
tpi(tc.getTox()),
|
||||||
ad(tc),
|
ad(tc),
|
||||||
tcm(cr, tc, tc),
|
tcm(cr, tc, tc),
|
||||||
tmm(rmm, cr, tcm, tc, tc),
|
tmm(rmm, cr, tcm, tc, tc),
|
||||||
@@ -20,7 +21,8 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
sdlrtu(renderer_),
|
sdlrtu(renderer_),
|
||||||
cg(conf, rmm, cr, sdlrtu),
|
cg(conf, rmm, cr, sdlrtu),
|
||||||
sw(conf),
|
sw(conf),
|
||||||
tuiu(tc, conf)
|
tuiu(tc, conf),
|
||||||
|
tdch(tpi)
|
||||||
{
|
{
|
||||||
tel.subscribeAll(tc);
|
tel.subscribeAll(tc);
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
g_provideInstance<RegistryMessageModel>("RegistryMessageModel", "host", &rmm);
|
g_provideInstance<RegistryMessageModel>("RegistryMessageModel", "host", &rmm);
|
||||||
|
|
||||||
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
||||||
|
g_provideInstance<ToxPrivateI>("ToxPrivateI", "host", &tpi);
|
||||||
g_provideInstance<ToxEventProviderI>("ToxEventProviderI", "host", &tc);
|
g_provideInstance<ToxEventProviderI>("ToxEventProviderI", "host", &tc);
|
||||||
g_provideInstance<ToxContactModel2>("ToxContactModel2", "host", &tcm);
|
g_provideInstance<ToxContactModel2>("ToxContactModel2", "host", &tcm);
|
||||||
|
|
||||||
@@ -107,12 +110,14 @@ Screen* MainScreen::poll(bool& quit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pm.tick(time_delta);
|
pm.tick(time_delta);
|
||||||
|
tdch.tick(time_delta);
|
||||||
|
|
||||||
mts.iterate();
|
mts.iterate();
|
||||||
|
|
||||||
cg.render();
|
cg.render();
|
||||||
sw.render();
|
sw.render();
|
||||||
tuiu.render();
|
tuiu.render();
|
||||||
|
tdch.render();
|
||||||
|
|
||||||
if constexpr (false) {
|
if constexpr (false) {
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include <solanaceae/message3/message_time_sort.hpp>
|
#include <solanaceae/message3/message_time_sort.hpp>
|
||||||
#include <solanaceae/plugin/plugin_manager.hpp>
|
#include <solanaceae/plugin/plugin_manager.hpp>
|
||||||
#include <solanaceae/toxcore/tox_event_logger.hpp>
|
#include <solanaceae/toxcore/tox_event_logger.hpp>
|
||||||
|
#include "./tox_private_impl.hpp"
|
||||||
|
|
||||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||||
#include <solanaceae/tox_messages/tox_message_manager.hpp>
|
#include <solanaceae/tox_messages/tox_message_manager.hpp>
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
#include "./settings_window.hpp"
|
#include "./settings_window.hpp"
|
||||||
#include "./tox_ui_utils.hpp"
|
#include "./tox_ui_utils.hpp"
|
||||||
|
#include "./tox_dht_cap_histo.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -47,6 +49,7 @@ struct MainScreen final : public Screen {
|
|||||||
|
|
||||||
ToxEventLogger tel{std::cout};
|
ToxEventLogger tel{std::cout};
|
||||||
ToxClient tc;
|
ToxClient tc;
|
||||||
|
ToxPrivateImpl tpi;
|
||||||
AutoDirty ad;
|
AutoDirty ad;
|
||||||
ToxContactModel2 tcm;
|
ToxContactModel2 tcm;
|
||||||
ToxMessageManager tmm;
|
ToxMessageManager tmm;
|
||||||
@@ -61,6 +64,7 @@ struct MainScreen final : public Screen {
|
|||||||
ChatGui4 cg;
|
ChatGui4 cg;
|
||||||
SettingsWindow sw;
|
SettingsWindow sw;
|
||||||
ToxUIUtils tuiu;
|
ToxUIUtils tuiu;
|
||||||
|
ToxDHTCapHisto tdch;
|
||||||
|
|
||||||
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
||||||
~MainScreen(void);
|
~MainScreen(void);
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#include "./image_loader_sdl_bmp.hpp"
|
#include "./image_loader_sdl_bmp.hpp"
|
||||||
#include "./image_loader_stb.hpp"
|
#include "./image_loader_stb.hpp"
|
||||||
#include "./image_loader_webp.hpp"
|
#include "./image_loader_webp.hpp"
|
||||||
|
#include "./media_meta_info_loader.hpp"
|
||||||
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
|
|
||||||
@@ -22,6 +23,10 @@ std::optional<TextureEntry> MessageImageLoader::load(TextureUploaderI& tu, Messa
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.all_of<Message::Components::TagNotImage>()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
if (m.all_of<Message::Components::Transfer::FileInfoLocal>()) {
|
if (m.all_of<Message::Components::Transfer::FileInfoLocal>()) {
|
||||||
const auto& file_list = m.get<Message::Components::Transfer::FileInfoLocal>().file_list;
|
const auto& file_list = m.get<Message::Components::Transfer::FileInfoLocal>().file_list;
|
||||||
assert(!file_list.empty());
|
assert(!file_list.empty());
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "./tox_client.hpp"
|
#include "./tox_client.hpp"
|
||||||
|
#include "toxcore/tox.h"
|
||||||
|
|
||||||
// meh, change this
|
// meh, change this
|
||||||
#include <exception>
|
#include <exception>
|
||||||
@@ -18,6 +19,10 @@ static void eee(std::string& mod) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tmp_tox_log_cb(Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func, const char *message, void *user_data) {
|
||||||
|
std::cerr << "l:" << level << " " << file << ":" << line << "@" << func << "(): '" << message << "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
ToxClient::ToxClient(std::string_view save_path, std::string_view save_password) :
|
ToxClient::ToxClient(std::string_view save_path, std::string_view save_password) :
|
||||||
_tox_profile_path(save_path), _tox_profile_password(save_password)
|
_tox_profile_path(save_path), _tox_profile_password(save_password)
|
||||||
{
|
{
|
||||||
@@ -67,6 +72,9 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tox_options_set_local_discovery_enabled(options, false);
|
||||||
|
tox_options_set_log_callback(options, tmp_tox_log_cb);
|
||||||
|
|
||||||
TOX_ERR_NEW err_new;
|
TOX_ERR_NEW err_new;
|
||||||
_tox = tox_new(options, &err_new);
|
_tox = tox_new(options, &err_new);
|
||||||
tox_options_free(options);
|
tox_options_free(options);
|
||||||
|
69
src/tox_dht_cap_histo.cpp
Normal file
69
src/tox_dht_cap_histo.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#include "./tox_dht_cap_histo.hpp"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
void ToxDHTCapHisto::tick(float time_delta) {
|
||||||
|
if (!_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_time_since_last_add += time_delta;
|
||||||
|
if (_time_since_last_add >= _value_add_interval) {
|
||||||
|
_time_since_last_add = 0.f; // very loose
|
||||||
|
|
||||||
|
const auto total = _tpi.toxDHTGetNumCloselist();
|
||||||
|
const auto with_cap = _tpi.toxDHTGetNumCloselistAnnounceCapable();
|
||||||
|
|
||||||
|
if (total == 0 || with_cap == 0) {
|
||||||
|
_ratios.push_back(0.f);
|
||||||
|
} else {
|
||||||
|
_ratios.push_back(float(with_cap) / float(total));
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: limit
|
||||||
|
while (_ratios.size() > 5*60) {
|
||||||
|
_ratios.erase(_ratios.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToxDHTCapHisto::render(void) {
|
||||||
|
{ // main window menubar injection
|
||||||
|
// assumes the window "tomato" was rendered already by cg
|
||||||
|
if (ImGui::Begin("tomato")) {
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::BeginMenu("Tox")) {
|
||||||
|
ImGui::SeparatorText("DHT diagnostics");
|
||||||
|
|
||||||
|
ImGui::Checkbox("enabled", &_enabled);
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("show DHT announce capability histogram")) {
|
||||||
|
_show_window = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_show_window) {
|
||||||
|
if (ImGui::Begin("Tox DHT announce capability histogram", &_show_window)) {
|
||||||
|
if (_enabled) {
|
||||||
|
ImGui::PlotHistogram("##histogram", _ratios.data(), _ratios.size(), 0, nullptr, 0.f, 1.f, {-1, -1});
|
||||||
|
} else {
|
||||||
|
ImGui::TextUnformatted("logging disabled!");
|
||||||
|
if (ImGui::Button("enable")) {
|
||||||
|
_enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
22
src/tox_dht_cap_histo.hpp
Normal file
22
src/tox_dht_cap_histo.hpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <solanaceae/toxcore/tox_private_interface.hpp>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class ToxDHTCapHisto {
|
||||||
|
ToxPrivateI& _tpi;
|
||||||
|
|
||||||
|
bool _enabled {true};
|
||||||
|
bool _show_window {false};
|
||||||
|
|
||||||
|
std::vector<float> _ratios;
|
||||||
|
const float _value_add_interval {1.f}; // every second
|
||||||
|
float _time_since_last_add {0.f};
|
||||||
|
|
||||||
|
public:
|
||||||
|
ToxDHTCapHisto(ToxPrivateI& tpi) : _tpi(tpi) {}
|
||||||
|
|
||||||
|
void tick(float time_delta);
|
||||||
|
void render(void);
|
||||||
|
};
|
19
src/tox_private_impl.hpp
Normal file
19
src/tox_private_impl.hpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <tox/tox_private.h>
|
||||||
|
#include <solanaceae/toxcore/tox_private_interface.hpp>
|
||||||
|
|
||||||
|
struct ToxPrivateImpl : public ToxPrivateI {
|
||||||
|
Tox* _tox = nullptr;
|
||||||
|
|
||||||
|
ToxPrivateImpl(Tox* tox) : _tox(tox) {}
|
||||||
|
virtual ~ToxPrivateImpl(void) {}
|
||||||
|
|
||||||
|
uint16_t toxDHTGetNumCloselist(void) override {
|
||||||
|
return tox_dht_get_num_closelist(_tox);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t toxDHTGetNumCloselistAnnounceCapable(void) override {
|
||||||
|
return tox_dht_get_num_closelist_announce_capable(_tox);
|
||||||
|
}
|
||||||
|
};
|
@@ -23,6 +23,8 @@ void ToxUIUtils::render(void) {
|
|||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::BeginMenu("Tox")) {
|
if (ImGui::BeginMenu("Tox")) {
|
||||||
|
ImGui::SeparatorText("Friends/Groups");
|
||||||
|
|
||||||
if (ImGui::MenuItem("add Friend by ID")) {
|
if (ImGui::MenuItem("add Friend by ID")) {
|
||||||
_show_add_friend_window = true;
|
_show_add_friend_window = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user