1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Debug room config form fields

This commit is contained in:
James Booth 2014-09-05 13:48:53 +01:00
parent c133b89313
commit 9728d1a727
3 changed files with 33 additions and 6 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -87,6 +87,8 @@ typedef struct disco_identity_t {
} DiscoIdentity;
typedef struct form_field_t {
char *label;
char *type;
char *var;
GSList *values;
} FormField;