diff options
Diffstat (limited to 'src/xmpp/iq.c')
-rw-r--r-- | src/xmpp/iq.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 17e19297..b866128b 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -149,6 +149,7 @@ static int _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userda static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata); +static int _register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static void _iq_free_room_data(ProfRoomInfoData* roominfo); static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set); @@ -2629,3 +2630,32 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata) return 0; } + +void +iq_register_change_password(const char* const user, const char* const password) +{ + xmpp_ctx_t* const ctx = connection_get_ctx(); + xmpp_stanza_t* iq = stanza_change_password(ctx, user, password); + + const char* id = xmpp_stanza_get_id(iq); + iq_id_handler_add(id, _register_change_password_result_id_handler, NULL, NULL); + + iq_send_stanza(iq); + xmpp_stanza_release(iq); +} + +static int +_register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata) +{ + const char* type = xmpp_stanza_get_type(stanza); + if (g_strcmp0(type, "error") == 0) { + char* error_message = stanza_get_error_message(stanza); + cons_show_error("Server error: %s", error_message); + log_debug("Password change error: %s", error_message); + free(error_message); + } else { + cons_show("Password successfully changed."); + log_debug("Password successfully changed."); + } + return 0; +} |