From b851cec9bccfeb7fe060a3e9b9aa74f2e09d9539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Tue, 18 Nov 2014 16:04:57 +0100 Subject: [PATCH] Added group chat title callback. --- src/twc-profile.c | 1 + src/twc-tox-callbacks.c | 25 +++++++++++++++++++++++++ src/twc-tox-callbacks.h | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/src/twc-profile.c b/src/twc-profile.c index 8d55bdb..067c1d3 100644 --- a/src/twc-profile.c +++ b/src/twc-profile.c @@ -311,6 +311,7 @@ twc_profile_load(struct t_twc_profile *profile) tox_callback_group_message(profile->tox, twc_group_message_callback, profile); tox_callback_group_action(profile->tox, twc_group_action_callback, profile); tox_callback_group_namelist_change(profile->tox, twc_group_namelist_change_callback, profile); + tox_callback_group_title(profile->tox, twc_group_title_callback, profile); } /** diff --git a/src/twc-tox-callbacks.c b/src/twc-tox-callbacks.c index d454a89..f41ccbd 100644 --- a/src/twc-tox-callbacks.c +++ b/src/twc-tox-callbacks.c @@ -388,3 +388,28 @@ twc_group_namelist_change_callback(Tox *tox, } } +void +twc_group_title_callback(Tox *tox, + int group_number, + int peer_number, + const uint8_t *title, + uint8_t length, + void *data) +{ + struct t_twc_profile *profile = data; + struct t_twc_chat *chat = twc_chat_search_group(profile, + group_number, + true); + twc_chat_queue_refresh(chat); + + if (peer_number >= 0) + { + char *name = twc_get_peer_name_nt(profile->tox, group_number, peer_number); + + char *topic = strndup((char *)title, length); + weechat_printf(chat->buffer, "%s%s has changed the topic to \"%s\"", + weechat_prefix("network"), name, topic); + free(topic); + } +} + diff --git a/src/twc-tox-callbacks.h b/src/twc-tox-callbacks.h index 3094e45..f5b6fd4 100644 --- a/src/twc-tox-callbacks.h +++ b/src/twc-tox-callbacks.h @@ -104,5 +104,13 @@ twc_group_namelist_change_callback(Tox *tox, uint8_t change_type, void *data); +void +twc_group_title_callback(Tox *tox, + int group_number, + int peer_number, + const uint8_t *title, + uint8_t length, + void *data); + #endif // TOX_WEECHAT_TOX_CALLBACKS_H