mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Show message when own nickname changed in chat rooms
This commit is contained in:
parent
c6b07533c9
commit
bd3f1d1575
19
src/jabber.c
19
src/jabber.c
@ -275,8 +275,6 @@ jabber_change_room_nick(const char * const room, const char * const nick)
|
||||
xmpp_send(jabber_conn.conn, presence);
|
||||
xmpp_stanza_release(presence);
|
||||
|
||||
room_change_nick(room, nick);
|
||||
|
||||
free(full_room_jid);
|
||||
}
|
||||
|
||||
@ -711,14 +709,23 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
|
||||
// handle self presence
|
||||
if (stanza_is_muc_self_presence(stanza)) {
|
||||
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
|
||||
gboolean nick_change = stanza_is_room_nick_change(stanza);
|
||||
|
||||
// left room
|
||||
if (type != NULL) {
|
||||
if (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0) {
|
||||
if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
|
||||
|
||||
// leave room if not self nick change
|
||||
if (nick_change) {
|
||||
room_set_pending_nick_change(room);
|
||||
} else {
|
||||
prof_handle_leave_room(room);
|
||||
}
|
||||
|
||||
// roster received
|
||||
// handle self nick change
|
||||
} else if (room_is_pending_nick_change(room)) {
|
||||
room_change_nick(room, nick);
|
||||
prof_handle_room_nick_change(room, nick);
|
||||
|
||||
// handle roster complete
|
||||
} else {
|
||||
prof_handle_room_roster_complete(room);
|
||||
}
|
||||
|
@ -310,6 +310,14 @@ prof_handle_room_member_nick_change(const char * const room,
|
||||
win_page_off();
|
||||
}
|
||||
|
||||
void
|
||||
prof_handle_room_nick_change(const char * const room,
|
||||
const char * const nick)
|
||||
{
|
||||
win_show_room_nick_change(room, nick);
|
||||
win_page_off();
|
||||
}
|
||||
|
||||
static void
|
||||
_create_config_directory(void)
|
||||
{
|
||||
|
@ -54,5 +54,7 @@ void prof_handle_room_member_offline(const char * const room,
|
||||
void prof_handle_leave_room(const char * const room);
|
||||
void prof_handle_room_member_nick_change(const char * const room,
|
||||
const char * const old_nick, const char * const nick);
|
||||
void prof_handle_room_nick_change(const char * const room,
|
||||
const char * const nick);
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@
|
||||
typedef struct _muc_room_t {
|
||||
char *room;
|
||||
char *nick;
|
||||
gboolean pending_nick_change;
|
||||
GHashTable *roster;
|
||||
GHashTable *nick_changes;
|
||||
gboolean roster_received;
|
||||
@ -55,10 +56,33 @@ room_join(const char * const room, const char * const nick)
|
||||
new_room->nick_changes = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
g_free, g_free);
|
||||
new_room->roster_received = FALSE;
|
||||
new_room->pending_nick_change = FALSE;
|
||||
|
||||
g_hash_table_insert(rooms, strdup(room), new_room);
|
||||
}
|
||||
|
||||
void
|
||||
room_set_pending_nick_change(const char * const room)
|
||||
{
|
||||
muc_room *chat_room = g_hash_table_lookup(rooms, room);
|
||||
|
||||
if (chat_room != NULL) {
|
||||
chat_room->pending_nick_change = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
room_is_pending_nick_change(const char * const room)
|
||||
{
|
||||
muc_room *chat_room = g_hash_table_lookup(rooms, room);
|
||||
|
||||
if (chat_room != NULL) {
|
||||
return chat_room->pending_nick_change;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
room_change_nick(const char * const room, const char * const nick)
|
||||
{
|
||||
@ -67,6 +91,7 @@ room_change_nick(const char * const room, const char * const nick)
|
||||
if (chat_room != NULL) {
|
||||
free(chat_room->nick);
|
||||
chat_room->nick = strdup(nick);
|
||||
chat_room->pending_nick_change = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,5 +47,7 @@ gboolean room_get_roster_received(const char * const room);
|
||||
void room_remove_from_roster(const char * const room, const char * const nick);
|
||||
char * room_create_full_room_jid(const char * const room,
|
||||
const char * const nick);
|
||||
void room_set_pending_nick_change(const char * const room);
|
||||
gboolean room_is_pending_nick_change(const char * const room);
|
||||
|
||||
#endif
|
||||
|
1
src/ui.h
1
src/ui.h
@ -133,6 +133,7 @@ void win_show_wins(void);
|
||||
int win_in_private_chat(void);
|
||||
void win_show_room_member_nick_change(const char * const room,
|
||||
const char * const old_nick, const char * const nick);
|
||||
void win_show_room_nick_change(const char * const room, const char * const nick);
|
||||
|
||||
// console window actions
|
||||
void cons_about(void);
|
||||
|
@ -735,7 +735,21 @@ win_show_room_member_nick_change(const char * const room,
|
||||
|
||||
if (win_index == _curr_prof_win)
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
win_show_room_nick_change(const char * const room, const char * const nick)
|
||||
{
|
||||
int win_index = _find_prof_win_index(room);
|
||||
WINDOW *win = _wins[win_index].win;
|
||||
|
||||
_win_show_time(win);
|
||||
wattron(win, COLOUR_ONLINE);
|
||||
wprintw(win, "** You are now known as %s\n", nick);
|
||||
wattroff(win, COLOUR_ONLINE);
|
||||
|
||||
if (win_index == _curr_prof_win)
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user