diff options
author | James Booth <boothj5@gmail.com> | 2013-05-19 17:19:16 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-05-19 17:19:16 +0100 |
commit | 0a3aaf5a36d3b3baae613eefdab695968abefe4b (patch) | |
tree | c0d55b43d6133523fcb9c256e409b1eeb2e7da9f | |
parent | e1c9cbc9554dcb0d52c66410ff9638fdb6d5291e (diff) | |
download | profani-tty-0a3aaf5a36d3b3baae613eefdab695968abefe4b.tar.gz |
Use handle in chat windows if available
-rw-r--r-- | src/ui/core.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 68cc9537..552b0103 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -292,7 +292,16 @@ ui_incoming_msg(const char * const from, const char * const message, display_from = get_nick_from_full_jid(from); } else { win_type = WIN_CHAT; - display_from = strdup(from); + PContact contact = roster_get_contact(from); + if (contact != NULL) { + if (p_contact_name(contact) != NULL) { + display_from = strdup(p_contact_name(contact)); + } else { + display_from = strdup(from); + } + } else { + display_from = strdup(from); + } } int win_index = _find_prof_win_index(from); @@ -317,12 +326,12 @@ ui_incoming_msg(const char * const from, const char * const message, if (strncmp(message, "/me ", 4) == 0) { wattron(console->win, COLOUR_THEM); - wprintw(console->win, "*%s ", from); + wprintw(console->win, "*%s ", display_from); wprintw(console->win, "%s", message + 4); wprintw(console->win, "\n"); wattroff(console->win, COLOUR_THEM); } else { - _win_show_user(console->win, from, 1); + _win_show_user(console->win, display_from, 1); _win_show_message(console->win, message); } @@ -414,7 +423,7 @@ ui_incoming_msg(const char * const from, const char * const message, if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) notify_message(display_from); - g_free(display_from); + FREE_SET_NULL(display_from); } void |