1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:53:02 +01:00

groupchat keys can sometimes start with a 0

This commit is contained in:
Jfreegman 2014-07-02 13:46:57 -04:00
parent 95d09e4b75
commit 0f37e50419
6 changed files with 11 additions and 9 deletions

View File

@ -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); 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); 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, "Type \"/join\" to join the chat.", SYS_MSG, 0, 0);
line_info_add(self, NULL, NULL, NULL, msg, 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); alert_window(self, WINDOW_ALERT_2, true);
} }

View File

@ -132,9 +132,9 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
return; 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."; errmsg = "No pending group chat invite.";
line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0);
return; return;

View File

@ -49,7 +49,8 @@ typedef struct {
uint16_t namelength; uint16_t namelength;
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH]; uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
uint16_t statusmsg_len; 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]; uint8_t pub_key[TOX_CLIENT_ID_SIZE];
int32_t num; int32_t num;
int chatwin; int chatwin;

View File

@ -307,7 +307,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum); groupchats[groupnum].num_peers = tox_group_number_peers(m, groupnum);
int num_peers = groupchats[groupnum].num_peers; int num_peers = groupchats[groupnum].num_peers;
if (peernum >= num_peers) if (peernum > num_peers)
return; return;
/* get old peer name before updating name list */ /* get old peer name before updating name list */

View File

@ -28,7 +28,7 @@
#define MAX_HISTORY 10000 #define MAX_HISTORY 10000
#define MIN_HISTORY 20 #define MIN_HISTORY 20
#define MAX_QUEUE 32 #define MAX_QUEUE 128
enum { enum {
SYS_MSG, SYS_MSG,

View File

@ -358,7 +358,7 @@ void on_window_resize(void)
delwin(w->chatwin->infobox.win); delwin(w->chatwin->infobox.win);
w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); 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); scrollok(w->chatwin->history, 0);
} }