diff options
author | James Booth <boothj5@gmail.com> | 2014-12-02 20:50:21 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-12-02 20:50:21 +0000 |
commit | 1a8c805319eb7fea0068bde124f5900877e61ec6 (patch) | |
tree | 0ef3bd7c923e60cc195fc4d3826e01988f4757a1 /src/command/commands.c | |
parent | aae88753a3593adc78d488576a0e7644f4ccc912 (diff) | |
download | profani-tty-1a8c805319eb7fea0068bde124f5900877e61ec6.tar.gz |
Added /resource command
Diffstat (limited to 'src/command/commands.c')
-rw-r--r-- | src/command/commands.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 4a69a05b..62a5a6dd 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1528,6 +1528,48 @@ cmd_roster(gchar **args, struct cmd_help_t help) } gboolean +cmd_resource(gchar **args, struct cmd_help_t help) +{ + ProfWin *current = wins_get_current(); + if (current->type != WIN_CHAT) { + cons_show("The /resource command is only valid in chat windows."); + return TRUE; + } + + char *cmd = args[0]; + + if (g_strcmp0(cmd, "set") == 0) { + char *resource = args[1]; + if (!resource) { + cons_show("Usage: %s", help.usage); + return TRUE; + } + + char *recipent = ui_current_recipient(); + PContact contact = roster_get_contact(recipent); + if (!contact) { + cons_show("Cannot choose resource for contact not in roster."); + return TRUE; + } + + if (!p_contact_get_resource(contact, resource)) { + cons_show("No such resource %s.", resource); + return TRUE; + } + + current->chat_resource = strdup(resource); + return TRUE; + + } else if (g_strcmp0(cmd, "off") == 0) { + FREE_SET_NULL(current->chat_resource); + return TRUE; + } else { + cons_show("Usage: %s", help.usage); + return TRUE; + } +} + +gboolean cmd_status(gchar **args, struct cmd_help_t help) { char *usr = args[0]; |