Compare commits

...

4 Commits

Author SHA1 Message Date
1941bdcd64 src/twc-profile.c 2024-04-30 08:51:38 +00:00
1a18e112a7 fixes 2024-03-18 18:11:21 +00:00
5213a1f99c update 2024-03-10 00:50:27 +00:00
3bcc10086e README.md 2024-03-10 00:11:22 +00:00
7 changed files with 69 additions and 39 deletions

View File

@ -40,15 +40,17 @@ an example.
## Usage
- If the plugin does not load automatically, load it with `/plugin load tox`.
You may have to specify the full path to the plugin binary if you installed
it to a non-standard location.
- Create a new profile with `/tox create <profile name>`. The data file is
stored in `~/.cache/weechat/tox/` by default.
it to a non-standard location (/usr/local/share/weechat/plugins).
- Create a new profile with `/tox create <profile name>`. The tox profile is
stored in `~/.local/share/weechat/tox/<profile name>` by default.
- Load your profile and connect to the Tox network with
`/tox load <profile name>` (see also /bootstrap, /conf, /friend, /invite,
/me, /msg, /myid, /name, /names, /nospam, /part, /send,
/status, /statusmsg, /topic, /tox).
- Run `/help -listfull tox` to get a list of all available commands, and
`/set tox.*` for a list of options, including proxies.
`/tox load <profile name>`. See all profiles with `/tox list`.
- Run `/help -listfull tox` to get a list of all available commands (see
/bootstrap, /conf, /friend, /invite, /me, /msg, /myid, /name, /names,
/nospam, /part, /send, /status, /statusmsg, /topic, as well as /tox)
- See `/fset tox.profile.*` for a list of options, including proxies.
- With weechat NOT running you can edit the settings in
`~/.cache/share/weechat/tox.conf`.
### Common issues
@ -92,6 +94,6 @@ along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
---
This is a hard fork of https://github.com/haavard/tox-weechat/
now at https://git.macaw.me/emdee/tox-weechat You can also run weechat under
toxygen https://git.macaw.me/emdee/toxygen using qweechat
https://git.macaw.me/emdee/qweechat
now at https://git.plastiras.org/emdee/tox-weechat You can also run weechat under
toxygen https://git.plastiras.org/emdee/toxygen using qweechat
https://git.plastiras.org/emdee/qweechat

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

@ -575,26 +575,34 @@ twc_profile_set_online_status(struct t_twc_profile *profile, bool status)
if (!(profile)) {
weechat_printf(profile->buffer, "%sno profile",
weechat_prefix("network"));
} else if (profile->tox_online ^ status) {
TOX_CONNECTION connection = tox_self_get_connection_status(profile->tox);
return;
}
/* failsafe - called while exiting! */
if (!(profile->tox)) {
weechat_printf(profile->buffer, "%sno tox",
weechat_prefix("network"));
return;
}
if (profile->tox_online ^ status) {
TOX_CONNECTION connection = tox_self_get_connection_status(profile->tox);
profile->tox_online = status;
twc_profile_refresh_online_status();
profile->tox_online = status;
twc_profile_refresh_online_status();
if (connection == TOX_CONNECTION_TCP)
if (connection == TOX_CONNECTION_TCP)
{
weechat_printf(profile->buffer, "%sprofile %s TCP",
weechat_prefix("network"), profile->name);
weechat_printf(profile->buffer, "%sprofile %s TCP",
weechat_prefix("network"), profile->name);
}
else if (connection == TOX_CONNECTION_UDP)
else if (connection == TOX_CONNECTION_UDP)
{
weechat_printf(profile->buffer, "%sprofile %s UDP",
weechat_prefix("network"), profile->name);
weechat_printf(profile->buffer, "%sprofile %s UDP",
weechat_prefix("network"), profile->name);
}
else
else
{
weechat_printf(profile->buffer, "%sprofile %s disconnected",
weechat_prefix("network"), profile->name);
weechat_printf(profile->buffer, "%sprofile %s disconnected",
weechat_prefix("network"), profile->name);
}
}
}

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