This commit is contained in:
emdee@spm.plastiras.org 2024-03-18 18:11:21 +00:00
parent 5213a1f99c
commit 1a18e112a7
5 changed files with 35 additions and 15 deletions

View File

@ -18,8 +18,11 @@
*/
#include <tox/tox.h>
#include <weechat/weechat-plugin.h>
#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;
}

View File

@ -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,

View File

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

View File

@ -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:

View File

@ -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 */