1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05: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; GSList *curr = fields;
while (curr != NULL) { while (curr != NULL) {
FormField *field = curr->data; 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) { if (field->var != NULL) {
cons_show(" Field: %s", field->var); cons_show(" var: %s", field->var);
} }
curr = g_slist_next(curr); curr = g_slist_next(curr);

View File

@ -1087,23 +1087,39 @@ stanza_create_form(xmpp_stanza_t * const stanza)
//handle fields //handle fields
while (child != NULL) { 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"); char *var = xmpp_stanza_get_attribute(child, "var");
// handle FORM_TYPE // handle FORM_TYPE
if (g_strcmp0(var, "FORM_TYPE") == 0) { if (g_strcmp0(var, "FORM_TYPE") == 0) {
xmpp_stanza_t *value = xmpp_stanza_get_child_by_name(child, "value"); xmpp_stanza_t *value = xmpp_stanza_get_child_by_name(child, "value");
char *value_text = xmpp_stanza_get_text(value); char *value_text = xmpp_stanza_get_text(value);
result->form_type = strdup(value_text); if (value_text != NULL) {
xmpp_free(ctx, value_text); result->form_type = strdup(value_text);
xmpp_free(ctx, value_text);
}
// handle regular fields // handle regular fields
} else { } else {
FormField *field = malloc(sizeof(FormField)); FormField *field = malloc(sizeof(FormField));
field->var = strdup(var); field->label = NULL;
field->values = NULL; field->type = NULL;
xmpp_stanza_t *value = xmpp_stanza_get_children(child); 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 // handle values
field->values = NULL;
xmpp_stanza_t *value = xmpp_stanza_get_children(child);
while (value != NULL) { while (value != NULL) {
char *text = xmpp_stanza_get_text(value); char *text = xmpp_stanza_get_text(value);
if (text != NULL) { if (text != NULL) {

View File

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