diff options
author | James Booth <boothj5@gmail.com> | 2016-02-02 23:25:26 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-02-02 23:25:26 +0000 |
commit | 292c9cf4540dd1c3010cda128ce47d67b8011755 (patch) | |
tree | 34b7c941b00ab758796747651ee7c109703eef74 | |
parent | 3ddef99dfe7948a9ba657dc6d34f5213ed0f00c5 (diff) | |
download | profani-tty-292c9cf4540dd1c3010cda128ce47d67b8011755.tar.gz |
Handle occupant nick change in private wins
-rw-r--r-- | src/event/server_events.c | 2 | ||||
-rw-r--r-- | src/window_list.c | 24 | ||||
-rw-r--r-- | src/window_list.h | 1 |
3 files changed, 27 insertions, 0 deletions
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); |