about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2018-03-23 21:10:10 +0220
committerPaul Fariello <paul@fariello.eu>2018-09-05 13:51:00 +0200
commit7123e94e82e1408b9abab1a9043617f58d396849 (patch)
tree326b838cae6ca79f4992277be723d0381c4b7748 /src
parent40eee1caabde94cc6bab82e9c583d4c1cc45c4c6 (diff)
downloadprofani-tty-7123e94e82e1408b9abab1a9043617f58d396849.tar.gz
Add support for form edition in command execution
Also change wins_get_by_string prototype in order to handle const str.
Diffstat (limited to 'src')
-rw-r--r--src/ui/window_list.c2
-rw-r--r--src/ui/window_list.h2
-rw-r--r--src/xmpp/iq.c31
3 files changed, 26 insertions, 9 deletions
diff --git a/src/ui/window_list.c b/src/ui/window_list.c
index 798f4e41..e408a2ac 100644
--- a/src/ui/window_list.c
+++ b/src/ui/window_list.c
@@ -364,7 +364,7 @@ wins_get_by_num(int i)
 }
 
 ProfWin*
-wins_get_by_string(char *str)
+wins_get_by_string(const char *str)
 {
     if (g_strcmp0(str, "console") == 0) {
         ProfWin *conswin = wins_get_console();
diff --git a/src/ui/window_list.h b/src/ui/window_list.h
index 68e72739..ba62ad32 100644
--- a/src/ui/window_list.h
+++ b/src/ui/window_list.h
@@ -68,7 +68,7 @@ ProfWin* wins_get_current(void);
 void wins_set_current_by_num(int i);
 
 ProfWin* wins_get_by_num(int i);
-ProfWin* wins_get_by_string(char *str);
+ProfWin* wins_get_by_string(const char *str);
 
 ProfWin* wins_get_next(void);
 ProfWin* wins_get_previous(void);
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index dd856298..f5bacddd 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1097,7 +1097,7 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata
 {
     const char *id = xmpp_stanza_get_id(stanza);
     const char *type = xmpp_stanza_get_type(stanza);
-    char *from = strdup(xmpp_stanza_get_from(stanza));
+    const char *from = xmpp_stanza_get_from(stanza);
     const char *const command = userdata;
 
     if (id) {
@@ -1115,7 +1115,6 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata
             win_command_exec_error(win, command, error_message);
         }
         free(error_message);
-        free(from);
         return 0;
     }
 
@@ -1136,13 +1135,31 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata
                 win_handle_command_exec_result_note(win, type, value);
             }
         }
-    } else if (g_strcmp0(status, "executing") == 0) {
-    } else if (g_strcmp0(status, "canceled") == 0) {
-    } else {
-        /* TODO */
+        return 0;
     }
 
-    free(from);
+    if (g_strcmp0(status, "executing") == 0) {
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA);
+        if (x == NULL) {
+            /* TODO */
+            return 0;
+        }
+
+        const char *form_type = xmpp_stanza_get_type(x);
+        if (g_strcmp0(form_type, "form") != 0) {
+            /* TODO */
+            return 0;
+        }
+
+        DataForm *form = form_create(x);
+        ProfMucConfWin *confwin = (ProfMucConfWin*)wins_new_muc_config(from, form);
+        mucconfwin_handle_configuration(confwin, form);
+    }
+
+    if (g_strcmp0(status, "canceled") == 0) {
+    }
+
+    /* TODO */
 
     return 0;
 }