nicklist added to proflie buffer to show online friends

This commit is contained in:
Gordon Quad 2016-12-05 00:19:33 +00:00
parent 043784e91d
commit 8501d36ee9
3 changed files with 23 additions and 0 deletions

View File

@ -285,6 +285,10 @@ twc_profile_load(struct t_twc_profile *profile)
profile, NULL);
if (!(profile->buffer))
return TWC_RC_ERROR;
profile->nicklist_group = weechat_nicklist_add_group(profile->buffer, NULL,
NULL, NULL, true);
weechat_buffer_set(profile->buffer, "nicklist", "1");
}
weechat_printf(profile->buffer,

View File

@ -51,6 +51,7 @@ struct t_twc_profile
int tox_online;
struct t_gui_buffer *buffer;
struct t_gui_nick_group *nicklist_group;
struct t_hook *tox_do_timer;
struct t_twc_list *chats;

View File

@ -84,6 +84,7 @@ twc_connection_status_callback(Tox *tox, uint32_t friend_number,
{
struct t_twc_profile *profile = data;
char *name = twc_get_name_nt(profile->tox, friend_number);
struct t_gui_nick *nick = NULL;
struct t_twc_chat *chat = twc_chat_search_friend(profile,
friend_number,
false);
@ -91,6 +92,11 @@ twc_connection_status_callback(Tox *tox, uint32_t friend_number,
// TODO: print in friend's buffer if it exists
if (status == 0)
{
nick = weechat_nicklist_search_nick(profile->buffer,
profile->nicklist_group, name);
if (nick)
weechat_nicklist_remove_nick(profile->buffer, nick);
weechat_printf(profile->buffer,
"%s%s just went offline.",
weechat_prefix("network"),
@ -105,6 +111,9 @@ twc_connection_status_callback(Tox *tox, uint32_t friend_number,
}
else if (status == 1)
{
weechat_nicklist_add_nick(profile->buffer, profile->nicklist_group,
name, NULL, NULL, NULL, 1);
weechat_printf(profile->buffer,
"%s%s just came online.",
weechat_prefix("network"),
@ -127,6 +136,7 @@ twc_name_change_callback(Tox *tox, uint32_t friend_number,
void *data)
{
struct t_twc_profile *profile = data;
struct t_gui_nick *nick = NULL;
struct t_twc_chat *chat = twc_chat_search_friend(profile,
friend_number,
false);
@ -146,6 +156,14 @@ twc_name_change_callback(Tox *tox, uint32_t friend_number,
old_name, new_name);
}
nick = weechat_nicklist_search_nick(profile->buffer,
profile->nicklist_group, old_name);
if (nick)
weechat_nicklist_remove_nick(profile->buffer, nick);
weechat_nicklist_add_nick(profile->buffer, profile->nicklist_group,
new_name, NULL, NULL, NULL, 1);
weechat_printf(profile->buffer,
"%s%s is now known as %s",
weechat_prefix("network"),