diff options
Diffstat (limited to 'src/xmpp/stanza.c')
-rw-r--r-- | src/xmpp/stanza.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 45c8f2c4..86bd0d91 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -2718,3 +2718,40 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s return iq; } + +xmpp_stanza_t* +stanza_change_password(xmpp_ctx_t* ctx, const char* const user, const char* const password) +{ + char* id = connection_create_stanza_id(); + xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id); + free(id); + + xmpp_stanza_t* change_password = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(change_password, STANZA_NAME_QUERY); + xmpp_stanza_set_ns(change_password, STANZA_NS_REGISTER); + + xmpp_stanza_t* username_st = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(username_st, STANZA_NAME_USERNAME); + xmpp_stanza_t* username_text = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(username_text, user); + xmpp_stanza_add_child(username_st, username_text); + xmpp_stanza_release(username_text); + + xmpp_stanza_t* password_st = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD); + xmpp_stanza_t* password_text = xmpp_stanza_new(ctx); + xmpp_stanza_set_text(password_text, password); + xmpp_stanza_add_child(password_st, password_text); + xmpp_stanza_release(password_text); + + xmpp_stanza_add_child(change_password, username_st); + xmpp_stanza_release(username_st); + + xmpp_stanza_add_child(change_password, password_st); + xmpp_stanza_release(password_st); + + xmpp_stanza_add_child(iq, change_password); + xmpp_stanza_release(change_password); + + return iq; +} |