diff --git a/src/jabber.c b/src/jabber.c index f8749930..dd86a6e5 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -144,8 +144,6 @@ jabber_process_events(void) void jabber_send(const char * const msg, const char * const recipient) { - char *encoded_xml = encode_xml(msg); - if (prefs_get_states()) { if (!chat_session_exists(recipient)) { chat_session_start(recipient, TRUE); @@ -156,16 +154,14 @@ jabber_send(const char * const msg, const char * const recipient) if (prefs_get_states() && chat_session_get_recipient_supports(recipient)) { chat_session_set_active(recipient); message = stanza_create_message(jabber_conn.ctx, recipient, "chat", - encoded_xml, "active"); + msg, "active"); } else { message = stanza_create_message(jabber_conn.ctx, recipient, "chat", - encoded_xml, NULL); + msg, NULL); } xmpp_send(jabber_conn.conn, message); xmpp_stanza_release(message); - - free(encoded_xml); } void diff --git a/src/stanza.c b/src/stanza.c index bf9665cd..2faab652 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -22,6 +22,8 @@ #include +#include "common.h" + xmpp_stanza_t * stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const recipient, const char * const state) @@ -46,6 +48,8 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, const char * const type, const char * const message, const char * const state) { + char *encoded_xml = encode_xml(message); + xmpp_stanza_t *msg, *body, *text; msg = xmpp_stanza_new(ctx); @@ -57,7 +61,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, xmpp_stanza_set_name(body, "body"); text = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(text, message); + xmpp_stanza_set_text(text, encoded_xml); xmpp_stanza_add_child(body, text); xmpp_stanza_add_child(msg, body); @@ -68,6 +72,8 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, xmpp_stanza_add_child(msg, chat_state); } + g_free(encoded_xml); + return msg; }