about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-12-29 01:17:59 +0000
committerJames Booth <boothj5@gmail.com>2014-12-29 01:17:59 +0000
commit10a3a3a67504225ffaaee6aabb39831db36c8f31 (patch)
treea0fa083c4f888e2908c9a83203d2f25232a3c279 /src/ui
parent4be06c0ae270ad8a04abba85ef3c608527a29d2c (diff)
downloadprofani-tty-10a3a3a67504225ffaaee6aabb39831db36c8f31.tar.gz
Use events for chat sessions
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c25
-rw-r--r--src/ui/ui.h2
2 files changed, 5 insertions, 22 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index e7264435..c3f185f6 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -315,7 +315,7 @@ ui_contact_typing(const char * const barejid)
 }
 
 GSList *
-ui_get_recipients(void)
+ui_get_chat_recipients(void)
 {
     GSList *recipients = wins_get_chat_recipients();
     return recipients;
@@ -705,15 +705,7 @@ ui_close_connected_win(int index)
                 otr_end_session(chatwin->barejid);
             }
 #endif
-            if (prefs_get_boolean(PREF_STATES)) {
-                // send <gone/> chat state before closing
-                if (chat_session_get_recipient_supports(chatwin->barejid)) {
-                    chat_session_set_gone(chatwin->barejid);
-                    message_send_gone(chatwin->barejid);
-                    chat_session_set_sent(chatwin->barejid);
-                    chat_session_end(chatwin->barejid);
-                }
-            }
+            chat_session_on_window_close(chatwin->barejid);
         }
     }
 }
@@ -1169,17 +1161,8 @@ ui_prune_wins(void)
         ProfWin *window = curr->data;
         if (window->type == WIN_CHAT) {
             if (conn_status == JABBER_CONNECTED) {
-                if (prefs_get_boolean(PREF_STATES)) {
-                    ProfChatWin *chatwin = (ProfChatWin*)window;
-
-                    // send <gone/> chat state before closing
-                    if (chat_session_get_recipient_supports(chatwin->barejid)) {
-                        chat_session_set_gone(chatwin->barejid);
-                        message_send_gone(chatwin->barejid);
-                        chat_session_set_sent(chatwin->barejid);
-                        chat_session_end(chatwin->barejid);
-                    }
-                }
+                ProfChatWin *chatwin = (ProfChatWin*)window;
+                chat_session_on_window_close(chatwin->barejid);
             }
         }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 7db2227f..e7b46766 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -60,7 +60,7 @@ void ui_update(void);
 void ui_close(void);
 void ui_redraw(void);
 void ui_resize(void);
-GSList* ui_get_recipients(void);
+GSList* ui_get_chat_recipients(void);
 void ui_handle_special_keys(const wint_t * const ch, const int result);
 gboolean ui_switch_win(const int i);
 void ui_next_win(void);