From e73b577e0b45233c437d234ba97820ffa3b74bb3 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Sat, 15 Jul 2017 20:35:16 +0300 Subject: [PATCH] auth: use xmpp_iq_new() for iq stanzas --- src/auth.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/auth.c b/src/auth.c index 64570de..0f09023 100644 --- a/src/auth.c +++ b/src/auth.c @@ -722,14 +722,11 @@ static void _auth(xmpp_conn_t * const conn) } else if (conn->type == XMPP_CLIENT) { /* legacy client authentication */ - iq = xmpp_stanza_new(conn->ctx); + iq = xmpp_iq_new(conn->ctx, "set", "_xmpp_auth1"); if (!iq) { disconnect_mem_error(conn); return; } - xmpp_stanza_set_name(iq, "iq"); - xmpp_stanza_set_type(iq, "set"); - xmpp_stanza_set_id(iq, "_xmpp_auth1"); query = xmpp_stanza_new(conn->ctx); if (!query) { @@ -905,16 +902,12 @@ static int _handle_features_sasl(xmpp_conn_t * const conn, BIND_TIMEOUT, NULL); /* send bind request */ - iq = xmpp_stanza_new(conn->ctx); + iq = xmpp_iq_new(conn->ctx, "set", "_xmpp_bind1"); if (!iq) { disconnect_mem_error(conn); return 0; } - xmpp_stanza_set_name(iq, "iq"); - xmpp_stanza_set_type(iq, "set"); - xmpp_stanza_set_id(iq, "_xmpp_bind1"); - bind = xmpp_stanza_copy(bind); if (!bind) { xmpp_stanza_release(iq); @@ -1017,20 +1010,17 @@ static int _handle_bind(xmpp_conn_t * const conn, SESSION_TIMEOUT, NULL); /* send session request */ - iq = xmpp_stanza_new(conn->ctx); + iq = xmpp_iq_new(conn->ctx, "set", "_xmpp_session1"); if (!iq) { disconnect_mem_error(conn); return 0; } - xmpp_stanza_set_name(iq, "iq"); - xmpp_stanza_set_type(iq, "set"); - xmpp_stanza_set_id(iq, "_xmpp_session1"); - session = xmpp_stanza_new(conn->ctx); if (!session) { xmpp_stanza_release(iq); disconnect_mem_error(conn); + return 0; } xmpp_stanza_set_name(session, "session");