diff options
author | Paul Fariello <paul@fariello.eu> | 2018-09-05 12:23:57 +0200 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2018-09-05 13:52:20 +0200 |
commit | 1d3baa99a7fb1e5e479536197a165f3c13a87af0 (patch) | |
tree | 8dfd673540565427956c91ba472f6af4a0f9b6ea /src | |
parent | afd4fc4ea1e29f9a390b62d84afb181a5aa78b1f (diff) | |
download | profani-tty-1d3baa99a7fb1e5e479536197a165f3c13a87af0.tar.gz |
Ensure cmd commands are run on the right type of window
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_funcs.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index cd996309..d45fde81 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7486,9 +7486,34 @@ cmd_command_list(ProfWin *window, const char *const command, gchar **args) char *jid = args[1]; if (jid == NULL) { - ProfMucWin *mucwin = (ProfMucWin*)window; - jid = mucwin->roomjid; + switch (window->type) { + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + jid = mucwin->roomjid; + break; + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + jid = chatwin->barejid; + break; + } + case WIN_PRIVATE: + { + ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + jid = privatewin->fulljid; + break; + } + default: + cons_show("Cannot send ad hoc commands."); + return TRUE; + } } + iq_command_list(jid); cons_show("List available ad hoc commands"); @@ -7512,8 +7537,32 @@ cmd_command_exec(ProfWin *window, const char *const command, gchar **args) char *jid = args[2]; if (jid == NULL) { - ProfMucWin *mucwin = (ProfMucWin*)window; - jid = mucwin->roomjid; + switch (window->type) { + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + jid = mucwin->roomjid; + break; + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + jid = chatwin->barejid; + break; + } + case WIN_PRIVATE: + { + ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + jid = privatewin->fulljid; + break; + } + default: + cons_show("Cannot send ad hoc commands."); + return TRUE; + } } iq_command_exec(jid, args[1]); |