about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-10-28 23:36:42 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-10-28 23:36:42 +0100
commit8c8c18c6fddec89cbaa83abfcac29a97ef98c294 (patch)
treef6e45d73f08a6227e526dc350604b4473e80ad8d /src
parentf186eb94da785f1eec33056837201c99e7e4f0d2 (diff)
downloadprofani-tty-8c8c18c6fddec89cbaa83abfcac29a97ef98c294.tar.gz
Actually log MUC PM messages
If I'm not mistaken MUC PMs have not been logged at all if there was no
other client sending carbons.
This should add MUC PM logging functionality.

We still need to make sure carbons log to the same file.

Regards https://github.com/profanity-im/profanity/issues/1214
Diffstat (limited to 'src')
-rw-r--r--src/event/client_events.c24
-rw-r--r--src/event/server_events.c3
-rw-r--r--src/log.c22
-rw-r--r--src/log.h8
-rw-r--r--src/otr/otr.c4
5 files changed, 33 insertions, 28 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c
index c3037392..21640150 100644
--- a/src/event/client_events.c
+++ b/src/event/client_events.c
@@ -151,7 +151,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
         gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-            chat_log_msg_out(chatwin->barejid, plugin_msg);
+            chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
             chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
             free(id);
         }
@@ -171,7 +171,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
     gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
     if (!handled) {
         char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-        chat_log_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
         free(id);
     }
@@ -194,7 +194,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
         free(id);
     } else {
         char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-        chat_log_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
         free(id);
     }
@@ -217,7 +217,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
         free(id);
     } else {
         char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-        chat_log_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
         free(id);
     }
@@ -242,7 +242,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
         gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-            chat_log_msg_out(chatwin->barejid, plugin_msg);
+            chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
             chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
             free(id);
         }
@@ -271,7 +271,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
         free(id);
     } else {
         char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-        chat_log_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
         free(id);
     }
@@ -289,19 +289,19 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
 #ifdef HAVE_OMEMO
     if (chatwin->is_omemo) {
         char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE);
-        chat_log_omemo_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_omemo_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_OMEMO, request_receipt);
         free(id);
     } else if (chatwin->pgp_send) {
         char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt);
-        chat_log_pgp_msg_out(chatwin->barejid, plugin_msg);
+        chat_log_pgp_msg_out(chatwin->barejid, plugin_msg, NULL);
         chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PGP, request_receipt);
         free(id);
     } else {
         gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt);
         if (!handled) {
             char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-            chat_log_msg_out(chatwin->barejid, plugin_msg);
+            chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
             chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
             free(id);
         }
@@ -319,7 +319,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo
 #ifndef HAVE_LIBGPGME
 #ifndef HAVE_OMEMO
     char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt);
-    chat_log_msg_out(chatwin->barejid, plugin_msg);
+    chat_log_msg_out(chatwin->barejid, plugin_msg, NULL);
     chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_ENC_PLAIN, request_receipt);
     free(id);
 
@@ -378,11 +378,15 @@ cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg, const char *
         privwin_message_left_room(privwin);
     } else {
         char *plugin_msg = plugins_pre_priv_message_send(privwin->fulljid, msg);
+        Jid *jidp = jid_create(privwin->fulljid);
 
         message_send_private(privwin->fulljid, plugin_msg, oob_url);
+        chat_log_msg_out(jidp->barejid, plugin_msg, jidp->resourcepart);
         privwin_outgoing_msg(privwin, plugin_msg);
 
         plugins_post_priv_message_send(privwin->fulljid, plugin_msg);
+
         free(plugin_msg);
+        jid_destroy(jidp);
     }
 }
diff --git a/src/event/server_events.c b/src/event/server_events.c
index cdbd5ad5..95e51f15 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -398,6 +398,7 @@ sv_ev_incoming_private_message(ProfMessage *message)
         privatewin = (ProfPrivateWin*)window;
     }
     privwin_incoming_msg(privatewin, message);
+    chat_log_msg_in(message);
 
     plugins_post_priv_message_display(message->jid->fulljid, message->plain);
 
@@ -436,7 +437,7 @@ sv_ev_outgoing_carbon(ProfMessage *message)
     chat_state_active(chatwin->state);
 
     if (message->plain) {
-        chat_log_msg_out(message->jid->barejid, message->plain);
+        chat_log_msg_out(message->jid->barejid, message->plain, NULL);
     }
 
 #ifdef HAVE_LIBGPGME
