From 360956cca0acce925ebaf9ffea87245fc8a3f72e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 12 Jan 2014 21:42:18 +0000 Subject: [PATCH] Call plugins on /msg command --- src/command/command.c | 22 +++++++++++----------- src/command/commands.c | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 559c2700..0913f0fd 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1180,49 +1180,49 @@ cmd_execute_default(const char * const inp) recipient_jid = recipient; } - char *new_message = plugins_on_message_send(recipient_jid, inp); + char *plugin_message = plugins_on_message_send(recipient_jid, inp); #ifdef PROF_HAVE_LIBOTR if (otr_is_secure(recipient)) { - char *encrypted = otr_encrypt_message(recipient, new_message); + char *encrypted = otr_encrypt_message(recipient, plugin_message); if (encrypted != NULL) { message_send(encrypted, recipient); otr_free_message(encrypted); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } - ui_outgoing_msg("me", recipient, new_message); + ui_outgoing_msg("me", recipient, plugin_message); } else { cons_show_error("Failed to send message."); } } else { - message_send(new_message, recipient); + message_send(plugin_message, recipient); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } - ui_outgoing_msg("me", recipient, new_message); + ui_outgoing_msg("me", recipient, plugin_message); } #else - message_send(new_message, recipient); + message_send(plugin_message, recipient); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, recipient, new_message, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, recipient, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } - ui_outgoing_msg("me", recipient, new_message); + ui_outgoing_msg("me", recipient, plugin_message); #endif - free(new_message); + free(plugin_message); } break; diff --git a/src/command/commands.c b/src/command/commands.c index 8468e346..9f734995 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -919,47 +919,49 @@ cmd_msg(gchar **args, struct cmd_help_t help) usr_jid = usr; } if (msg != NULL) { + char *plugin_message = plugins_on_message_send(usr_jid, msg); #ifdef PROF_HAVE_LIBOTR if (otr_is_secure(usr_jid)) { - char *encrypted = otr_encrypt_message(usr_jid, msg); + char *encrypted = otr_encrypt_message(usr_jid, plugin_message); if (encrypted != NULL) { message_send(encrypted, usr_jid); otr_free_message(encrypted); - ui_outgoing_msg("me", usr_jid, msg); + ui_outgoing_msg("me", usr_jid, plugin_message); if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } } else { cons_show_error("Failed to encrypt and send message,"); } } else { - message_send(msg, usr_jid); - ui_outgoing_msg("me", usr_jid, msg); + message_send(plugin_message, usr_jid); + ui_outgoing_msg("me", usr_jid, plugin_message); if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } } return TRUE; #else - message_send(msg, usr_jid); - ui_outgoing_msg("me", usr_jid, msg); + message_send(plugin_message, usr_jid); + ui_outgoing_msg("me", usr_jid, plugin_message); if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); - chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL); + chat_log_chat(jidp->barejid, usr_jid, plugin_message, PROF_OUT_LOG, NULL); jid_destroy(jidp); } return TRUE; #endif + free(plugin_message); } else { const char * jid = NULL;