diff options
author | James Booth <boothj5@gmail.com> | 2012-10-31 21:30:58 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-31 21:30:58 +0000 |
commit | baced85767ab1882ca0e2da6580042ec3a9c7d06 (patch) | |
tree | 1ae6cb08f825d0172928440e88926b4538e146f0 | |
parent | 3c82fb28c4e19e390159cbb60563b541d88ae343 (diff) | |
download | profani-tty-baced85767ab1882ca0e2da6580042ec3a9c7d06.tar.gz |
Send <gone/> when closing chat window
-rw-r--r-- | src/command.c | 16 | ||||
-rw-r--r-- | src/ui.h | 2 | ||||
-rw-r--r-- | src/windows.c | 30 |
3 files changed, 27 insertions, 21 deletions
diff --git a/src/command.c b/src/command.c index f8c5b1e9..d4f1756d 100644 --- a/src/command.c +++ b/src/command.c @@ -25,6 +25,7 @@ #include <glib.h> +#include "chat_session.h" #include "command.h" #include "common.h" #include "contact.h" @@ -985,8 +986,21 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help) static gboolean _cmd_close(const char * const inp, struct cmd_help_t help) { - if (!win_close_win()) + if (win_in_chat()) { + char *recipient = win_get_recipient(); + + // send <gone/> chat state before closing + if (chat_session_get_recipient_supports(recipient)) { + chat_session_gone(recipient); + jabber_send_gone(recipient); + chat_session_end(recipient); + } + + win_close_win(); + + } else { cons_bad_command(inp); + } return TRUE; } diff --git a/src/ui.h b/src/ui.h index 642d2ec5..46fb22bf 100644 --- a/src/ui.h +++ b/src/ui.h @@ -83,7 +83,7 @@ void title_bar_set_typing(gboolean is_typing); void title_bar_draw(void); // main window actions -int win_close_win(void); +void win_close_win(void); int win_in_chat(void); char *win_get_recipient(void); void win_show_typing(const char * const from); diff --git a/src/windows.c b/src/windows.c index 57cebdf5..0d4c0b7c 100644 --- a/src/windows.c +++ b/src/windows.c @@ -171,30 +171,22 @@ gui_resize(const int ch, const char * const input, const int size) dirty = TRUE; } -int +void win_close_win(void) { - if (win_in_chat()) { - // reset the chat win to unused - strcpy(_wins[_curr_prof_win].from, ""); - wclear(_wins[_curr_prof_win].win); - _wins[_curr_prof_win].history_shown = 0; + // reset the chat win to unused + strcpy(_wins[_curr_prof_win].from, ""); + wclear(_wins[_curr_prof_win].win); + _wins[_curr_prof_win].history_shown = 0; - // set it as inactive in the status bar - status_bar_inactive(_curr_prof_win); + // set it as inactive in the status bar + status_bar_inactive(_curr_prof_win); - // go back to console window - _curr_prof_win = 0; - title_bar_title(); - - dirty = TRUE; + // go back to console window + _curr_prof_win = 0; + title_bar_title(); - // success - return 1; - } else { - // didn't close anything - return 0; - } + dirty = TRUE; } int |