diff --git a/src/command.c b/src/command.c index 98b63fa4..90a436a9 100644 --- a/src/command.c +++ b/src/command.c @@ -28,6 +28,7 @@ #include "command.h" #include "common.h" #include "contact_list.h" +#include "chat_log.h" #include "history.h" #include "jabber.h" #include "log.h" @@ -450,6 +451,12 @@ cmd_execute_default(const char * const inp) if (win_in_chat()) { char *recipient = win_get_recipient(); jabber_send(inp, recipient); + + if (prefs_get_chlog()) { + const char *jid = jabber_get_jid(); + chat_log_chat(jid, recipient, inp, OUT); + } + win_show_outgoing_msg("me", recipient, inp); free(recipient); } else { @@ -604,8 +611,15 @@ _cmd_msg(const char * const inp, struct cmd_help_t help) if ((usr != NULL) && (strlen(inp) > (5 + strlen(usr) + 1))) { // get message msg = strndup(inp+5+strlen(usr)+1, strlen(inp)-(5+strlen(usr)+1)); + if (msg != NULL) { jabber_send(msg, usr); + + if (prefs_get_chlog()) { + const char *jid = jabber_get_jid(); + chat_log_chat(jid, usr, msg, OUT); + } + win_show_outgoing_msg("me", usr, msg); } else { char usage[strlen(help.usage + 8)]; @@ -641,6 +655,12 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help) char *tiny = tinyurl_get(url); char *recipient = win_get_recipient(); jabber_send(tiny, recipient); + + if (prefs_get_chlog()) { + const char *jid = jabber_get_jid(); + chat_log_chat(jid, recipient, tiny, OUT); + } + win_show_outgoing_msg("me", recipient, tiny); free(recipient); free(tiny); diff --git a/src/jabber.c b/src/jabber.c index 71f8dfab..b51d5f68 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -25,7 +25,6 @@ #include -#include "chat_log.h" #include "common.h" #include "jabber.h" #include "log.h" @@ -161,11 +160,6 @@ jabber_send(const char * const msg, const char * const recipient) free(coded_msg); free(coded_msg2); free(coded_msg3); - - if (prefs_get_chlog()) { - const char *jid = xmpp_conn_get_jid(jabber_conn.conn); - chat_log_chat(jid, (char *)recipient, msg, OUT); - } } void @@ -280,15 +274,6 @@ _message_handler(xmpp_conn_t * const conn, char *from = xmpp_stanza_get_attribute(stanza, "from"); prof_handle_incoming_message(from, message); - if (prefs_get_chlog()) { - char from_cpy[strlen(from) + 1]; - strcpy(from_cpy, from); - char *short_from = strtok(from_cpy, "/"); - const char *jid = xmpp_conn_get_jid(jabber_conn.conn); - - chat_log_chat(jid, short_from, message, IN); - } - return 1; } diff --git a/src/profanity.c b/src/profanity.c index 564afa0e..c37609c9 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -101,6 +101,15 @@ prof_handle_incoming_message(char *from, char *message) { win_show_incomming_msg(from, message); win_page_off(); + + if (prefs_get_chlog()) { + char from_cpy[strlen(from) + 1]; + strcpy(from_cpy, from); + char *short_from = strtok(from_cpy, "/"); + const char *jid = jabber_get_jid(); + + chat_log_chat(jid, short_from, message, IN); + } } void