diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xmpp/message.c | 29 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 23 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 3 |
3 files changed, 21 insertions, 34 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 407b7485..e9fc8297 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -141,7 +141,8 @@ message_send_chat(const char *const barejid, const char *const msg, const char * char *jid = chat_session_get_jid(barejid); char *id = create_unique_id("msg"); - xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); + xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_message_set_body(message, msg); free(jid); if (state) { @@ -179,7 +180,8 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean Jid *jidp = jid_create(jid); char *encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid); if (encrypted) { - message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, "This message is encrypted."); + message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_message_set_body(message, "This message is encrypted."); xmpp_stanza_t *x = xmpp_stanza_new(ctx); xmpp_stanza_set_name(x, STANZA_NAME_X); xmpp_stanza_set_ns(x, STANZA_NS_ENCRYPTED); @@ -191,15 +193,18 @@ message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean xmpp_stanza_release(x); free(encrypted); } else { - message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); + message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_message_set_body(message, msg); } jid_destroy(jidp); } else { - message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); + message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_message_set_body(message, msg); } account_free(account); #else - message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); + message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id); + xmpp_message_set_body(message, msg); #endif free(jid); @@ -226,7 +231,9 @@ message_send_chat_otr(const char *const barejid, const char *const msg, gboolean char *jid = chat_session_get_jid(barejid); char *id = create_unique_id("msg"); - xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg); + xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id); + xmpp_message_set_body(message, msg); + free(jid); if (state) { @@ -252,7 +259,10 @@ message_send_private(const char *const fulljid, const char *const msg, const cha { xmpp_ctx_t * const ctx = connection_get_ctx(); char *id = create_unique_id("prv"); - xmpp_stanza_t *message = stanza_create_message(ctx, id, fulljid, STANZA_TYPE_CHAT, msg); + + xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id); + xmpp_message_set_body(message, msg); + free(id); if (oob_url) { @@ -268,7 +278,10 @@ message_send_groupchat(const char *const roomjid, const char *const msg, const c { xmpp_ctx_t * const ctx = connection_get_ctx(); char *id = create_unique_id("muc"); - xmpp_stanza_t *message = stanza_create_message(ctx, id, roomjid, STANZA_TYPE_GROUPCHAT, msg); + + xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id); + xmpp_message_set_body(message, msg); + free(id); if (oob_url) { diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 1844cfd5..7b7396fe 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -443,29 +443,6 @@ stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *cons } xmpp_stanza_t* -stanza_create_message(xmpp_ctx_t *ctx, char *id, const char *const recipient, - const char *const type, const char *const message) -{ - xmpp_stanza_t *msg = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE); - xmpp_stanza_set_type(msg, type); - xmpp_stanza_set_to(msg, recipient); - xmpp_stanza_set_id(msg, id); - - xmpp_stanza_t *body = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(body, STANZA_NAME_BODY); - - xmpp_stanza_t *text = xmpp_stanza_new(ctx); - xmpp_stanza_set_text(text, message); - xmpp_stanza_add_child(body, text); - xmpp_stanza_release(text); - xmpp_stanza_add_child(msg, body); - xmpp_stanza_release(body); - - return msg; -} - -xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid) { xmpp_stanza_t *iq = xmpp_stanza_new(ctx); diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 806ba615..5a11f3c1 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -228,9 +228,6 @@ xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stan xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url); -xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, char *id, - const char *const recipient, const char *const type, const char *const message); - xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx, const char *const full_room_jid, const char *const passwd); |