about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-18 23:16:19 +0100
committerJames Booth <boothj5@gmail.com>2014-10-18 23:16:19 +0100
commit6246c8b94074d0fa28aa36d4412b834c8657b819 (patch)
tree719cf91d450d11994c62fe5e227363d1eab7abaf /src/command
parentbd03bbad730a7b5f2a935dcda3f7b06184cb72d7 (diff)
downloadprofani-tty-6246c8b94074d0fa28aa36d4412b834c8657b819.tar.gz
Add fields to command autocompleter on switch/previous/next
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c35
-rw-r--r--src/command/command.h4
2 files changed, 39 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 03dc6e01..2a3afb24 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -53,6 +53,7 @@
 #include "contact.h"
 #include "roster_list.h"
 #include "jid.h"
+#include "xmpp/form.h"
 #include "log.h"
 #include "muc.h"
 #ifdef HAVE_LIBOTR
@@ -1421,6 +1422,40 @@ cmd_autocomplete_add(char *value)
 }
 
 void
+cmd_autocomplete_add_form_fields(DataForm *form)
+{
+    if (form) {
+        GSList *fields = autocomplete_create_list(form->tag_ac);
+        GSList *curr_field = fields;
+        while (curr_field) {
+            GString *field_str = g_string_new("/");
+            g_string_append(field_str, curr_field->data);
+            cmd_autocomplete_add(field_str->str);
+            g_string_free(field_str, TRUE);
+            curr_field = g_slist_next(curr_field);
+        }
+        g_slist_free_full(fields, free);
+    }
+}
+
+void
+cmd_autocomplete_remove_form_fields(DataForm *form)
+{
+    if (form) {
+        GSList *fields = autocomplete_create_list(form->tag_ac);
+        GSList *curr_field = fields;
+        while (curr_field) {
+            GString *field_str = g_string_new("/");
+            g_string_append(field_str, curr_field->data);
+            cmd_autocomplete_remove(field_str->str);
+            g_string_free(field_str, TRUE);
+            curr_field = g_slist_next(curr_field);
+        }
+        g_slist_free_full(fields, free);
+    }
+}
+
+void
 cmd_autocomplete_remove(char *value)
 {
     if (commands_ac != NULL) {
diff --git a/src/command/command.h b/src/command/command.h
index a2ded657..13cf2d00 100644
--- a/src/command/command.h
+++ b/src/command/command.h
@@ -37,6 +37,8 @@
 
 #include <glib.h>
 
+#include "xmpp/form.h"
+
 GHashTable *commands;
 
 void cmd_init(void);
@@ -46,6 +48,8 @@ void cmd_autocomplete(char *input, int *size);
 void cmd_reset_autocomplete(void);
 void cmd_autocomplete_add(char *value);
 void cmd_autocomplete_remove(char *value);
+void cmd_autocomplete_add_form_fields(DataForm *form);
+void cmd_autocomplete_remove_form_fields(DataForm *form);
 void cmd_alias_add(char *value);
 void cmd_alias_remove(char *value);