diff options
author | Paul Fariello <paul@fariello.eu> | 2018-07-02 08:10:01 +0320 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2018-09-05 13:52:20 +0200 |
commit | ec5fc3612fd46cc3661f5ec6988e54900f271447 (patch) | |
tree | 95a881e168be9295a3fb71d2bacce2d35b6f3881 /src | |
parent | e555e41eaf97bb40a41bbb25f1cc68cf537f9fd5 (diff) | |
download | profani-tty-ec5fc3612fd46cc3661f5ec6988e54900f271447.tar.gz |
Allow to use cmd without being in a window
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_defs.c | 4 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 17 | ||||
-rw-r--r-- | src/xmpp/iq.c | 6 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index deffd954..b3bfa22d 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2308,8 +2308,8 @@ static struct cmd_t command_defs[] = CMD_NOMAINFUNC CMD_NOTAGS CMD_SYN( - "/cmd list", - "/cmd exec <command>") + "/cmd list [<jid>]", + "/cmd exec <command> [<jid>]") CMD_DESC( "Execute ad hoc commands.") CMD_ARGS( diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 475a81b4..f067d67a 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7484,9 +7484,12 @@ cmd_command_list(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; - - iq_command_list(mucwin->roomjid); + char *jid = args[1]; + if (jid == NULL) { + ProfMucWin *mucwin = (ProfMucWin*)window; + jid = mucwin->roomjid; + } + iq_command_list(jid); cons_show("List available ad hoc commands"); return TRUE; @@ -7507,9 +7510,13 @@ cmd_command_exec(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ProfMucWin *mucwin = (ProfMucWin*)window; + char *jid = args[2]; + if (jid == NULL) { + ProfMucWin *mucwin = (ProfMucWin*)window; + jid = mucwin->roomjid; + } - iq_command_exec(mucwin->roomjid, args[1]); + iq_command_exec(jid, args[1]); cons_show("Execute %s...", args[1]); return TRUE; diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 337701bc..9204f196 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1118,9 +1118,11 @@ _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata) } ProfWin *win = wins_get_by_string(from); - if (win) { - win_handle_command_list(win, cmds); + if (win == NULL) { + win = wins_get_console(); } + + win_handle_command_list(win, cmds); g_slist_free(cmds); free(from); |