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

Using /who in chat room shows room occupants

This commit is contained in:
James Booth 2012-11-08 00:22:15 +00:00
parent 181669a8cb
commit c967cd9dc9
2 changed files with 55 additions and 49 deletions

View File

@ -896,47 +896,52 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
// valid arg // valid arg
} else { } else {
GSList *list = get_contact_list(); if (win_in_groupchat()) {
char *room = win_get_recipient();
// no arg, show all contacts win_show_room_roster(room);
if (presence == NULL) {
cons_show("All contacts:");
cons_show_contacts(list);
// online, show all status that indicate online
} else if (strcmp("online", presence) == 0) {
cons_show("Contacts (%s):", presence);
GSList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
const char * const contact_presence = (p_contact_presence(contact));
if ((strcmp(contact_presence, "online") == 0)
|| (strcmp(contact_presence, "away") == 0)
|| (strcmp(contact_presence, "dnd") == 0)
|| (strcmp(contact_presence, "xa") == 0)
|| (strcmp(contact_presence, "chat") == 0)) {
filtered = g_slist_append(filtered, contact);
}
list = g_slist_next(list);
}
cons_show_contacts(filtered);
// show specific status
} else { } else {
cons_show("Contacts (%s):", presence); GSList *list = get_contact_list();
GSList *filtered = NULL;
while (list != NULL) { // no arg, show all contacts
PContact contact = list->data; if (presence == NULL) {
if (strcmp(p_contact_presence(contact), presence) == 0) { cons_show("All contacts:");
filtered = g_slist_append(filtered, contact); cons_show_contacts(list);
// online, show all status that indicate online
} else if (strcmp("online", presence) == 0) {
cons_show("Contacts (%s):", presence);
GSList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
const char * const contact_presence = (p_contact_presence(contact));
if ((strcmp(contact_presence, "online") == 0)
|| (strcmp(contact_presence, "away") == 0)
|| (strcmp(contact_presence, "dnd") == 0)
|| (strcmp(contact_presence, "xa") == 0)
|| (strcmp(contact_presence, "chat") == 0)) {
filtered = g_slist_append(filtered, contact);
}
list = g_slist_next(list);
} }
list = g_slist_next(list);
}
cons_show_contacts(filtered); cons_show_contacts(filtered);
// show specific status
} else {
cons_show("Contacts (%s):", presence);
GSList *filtered = NULL;
while (list != NULL) {
PContact contact = list->data;
if (strcmp(p_contact_presence(contact), presence) == 0) {
filtered = g_slist_append(filtered, contact);
}
list = g_slist_next(list);
}
cons_show_contacts(filtered);
}
} }
} }
} }

View File

@ -502,22 +502,23 @@ win_show_room_roster(const char * const room)
GList *roster = room_get_roster(room); GList *roster = room_get_roster(room);
if (roster != NULL) { if ((roster == NULL) || (g_list_length(roster) == 0)) {
wprintw(win, "You are alone!\n");
} else {
wprintw(win, "Room occupants:\n"); wprintw(win, "Room occupants:\n");
} wattron(win, COLOUR_ONLINE);
wattron(win, COLOUR_ONLINE); while (roster != NULL) {
wprintw(win, "%s", roster->data);
while (roster != NULL) { if (roster->next != NULL) {
wprintw(win, "%s", roster->data); wprintw(win, ", ");
if (roster->next != NULL) { }
wprintw(win, ", "); roster = g_list_next(roster);
} }
roster = g_list_next(roster);
}
wprintw(win, "\n");
wattroff(win, COLOUR_ONLINE); wprintw(win, "\n");
wattroff(win, COLOUR_ONLINE);
}
if (win_index == _curr_prof_win) if (win_index == _curr_prof_win)
dirty = TRUE; dirty = TRUE;