about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-08-18 22:51:06 +0100
committerJames Booth <boothj5@gmail.com>2016-08-18 22:53:23 +0100
commita978bb12bf0235be9e57e0e08b6328acc88add8b (patch)
treef5245c813a82bcbcf5d403ceed2c9ec189abc3e0 /src/event
parent71dcb2e427ec3e7e15f2131f18d64b84fc6230f8 (diff)
downloadprofani-tty-a978bb12bf0235be9e57e0e08b6328acc88add8b.tar.gz
Send receipt request only when receiver supports feature
issue #829
Diffstat (limited to 'src/event')
-rw-r--r--src/event/client_events.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index dd9c4432..c8111970 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -38,6 +38,7 @@
 #include <glib.h>
 
 #include "log.h"
+#include "config/preferences.h"
 #include "plugins/plugins.h"
 #include "ui/window_list.h"
 #include "ui/ui.h"
@@ -111,22 +112,38 @@ void
 cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oob_url)
 {
     chat_state_active(chatwin->state);
+
+    gboolean request_receipt = FALSE;
+    if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
+        char *session_jid = chat_session_get_jid(chatwin->barejid);
+        if (session_jid) {
+            Jid *session_jidp = jid_create(session_jid);
+            if (session_jidp && session_jidp->resourcepart) {
+                if (caps_jid_has_feature(session_jid, XMPP_FEATURE_RECEIPTS)) {
+                    request_receipt = TRUE;
+                }
+            }
+            jid_destroy(session_jidp);
+            free(session_jid);
+        }
+    }
+
     char *plugin_msg = plugins_pre_chat_message_send(chatwin->barejid, msg);
 
 // OTR suported, PGP supported
 #ifdef HAVE_LIBOTR
 #ifdef HAVE_LIBGPGME
     if (chatwin->pgp_send) {
-        char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg);
+        char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
         chat_log_pgp_msg_out(chatwin->barejid, plugin_msg);
-        chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP);
+        chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP, request_receipt);
         free(id);
     } else {
-        gboolean handled = otr_on_message_send(chatwin, plugin_msg);
+        gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
         if (!handled) {
-            char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url);
+            char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
             chat_log_msg_out(chatwin->barejid, plugin_msg);
-            chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN);
+            chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN, request_receipt);
             free(id);
         }
     }