Fixed group chat joining.
This commit is contained in:
parent
4d852487b2
commit
06ca342213
@ -273,11 +273,15 @@ twc_chat_send_message(struct t_twc_chat *chat,
|
|||||||
twc_message_queue_add_friend_message(chat->profile,
|
twc_message_queue_add_friend_message(chat->profile,
|
||||||
chat->friend_number,
|
chat->friend_number,
|
||||||
message, message_type);
|
message, message_type);
|
||||||
}
|
|
||||||
|
|
||||||
char *name = twc_get_self_name_nt(chat->profile->tox);
|
char *name = twc_get_self_name_nt(chat->profile->tox);
|
||||||
twc_chat_print_message(chat, "", name, message, message_type);
|
twc_chat_print_message(chat, "", name, message, message_type);
|
||||||
free(name);
|
free(name);
|
||||||
|
}
|
||||||
|
else if (chat->group_number >= 0)
|
||||||
|
{
|
||||||
|
tox_group_message_send(chat->profile->tox, chat->group_number,
|
||||||
|
(uint8_t *)message, strlen(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
int
|
int
|
||||||
twc_group_chat_invite_add(struct t_twc_profile *profile,
|
twc_group_chat_invite_add(struct t_twc_profile *profile,
|
||||||
int32_t friend_number,
|
int32_t friend_number,
|
||||||
const uint8_t *data,
|
uint8_t *data,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
// create a new invite object
|
// create a new invite object
|
||||||
@ -46,9 +46,12 @@ twc_group_chat_invite_add(struct t_twc_profile *profile,
|
|||||||
if (!invite)
|
if (!invite)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
uint8_t *data_copy = malloc(size);
|
||||||
|
memcpy(data_copy, data, size);
|
||||||
|
|
||||||
invite->profile = profile;
|
invite->profile = profile;
|
||||||
invite->friend_number = friend_number;
|
invite->friend_number = friend_number;
|
||||||
invite->data = data;
|
invite->data = data_copy;
|
||||||
invite->data_size = size;
|
invite->data_size = size;
|
||||||
|
|
||||||
twc_list_item_new_data_add(profile->group_chat_invites, invite);
|
twc_list_item_new_data_add(profile->group_chat_invites, invite);
|
||||||
@ -98,6 +101,7 @@ twc_group_chat_invite_with_index(struct t_twc_profile *profile,
|
|||||||
void
|
void
|
||||||
twc_group_chat_invite_free(struct t_twc_group_chat_invite *invite)
|
twc_group_chat_invite_free(struct t_twc_group_chat_invite *invite)
|
||||||
{
|
{
|
||||||
|
free(invite->data);
|
||||||
free(invite);
|
free(invite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ struct t_twc_group_chat_invite
|
|||||||
struct t_twc_profile *profile;
|
struct t_twc_profile *profile;
|
||||||
|
|
||||||
int32_t friend_number;
|
int32_t friend_number;
|
||||||
const uint8_t *data;
|
uint8_t *data;
|
||||||
size_t data_size;
|
size_t data_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
twc_group_chat_invite_add(struct t_twc_profile *profile,
|
twc_group_chat_invite_add(struct t_twc_profile *profile,
|
||||||
int32_t friend_number,
|
int32_t friend_number,
|
||||||
const uint8_t *data,
|
uint8_t *data,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -250,7 +250,8 @@ twc_group_invite_callback(Tox *tox,
|
|||||||
{
|
{
|
||||||
struct t_twc_profile *profile = data;
|
struct t_twc_profile *profile = data;
|
||||||
|
|
||||||
int64_t rc = twc_group_chat_invite_add(profile, friend_number, invite_data, length);
|
int64_t rc = twc_group_chat_invite_add(profile, friend_number,
|
||||||
|
(uint8_t *)invite_data, length);
|
||||||
|
|
||||||
char *friend_name = twc_get_name_nt(profile->tox, friend_number);
|
char *friend_name = twc_get_name_nt(profile->tox, friend_number);
|
||||||
weechat_printf(profile->buffer,
|
weechat_printf(profile->buffer,
|
||||||
@ -259,7 +260,6 @@ twc_group_invite_callback(Tox *tox,
|
|||||||
weechat_prefix("network"),
|
weechat_prefix("network"),
|
||||||
friend_name, rc);
|
friend_name, rc);
|
||||||
|
|
||||||
|
|
||||||
free(friend_name);
|
free(friend_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user