diff --git a/src/command.c b/src/command.c index 3606ad3b..d688061f 100644 --- a/src/command.c +++ b/src/command.c @@ -1584,7 +1584,11 @@ _cmd_info(gchar **args, struct cmd_help_t help) if (conn_status != JABBER_CONNECTED) { cons_show("You are not currently connected."); } else { - cons_show_status(usr); + if (win_current_is_groupchat()) { + win_show_status(usr); + } else { + cons_show_status(usr); + } } return TRUE; diff --git a/src/muc.c b/src/muc.c index 79cf1208..ece77818 100644 --- a/src/muc.c +++ b/src/muc.c @@ -241,6 +241,19 @@ muc_remove_from_roster(const char * const room, const char * const nick) } } +PContact +muc_get_participant(const char * const room, const char * const nick) +{ + ChatRoom *chat_room = g_hash_table_lookup(rooms, room); + + if (chat_room != NULL) { + PContact participant = g_hash_table_lookup(chat_room->roster, nick); + return participant; + } + + return NULL; +} + /* * Return a list of PContacts representing the room members in the room's roster * The list is owned by the room and must not be mofified or freed diff --git a/src/muc.h b/src/muc.h index b0722e96..8411cb39 100644 --- a/src/muc.h +++ b/src/muc.h @@ -44,6 +44,7 @@ void muc_remove_from_roster(const char * const room, const char * const nick); GList * muc_get_roster(const char * const room); PAutocomplete muc_get_roster_ac(const char * const room); gboolean muc_nick_in_roster(const char * const room, const char * const nick); +PContact muc_get_participant(const char * const room, const char * const nick); void muc_set_roster_received(const char * const room); gboolean muc_get_roster_received(const char * const room); diff --git a/src/ui.h b/src/ui.h index 223b6a0c..32f34484 100644 --- a/src/ui.h +++ b/src/ui.h @@ -132,6 +132,7 @@ void win_show_room_member_nick_change(const char * const room, 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); +void win_show_status(const char * const contact); // console window actions void cons_about(void); diff --git a/src/windows.c b/src/windows.c index a4b12917..51322de2 100644 --- a/src/windows.c +++ b/src/windows.c @@ -88,7 +88,7 @@ static void _set_current(int index); static void _create_windows(void); static void _cons_splash_logo(void); static void _cons_show_basic_help(void); -static void _cons_show_contact(PContact contact); +static void _win_show_contact(ProfWin *window, PContact contact); static int _find_prof_win_index(const char * const contact); static int _new_prof_win(const char * const contact, win_type_t type); static void _current_window_refresh(void); @@ -1166,12 +1166,24 @@ cons_show_status(const char * const contact) PContact pcontact = contact_list_get_contact(contact); if (pcontact != NULL) { - _cons_show_contact(pcontact); + _win_show_contact(console, pcontact); } else { cons_show("No such contact \"%s\" in roster.", contact); } } +void +win_show_status(const char * const contact) +{ + PContact pcontact = muc_get_participant(win_current_get_recipient(), contact); + + if (pcontact != NULL) { + _win_show_contact(current, pcontact); + } else { + win_current_show("No such participant \"%s\" in room.", contact); + } +} + void cons_show_account(ProfAccount *account) { @@ -1522,7 +1534,7 @@ cons_show_contacts(GSList *list) while(curr) { PContact contact = curr->data; if (strcmp(p_contact_subscription(contact), "none") != 0) { - _cons_show_contact(contact); + _win_show_contact(console, contact); } curr = g_slist_next(curr); } @@ -2063,7 +2075,7 @@ _cons_show_incoming_message(const char * const short_from, const int win_index) } static void -_cons_show_contact(PContact contact) +_win_show_contact(ProfWin *window, PContact contact) { const char *jid = p_contact_jid(contact); const char *name = p_contact_name(contact); @@ -2071,68 +2083,68 @@ _cons_show_contact(PContact contact) const char *status = p_contact_status(contact); GDateTime *last_activity = p_contact_last_activity(contact); - _win_show_time(console->win); + _win_show_time(window->win); if (strcmp(presence, "online") == 0) { - wattron(console->win, COLOUR_ONLINE); + wattron(window->win, COLOUR_ONLINE); } else if (strcmp(presence, "away") == 0) { - wattron(console->win, COLOUR_AWAY); + wattron(window->win, COLOUR_AWAY); } else if (strcmp(presence, "chat") == 0) { - wattron(console->win, COLOUR_CHAT); + wattron(window->win, COLOUR_CHAT); } else if (strcmp(presence, "dnd") == 0) { - wattron(console->win, COLOUR_DND); + wattron(window->win, COLOUR_DND); } else if (strcmp(presence, "xa") == 0) { - wattron(console->win, COLOUR_XA); + wattron(window->win, COLOUR_XA); } else { - wattron(console->win, COLOUR_OFFLINE); + wattron(window->win, COLOUR_OFFLINE); } - wprintw(console->win, "%s", jid); + wprintw(window->win, "%s", jid); if (name != NULL) { - wprintw(console->win, " (%s)", name); + wprintw(window->win, " (%s)", name); } - wprintw(console->win, " is %s", presence); + wprintw(window->win, " is %s", presence); if (last_activity != NULL) { GDateTime *now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); - wprintw(console->win, ", idle "); + wprintw(window->win, ", idle "); int hours = span / G_TIME_SPAN_HOUR; span = span - hours * G_TIME_SPAN_HOUR; if (hours > 0) { - wprintw(console->win, "%dh", hours); + wprintw(window->win, "%dh", hours); } int minutes = span / G_TIME_SPAN_MINUTE; span = span - minutes * G_TIME_SPAN_MINUTE; - wprintw(console->win, "%dm", minutes); + wprintw(window->win, "%dm", minutes); int seconds = span / G_TIME_SPAN_SECOND; - wprintw(console->win, "%ds", seconds); + wprintw(window->win, "%ds", seconds); } if (status != NULL) { - wprintw(console->win, ", \"%s\"", p_contact_status(contact)); + wprintw(window->win, ", \"%s\"", p_contact_status(contact)); } - wprintw(console->win, "\n"); + wprintw(window->win, "\n"); if (strcmp(presence, "online") == 0) { - wattroff(console->win, COLOUR_ONLINE); + wattroff(window->win, COLOUR_ONLINE); } else if (strcmp(presence, "away") == 0) { - wattroff(console->win, COLOUR_AWAY); + wattroff(window->win, COLOUR_AWAY); } else if (strcmp(presence, "chat") == 0) { - wattroff(console->win, COLOUR_CHAT); + wattroff(window->win, COLOUR_CHAT); } else if (strcmp(presence, "dnd") == 0) { - wattroff(console->win, COLOUR_DND); + wattroff(window->win, COLOUR_DND); } else if (strcmp(presence, "xa") == 0) { - wattroff(console->win, COLOUR_XA); + wattroff(window->win, COLOUR_XA); } else { - wattroff(console->win, COLOUR_OFFLINE); + wattroff(window->win, COLOUR_OFFLINE); } }