From 1a18e112a77a9e7d04b0360b0d0dfc1f18cd25e6 Mon Sep 17 00:00:00 2001 From: "emdee@spm.plastiras.org" Date: Mon, 18 Mar 2024 18:11:21 +0000 Subject: [PATCH] fixes --- src/twc-bootstrap.c | 5 +++++ src/twc-commands.c | 8 +++++--- src/twc-tfer.c | 11 ++++++----- src/twc-tox-callbacks.c | 16 ++++++++++++++-- src/twc-utils.h | 10 +++++----- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/twc-bootstrap.c b/src/twc-bootstrap.c index 45c5325..68e638f 100644 --- a/src/twc-bootstrap.c +++ b/src/twc-bootstrap.c @@ -18,8 +18,11 @@ */ #include +#include #include "twc-utils.h" +#include "twc-profile.h" +#include "twc.h" #include "twc-bootstrap.h" @@ -209,6 +212,7 @@ twc_bootstrap_random_dht(Tox *tox) struct t_twc_bootstrap_node const *const node = &twc_bootstrap_nodes[i]; int result; result = twc_bootstrap_dht(tox, node->address, node->port, node->key); + weechat_printf(NULL, "Bootstrapped node %s %d %s", node->address, node->port, node->key); return result; } @@ -222,5 +226,6 @@ twc_bootstrap_random_relay(Tox *tox) struct t_twc_bootstrap_node const *const node = &twc_bootstrap_relays[i]; int result; result = twc_bootstrap_relay(tox, node->address, node->port, node->key); + weechat_printf(NULL, "Bootstrapped relay %s %d %s", node->address, node->port, node->key); return result; } diff --git a/src/twc-commands.c b/src/twc-commands.c index 297c49c..e68b7da 100644 --- a/src/twc-commands.c +++ b/src/twc-commands.c @@ -254,8 +254,9 @@ twc_cmd_bootstrap(const void *pointer, void *data, struct t_gui_buffer *buffer, } else { uint16_t i = 0; uint16_t num = atoi(argv[2]); + if (num == 0) num = 1; while (i < num) { - num = num + 1; + i = i + 1; if (!twc_bootstrap_random_dht(profile->tox)) { weechat_printf(profile->buffer, @@ -308,7 +309,7 @@ twc_cmd_bootstrap(const void *pointer, void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } status = tox_self_get_connection_status(profile->tox); - if ( status == TOX_CONNECTION_NONE) { + if ( status != TOX_CONNECTION_NONE) { weechat_printf(profile->buffer, "%sBootstrap connected.", weechat_prefix("network")); @@ -320,8 +321,9 @@ twc_cmd_bootstrap(const void *pointer, void *data, struct t_gui_buffer *buffer, } else { uint16_t i = 0; uint16_t num = atoi(argv[2]); + if (num == 0) num = 1; while (i < num) { - num = num + 1; + i = i + 1; if (!twc_bootstrap_random_relay(profile->tox)) { weechat_printf(profile->buffer, diff --git a/src/twc-tfer.c b/src/twc-tfer.c index c2a0331..d86cc9f 100644 --- a/src/twc-tfer.c +++ b/src/twc-tfer.c @@ -626,7 +626,7 @@ twc_tfer_buffer_refresh(struct t_twc_tfer *tfer) int twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index, enum t_twc_tfer_file_status check, - enum TOX_FILE_CONTROL send, + enum Tox_File_Control send, enum t_twc_tfer_file_status set) { struct t_twc_tfer_file *file; @@ -637,15 +637,16 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index, if (file->type == TWC_TFER_FILE_TYPE_UPLOADING && send == TOX_FILE_CONTROL_RESUME) return -1; - enum TOX_ERR_FILE_CONTROL control_error; + enum Tox_Err_File_Control control_error; tox_file_control(profile->tox, file->friend_number, file->file_number, send, &control_error); if (control_error) { weechat_printf(profile->buffer, - "%scannot send control command for \"%s\" file: %s", + "%scannot send control command for \"%s\" file: %d", weechat_prefix("error"), file->filename, - twc_tox_err_file_control(control_error)); + /* twc_tox_err_file_control() tox_err_file_control_to_string? */ + control_error); return 0; } else @@ -661,7 +662,7 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index, twc_tfer_file_update(profile->tfer, file); return 1; } - /* proforma */ + /* dunno */ return 0; } diff --git a/src/twc-tox-callbacks.c b/src/twc-tox-callbacks.c index a77dc84..e38c7c3 100644 --- a/src/twc-tox-callbacks.c +++ b/src/twc-tox-callbacks.c @@ -796,10 +796,22 @@ twc_tox_log_callback(Tox *tox, TOX_LOG_LEVEL level, const char *file, { case TOX_LOG_LEVEL_TRACE: color = weechat_color("gray"); - if (weechat_strcasecmp(file, "network.c") == 0) + if ((weechat_strcasecmp(file, "network.c") == 0) && + (weechat_strcasecmp(func, "loglogdata") == 0)) + return; + if ((weechat_strcasecmp(file, "TCP_common.c") == 0) && + (weechat_strcasecmp(func, "read_tcp_packet") == 0)) return; if (weechat_strcasecmp(file, "onion_client.c") == 0 && - weechat_strcasecmp(file, "onion_isconnected") != 0) + ( (weechat_strcasecmp(func, "onion_isconnected") == 0) || + ((weechat_strcasecmp(func, "new_sendback") == 0) || + (weechat_strcasecmp(func, "do_announce") == 0) || + (weechat_strcasecmp(func, "handle_announce_response_old") == 0) || + (weechat_strcasecmp(func, "client_send_announce_request") == 0) || + (weechat_strcasecmp(func, "handle_announce_response") == 0)))) + return; + if (weechat_strcasecmp(file, "Messenger.c") == 0 && + weechat_strcasecmp(func, "do_messenger") == 0) return; break; case TOX_LOG_LEVEL_DEBUG: diff --git a/src/twc-utils.h b/src/twc-utils.h index b1d2f3d..141fd54 100644 --- a/src/twc-utils.h +++ b/src/twc-utils.h @@ -59,18 +59,18 @@ int twc_set_buffer_logging(struct t_gui_buffer *buffer, bool logging); char * -twc_tox_err_file_control(enum TOX_ERR_FILE_CONTROL error); +twc_tox_err_file_control(enum Tox_Err_File_Control error); char * -twc_tox_err_file_get(enum TOX_ERR_FILE_GET error); +twc_tox_err_file_get(enum Tox_Err_File_Get error); char * -twc_tox_err_file_seek(enum TOX_ERR_FILE_SEEK error); +twc_tox_err_file_seek(enum Tox_Err_File_Seek error); char * -twc_tox_err_file_send(enum TOX_ERR_FILE_SEND error); +twc_tox_err_file_send(enum Tox_Err_File_Send error); char * -twc_tox_err_file_send_chunk(enum TOX_ERR_FILE_SEND_CHUNK error); +twc_tox_err_file_send_chunk(enum Tox_Err_File_Send_Chunk error); #endif /* TOX_WEECHAT_UTILS_H */