Fixed group chat joining.

This commit is contained in:
Håvard Pettersson 2014-10-05 02:16:43 +02:00
parent 4d852487b2
commit 06ca342213
4 changed files with 18 additions and 10 deletions

View File

@ -273,11 +273,15 @@ twc_chat_send_message(struct t_twc_chat *chat,
twc_message_queue_add_friend_message(chat->profile,
chat->friend_number,
message, message_type);
char *name = twc_get_self_name_nt(chat->profile->tox);
twc_chat_print_message(chat, "", name, message, message_type);
free(name);
}
else if (chat->group_number >= 0)
{
tox_group_message_send(chat->profile->tox, chat->group_number,
(uint8_t *)message, strlen(message));
}
char *name = twc_get_self_name_nt(chat->profile->tox);
twc_chat_print_message(chat, "", name, message, message_type);
free(name);
}
/**

View File

@ -37,7 +37,7 @@
int
twc_group_chat_invite_add(struct t_twc_profile *profile,
int32_t friend_number,
const uint8_t *data,
uint8_t *data,
size_t size)
{
// create a new invite object
@ -46,9 +46,12 @@ twc_group_chat_invite_add(struct t_twc_profile *profile,
if (!invite)
return -1;
uint8_t *data_copy = malloc(size);
memcpy(data_copy, data, size);
invite->profile = profile;
invite->friend_number = friend_number;
invite->data = data;
invite->data = data_copy;
invite->data_size = size;
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
twc_group_chat_invite_free(struct t_twc_group_chat_invite *invite)
{
free(invite->data);
free(invite);
}

View File

@ -34,14 +34,14 @@ struct t_twc_group_chat_invite
struct t_twc_profile *profile;
int32_t friend_number;
const uint8_t *data;
uint8_t *data;
size_t data_size;
};
int
twc_group_chat_invite_add(struct t_twc_profile *profile,
int32_t friend_number,
const uint8_t *data,
uint8_t *data,
size_t size);
int

View File

@ -250,7 +250,8 @@ twc_group_invite_callback(Tox *tox,
{
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);
weechat_printf(profile->buffer,
@ -259,7 +260,6 @@ twc_group_invite_callback(Tox *tox,
weechat_prefix("network"),
friend_name, rc);
free(friend_name);
}