diff --git a/src/twc-chat.c b/src/twc-chat.c index 9d270ad..2a021a7 100644 --- a/src/twc-chat.c +++ b/src/twc-chat.c @@ -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); } /** diff --git a/src/twc-group-invite.c b/src/twc-group-invite.c index 2d24b03..4fd2f2b 100644 --- a/src/twc-group-invite.c +++ b/src/twc-group-invite.c @@ -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); } diff --git a/src/twc-group-invite.h b/src/twc-group-invite.h index d1d7124..edd3838 100644 --- a/src/twc-group-invite.h +++ b/src/twc-group-invite.h @@ -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 diff --git a/src/twc-tox-callbacks.c b/src/twc-tox-callbacks.c index 4cce32b..51492ea 100644 --- a/src/twc-tox-callbacks.c +++ b/src/twc-tox-callbacks.c @@ -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); }