mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 06:13:03 +01:00
Merge branch 'master' of github.com:Tox/toxic
This commit is contained in:
commit
a01cc35368
26
src/chat.c
26
src/chat.c
@ -563,28 +563,36 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int32_t num, uint8_t filenu
|
|||||||
Friends.list[num].file_receiver[filenum].bytes_recv += length;
|
Friends.list[num].file_receiver[filenum].bytes_recv += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, const char *group_pub_key)
|
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, const char *group_pub_key, uint16_t length)
|
||||||
{
|
{
|
||||||
if (self->num != friendnumber)
|
if (self->num != friendnumber)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Friends.list[friendnumber].group_invite.key != NULL)
|
||||||
|
free(Friends.list[friendnumber].group_invite.key);
|
||||||
|
|
||||||
|
char *k = malloc(length);
|
||||||
|
|
||||||
|
if (k == NULL)
|
||||||
|
exit_toxic_err("Failed in chat_onGroupInvite", FATALERR_MEMORY);
|
||||||
|
|
||||||
|
memcpy(k, group_pub_key, length);
|
||||||
|
Friends.list[friendnumber].group_invite.key = k;
|
||||||
|
Friends.list[friendnumber].group_invite.pending = true;
|
||||||
|
Friends.list[friendnumber].group_invite.length = length;
|
||||||
|
|
||||||
char name[TOX_MAX_NAME_LENGTH];
|
char name[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, name, friendnumber);
|
get_nick_truncate(m, name, friendnumber);
|
||||||
|
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s has invited you to a group chat.", name);
|
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
|
|
||||||
|
|
||||||
memcpy(Friends.list[friendnumber].groupchat_key, group_pub_key,
|
|
||||||
sizeof(Friends.list[friendnumber].groupchat_key));
|
|
||||||
Friends.list[friendnumber].groupchat_pending = true;
|
|
||||||
|
|
||||||
|
|
||||||
sound_notify(self, generic_message, NT_WNDALERT_2, NULL);
|
sound_notify(self, generic_message, NT_WNDALERT_2, NULL);
|
||||||
|
|
||||||
if (self->active_box != -1)
|
if (self->active_box != -1)
|
||||||
box_silent_notify2(self, NT_WNDALERT_2 | NT_NOFOCUS, self->active_box, "invites you to join group chat");
|
box_silent_notify2(self, NT_WNDALERT_2 | NT_NOFOCUS, self->active_box, "invites you to join group chat");
|
||||||
else
|
else
|
||||||
box_silent_notify(self, NT_WNDALERT_2 | NT_NOFOCUS, &self->active_box, name, "invites you to join group chat");
|
box_silent_notify(self, NT_WNDALERT_2 | NT_NOFOCUS, &self->active_box, name, "invites you to join group chat");
|
||||||
|
|
||||||
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s has invited you to a group chat.", name);
|
||||||
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Av Stuff */
|
/* Av Stuff */
|
||||||
|
@ -123,14 +123,15 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *groupkey = Friends.list[self->num].groupchat_key;
|
const char *groupkey = Friends.list[self->num].group_invite.key;
|
||||||
|
uint16_t length = Friends.list[self->num].group_invite.length;
|
||||||
|
|
||||||
if (!Friends.list[self->num].groupchat_pending) {
|
if (!Friends.list[self->num].group_invite.pending) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending group chat invite.");
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending group chat invite.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int groupnum = tox_join_groupchat(m, self->num, (uint8_t *) groupkey);
|
int groupnum = tox_join_groupchat(m, self->num, (uint8_t *) groupkey, length);
|
||||||
|
|
||||||
if (groupnum == -1) {
|
if (groupnum == -1) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize.");
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize.");
|
||||||
|
@ -112,6 +112,13 @@ static void realloc_blocklist(int n)
|
|||||||
|
|
||||||
void kill_friendlist(void)
|
void kill_friendlist(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i <= Friends.max_idx; ++i) {
|
||||||
|
if (Friends.list[i].group_invite.key != NULL)
|
||||||
|
free(Friends.list[i].group_invite.key);
|
||||||
|
}
|
||||||
|
|
||||||
realloc_blocklist(0);
|
realloc_blocklist(0);
|
||||||
realloc_friends(0);
|
realloc_friends(0);
|
||||||
}
|
}
|
||||||
@ -478,7 +485,7 @@ static void friendlist_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const char *group_pub_key)
|
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const char *group_pub_key, uint16_t length)
|
||||||
{
|
{
|
||||||
if (num >= Friends.max_idx)
|
if (num >= Friends.max_idx)
|
||||||
return;
|
return;
|
||||||
@ -521,6 +528,9 @@ static void delete_friend(Tox *m, int32_t f_num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Friends.list[f_num].group_invite.key != NULL)
|
||||||
|
free(Friends.list[f_num].group_invite.key);
|
||||||
|
|
||||||
tox_del_friend(m, f_num);
|
tox_del_friend(m, f_num);
|
||||||
memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));
|
memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));
|
||||||
|
|
||||||
|
@ -48,13 +48,17 @@ struct LastOnline {
|
|||||||
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
|
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GroupChatInvite {
|
||||||
|
char *key;
|
||||||
|
uint16_t length;
|
||||||
|
bool pending;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TOXIC_MAX_NAME_LENGTH];
|
char name[TOXIC_MAX_NAME_LENGTH];
|
||||||
int namelength;
|
int namelength;
|
||||||
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
|
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||||
uint16_t statusmsg_len;
|
uint16_t statusmsg_len;
|
||||||
char groupchat_key[TOX_CLIENT_ID_SIZE];
|
|
||||||
bool groupchat_pending;
|
|
||||||
char pub_key[TOX_CLIENT_ID_SIZE];
|
char pub_key[TOX_CLIENT_ID_SIZE];
|
||||||
int32_t num;
|
int32_t num;
|
||||||
int chatwin;
|
int chatwin;
|
||||||
@ -65,6 +69,7 @@ typedef struct {
|
|||||||
uint8_t status;
|
uint8_t status;
|
||||||
struct LastOnline last_online;
|
struct LastOnline last_online;
|
||||||
struct FileReceiver file_receiver[MAX_FILES];
|
struct FileReceiver file_receiver[MAX_FILES];
|
||||||
|
struct GroupChatInvite group_invite;
|
||||||
uint8_t active_file_receivers;
|
uint8_t active_file_receivers;
|
||||||
} ToxicFriend;
|
} ToxicFriend;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ void on_statusmessagechange(Tox *m, int32_t friendnumber, const uint8_t *string,
|
|||||||
void on_friendadded(Tox *m, int32_t friendnumber, bool sort);
|
void on_friendadded(Tox *m, int32_t friendnumber, bool sort);
|
||||||
void on_groupmessage(Tox *m, int groupnumber, int peernumber, const uint8_t *message, uint16_t length, void *userdata);
|
void on_groupmessage(Tox *m, int groupnumber, int peernumber, const uint8_t *message, uint16_t length, void *userdata);
|
||||||
void on_groupaction(Tox *m, int groupnumber, int peernumber, const uint8_t *action, uint16_t length, void *userdata);
|
void on_groupaction(Tox *m, int groupnumber, int peernumber, const uint8_t *action, uint16_t length, void *userdata);
|
||||||
void on_groupinvite(Tox *m, int32_t friendnumber, const uint8_t *group_pub_key, void *userdata);
|
void on_groupinvite(Tox *m, int32_t friendnumber, const uint8_t *group_pub_key, uint16_t length, void *userdata);
|
||||||
void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
||||||
void on_file_sendrequest(Tox *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, const uint8_t *pathname,
|
void on_file_sendrequest(Tox *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, const uint8_t *pathname,
|
||||||
uint16_t pathname_length, void *userdata);
|
uint16_t pathname_length, void *userdata);
|
||||||
|
@ -164,13 +164,13 @@ void on_groupaction(Tox *m, int groupnumber, int peernumber, const uint8_t *acti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_groupinvite(Tox *m, int32_t friendnumber, const uint8_t *group_pub_key, void *userdata)
|
void on_groupinvite(Tox *m, int32_t friendnumber, const uint8_t *group_pub_key, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||||
if (windows[i].onGroupInvite != NULL)
|
if (windows[i].onGroupInvite != NULL)
|
||||||
windows[i].onGroupInvite(&windows[i], m, friendnumber, (const char *) group_pub_key);
|
windows[i].onGroupInvite(&windows[i], m, friendnumber, (const char *) group_pub_key, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ struct ToxWindow {
|
|||||||
void(*onAction)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
|
void(*onAction)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
|
||||||
void(*onGroupMessage)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
|
void(*onGroupMessage)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
|
||||||
void(*onGroupAction)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
|
void(*onGroupAction)(ToxWindow *, Tox *, int, int, const char *, uint16_t);
|
||||||
void(*onGroupInvite)(ToxWindow *, Tox *, int32_t, const char *);
|
void(*onGroupInvite)(ToxWindow *, Tox *, int32_t, const char *, uint16_t);
|
||||||
void(*onGroupNamelistChange)(ToxWindow *, Tox *, int, int, uint8_t);
|
void(*onGroupNamelistChange)(ToxWindow *, Tox *, int, int, uint8_t);
|
||||||
void(*onFileSendRequest)(ToxWindow *, Tox *, int32_t, uint8_t, uint64_t, const char *, uint16_t);
|
void(*onFileSendRequest)(ToxWindow *, Tox *, int32_t, uint8_t, uint64_t, const char *, uint16_t);
|
||||||
void(*onFileControl)(ToxWindow *, Tox *, int32_t, uint8_t, uint8_t, uint8_t, const char *, uint16_t);
|
void(*onFileControl)(ToxWindow *, Tox *, int32_t, uint8_t, uint8_t, uint8_t, const char *, uint16_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user