mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Show resource in titlebar and on each message
This commit is contained in:
parent
3e1832b02e
commit
c3ad3c0ba6
@ -297,7 +297,7 @@ handle_incoming_private_message(char *fulljid, char *message)
|
||||
}
|
||||
|
||||
void
|
||||
handle_incoming_message(char *barejid, char *message)
|
||||
handle_incoming_message(char *barejid, char *resource, char *message)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
gboolean was_decrypted = FALSE;
|
||||
@ -336,7 +336,7 @@ handle_incoming_message(char *barejid, char *message)
|
||||
message_send_chat(barejid, otr_query_message);
|
||||
}
|
||||
|
||||
ui_incoming_msg(barejid, newmessage, NULL);
|
||||
ui_incoming_msg(barejid, resource, newmessage, NULL);
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
@ -355,7 +355,7 @@ handle_incoming_message(char *barejid, char *message)
|
||||
|
||||
otr_free_message(newmessage);
|
||||
#else
|
||||
ui_incoming_msg(barejid, message, NULL);
|
||||
ui_incoming_msg(barejid, resource, message, NULL);
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
@ -375,7 +375,7 @@ handle_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp)
|
||||
void
|
||||
handle_delayed_message(char *barejid, char *message, GTimeVal tv_stamp)
|
||||
{
|
||||
ui_incoming_msg(barejid, message, &tv_stamp);
|
||||
ui_incoming_msg(barejid, NULL, message, &tv_stamp);
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
|
@ -69,7 +69,7 @@ void handle_room_role_list(const char * const from, const char * const role, GSL
|
||||
void handle_room_role_set_error(const char * const room, const char * const nick, const char * const role,
|
||||
const char * const error);
|
||||
void handle_room_kick_result_error(const char * const room, const char * const nick, const char * const error);
|
||||
void handle_incoming_message(char *barejid, char *message);
|
||||
void handle_incoming_message(char *barejid, char *resource, char *message);
|
||||
void handle_incoming_private_message(char *fulljid, char *message);
|
||||
void handle_delayed_message(char *fulljid, char *message, GTimeVal tv_stamp);
|
||||
void handle_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp);
|
||||
|
@ -328,20 +328,25 @@ ui_get_current_chat(void)
|
||||
}
|
||||
|
||||
void
|
||||
ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal *tv_stamp)
|
||||
ui_incoming_msg(const char * const barejid, const char * const resource, const char * const message, GTimeVal *tv_stamp)
|
||||
{
|
||||
gboolean win_created = FALSE;
|
||||
char *display_from = NULL;
|
||||
GString *user = g_string_new("");
|
||||
|
||||
PContact contact = roster_get_contact(barejid);
|
||||
if (contact != NULL) {
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
display_from = strdup(p_contact_name(contact));
|
||||
g_string_append(user, p_contact_name(contact));
|
||||
} else {
|
||||
display_from = strdup(barejid);
|
||||
g_string_append(user, barejid);
|
||||
}
|
||||
} else {
|
||||
display_from = strdup(barejid);
|
||||
g_string_append(user,barejid);
|
||||
}
|
||||
|
||||
if (resource) {
|
||||
g_string_append(user, "/");
|
||||
g_string_append(user, resource);
|
||||
}
|
||||
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
@ -362,14 +367,14 @@ ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal
|
||||
|
||||
// currently viewing chat window with sender
|
||||
if (wins_is_current(window)) {
|
||||
win_print_incoming_message(window, tv_stamp, display_from, message);
|
||||
win_print_incoming_message(window, tv_stamp, user->str, 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(display_from, num);
|
||||
cons_show_incoming_message(user->str, num);
|
||||
|
||||
if (prefs_get_boolean(PREF_FLASH)) {
|
||||
flash();
|
||||
@ -388,7 +393,7 @@ ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal
|
||||
}
|
||||
}
|
||||
|
||||
win_print_incoming_message(window, tv_stamp, display_from, message);
|
||||
win_print_incoming_message(window, tv_stamp, user->str, message);
|
||||
}
|
||||
|
||||
int ui_index = num;
|
||||
@ -404,14 +409,14 @@ ui_incoming_msg(const char * const barejid, const char * const message, GTimeVal
|
||||
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(display_from, ui_index, message);
|
||||
notify_message(user->str, ui_index, message);
|
||||
} else {
|
||||
notify_message(display_from, ui_index, NULL);
|
||||
notify_message(user->str, ui_index, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(display_from);
|
||||
g_string_free(user, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "ui/windows.h"
|
||||
#include "ui/window.h"
|
||||
#include "roster_list.h"
|
||||
#include "chat_session.h"
|
||||
|
||||
static WINDOW *win;
|
||||
static contact_presence_t current_presence;
|
||||
@ -307,9 +308,17 @@ static void
|
||||
_show_contact_presence(ProfChatWin *chatwin)
|
||||
{
|
||||
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
|
||||
if (chatwin && chatwin->resource_override) {
|
||||
char *resource = NULL;
|
||||
|
||||
ChatSession *session = chat_session_get(chatwin->barejid);
|
||||
if (chatwin->resource_override) {
|
||||
resource = chatwin->resource_override;
|
||||
} else if (session && session->resource) {
|
||||
resource = session->resource;
|
||||
}
|
||||
if (resource) {
|
||||
wprintw(win, "/");
|
||||
wprintw(win, chatwin->resource_override);
|
||||
wprintw(win, resource);
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_PRESENCE)) {
|
||||
@ -318,10 +327,10 @@ _show_contact_presence(ProfChatWin *chatwin)
|
||||
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact) {
|
||||
if (chatwin && chatwin->resource_override) {
|
||||
Resource *resource = p_contact_get_resource(contact, chatwin->resource_override);
|
||||
if (resource) {
|
||||
presence = string_from_resource_presence(resource->presence);
|
||||
if (resource) {
|
||||
Resource *resourcep = p_contact_get_resource(contact, resource);
|
||||
if (resourcep) {
|
||||
presence = string_from_resource_presence(resourcep->presence);
|
||||
}
|
||||
} else {
|
||||
presence = p_contact_presence(contact);
|
||||
|
@ -116,7 +116,7 @@ void ui_handle_stanza(const char * const msg);
|
||||
|
||||
// ui events
|
||||
void ui_contact_typing(const char * const from);
|
||||
void ui_incoming_msg(const char * const from, const char * const message, GTimeVal *tv_stamp);
|
||||
void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp);
|
||||
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp);
|
||||
|
||||
void ui_disconnected(void);
|
||||
|
@ -499,7 +499,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
if (delayed) {
|
||||
handle_delayed_message(jid->barejid, message, tv_stamp);
|
||||
} else {
|
||||
handle_incoming_message(jid->barejid, message);
|
||||
handle_incoming_message(jid->barejid, jid->resourcepart, message);
|
||||
}
|
||||
xmpp_free(ctx, message);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ void ui_handle_stanza(const char * const msg) {}
|
||||
|
||||
// ui events
|
||||
void ui_contact_typing(const char * const from) {}
|
||||
void ui_incoming_msg(const char * const from, const char * const message, GTimeVal *tv_stamp) {}
|
||||
void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp) {}
|
||||
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp) {}
|
||||
|
||||
void ui_disconnected(void) {}
|
||||
|
Loading…
Reference in New Issue
Block a user