From 292c9cf4540dd1c3010cda128ce47d67b8011755 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 2 Feb 2016 23:25:26 +0000 Subject: Handle occupant nick change in private wins --- src/event/server_events.c | 2 ++ src/window_list.c | 24 ++++++++++++++++++++++++ src/window_list.h | 1 + 3 files changed, 27 insertions(+) diff --git a/src/event/server_events.c b/src/event/server_events.c index 17754272..35466be3 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -850,7 +850,9 @@ sv_ev_muc_occupant_online(const char *const room, const char *const nick, const if (mucwin) { mucwin_occupant_nick_change(mucwin, old_nick, nick); } + wins_private_nick_change(mucwin->roomjid, old_nick, nick); free(old_nick); + occupantswin_occupants(room); rosterwin_roster(); return; diff --git a/src/window_list.c b/src/window_list.c index 2acfd0fb..e4ef8a64 100644 --- a/src/window_list.c +++ b/src/window_list.c @@ -197,6 +197,30 @@ wins_get_private_chats(const char *const roomjid) return result; } +void +wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick) +{ + Jid *oldjid = jid_create_from_bare_and_resource(roomjid, oldnick); + + ProfPrivateWin *privwin = wins_get_private(oldjid->fulljid); + if (privwin) { + free(privwin->fulljid); + + Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); + privwin->fulljid = strdup(newjid->fulljid); + win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); + + autocomplete_remove(wins_ac, oldjid->fulljid); + autocomplete_remove(wins_close_ac, oldjid->fulljid); + autocomplete_add(wins_ac, newjid->fulljid); + autocomplete_add(wins_close_ac, newjid->fulljid); + + jid_destroy(newjid); + } + + jid_destroy(oldjid); +} + ProfWin* wins_get_current(void) { diff --git a/src/window_list.h b/src/window_list.h index 0d20d714..3c4c29fe 100644 --- a/src/window_list.h +++ b/src/window_list.h @@ -47,6 +47,7 @@ ProfWin* wins_new_private(const char *const fulljid); gboolean wins_chat_exists(const char *const barejid); GList* wins_get_private_chats(const char *const roomjid); +void wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick); ProfWin* wins_get_console(void); ProfChatWin* wins_get_chat(const char *const barejid); -- cgit 1.4.1-2-gfad0