From 1925cb80ecc9a1f689a2797d65f34ead7b628bee Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 3 Jun 2014 21:35:27 +0100 Subject: [PATCH] Show info in chat and private chat windows --- src/command/commands.c | 18 +++--------------- src/ui/core.c | 32 ++++++++++++++++++++++++++++++++ src/ui/ui.h | 2 ++ 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index 100b90b5..b8124120 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1402,28 +1402,16 @@ cmd_info(gchar **args, struct cmd_help_t help) break; case WIN_CHAT: if (usr != NULL) { - cons_show("No parameter required for /info in chat."); + ui_current_print_line("No parameter required when in chat."); } else { - pcontact = roster_get_contact(recipient); - if (pcontact != NULL) { - cons_show_info(pcontact); - } else { - cons_show("No such contact \"%s\" in roster.", recipient); - } + ui_info(); } break; case WIN_PRIVATE: if (usr != NULL) { ui_current_print_line("No parameter required when in chat."); } else { - Jid *jid = jid_create(recipient); - pcontact = muc_get_participant(jid->barejid, jid->resourcepart); - if (pcontact != NULL) { - cons_show_info(pcontact); - } else { - cons_show("No such participant \"%s\" in room.", jid->resourcepart); - } - jid_destroy(jid); + ui_info_private(); } break; case WIN_CONSOLE: diff --git a/src/ui/core.c b/src/ui/core.c index d9a5d71b..b6a0ab9c 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1804,6 +1804,20 @@ _ui_status(void) } } +static void +_ui_info(void) +{ + char *recipient = ui_current_recipient(); + PContact pcontact = roster_get_contact(recipient); + ProfWin *current = wins_get_current(); + + if (pcontact != NULL) { + win_show_info(current, pcontact); + } else { + win_print_line(current, '-', 0, "Error getting contact info."); + } +} + static void _ui_status_private(void) { @@ -1820,6 +1834,22 @@ _ui_status_private(void) jid_destroy(jid); } +static void +_ui_info_private(void) +{ + Jid *jid = jid_create(ui_current_recipient()); + PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart); + ProfWin *current = wins_get_current(); + + if (pcontact != NULL) { + win_show_info(current, pcontact); + } else { + win_print_line(current, '-', 0, "Error getting contact info."); + } + + jid_destroy(jid); +} + static void _ui_status_room(const char * const contact) { @@ -2172,7 +2202,9 @@ ui_init_module(void) ui_room_subject = _ui_room_subject; ui_room_broadcast = _ui_room_broadcast; ui_status = _ui_status; + ui_info = _ui_info; ui_status_private = _ui_status_private; + ui_info_private = _ui_info_private; ui_status_room = _ui_status_room; ui_info_room = _ui_info_room; ui_unread = _ui_unread; diff --git a/src/ui/ui.h b/src/ui/ui.h index 3a3c311c..4021527d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -153,7 +153,9 @@ void (*ui_handle_room_join_error)(const char * const room, const char * const er void (*ui_status_room)(const char * const contact); void (*ui_info_room)(const char * const contact); void (*ui_status)(void); +void (*ui_info)(void); void (*ui_status_private)(void); +void (*ui_info_private)(void); void (*ui_create_duck_win)(void); void (*ui_open_duck_win)(void);