Adding password handling for joining chatrooms

This commit is contained in:
Kristofer M White
2014-02-27 05:31:10 +00:00
parent 79d55a4668
commit 8a54c5895d
6 changed files with 27 additions and 8 deletions

View File

@@ -249,7 +249,7 @@ stanza_create_invite(xmpp_ctx_t *ctx, const char * const room,
xmpp_stanza_t *
stanza_create_room_join_presence(xmpp_ctx_t * const ctx,
const char * const full_room_jid)
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);
@@ -260,6 +260,19 @@ stanza_create_room_join_presence(xmpp_ctx_t * const ctx,
xmpp_stanza_t *x = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(x, STANZA_NAME_X);
xmpp_stanza_set_ns(x, STANZA_NS_MUC);
// if a password was given
if (passwd != NULL) {
xmpp_stanza_t *pass = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pass, "password");
xmpp_stanza_t *text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(text, strdup(passwd));
xmpp_stanza_add_child(pass, text);
xmpp_stanza_add_child(x, pass);
xmpp_stanza_release(text);
xmpp_stanza_release(pass);
}
xmpp_stanza_add_child(presence, x);
xmpp_stanza_release(x);