about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server_events.c71
-rw-r--r--src/ui/core.c76
-rw-r--r--src/ui/ui.h1
3 files changed, 78 insertions, 70 deletions
diff --git a/src/server_events.c b/src/server_events.c
index a9c6c6e6..e798eb9c 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -466,76 +466,7 @@ handle_room_destroy(const char * const room)
 void
 handle_room_configure(const char * const room, DataForm *form)
 {
-    cons_show("Recieved configuration form for %s", room);
-
-    if (form->type != NULL) {
-        cons_show("  Type: %s", form->type);
-    }
-    if (form->title != NULL) {
-        cons_show("  Title: %s", form->title);
-    }
-    if (form->instructions != NULL) {
-        cons_show("  Instructions: %s", form->instructions);
-    }
-
-    GSList *fields = form->fields;
-    GSList *curr_field = fields;
-    while (curr_field != NULL) {
-        FormField *field = curr_field->data;
-        cons_show("  Field:");
-
-        if (field->label != NULL) {
-            cons_show("    Label: %s", field->label);
-        }
-        if (field->type != NULL) {
-            cons_show("    Type: %s", field->type);
-        }
-        if (field->var != NULL) {
-            cons_show("    Var: %s", field->var);
-        }
-        if (field->description != NULL) {
-            cons_show("    Description: %s", field->description);
-        }
-
-        if (field->required) {
-            cons_show("    Required: TRUE");
-        } else {
-            cons_show("    Required: FALSE");
-        }
-
-        GSList *values = field->values;
-        GSList *curr_value = values;
-        if (curr_value != NULL) {
-            cons_show("    Values:");
-        }
-        while (curr_value != NULL) {
-            char *value = curr_value->data;
-            cons_show("      %s", value);
-
-            curr_value = g_slist_next(curr_value);
-        }
-
-        GSList *options = field->options;
-        GSList *curr_option = options;
-        if (curr_option != NULL) {
-            cons_show("    Options:");
-        }
-        while (curr_option != NULL) {
-            FormOption *option = curr_option->data;
-            if (option->label != NULL) {
-                cons_show("      Label: %s", option->label);
-            }
-            if (option->value != NULL) {
-                cons_show("        Value: %s", option->value);
-            }
-
-            curr_option = g_slist_next(curr_option);
-        }
-
-        curr_field = g_slist_next(curr_field);
-    }
-
-    form_destroy(form);
+    ui_handle_room_configuration(room, form);
 }
 
 void
diff --git a/src/ui/core.c b/src/ui/core.c
index 8495cd23..f5827cee 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1871,6 +1871,81 @@ _ui_draw_term_title(void)
 }
 
 static void
+_ui_handle_room_configuration(const char * const room, DataForm *form)
+{
+    cons_show("Recieved configuration form for %s", room);
+
+    if (form->type != NULL) {
+        cons_show("  Type: %s", form->type);
+    }
+    if (form->title != NULL) {
+        cons_show("  Title: %s", form->title);
+    }
+    if (form->instructions != NULL) {
+        cons_show("  Instructions: %s", form->instructions);
+    }
+
+    GSList *fields = form->fields;
+    GSList *curr_field = fields;
+    while (curr_field != NULL) {
+        FormField *field = curr_field->data;
+        cons_show("  Field:");
+
+        if (field->label != NULL) {
+            cons_show("    Label: %s", field->label);
+        }
+        if (field->type != NULL) {
+            cons_show("    Type: %s", field->type);
+        }
+        if (field->var != NULL) {
+            cons_show("    Var: %s", field->var);
+        }
+        if (field->description != NULL) {
+            cons_show("    Description: %s", field->description);
+        }
+
+        if (field->required) {
+            cons_show("    Required: TRUE");
+        } else {
+            cons_show("    Required: FALSE");
+        }
+
+        GSList *values = field->values;
+        GSList *curr_value = values;
+        if (curr_value != NULL) {
+            cons_show("    Values:");
+        }
+        while (curr_value != NULL) {
+            char *value = curr_value->data;
+            cons_show("      %s", value);
+
+            curr_value = g_slist_next(curr_value);
+        }
+
+        GSList *options = field->options;
+        GSList *curr_option = options;
+        if (curr_option != NULL) {
+            cons_show("    Options:");
+        }
+        while (curr_option != NULL) {
+            FormOption *option = curr_option->data;
+            if (option->label != NULL) {
+                cons_show("      Label: %s", option->label);
+            }
+            if (option->value != NULL) {
+                cons_show("        Value: %s", option->value);
+            }
+
+            curr_option = g_slist_next(curr_option);
+        }
+
+        curr_field = g_slist_next(curr_field);
+    }
+
+    form_destroy(form);
+}
+
+static void
 _win_handle_switch(const wint_t * const ch)
 {
     if (*ch == KEY_F(1)) {
@@ -2107,4 +2182,5 @@ ui_init_module(void)
     ui_update = _ui_update;
     ui_room_requires_config = _ui_room_requires_config;
     ui_room_destroyed = _ui_room_destroyed;
+    ui_handle_room_configuration = _ui_handle_room_configuration;
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 7e8967c0..cb1a92ee 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -160,6 +160,7 @@ void (*ui_handle_recipient_error)(const char * const recipient, const char * con
 void (*ui_handle_error)(const char * const err_msg);
 void (*ui_clear_win_title)(void);
 void (*ui_handle_room_join_error)(const char * const room, const char * const err);
+void (*ui_handle_room_configuration)(const char * const room, DataForm *form);
 
 // contact status functions
 void (*ui_status_room)(const char * const contact);