From 0f37e50419954dc7d57cc59c847f4c2a3b220150 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 2 Jul 2014 13:46:57 -0400 Subject: [PATCH] groupchat keys can sometimes start with a 0 --- src/chat.c | 7 ++++--- src/chat_commands.c | 4 ++-- src/friendlist.h | 3 ++- src/groupchat.c | 2 +- src/line_info.h | 2 +- src/windows.c | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/chat.c b/src/chat.c index 9518647..83d04f5 100644 --- a/src/chat.c +++ b/src/chat.c @@ -424,10 +424,11 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui snprintf(msg, sizeof(msg), "%s has invited you to a group chat.", name); line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); - snprintf(msg, sizeof(msg), "Type \"/join\" to join the chat.", name); - line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); + line_info_add(self, NULL, NULL, NULL, "Type \"/join\" to join the chat.", SYS_MSG, 0, 0); + + memcpy(friends[friendnumber].groupchat_key, group_pub_key, TOX_CLIENT_ID_SIZE); + friends[friendnumber].groupchat_pending = true; - memcpy(friends[friendnumber].pending_groupchat, group_pub_key, TOX_CLIENT_ID_SIZE); alert_window(self, WINDOW_ALERT_2, true); } diff --git a/src/chat_commands.c b/src/chat_commands.c index 4835a06..63f7035 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -132,9 +132,9 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar return; } - uint8_t *groupkey = friends[self->num].pending_groupchat; + uint8_t *groupkey = friends[self->num].groupchat_key; - if (groupkey[0] == '\0') { + if (!friends[self->num].groupchat_pending) { errmsg = "No pending group chat invite."; line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0); return; diff --git a/src/friendlist.h b/src/friendlist.h index 67761da..ebd4894 100644 --- a/src/friendlist.h +++ b/src/friendlist.h @@ -49,7 +49,8 @@ typedef struct { uint16_t namelength; uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH]; uint16_t statusmsg_len; - uint8_t pending_groupchat[TOX_CLIENT_ID_SIZE]; + uint8_t groupchat_key[TOX_CLIENT_ID_SIZE]; + bool groupchat_pending; uint8_t pub_key[TOX_CLIENT_ID_SIZE]; int32_t num; int chatwin; diff --git a/src/groupchat.c b/src/groupchat.c index 04a93da..44d62f9 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -307,7 +307,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum); int num_peers = groupchats[groupnum].num_peers; - if (peernum >= num_peers) + if (peernum > num_peers) return; /* get old peer name before updating name list */ diff --git a/src/line_info.h b/src/line_info.h index b04f7cc..8262004 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -28,7 +28,7 @@ #define MAX_HISTORY 10000 #define MIN_HISTORY 20 -#define MAX_QUEUE 32 +#define MAX_QUEUE 128 enum { SYS_MSG, diff --git a/src/windows.c b/src/windows.c index 19a4adf..f77e681 100644 --- a/src/windows.c +++ b/src/windows.c @@ -358,7 +358,7 @@ void on_window_resize(void) delwin(w->chatwin->infobox.win); w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); } -#endif /* #ifdef _SUPPORT_AUDIO */ +#endif /* _SUPPORT_AUDIO */ scrollok(w->chatwin->history, 0); }