diff options
author | James Booth <boothj5@gmail.com> | 2015-05-04 00:43:36 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-04 00:43:36 +0100 |
commit | bab4da039a69b4a51d7d909eb63c4667807c900c (patch) | |
tree | 46cfdf7835c9159806126d1285c67f9155f15b91 /src/ui | |
parent | 0f3bece9e2238a0d13731f4415dca573aec15415 (diff) | |
parent | c3d2a7e9377c9d16f1ee4ea57c6e0c1f78b5ac6e (diff) | |
download | profani-tty-bab4da039a69b4a51d7d909eb63c4667807c900c.tar.gz |
Merge branch 'master' into pgp
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/core.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 9deca664..fb1a4219 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -389,23 +389,6 @@ void ui_incoming_msg(const char * const barejid, const char * const resource, const char * const message, GTimeVal *tv_stamp) { gboolean win_created = FALSE; - GString *user = g_string_new(""); - - PContact contact = roster_get_contact(barejid); - if (contact != NULL) { - if (p_contact_name(contact) != NULL) { - g_string_append(user, p_contact_name(contact)); - } else { - g_string_append(user, barejid); - } - } else { - g_string_append(user, barejid); - } - - if (resource && prefs_get_boolean(PREF_RESOURCE_MESSAGE)) { - g_string_append(user, "/"); - g_string_append(user, resource); - } ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin == NULL) { @@ -415,19 +398,20 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c } ProfWin *window = (ProfWin*) chatwin; - int num = wins_get_num(window); + char *display_name = roster_get_msg_display_name(barejid, resource); + // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, tv_stamp, user->str, message); + win_print_incoming_message(window, tv_stamp, display_name, message); title_bar_set_typing(FALSE); status_bar_active(num); // not currently viewing chat window with sender } else { status_bar_new(num); - cons_show_incoming_message(user->str, num); + cons_show_incoming_message(display_name, num); if (prefs_get_boolean(PREF_FLASH)) { flash(); @@ -446,7 +430,7 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c } } - win_print_incoming_message(window, tv_stamp, user->str, message); + win_print_incoming_message(window, tv_stamp, display_name, message); } int ui_index = num; @@ -462,14 +446,14 @@ ui_incoming_msg(const char * const barejid, const char * const resource, const c gboolean is_current = wins_is_current(window); if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) { if (prefs_get_boolean(PREF_NOTIFY_MESSAGE_TEXT)) { - notify_message(user->str, ui_index, message); + notify_message(display_name, ui_index, message); } else { - notify_message(user->str, ui_index, NULL); + notify_message(display_name, ui_index, NULL); } } } - g_string_free(user, TRUE); + free(display_name); } void |