1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-27 23:46:44 +02:00

Compare commits

..

35 Commits

Author SHA1 Message Date
f07283848f Add timestamps to logger and enable widechar for bazel build 2022-03-07 11:26:44 -05:00
d113b92baa Fix second bootstrap node info 2022-03-07 11:03:25 -05:00
59d1aed84c Add second testnet bootstrap node 2022-03-06 16:01:31 -05:00
7c799b0b60 some logging code cleanup 2022-03-06 15:45:48 -05:00
df77dbfeae Add support for new voice state feature 2022-03-06 15:45:47 -05:00
a7bee7e031 Fix name change notifications
Due to recent core changes we now need to store a peer's
previous name instead of relying on API lookups via the
peer_id in the name change callback in order to display
the correct info
2022-03-06 15:45:47 -05:00
a9ccaeab8d Fix some weird/incorrect code for printing private messages 2022-03-06 15:45:47 -05:00
a04da99aff Remove usage of deprecated API typedefs 2022-03-06 15:45:46 -05:00
13c38406e1 Hardcode testnet bootstrap node 2022-03-06 15:45:46 -05:00
73cfe94eb2 Add more descriptive errors to some moderation commands 2022-03-06 15:45:45 -05:00
229d334b75 Properly handle group mod event
We now update all peer roles if we get a moderation event
in which the peer ID is invalid, per recent API changes
2022-03-06 15:45:45 -05:00
375f511f70 Fix duplicate config example line 2022-03-06 15:45:45 -05:00
0907087439 Fix possible null deref 2022-03-06 15:45:44 -05:00
e1576e23b7 Update function name (merge conflict) 2022-03-06 15:45:44 -05:00
7f29705966 Refactor peer-specific commands
This takes into account the possibility of multiple peers in
the group using the same nick. The /whois command now lists
all peers associated with the input name, and all commands
that target a peer with a non-unique nick will require the
public key to be used.
2022-03-06 15:45:44 -05:00
493dfeff22 Fix rebase mistakes 2022-03-06 15:45:43 -05:00
e9f8293a0a Add topic lock command and callbacks 2022-03-06 15:45:43 -05:00
1d8aafba3b Don't announce/alert on self group join 2022-03-06 15:45:43 -05:00
f16aa35ebc Make /whois show both public key and name 2022-03-06 15:45:42 -05:00
a5b44dffd2 Add the ability to make peer-specific commands using public keys
This allows us to use commands on peers who may be using nicks with strange
or unsupported unicode characters
2022-03-06 15:45:42 -05:00
408c8f7c10 Add /list command that lists all group peers w/ public keys 2022-03-06 15:45:41 -05:00
85f9c1241c Remove some unnecessary code 2022-03-06 15:45:41 -05:00
6c88be7255 Re-add /group command
Another one lost in a rebase
2022-03-06 15:45:41 -05:00
707fb7f107 Add connection type to whois group peer queries 2022-03-06 15:45:40 -05:00
9a885ed2ba Remove redundant command /mykey
You can get your own key with the /whois command
2022-03-06 15:45:40 -05:00
d52604f43c Add groupchat help menu
It seems to have disappeared after a recent rebase
2022-03-06 15:45:40 -05:00
c136d18fc4 Disable DHT nodeslist fetching temporarily
We don't want to fetch the mainnet nodes list when we're on
the NGC testnet. This should be fixed before the NGC merge
2022-03-06 15:45:39 -05:00
2444b1f79a Merge with master (V0.11.1) 2022-03-06 15:45:39 -05:00
ad238fc2fd Sync with master branch 2022-03-06 15:45:39 -05:00
2625094d34 Fix/update groupchat UI 2022-03-06 15:45:38 -05:00
9848ca902e Fix bug causing group PM's to increment window notifications by 2 instead of 1 2022-03-06 15:45:38 -05:00
4c903bab64 Port fix for invalid error handling of widechar conversions from master 2022-03-06 15:45:37 -05:00
0a0756ec6a Fix/update group logging implementation 2022-03-06 15:45:37 -05:00
18ef7ff693 Fix merge conflicts with master 2022-03-06 15:45:37 -05:00
e6136d45d2 Implement new groupchats 2022-03-06 15:45:34 -05:00
17 changed files with 48 additions and 76 deletions

