diff options
author | James Booth <boothj5@gmail.com> | 2012-12-06 00:23:11 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-12-06 00:23:11 +0000 |
commit | c8b650e8be50bcf3a8938833e4a8f29cb503047a (patch) | |
tree | 5fbc39e86c5f744e70faa47edd1f54952ed9583b /src | |
parent | b89ca4fc3ecfce7a99a5b3d4216eebeec657f586 (diff) | |
download | profani-tty-c8b650e8be50bcf3a8938833e4a8f29cb503047a.tar.gz |
Colour chat room members by presence for /who
Diffstat (limited to 'src')
-rw-r--r-- | src/room_chat.c | 2 | ||||
-rw-r--r-- | src/windows.c | 36 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/room_chat.c b/src/room_chat.c index a55b8910..46cb8ee6 100644 --- a/src/room_chat.c +++ b/src/room_chat.c @@ -275,7 +275,7 @@ room_get_roster(const char * const room) muc_room *chat_room = g_hash_table_lookup(rooms, room); if (chat_room != NULL) { - return g_hash_table_get_keys(chat_room->roster); + return g_hash_table_get_values(chat_room->roster); } else { return NULL; } diff --git a/src/windows.c b/src/windows.c index 3563f4ca..2aee2ec5 100644 --- a/src/windows.c +++ b/src/windows.c @@ -789,10 +789,44 @@ win_show_room_roster(const char * const room) wattron(win, COLOUR_ONLINE); while (roster != NULL) { - wprintw(win, "%s", roster->data); + PContact member = roster->data; + const char const *name = p_contact_jid(member); + const char const *show = p_contact_presence(member); + + if (strcmp(show, "away") == 0) { + wattron(win, COLOUR_AWAY); + } else if (strcmp(show, "chat") == 0) { + wattron(win, COLOUR_CHAT); + } else if (strcmp(show, "dnd") == 0) { + wattron(win, COLOUR_DND); + } else if (strcmp(show, "xa") == 0) { + wattron(win, COLOUR_XA); + } else if (strcmp(show, "online") == 0) { + wattron(win, COLOUR_ONLINE); + } else { + wattron(win, COLOUR_OFFLINE); + } + + wprintw(win, "%s", name); + + if (strcmp(show, "away") == 0) { + wattroff(win, COLOUR_AWAY); + } else if (strcmp(show, "chat") == 0) { + wattroff(win, COLOUR_CHAT); + } else if (strcmp(show, "dnd") == 0) { + wattroff(win, COLOUR_DND); + } else if (strcmp(show, "xa") == 0) { + wattroff(win, COLOUR_XA); + } else if (strcmp(show, "online") == 0) { + wattroff(win, COLOUR_ONLINE); + } else { + wattroff(win, COLOUR_OFFLINE); + } + if (roster->next != NULL) { wprintw(win, ", "); } + roster = g_list_next(roster); } |