1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Tidied ui_recipient_gone

This commit is contained in:
James Booth 2015-10-27 23:05:20 +00:00
parent f4fbf0ecf0
commit 62c2febc11
4 changed files with 29 additions and 31 deletions

View File

@ -346,7 +346,21 @@ sv_ev_inactive(char *barejid, char *resource)
void void
sv_ev_gone(const char *const barejid, const char *const resource) sv_ev_gone(const char *const barejid, const char *const resource)
{ {
ui_recipient_gone(barejid, resource); if (barejid && resource) {
gboolean show_message = TRUE;
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
ChatSession *session = chat_session_get(barejid);
if (session && g_strcmp0(session->resource, resource) != 0) {
show_message = FALSE;
}
if (show_message) {
ui_recipient_gone(chatwin);
}
}
}
if (wins_chat_exists(barejid)) { if (wins_chat_exists(barejid)) {
chat_session_recipient_gone(barejid, resource); chat_session_recipient_gone(barejid, resource);
} }

View File

@ -191,37 +191,21 @@ ui_handle_otr_error(const char *const barejid, const char *const message)
} }
void void
ui_recipient_gone(const char *const barejid, const char *const resource) ui_recipient_gone(ProfChatWin *chatwin)
{ {
if (barejid == NULL) const char *display_usr = NULL;
return; PContact contact = roster_get_contact(chatwin->barejid);
if (resource == NULL) if (contact) {
return; if (p_contact_name(contact)) {
display_usr = p_contact_name(contact);
gboolean show_message = TRUE; } else {
display_usr = chatwin->barejid;
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
ChatSession *session = chat_session_get(barejid);
if (session && g_strcmp0(session->resource, resource) != 0) {
show_message = FALSE;
}
if (show_message) {
const char * display_usr = NULL;
PContact contact = roster_get_contact(barejid);
if (contact) {
if (p_contact_name(contact)) {
display_usr = p_contact_name(contact);
} else {
display_usr = barejid;
}
} else {
display_usr = barejid;
}
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr);
} }
} else {
display_usr = chatwin->barejid;
} }
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr);
} }
ProfChatWin* ProfChatWin*

View File

@ -104,7 +104,7 @@ void ui_incoming_private_msg(const char *const fulljid, const char *const messag
void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id);
void ui_disconnected(void); void ui_disconnected(void);
void ui_recipient_gone(const char *const barejid, const char *const resource); void ui_recipient_gone(ProfChatWin *chatwin);
void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode); void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode);
void ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message); void ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message);

View File

@ -179,7 +179,7 @@ void chatwin_receipt_received(ProfChatWin *chatwin, const char * const id) {}
void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) {} void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) {}
void ui_disconnected(void) {} void ui_disconnected(void) {}
void ui_recipient_gone(const char * const barejid, const char * const resource) {} void ui_recipient_gone(ProfChatWin *chatwin) {}
void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {} void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {}
void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {} void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {}