diff options
author | James Booth <boothj5@gmail.com> | 2014-09-04 23:15:51 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-04 23:15:51 +0100 |
commit | 5e1023dfd98c0d978958d1763ced483fa2e53ce2 (patch) | |
tree | 795c26f9bb99c7e59c3efe6d0fb85f0a594fa9ad /src | |
parent | 763356464ad35b3d6823341604eeefffec741584 (diff) | |
download | profani-tty-5e1023dfd98c0d978958d1763ced483fa2e53ce2.tar.gz |
Parse data form for room configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/server_events.c | 17 | ||||
-rw-r--r-- | src/server_events.h | 2 | ||||
-rw-r--r-- | src/xmpp/iq.c | 21 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 11 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 10 |
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); |