View File

@ -2,12 +2,12 @@
.\" Title: toxic.conf
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 2020-11-12
.\" Date: 2021-05-24
.\" Manual: Toxic Manual
.\" Source: toxic __VERSION__
.\" Language: English
.\"
.TH "TOXIC\&.CONF" "5" "2020\-11\-12" "toxic __VERSION__" "Toxic Manual"
.TH "TOXIC\&.CONF" "5" "2021\-05\-24" "toxic __VERSION__" "Toxic Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -138,11 +138,6 @@ Show welcome message on startup\&. true or false
Enable friend connection change notifications\&. true or false
.RE
.PP
\fBshow_group_connection_msg\fR
.RS 4
Enable group connection change notifications (does not include quit messages)\&. true or false
.RE
.PP
\fBnodelist_update_freq\fR
.RS 4
How often in days to update the DHT nodes list\&. (integer; 0 to disable)

View File

@ -87,9 +87,6 @@ OPTIONS
*show_connection_msg*;;
Enable friend connection change notifications. true or false
*show_group_connection_msg*;;
Enable group connection change notifications (does not include quit messages). true or false
*nodelist_update_freq*;;
How often in days to update the DHT nodes list. (integer; 0 to disable)

View File

@ -56,9 +56,6 @@ ui = {
// true to show friend connection change messages on the home screen
show_connection_msg=true;
// true to show peer connection change messages in groups (setting to false does not include user quit messages)
show_group_connection_msg=true;
// How often in days to update the DHT nodes list. (0 to disable updates)
nodeslist_update_freq=7;

View File

@ -593,10 +593,10 @@ int load_DHT_nodeslist(void)
memcpy(node->ip4, TESTNET_IP, sizeof(TESTNET_IP));
struct Node *node2 = &Nodes.list[1];
node2->have_ip4 = true;
node2->have_ip6 = true;
node2->port = TESTNET_PORT2;
memcpy(node2->key, TESTNET_KEY2, sizeof(TESTNET_KEY2));
memcpy(node2->ip4, TESTNET_IP2, sizeof(TESTNET_IP2));
memcpy(node2->ip6, TESTNET_IP2, sizeof(TESTNET_IP2));
Nodes.count = 2;

View File

@ -134,7 +134,7 @@ static void set_self_typingstatus(ToxWindow *self, Tox *m, bool is_typing)
ChatContext *ctx = self->chatwin;
Tox_Err_Set_Typing err;
TOX_ERR_SET_TYPING err;
tox_self_set_typing(m, self->num, is_typing, &err);
if (err != TOX_ERR_SET_TYPING_OK) {

View File

@ -1129,7 +1129,7 @@ int game_packet_send(const GameData *game, const uint8_t *data, size_t length, G
memcpy(packet + 1 + GAME_PACKET_HEADER_SIZE, data, length);
packet_length += length;
Tox_Err_Friend_Custom_Packet err;
TOX_ERR_FRIEND_CUSTOM_PACKET err;
if (!tox_friend_send_lossless_packet(game->tox, game->friend_number, packet, packet_length, &err)) {
fprintf(stderr, "failed to send game packet: error %d\n", err);

View File

@ -90,20 +90,20 @@ void cmd_ignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
return;
}
Tox_Err_Group_Set_Ignore err;
tox_group_set_ignore(m, self->num, peer_id, true, &err);
Tox_Err_Group_Toggle_Ignore err;
tox_group_toggle_ignore(m, self->num, peer_id, true, &err);
switch (err) {
case TOX_ERR_GROUP_SET_IGNORE_OK: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_OK: {
break;
}
case TOX_ERR_GROUP_SET_IGNORE_SELF: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_SELF: {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot ignore yourself.");
return;
}
case TOX_ERR_GROUP_SET_IGNORE_PEER_NOT_FOUND: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_PEER_NOT_FOUND: {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid.");
return;
}
@ -791,20 +791,20 @@ void cmd_unignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
Tox_Err_Group_Set_Ignore err;
tox_group_set_ignore(m, self->num, peer_id, false, &err);
Tox_Err_Group_Toggle_Ignore err;
tox_group_toggle_ignore(m, self->num, peer_id, false, &err);
switch (err) {
case TOX_ERR_GROUP_SET_IGNORE_OK: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_OK: {
break;
}
case TOX_ERR_GROUP_SET_IGNORE_SELF: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_SELF: {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot unignore yourself.");
return;
}
case TOX_ERR_GROUP_SET_IGNORE_PEER_NOT_FOUND: {
case TOX_ERR_GROUP_TOGGLE_IGNORE_PEER_NOT_FOUND: {
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid.");
return;
}

View File

@ -68,7 +68,7 @@ static int max_groupchat_index = 0;
extern struct user_settings *user_settings;
extern struct Winthread Winthread;
#define GROUP_SIDEBAR_OFFSET 3 /* Offset for the peer number box at the top of the statusbar */
#define GROUP_SIDEBAR_OFFSET 2 /* Offset for the peer number box at the top of the statusbar */
/* groupchat command names used for tab completion. */
static const char *group_cmd_list[] = {
@ -991,7 +991,7 @@ static void groupchat_onGroupPeerJoin(ToxWindow *self, Tox *m, uint32_t groupnum
++chat->max_idx;
}
if (timed_out(chat->time_connected, 60) && user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) { /* ignore join messages when we first connect to the group */
if (timed_out(chat->time_connected, 7)) { /* ignore join messages when we first connect to the group */
line_info_add(self, true, peer->name, NULL, CONNECTION, 0, GREEN, "has joined the room");
write_to_log("has joined the room", peer->name, self->chatwin->log, true);
@ -1027,7 +1027,7 @@ void groupchat_onGroupPeerExit(ToxWindow *self, Tox *m, uint32_t groupnumber, ui
if (length > 0) {
line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[Quit]: %s", part_message);
snprintf(log_str, sizeof(log_str), "has left the room (%s)", part_message);
} else if (user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) {
} else {
const char *exit_string = get_group_exit_string(exit_type);
line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[%s]", exit_string);
snprintf(log_str, sizeof(log_str), "[%s]", exit_string);
@ -1372,7 +1372,7 @@ static void send_group_message(ToxWindow *self, Tox *m, uint32_t groupnumber, co
Tox_Err_Group_Send_Message err;
if (!tox_group_send_message(m, groupnumber, type, (uint8_t *) msg, strlen(msg), NULL, &err)) {
if (!tox_group_send_message(m, groupnumber, type, (uint8_t *) msg, strlen(msg), &err)) {
if (err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS) {
const Tox_Group_Role role = tox_group_self_get_role(m, groupnumber, NULL);
@ -1669,15 +1669,14 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
mvwhline(ctx->sidebar, 1, 1, ACS_HLINE, SIDEBAR_WIDTH - 1);
wattroff(ctx->sidebar, COLOR_PAIR(BLUE));
const int maxlines = y2 - GROUP_SIDEBAR_OFFSET - CHATBOX_HEIGHT;
uint32_t offset = 0;
int maxlines = y2 - GROUP_SIDEBAR_OFFSET - CHATBOX_HEIGHT;
uint32_t i, offset = 0;
pthread_mutex_lock(&Winthread.lock);
const uint32_t max_idx = chat->max_idx;
const uint32_t start = chat->side_pos;
uint32_t max_idx = chat->max_idx;
pthread_mutex_unlock(&Winthread.lock);
for (uint32_t i = start; i < max_idx && offset < maxlines; ++i) {
for (i = 0; i < max_idx && i < maxlines; ++i) {
pthread_mutex_lock(&Winthread.lock);
if (!chat->peer_list[i].active) {
@ -1687,21 +1686,22 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
wmove(ctx->sidebar, offset + 2, 1);
const int maxlen_offset = chat->peer_list[i].role == TOX_GROUP_ROLE_USER ? 2 : 3;
int p = i + chat->side_pos;
int maxlen_offset = chat->peer_list[p].role == TOX_GROUP_ROLE_USER ? 2 : 3;
/* truncate nick to fit in side panel without modifying list */
char tmpnck[TOX_MAX_NAME_LENGTH];
const int maxlen = SIDEBAR_WIDTH - maxlen_offset;
int maxlen = SIDEBAR_WIDTH - maxlen_offset;
memcpy(tmpnck, chat->peer_list[i].name, maxlen);
memcpy(tmpnck, chat->peer_list[p].name, maxlen);
tmpnck[maxlen] = '\0';
int namecolour = WHITE;
if (chat->peer_list[i].status == TOX_USER_STATUS_AWAY) {
if (chat->peer_list[p].status == TOX_USER_STATUS_AWAY) {
namecolour = YELLOW;
} else if (chat->peer_list[i].status == TOX_USER_STATUS_BUSY) {
} else if (chat->peer_list[p].status == TOX_USER_STATUS_BUSY) {
namecolour = RED;
}
@ -1709,13 +1709,13 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
const char *rolesig = "";
int rolecolour = WHITE;
if (chat->peer_list[i].role == TOX_GROUP_ROLE_FOUNDER) {
if (chat->peer_list[p].role == TOX_GROUP_ROLE_FOUNDER) {
rolesig = "&";
rolecolour = BLUE;
} else if (chat->peer_list[i].role == TOX_GROUP_ROLE_MODERATOR) {
} else if (chat->peer_list[p].role == TOX_GROUP_ROLE_MODERATOR) {
rolesig = "+";
rolecolour = GREEN;
} else if (chat->peer_list[i].role == TOX_GROUP_ROLE_OBSERVER) {
} else if (chat->peer_list[p].role == TOX_GROUP_ROLE_OBSERVER) {
rolesig = "-";
rolecolour = MAGENTA;
}

View File

@ -186,6 +186,7 @@ static void help_draw_global(ToxWindow *self)
wprintw(win, " /nick <nick> : Set your nickname\n");
wprintw(win, " /nospam <value> : Change part of your Tox ID to stop spam\n");
wprintw(win, " /log <on> or <off> : Enable/disable logging\n");
wprintw(win, " /conference <type> : Create a conference where type: text | audio\n");
wprintw(win, " /myid : Print your Tox ID\n");
wprintw(win, " /group <name> : Create a new group chat\n");
#ifdef GAMES

View File

@ -144,14 +144,11 @@ static struct line_info *line_info_ret_queue(struct history *hst)
*/
static int print_n_chars(WINDOW *win, const wchar_t *s, size_t n, int max_y)
{
// we use an array to represent a single wchar in order to get around an ncurses
// bug with waddnwstr() that overreads the memory address by one byte when
// supplied with a single wchar.
wchar_t ch[2] = {0};
bool newline = false;
wchar_t ch;
for (size_t i = 0; i < n && (ch[0] = s[i]); ++i) {
if (ch[0] == L'\n') {
for (size_t i = 0; i < n && (ch = s[i]); ++i) {
if (ch == L'\n') {
newline = true;
int x;
@ -168,11 +165,11 @@ static int print_n_chars(WINDOW *win, const wchar_t *s, size_t n, int max_y)
if (win) {
#ifdef HAVE_WIDECHAR
waddnwstr(win, ch, 1);
waddnwstr(win, &ch, 1);
#else
char b;
if (wcstombs(&b, ch, sizeof(char)) != 1) {
if (wcstombs(&b, &ch, sizeof(char)) != 1) {
continue;
}

View File

@ -48,7 +48,7 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type,
return;
}
struct cqueue_msg *new_m = calloc(1, sizeof(struct cqueue_msg));
struct cqueue_msg *new_m = malloc(sizeof(struct cqueue_msg));
if (new_m == NULL) {
exit_toxic_err("failed in cqueue_message", FATALERR_MEMORY);
@ -62,7 +62,6 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type,
new_m->time_added = get_unix_time();
new_m->receipt = -1;
new_m->next = NULL;
new_m->noread_flag = false;
if (q->root == NULL) {
new_m->prev = NULL;
@ -204,7 +203,7 @@ void cqueue_try_send(ToxWindow *self, Tox *m)
return;
}
Tox_Err_Friend_Send_Message err;
TOX_ERR_FRIEND_SEND_MESSAGE err;
Tox_Message_Type type = msg->type == OUT_MSG ? TOX_MESSAGE_TYPE_NORMAL : TOX_MESSAGE_TYPE_ACTION;
uint32_t receipt = tox_friend_send_message(m, self->num, type, (uint8_t *) msg->message, msg->len, &err);

View File

@ -20,10 +20,9 @@
*
*/
#include "api.h"
#ifdef PYTHON
#include <Python.h>
#include "api.h"
#include "execute.h"

View File

@ -63,7 +63,6 @@ static struct ui_strings {
const char *show_typing_other;
const char *show_welcome_msg;
const char *show_connection_msg;
const char *show_group_connection_msg;
const char *nodeslist_update_freq;
const char *autosave_freq;
@ -100,7 +99,6 @@ static struct ui_strings {
"show_typing_other",
"show_welcome_msg",
"show_connection_msg",
"show_group_connection_msg",
"nodeslist_update_freq",
"autosave_freq",
"line_join",
@ -138,7 +136,6 @@ static void ui_defaults(struct user_settings *settings)
settings->show_typing_other = SHOW_TYPING_ON;
settings->show_welcome_msg = SHOW_WELCOME_MSG_ON;
settings->show_connection_msg = SHOW_CONNECTION_MSG_ON;
settings->show_group_connection_msg = SHOW_GROUP_CONNECTION_MSG_ON;
settings->nodeslist_update_freq = 1;
settings->autosave_freq = 600;
@ -408,7 +405,6 @@ int settings_load(struct user_settings *s, const char *patharg)
config_setting_lookup_bool(setting, ui_strings.show_typing_other, &s->show_typing_other);
config_setting_lookup_bool(setting, ui_strings.show_welcome_msg, &s->show_welcome_msg);
config_setting_lookup_bool(setting, ui_strings.show_connection_msg, &s->show_connection_msg);
config_setting_lookup_bool(setting, ui_strings.show_group_connection_msg, &s->show_group_connection_msg);
config_setting_lookup_int(setting, ui_strings.history_size, &s->history_size);
config_setting_lookup_int(setting, ui_strings.notification_timeout, &s->notification_timeout);

View File

@ -54,7 +54,6 @@ struct user_settings {
int show_typing_other; /* boolean */
int show_welcome_msg; /* boolean */
int show_connection_msg; /* boolean */
int show_group_connection_msg; /* boolean */
int nodeslist_update_freq; /* int (<= 0 to disable updates) */
int autosave_freq; /* int (<= 0 to disable autosave) */
@ -123,9 +122,6 @@ enum settings_values {
SHOW_CONNECTION_MSG_OFF = 0,
SHOW_CONNECTION_MSG_ON = 1,
SHOW_GROUP_CONNECTION_MSG_OFF = 0,
SHOW_GROUP_CONNECTION_MSG_ON = 1,
DFLT_HST_SIZE = 700,
MPLEX_OFF = 0,

View File

@ -37,7 +37,6 @@
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <termios.h>
#include <time.h>
@ -268,14 +267,12 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l
fp = stderr;
}
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm tmp;
gmtime_r(&tv.tv_sec, &tmp);
const time_t t = time(NULL);
struct tm *tmp = gmtime(&t);
char timestamp[200];
strftime(timestamp, sizeof(timestamp), "%F %T", &tmp);
strftime(timestamp, sizeof(timestamp), "%F %T", tmp);
fprintf(fp, "%c %s.%06ld %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, tv.tv_usec, file, line, func, message);
fprintf(fp, "[%c] %s %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, file, line, func, message);
fflush(fp);
}

View File

@ -152,7 +152,7 @@ void on_group_invite(Tox *m, uint32_t friendnumber, const uint8_t *invite_data,
const uint8_t *group_name,
size_t group_name_length, void *userdata);
void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type,
const uint8_t *message, size_t length, uint32_t message_id, void *userdata);
const uint8_t *message, size_t length, void *userdata);
void on_group_private_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type,
const uint8_t *message, size_t length,
void *userdata);

View File

@ -395,10 +395,8 @@ void on_group_invite(Tox *m, uint32_t friendnumber, const uint8_t *invite_data,
}
void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type,
const uint8_t *message, size_t length, uint32_t message_id, void *userdata)
const uint8_t *message, size_t length, void *userdata)
{
UNUSED_VAR(message_id);
char msg[MAX_STR_SIZE + 1];
length = copy_tox_str(msg, sizeof(msg), (const char *) message, length);