mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handle /who command in chat rooms
This commit is contained in:
parent
efdd3e55db
commit
02a71e2510
@ -777,10 +777,9 @@ cmd_reset_autocomplete()
|
|||||||
if (nick_ac != NULL) {
|
if (nick_ac != NULL) {
|
||||||
p_autocomplete_reset(nick_ac);
|
p_autocomplete_reset(nick_ac);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p_autocomplete_reset(who_ac);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_autocomplete_reset(who_ac);
|
||||||
p_autocomplete_reset(prefs_ac);
|
p_autocomplete_reset(prefs_ac);
|
||||||
p_autocomplete_reset(log_ac);
|
p_autocomplete_reset(log_ac);
|
||||||
p_autocomplete_reset(commands_ac);
|
p_autocomplete_reset(commands_ac);
|
||||||
@ -1429,7 +1428,81 @@ _cmd_who(gchar **args, struct cmd_help_t help)
|
|||||||
} else {
|
} else {
|
||||||
if (win_current_is_groupchat()) {
|
if (win_current_is_groupchat()) {
|
||||||
char *room = win_current_get_recipient();
|
char *room = win_current_get_recipient();
|
||||||
win_show_room_roster(room);
|
GList *list = muc_get_roster(room);
|
||||||
|
|
||||||
|
// no arg, show all contacts
|
||||||
|
if (presence == NULL) {
|
||||||
|
win_show_room_roster(room, list, NULL);
|
||||||
|
|
||||||
|
// available
|
||||||
|
} else if (strcmp("available", presence) == 0) {
|
||||||
|
GList *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, "chat") == 0)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_show_room_roster(room, filtered, "available");
|
||||||
|
|
||||||
|
// unavailable
|
||||||
|
} else if (strcmp("unavailable", presence) == 0) {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
const char * const contact_presence = (p_contact_presence(contact));
|
||||||
|
if ((strcmp(contact_presence, "offline") == 0)
|
||||||
|
|| (strcmp(contact_presence, "away") == 0)
|
||||||
|
|| (strcmp(contact_presence, "dnd") == 0)
|
||||||
|
|| (strcmp(contact_presence, "xa") == 0)) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_show_room_roster(room, filtered, "unavailable");
|
||||||
|
|
||||||
|
// online, show all status that indicate online
|
||||||
|
} else if (strcmp("online", presence) == 0) {
|
||||||
|
GList *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_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_show_room_roster(room, filtered, "online");
|
||||||
|
|
||||||
|
// show specific status
|
||||||
|
} else {
|
||||||
|
GList *filtered = NULL;
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
PContact contact = list->data;
|
||||||
|
if (strcmp(p_contact_presence(contact), presence) == 0) {
|
||||||
|
filtered = g_list_append(filtered, contact);
|
||||||
|
}
|
||||||
|
list = g_list_next(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_show_room_roster(room, filtered, presence);
|
||||||
|
}
|
||||||
|
|
||||||
|
// not in groupchat window
|
||||||
} else {
|
} else {
|
||||||
GSList *list = get_contact_list();
|
GSList *list = get_contact_list();
|
||||||
|
|
||||||
|
@ -297,7 +297,8 @@ void
|
|||||||
prof_handle_room_roster_complete(const char * const room)
|
prof_handle_room_roster_complete(const char * const room)
|
||||||
{
|
{
|
||||||
muc_set_roster_received(room);
|
muc_set_roster_received(room);
|
||||||
win_show_room_roster(room);
|
GList *roster = muc_get_roster(room);
|
||||||
|
win_show_room_roster(room, roster, NULL);
|
||||||
win_current_page_off();
|
win_current_page_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
src/ui.h
2
src/ui.h
@ -115,7 +115,7 @@ void win_show_outgoing_msg(const char * const from, const char * const to,
|
|||||||
void win_new_chat_win(const char * const to);
|
void win_new_chat_win(const char * const to);
|
||||||
|
|
||||||
void win_join_chat(Jid *jid);
|
void win_join_chat(Jid *jid);
|
||||||
void win_show_room_roster(const char * const room);
|
void win_show_room_roster(const char * const room, GList *roster, const char * const presence);
|
||||||
void win_show_room_history(const char * const room_jid, const char * const nick,
|
void win_show_room_history(const char * const room_jid, const char * const nick,
|
||||||
GTimeVal tv_stamp, const char * const message);
|
GTimeVal tv_stamp, const char * const message);
|
||||||
void win_show_room_message(const char * const room_jid, const char * const nick,
|
void win_show_room_message(const char * const room_jid, const char * const nick,
|
||||||
|
@ -810,21 +810,27 @@ win_join_chat(Jid *jid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
win_show_room_roster(const char * const room)
|
win_show_room_roster(const char * const room, GList *roster, const char * const presence)
|
||||||
{
|
{
|
||||||
int win_index = _find_prof_win_index(room);
|
int win_index = _find_prof_win_index(room);
|
||||||
WINDOW *win = windows[win_index]->win;
|
WINDOW *win = windows[win_index]->win;
|
||||||
|
|
||||||
GList *roster = muc_get_roster(room);
|
|
||||||
|
|
||||||
_win_show_time(win, '!');
|
_win_show_time(win, '!');
|
||||||
if ((roster == NULL) || (g_list_length(roster) == 0)) {
|
if ((roster == NULL) || (g_list_length(roster) == 0)) {
|
||||||
wattron(win, COLOUR_ROOMINFO);
|
wattron(win, COLOUR_ROOMINFO);
|
||||||
|
if (presence == NULL) {
|
||||||
wprintw(win, "Room is empty.\n");
|
wprintw(win, "Room is empty.\n");
|
||||||
|
} else {
|
||||||
|
wprintw(win, "No participants are %s.\n", presence);
|
||||||
|
}
|
||||||
wattroff(win, COLOUR_ROOMINFO);
|
wattroff(win, COLOUR_ROOMINFO);
|
||||||
} else {
|
} else {
|
||||||
wattron(win, COLOUR_ROOMINFO);
|
wattron(win, COLOUR_ROOMINFO);
|
||||||
|
if (presence == NULL) {
|
||||||
wprintw(win, "Participants: ");
|
wprintw(win, "Participants: ");
|
||||||
|
} else {
|
||||||
|
wprintw(win, "Participants (%s): ", presence);
|
||||||
|
}
|
||||||
wattroff(win, COLOUR_ROOMINFO);
|
wattroff(win, COLOUR_ROOMINFO);
|
||||||
wattron(win, COLOUR_ONLINE);
|
wattron(win, COLOUR_ONLINE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user