From ce48525e99762685a531c057295dba964f9d5093 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 7 Feb 2020 21:12:59 +0100 Subject: [PATCH] avatar: use unique id for stanza id "retrieve1" should have been only for testing. --- src/xmpp/avatar.c | 9 ++++++--- src/xmpp/stanza.c | 6 +++--- src/xmpp/stanza.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c index bdf232a5..1a3a08b9 100644 --- a/src/xmpp/avatar.c +++ b/src/xmpp/avatar.c @@ -158,11 +158,14 @@ _avatar_request_item_by_id(const char *jid, avatar_metadata *data) xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *iq = stanza_create_avatar_retrieve_data_request(ctx, data->id, jid); - iq_id_handler_add("retrieve1", _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data); + char *uid = connection_create_stanza_id(); + + xmpp_stanza_t *iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid); + iq_id_handler_add(uid, _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data); + + free(uid); iq_send_stanza(iq); - xmpp_stanza_release(iq); } diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 3a8d2b56..f398a268 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -2577,9 +2577,9 @@ stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const } xmpp_stanza_t* -stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid) +stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid) { - xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "retrieve1"); + xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, stanza_id); xmpp_stanza_set_to(iq, jid); xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx); @@ -2594,7 +2594,7 @@ stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *const id xmpp_stanza_t *item = xmpp_stanza_new(ctx); xmpp_stanza_set_name(item, STANZA_NAME_ITEM); - xmpp_stanza_set_attribute(item, "id", id); + xmpp_stanza_set_attribute(item, "id", item_id); xmpp_stanza_add_child(items, item); xmpp_stanza_add_child(pubsub, items); diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 04749fd2..7b5cbe35 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -355,6 +355,6 @@ void stanza_free_caps(XMPPCaps *caps); xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns); -xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid); +xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid); #endif