about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-03-29 03:16:41 +0100
committerJames Booth <boothj5@gmail.com>2015-03-29 03:16:41 +0100
commit71c2be599b54fb3cf7beb2a0855ad2a9d1bf6a0b (patch)
tree8cd55ad9cc7c804fc0434d8b4488b50e364fefaa /src/xmpp
parent1917d4c095d3df705a79a92078bef060d50b6947 (diff)
downloadprofani-tty-71c2be599b54fb3cf7beb2a0855ad2a9d1bf6a0b.tar.gz
Use password for chat room invites
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c17
1 files changed, 13 insertions, 4 deletions
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);