diff options
author | James Booth <boothj5@gmail.com> | 2014-09-12 00:21:28 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-12 00:21:28 +0100 |
commit | 38959e0c33f292a7824aeb64ddb6f5e2b2831206 (patch) | |
tree | eb0988ad904ea8a8d79e105cf78ad1be5dc27fa7 /src/xmpp | |
parent | 42a14d018274d2ab306e95765a735ee25aafa6ee (diff) | |
download | profani-tty-38959e0c33f292a7824aeb64ddb6f5e2b2831206.tar.gz |
Added setting of *-single room config values
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/form.c | 23 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/xmpp/form.c b/src/xmpp/form.c index 3ee31a6b..c23ffa26 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -382,9 +382,32 @@ _form_get_field_by_var(DataForm *form, const char * const var) return NULL; } +static void +_form_set_value_by_tag(DataForm *form, const char * const tag, char *value) +{ + char *var = g_hash_table_lookup(form->tag_to_var, tag); + if (var != NULL) { + GSList *curr = form->fields; + while (curr != NULL) { + FormField *field = curr->data; + if (g_strcmp0(field->var, var) == 0) { + if (g_slist_length(field->values) == 0) { + field->values = g_slist_append(field->values, strdup(value)); + } else if (g_slist_length(field->values) == 1) { + free(field->values->data); + field->values->data = strdup(value); + return; + } + } + curr = g_slist_next(curr); + } + } +} + void form_init_module(void) { form_destroy = _form_destroy; form_get_field_by_var = _form_get_field_by_var; + form_set_value_by_tag = _form_set_value_by_tag; } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 0186fba5..97a405ed 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -206,5 +206,6 @@ void (*roster_send_remove)(const char * const barejid); void (*form_destroy)(DataForm *form); char * (*form_get_field_by_var)(DataForm *form, const char * const var); +void (*form_set_value_by_tag)(DataForm *form, const char * const tag, char *value); #endif |