From 71c2be599b54fb3cf7beb2a0855ad2a9d1bf6a0b Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 29 Mar 2015 03:16:41 +0100 Subject: Use password for chat room invites --- src/xmpp/message.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/xmpp') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index bdbd5907..02c748d9 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -340,11 +340,18 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, reason = xmpp_stanza_get_text(reason_st); } - handle_room_invite(INVITE_MEDIATED, invitor, room, reason); + char *password = NULL; + xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD); + password = xmpp_stanza_get_text(password_st); + + handle_room_invite(INVITE_MEDIATED, invitor, room, reason, password); jid_destroy(jidp); - if (reason != NULL) { + if (reason) { xmpp_free(ctx, reason); } + if (password) { + xmpp_free(ctx, password); + } } return 1; @@ -359,13 +366,14 @@ _conference_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *room = NULL; char *invitor = NULL; char *reason = NULL; + char *password = NULL; if (from == NULL) { log_warning("Message received with no from attribute, ignoring"); return 1; } - // XEP-0429 + // XEP-0249 room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID); if (room == NULL) { return 1; @@ -378,8 +386,9 @@ _conference_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, invitor = jidp->barejid; reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON); + password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD); - handle_room_invite(INVITE_DIRECT, invitor, room, reason); + handle_room_invite(INVITE_DIRECT, invitor, room, reason, password); jid_destroy(jidp); -- cgit 1.4.1-2-gfad0