diff --git a/src/log.c b/src/log.c
index 80e91c56..907b732d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -267,27 +267,27 @@ groupchat_log_init(void)
 }
 
 void
-chat_log_msg_out(const char *const barejid, const char *const msg)
+chat_log_msg_out(const char *const barejid, const char *const msg, const char *const resource)
 {
     if (prefs_get_boolean(PREF_CHLOG)) {
         const char *jid = connection_get_fulljid();
         Jid *jidp = jid_create(jid);
-        _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, NULL);
+        _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
         jid_destroy(jidp);
     }
 }
 
 void
-chat_log_otr_msg_out(const char *const barejid, const char *const msg)
+chat_log_otr_msg_out(const char *const barejid, const char *const msg, const char *const resource)
 {
     if (prefs_get_boolean(PREF_CHLOG)) {
         const char *jid = connection_get_fulljid();
         Jid *jidp = jid_create(jid);
         char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
         if (strcmp(pref_otr_log, "on") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
         } else if (strcmp(pref_otr_log, "redact") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
         }
         prefs_free_string(pref_otr_log);
         jid_destroy(jidp);
@@ -295,16 +295,16 @@ chat_log_otr_msg_out(const char *const barejid, const char *const msg)
 }
 
 void
-chat_log_pgp_msg_out(const char *const barejid, const char *const msg)
+chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const char *const resource)
 {
     if (prefs_get_boolean(PREF_CHLOG)) {
         const char *jid = connection_get_fulljid();
         Jid *jidp = jid_create(jid);
         char *pref_pgp_log = prefs_get_string(PREF_PGP_LOG);
         if (strcmp(pref_pgp_log, "on") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
         } else if (strcmp(pref_pgp_log, "redact") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
         }
         prefs_free_string(pref_pgp_log);
         jid_destroy(jidp);
@@ -312,16 +312,16 @@ chat_log_pgp_msg_out(const char *const barejid, const char *const msg)
 }
 
 void
-chat_log_omemo_msg_out(const char *const barejid, const char *const msg)
+chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *const resource)
 {
     if (prefs_get_boolean(PREF_CHLOG)) {
         const char *jid = connection_get_fulljid();
         Jid *jidp = jid_create(jid);
         char *pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
         if (strcmp(pref_omemo_log, "on") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, msg, PROF_OUT_LOG, NULL, resource);
         } else if (strcmp(pref_omemo_log, "redact") == 0) {
-            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, NULL);
+            _chat_log_chat(jidp->barejid, barejid, "[redacted]", PROF_OUT_LOG, NULL, resource);
         }
         prefs_free_string(pref_omemo_log);
         jid_destroy(jidp);
diff --git a/src/log.h b/src/log.h
index 09238602..32d9db94 100644
--- a/src/log.h
+++ b/src/log.h
@@ -70,10 +70,10 @@ void log_stderr_handler(void);
 
 void chat_log_init(void);
 
-void chat_log_msg_out(const char *const barejid, const char *const msg);
-void chat_log_otr_msg_out(const char *const barejid, const char *const msg);
-void chat_log_pgp_msg_out(const char *const barejid, const char *const msg);
-void chat_log_omemo_msg_out(const char *const barejid, const char *const msg);
+void chat_log_msg_out(const char *const barejid, const char *const msg, const char *resource);
+void chat_log_otr_msg_out(const char *const barejid, const char *const msg, const char *resource);
+void chat_log_pgp_msg_out(const char *const barejid, const char *const msg, const char *resource);
+void chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *resource);
 
 void chat_log_msg_in(ProfMessage *message);
 void chat_log_otr_msg_in(ProfMessage *message);
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 90d2fbd8..d37f2130 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -346,7 +346,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
         char *encrypted = otr_encrypt_message(chatwin->barejid, message);
         if (encrypted) {
             id = message_send_chat_otr(chatwin->barejid, encrypted, request_receipt);
-            chat_log_otr_msg_out(chatwin->barejid, message);
+            chat_log_otr_msg_out(chatwin->barejid, message, NULL);
             chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_OTR, request_receipt);
             otr_free_message(encrypted);
             free(id);
@@ -368,7 +368,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
         char *otr_tagged_msg = otr_tag_message(message);
         id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg, request_receipt);
         chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_ENC_PLAIN, request_receipt);
-        chat_log_msg_out(chatwin->barejid, message);
+        chat_log_msg_out(chatwin->barejid, message, NULL);
         free(otr_tagged_msg);
         free(id);
         return TRUE;