diff options
author | James Booth <boothj5@gmail.com> | 2014-09-05 13:48:53 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-05 13:48:53 +0100 |
commit | 9728d1a727917aa40b27e2f76c02d5d11759f387 (patch) | |
tree | ee30a5cca5cadada1911e4e940204491cdb31327 /src | |
parent | c133b8931389bbfdfc3ac4b37ad4aad052ad9f9a (diff) | |
download | profani-tty-9728d1a727917aa40b27e2f76c02d5d11759f387.tar.gz |
Debug room config form fields
Diffstat (limited to 'src')
-rw-r--r-- | src/server_events.c | 11 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 26 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 2 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/server_events.c b/src/server_events.c index 1d9546fb..2fe6ace1 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -477,8 +477,17 @@ handle_room_configure(const char * const room, DataForm *form) GSList *curr = fields; while (curr != NULL) { FormField *field = curr->data; + + if (field->label != NULL) { + cons_show(" Field: %s", field->label); + } else { + cons_show(" Field:"); + } + if (field->type != NULL) { + cons_show(" Type: %s", field->type); + } if (field->var != NULL) { - cons_show(" Field: %s", field->var); + cons_show(" var: %s", field->var); } curr = g_slist_next(curr); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index b37d3fbd..e78f5b9f 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -1087,23 +1087,39 @@ stanza_create_form(xmpp_stanza_t * const stanza) //handle fields while (child != NULL) { + char *label = xmpp_stanza_get_attribute(child, "label"); + char *type = xmpp_stanza_get_attribute(child, "type"); char *var = xmpp_stanza_get_attribute(child, "var"); // handle FORM_TYPE if (g_strcmp0(var, "FORM_TYPE") == 0) { xmpp_stanza_t *value = xmpp_stanza_get_child_by_name(child, "value"); char *value_text = xmpp_stanza_get_text(value); - result->form_type = strdup(value_text); - xmpp_free(ctx, value_text); + if (value_text != NULL) { + result->form_type = strdup(value_text); + xmpp_free(ctx, value_text); + } // handle regular fields } else { FormField *field = malloc(sizeof(FormField)); - field->var = strdup(var); - field->values = NULL; - xmpp_stanza_t *value = xmpp_stanza_get_children(child); + field->label = NULL; + field->type = NULL; + field->var = NULL; + + if (label != NULL) { + field->label = strdup(label); + } + if (type != NULL) { + field->type = strdup(type); + } + if (var != NULL) { + field->var = strdup(var); + } // handle values + field->values = NULL; + xmpp_stanza_t *value = xmpp_stanza_get_children(child); while (value != NULL) { char *text = xmpp_stanza_get_text(value); if (text != NULL) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 38fde49f..cdb19c27 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -87,6 +87,8 @@ typedef struct disco_identity_t { } DiscoIdentity; typedef struct form_field_t { + char *label; + char *type; char *var; GSList *values; } FormField; |