From 7123e94e82e1408b9abab1a9043617f58d396849 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Fri, 23 Mar 2018 21:10:10 +0220 Subject: Add support for form edition in command execution Also change wins_get_by_string prototype in order to handle const str. --- src/ui/window_list.c | 2 +- src/ui/window_list.h | 2 +- src/xmpp/iq.c | 31 ++++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') 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; } -- cgit 1.4.1-2-gfad0