about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/form.c37
-rw-r--r--src/xmpp/xmpp.h15
2 files changed, 52 insertions, 0 deletions
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index 002f366c..4b79d8e6 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -137,6 +137,42 @@ _is_required(xmpp_stanza_t * const stanza)
     }
 }
 
+static form_field_type_t
+_get_field_type(const char * const type)
+{
+    if (g_strcmp0(type, "hidden") == 0) {
+        return FIELD_HIDDEN;
+    }
+    if (g_strcmp0(type, "text-single") == 0) {
+        return FIELD_TEXT_SINGLE;
+    }
+    if (g_strcmp0(type, "text-private") == 0) {
+        return FIELD_TEXT_PRIVATE;
+    }
+    if (g_strcmp0(type, "text-multi") == 0) {
+        return FIELD_TEXT_MULTI;
+    }
+    if (g_strcmp0(type, "boolean") == 0) {
+        return FIELD_BOOLEAN;
+    }
+    if (g_strcmp0(type, "list-single") == 0) {
+        return FIELD_LIST_SINGLE;
+    }
+    if (g_strcmp0(type, "list-multi") == 0) {
+        return FIELD_LIST_MUTLI;
+    }
+    if (g_strcmp0(type, "jid-single") == 0) {
+        return FIELD_JID_SINGLE;
+    }
+    if (g_strcmp0(type, "jid-multi") == 0) {
+        return FIELD_JID_MULTI;
+    }
+    if (g_strcmp0(type, "fixed") == 0) {
+        return FIELD_FIXED;
+    }
+    return FIELD_UNKNOWN;
+}
+
 DataForm *
 form_create(xmpp_stanza_t * const form_stanza)
 {
@@ -161,6 +197,7 @@ form_create(xmpp_stanza_t * const form_stanza)
             FormField *field = _field_new();
             field->label = _get_attr(field_stanza, "label");
             field->type = _get_attr(field_stanza, "type");
+            field->type_t = _get_field_type(field->type);
             field->var = _get_attr(field_stanza, "var");
             field->description = _get_property(field_stanza, "desc");
             field->required = _is_required(field_stanza);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 6510a50e..c5583517 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -86,6 +86,20 @@ typedef struct disco_identity_t {
     char *category;
 } DiscoIdentity;
 
+typedef enum {
+    FIELD_HIDDEN,
+    FIELD_TEXT_SINGLE,
+    FIELD_TEXT_PRIVATE,
+    FIELD_TEXT_MULTI,
+    FIELD_BOOLEAN,
+    FIELD_LIST_SINGLE,
+    FIELD_LIST_MUTLI,
+    FIELD_JID_SINGLE,
+    FIELD_JID_MULTI,
+    FIELD_FIXED,
+    FIELD_UNKNOWN
+} form_field_type_t;
+
 typedef struct form_option_t {
     char *label;
     char *value;
@@ -94,6 +108,7 @@ typedef struct form_option_t {
 typedef struct form_field_t {
     char *label;
     char *type;
+    form_field_type_t type_t;
     char *var;
     char *description;
     gboolean required;