From 1eba4f5ab1e4148efdbcef22fb16d7c1bf0ed9d5 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 30 May 2013 22:48:56 +0100 Subject: Added /leave command --- src/command/command.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index d181f48a..d5919496 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -102,6 +102,7 @@ static gboolean _cmd_tiny(gchar **args, struct cmd_help_t help); static gboolean _cmd_close(gchar **args, struct cmd_help_t help); static gboolean _cmd_clear(gchar **args, struct cmd_help_t help); static gboolean _cmd_join(gchar **args, struct cmd_help_t help); +static gboolean _cmd_leave(gchar **args, struct cmd_help_t help); static gboolean _cmd_invite(gchar **args, struct cmd_help_t help); static gboolean _cmd_invites(gchar **args, struct cmd_help_t help); static gboolean _cmd_decline(gchar **args, struct cmd_help_t help); @@ -358,6 +359,14 @@ static struct cmd_t main_commands[] = "Example : /join jdev (as user@jabber.org will join jdev@conference.jabber.org)", NULL } } }, + { "/leave", + _cmd_leave, parse_args, 0, 0, + { "/leave", "Leave a chat room.", + { "/leave", + "------", + "Leave the current chat room.", + NULL } } }, + { "/invite", _cmd_invite, parse_args_with_freetext, 1, 2, { "/invite jid [message]", "Invite contact to chat room.", @@ -2663,6 +2672,30 @@ _cmd_close(gchar **args, struct cmd_help_t help) return TRUE; } +static gboolean +_cmd_leave(gchar **args, struct cmd_help_t help) +{ + jabber_conn_status_t conn_status = jabber_get_connection_status(); + win_type_t win_type = ui_current_win_type(); + int index = ui_current_win_index(); + + if (win_type != WIN_MUC) { + cons_show("You can only use the /leave command in a chat room."); + cons_alert(); + return TRUE; + } + + // handle leaving rooms, or chat + if (conn_status == JABBER_CONNECTED) { + ui_close_connected_win(index); + } + + // close the window + ui_close_win(index); + + return TRUE; +} + static gboolean _cmd_set_beep(gchar **args, struct cmd_help_t help) { -- cgit 1.4.1-2-gfad0