about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server_events.c17
-rw-r--r--src/server_events.h2
-rw-r--r--src/xmpp/iq.c21
-rw-r--r--src/xmpp/stanza.h11
-rw-r--r--src/xmpp/xmpp.h10
5 files changed, 50 insertions, 11 deletions
diff --git a/src/server_events.c b/src/server_events.c
index eda847d2..f5f3b360 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -464,6 +464,23 @@ handle_room_destroy(const char * const room)
 }
 
 void
+handle_room_configure(const char * const room, DataForm *form)
+{
+    cons_show("Recieved configuration form for %s", room);
+    if (form->form_type != NULL) {
+        cons_show("Form type: %s", form->form_type);
+    } else {
+        cons_show("No form type specified");
+    }
+}
+
+void
+handle_room_configuration_form_error(void)
+{
+    cons_show("Error parsing room configuration form.");
+}
+
+void
 handle_room_roster_complete(const char * const room)
 {
     if (muc_room_is_autojoin(room)) {
diff --git a/src/server_events.h b/src/server_events.h
index 54d04b54..35fa00b5 100644
--- a/src/server_events.h
+++ b/src/server_events.h
@@ -95,5 +95,7 @@ void handle_presence_error(const char *from, const char * const type,
     const char *err_msg);
 void handle_xmpp_stanza(const char * const msg);
 void handle_ping_result(const char * const from, int millis);
+void handle_room_configure(const char * const room, DataForm *form);
+void handle_room_configuration_form_error(void);
 
 #endif
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 5c954b53..ab3a29a0 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -592,10 +592,29 @@ _room_config_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         log_error("No from attribute for IQ destroy room result");
     } else {
         // get form
+        xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+        if (query == NULL) {
+            log_error("No query element found parsing room config response");
+            handle_room_configuration_form_error();
+            return 0;
+        }
 
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
+        if (x == NULL) {
+            log_error("No x element found with %s namespace parsing room config response", STANZA_NS_DATA);
+            handle_room_configuration_form_error();
+            return 0;
+        }
 
+        char *type = xmpp_stanza_get_attribute(x, STANZA_ATTR_TYPE);
+        if (g_strcmp0(type, "form") != 0) {
+            log_error("x element not of type 'form' parsing room config response");
+            handle_room_configuration_form_error();
+            return 0;
+        }
 
-//        handle_room_configure(from);
+        DataForm *form = stanza_create_form(x);
+        handle_room_configure(from, form);
     }
 
     return 0;
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index ea8e0cdb..b13c2960 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -36,6 +36,7 @@
 #define XMPP_STANZA_H
 
 #include <strophe.h>
+#include <xmpp/xmpp.h>
 
 #define STANZA_NAME_ACTIVE "active"
 #define STANZA_NAME_INACTIVE "inactive"
@@ -154,16 +155,6 @@
 
 #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
 
-typedef struct form_field_t {
-    char *var;
-    GSList *values;
-} FormField;
-
-typedef struct data_form_t {
-    char *form_type;
-    GSList *fields;
-} DataForm;
-
 xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
 
 xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index c1060c69..38fde49f 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -86,6 +86,16 @@ typedef struct disco_identity_t {
     char *category;
 } DiscoIdentity;
 
+typedef struct form_field_t {
+    char *var;
+    GSList *values;
+} FormField;
+
+typedef struct data_form_t {
+    char *form_type;
+    GSList *fields;
+} DataForm;
+
 void jabber_init_module(void);
 void bookmark_init_module(void);
 void capabilities_init_module(void);
1'>351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524