about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-10-31 22:08:00 +0000
committerJames Booth <boothj5@gmail.com>2012-10-31 22:08:00 +0000
commit81dd0a1556398b636b036fc4e8dff015a2670968 (patch)
tree33b7d674a4e4cae28d36ae784880bfecf9e7b4c1 /src
parent7982d7061b89e3bd3a6c8528f8d0491104998bc7 (diff)
downloadprofani-tty-81dd0a1556398b636b036fc4e8dff015a2670968.tar.gz
Only send chat states when preference set
Diffstat (limited to 'src')
-rw-r--r--src/command.c15
-rw-r--r--src/input_win.c41
-rw-r--r--src/jabber.c21
3 files changed, 44 insertions, 33 deletions
diff --git a/src/command.c b/src/command.c
index 475bb433..03670f7e 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1009,13 +1009,16 @@ static gboolean
 _cmd_close(const char * const inp, struct cmd_help_t help)
 {
     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);
+        if (prefs_get_states()) {
+            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();
diff --git a/src/input_win.c b/src/input_win.c
index 21f2ca86..050156f0 100644
--- a/src/input_win.c
+++ b/src/input_win.c
@@ -137,28 +137,31 @@ inp_get_char(int *ch, char *input, int *size)
     noecho();
     *ch = wgetch(inp_win);
 
-    // if not got char, and in chat window, flag as no activity
-    // send inactive or gone, depending how long inactive
-    if (*ch == ERR) {
-        if (win_in_chat()) {
-            char *recipient = win_get_recipient();
-            chat_session_no_activity(recipient);
-
-            if (chat_session_gone(recipient) &&
-                    !chat_session_get_sent(recipient)) {
-                jabber_send_gone(recipient);
-            } else if (chat_session_inactive(recipient) &&
-                    !chat_session_get_sent(recipient)) {
-                jabber_send_inactive(recipient);
+    if (prefs_get_states()) {
+
+        // if not got char, and in chat window, flag as no activity
+        // send inactive or gone, depending how long inactive
+        if (*ch == ERR) {
+            if (win_in_chat()) {
+                char *recipient = win_get_recipient();
+                chat_session_no_activity(recipient);
+
+                if (chat_session_gone(recipient) &&
+                        !chat_session_get_sent(recipient)) {
+                    jabber_send_gone(recipient);
+                } else if (chat_session_inactive(recipient) &&
+                        !chat_session_get_sent(recipient)) {
+                    jabber_send_inactive(recipient);
+                }
             }
         }
-    }
 
-    // if got char and in chat window, chat session active
-    if (*ch != ERR) {
-        if (win_in_chat()) {
-            char *recipient = win_get_recipient();
-            chat_session_set_active(recipient);
+        // if got char and in chat window, chat session active
+        if (*ch != ERR) {
+            if (win_in_chat()) {
+                char *recipient = win_get_recipient();
+                chat_session_set_active(recipient);
+            }
         }
     }
 
diff --git a/src/jabber.c b/src/jabber.c
index 11ada5ed..1a24be47 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -137,8 +137,10 @@ jabber_process_events(void)
 void
 jabber_send(const char * const msg, const char * const recipient)
 {
-    if (!chat_session_exists(recipient)) {
-        chat_session_start(recipient, TRUE);
+    if (prefs_get_states()) {
+        if (!chat_session_exists(recipient)) {
+            chat_session_start(recipient, TRUE);
+        }
     }
 
     char *coded_msg = str_replace(msg, "&", "&amp;");
@@ -158,12 +160,15 @@ jabber_send(const char * const msg, const char * const recipient)
     text = xmpp_stanza_new(jabber_conn.ctx);
     xmpp_stanza_set_text(text, coded_msg3);
 
-    // always send <active/> with messages when recipient supports chat states
-    if (chat_session_get_recipient_supports(recipient)) {
-        active = xmpp_stanza_new(jabber_conn.ctx);
-        xmpp_stanza_set_name(active, "active");
-        xmpp_stanza_set_ns(active, "http://jabber.org/protocol/chatstates");
-        xmpp_stanza_add_child(reply, active);
+    if (prefs_get_states()) {
+
+        // always send <active/> with messages when recipient supports chat states
+        if (chat_session_get_recipient_supports(recipient)) {
+            active = xmpp_stanza_new(jabber_conn.ctx);
+            xmpp_stanza_set_name(active, "active");
+            xmpp_stanza_set_ns(active, "http://jabber.org/protocol/chatstates");
+            xmpp_stanza_add_child(reply, active);
+        }
     }
 
     xmpp_stanza_add_child(body, text);