From 583fb2b8c66d1af9059763b2f8f56b7f78da246a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 20 Aug 2016 20:37:48 +0100 Subject: [PATCH] Use libstrophe xmpp_presence_new convenience function --- src/xmpp/presence.c | 5 ++--- src/xmpp/stanza.c | 18 +++--------------- src/xmpp/stanza.h | 2 -- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 1ad32293..31fc6cde 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -172,10 +172,9 @@ presence_subscription(const char *const jid, const jabber_subscr_t action) break; } - xmpp_stanza_t *presence = xmpp_stanza_new(ctx); + xmpp_stanza_t *presence = xmpp_presence_new(ctx); char *id = create_unique_id("sub"); xmpp_stanza_set_id(presence, id); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); xmpp_stanza_set_type(presence, type); xmpp_stanza_set_to(presence, jidp->barejid); _send_presence_stanza(presence); @@ -258,7 +257,7 @@ presence_send(const resource_presence_t presence_type, const char *const msg, co connection_set_presence_msg(msg); connection_set_priority(pri); - xmpp_stanza_t *presence = stanza_create_presence(ctx); + xmpp_stanza_t *presence = xmpp_presence_new(ctx); char *id = create_unique_id("presence"); xmpp_stanza_set_id(presence, id); stanza_attach_show(ctx, presence, show); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 4dd8c526..bf4e44e1 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -554,8 +554,7 @@ xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx, const char *const full_room_jid, const char *const passwd) { - xmpp_stanza_t *presence = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); + xmpp_stanza_t *presence = xmpp_presence_new(ctx); xmpp_stanza_set_to(presence, full_room_jid); _stanza_add_unique_id(presence, "join"); @@ -584,9 +583,8 @@ xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, const char *const full_room_jid) { - xmpp_stanza_t *presence = xmpp_stanza_new(ctx); + xmpp_stanza_t *presence = xmpp_presence_new(ctx); _stanza_add_unique_id(presence, "sub"); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); xmpp_stanza_set_to(presence, full_room_jid); return presence; @@ -600,8 +598,7 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room, g_string_append(full_jid, "/"); g_string_append(full_jid, nick); - xmpp_stanza_t *presence = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); + xmpp_stanza_t *presence = xmpp_presence_new(ctx); xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE); xmpp_stanza_set_to(presence, full_jid->str); _stanza_add_unique_id(presence, "leave"); @@ -867,15 +864,6 @@ stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const return iq; } -xmpp_stanza_t* -stanza_create_presence(xmpp_ctx_t *const ctx) -{ - xmpp_stanza_t *presence = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(presence, STANZA_NAME_PRESENCE); - - return presence; -} - xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid) { diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 5a11f3c1..5bc1ff74 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -237,8 +237,6 @@ xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t *ctx, xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room, const char *const nick); -xmpp_stanza_t* stanza_create_presence(xmpp_ctx_t *const ctx); - xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx); xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target); xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id,