From e45e6c46b79a3cf8468a5bd26ab9b8eaeb8afe8d Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 1 Nov 2012 01:21:00 +0000 Subject: [PATCH] Show message when other user --- src/jabber.c | 2 +- src/profanity.c | 7 +++++++ src/profanity.h | 1 + src/ui.h | 1 + src/windows.c | 25 +++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/jabber.c b/src/jabber.c index 150f7c6f..766c78bf 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -443,7 +443,7 @@ _message_handler(xmpp_conn_t * const conn, // handle } else if (xmpp_stanza_get_child_by_name(stanza, "gone") != NULL) { - // do something + prof_handle_gone(short_from); // handle } else { diff --git a/src/profanity.c b/src/profanity.c index 885c55ea..41a89956 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -145,6 +145,13 @@ prof_handle_login_success(const char *jid) prefs_add_login(jid); } +void +prof_handle_gone(const char * const from) +{ + win_show_gone(from); + win_page_off(); +} + void prof_handle_lost_connection(void) { diff --git a/src/profanity.h b/src/profanity.h index a67fb2df..dc56b775 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -34,5 +34,6 @@ void prof_handle_contact_offline(char *contact, char *show, char *status); void prof_handle_incoming_message(char *from, char *message); void prof_handle_error_message(const char *from, const char *err_msg); void prof_handle_roster(GSList *roster); +void prof_handle_gone(const char * const from); #endif diff --git a/src/ui.h b/src/ui.h index 46fb22bf..2c60428d 100644 --- a/src/ui.h +++ b/src/ui.h @@ -87,6 +87,7 @@ void win_close_win(void); int win_in_chat(void); char *win_get_recipient(void); void win_show_typing(const char * const from); +void win_show_gone(const char * const from); void win_show_incomming_msg(const char * const from, const char * const message); void win_show_error_msg(const char * const from, const char *err_msg); void win_show_outgoing_msg(const char * const from, const char * const to, diff --git a/src/windows.c b/src/windows.c index 792c4556..cda57fa8 100644 --- a/src/windows.c +++ b/src/windows.c @@ -337,6 +337,31 @@ win_show_error_msg(const char * const from, const char *err_msg) } } +void +win_show_gone(const char * const from) +{ + int win_index; + WINDOW *win; + + if (from == NULL) + return; + + win_index = _find_prof_win_index(from); + // chat window exists + if (win_index < NUM_WINS) { + win = _wins[win_index].win; + _win_show_time(win); + wattron(win, COLOUR_AWAY); + wprintw(win, "*%s ", from); + wprintw(win, "has left the conversation."); + wprintw(win, "\n"); + wattroff(win, COLOUR_AWAY); + if (win_index == _curr_prof_win) { + dirty = TRUE; + } + } +} + #ifdef HAVE_LIBNOTIFY static void _win_notify(const char * const message, int timeout,