1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Handle room member presence

This commit is contained in:
James Booth 2012-11-19 00:26:31 +00:00
parent 6c52ccae1f
commit 645d1b74d5
7 changed files with 55 additions and 1 deletions

View File

@ -767,7 +767,11 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
room_add_to_roster(room, nick, show_str, status_str);
prof_handle_room_member_nick_change(room, old_nick, nick);
} else {
prof_handle_room_member_online(room, nick, show_str, status_str);
if (!room_nick_in_roster(room, nick)) {
prof_handle_room_member_online(room, nick, show_str, status_str);
} else {
prof_handle_room_member_presence(room, nick, show_str, status_str);
}
}
}
}

View File

@ -246,6 +246,19 @@ prof_handle_room_roster_complete(const char * const room)
win_page_off();
}
void
prof_handle_room_member_presence(const char * const room,
const char * const nick, const char * const show,
const char * const status)
{
gboolean updated = room_add_to_roster(room, nick, show, status);
if (updated) {
win_show_room_member_presence(room, nick, show, status);
win_page_off();
}
}
void
prof_handle_room_member_online(const char * const room, const char * const nick,
const char * const show, const char * const status)

View File

@ -51,6 +51,9 @@ void prof_handle_room_member_online(const char * const room,
const char * const nick, const char * const show, const char * const status);
void prof_handle_room_member_offline(const char * const room,
const char * const nick, const char * const show, const char * const status);
void prof_handle_room_member_presence(const char * const room,
const char * const nick, const char * const show,
const char * const status);
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);

View File

@ -201,6 +201,23 @@ room_parse_room_jid(const char * const full_room_jid, char **room, char **nick)
}
}
gboolean
room_nick_in_roster(const char * const room, const char * const nick)
{
muc_room *chat_room = g_hash_table_lookup(rooms, room);
if (chat_room != NULL) {
PContact contact = g_hash_table_lookup(chat_room->roster, nick);
if (contact != NULL) {
return TRUE;
} else {
return FALSE;
}
}
return FALSE;
}
gboolean
room_add_to_roster(const char * const room, const char * const nick,
const char * const show, const char * const status)

View File

@ -40,6 +40,7 @@ void room_add_pending_nick_change(const char * const room,
const char * const new_nick, const char * const old_nick);
char* room_complete_pending_nick_change(const char * const room,
const char * const nick);
gboolean room_nick_in_roster(const char * const room, const char * const nick);
GList * room_get_roster(const char * const room);
void room_set_roster_received(const char * const room);

View File

@ -134,6 +134,8 @@ 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);
void win_show_room_member_presence(const char * const room,
const char * const nick, const char * const show, const char * const status);
// console window actions
void cons_about(void);

View File

@ -721,6 +721,20 @@ win_show_room_member_online(const char * const room, const char * const nick,
dirty = TRUE;
}
void
win_show_room_member_presence(const char * const room, const char * const nick,
const char * const show, const char * const status)
{
int win_index = _find_prof_win_index(room);
if (win_index != NUM_WINS) {
WINDOW *win = _wins[win_index].win;
_show_status_string(win, nick, show, status, "++", "online");
}
if (win_index == _curr_prof_win)
dirty = TRUE;
}
void
win_show_room_member_nick_change(const char * const room,
const char * const old_nick, const char * const nick)