diff options
author | James Booth <boothj5@gmail.com> | 2013-03-13 23:38:26 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-03-13 23:38:26 +0000 |
commit | b960b76034c2655d0c69219f8bcb90fec08ab1b4 (patch) | |
tree | c5a34fadb59596a9a58d1fc4d9ca40197a249641 /src/command | |
parent | ed2212a0cac573dd90847b954e38eddb591d2223 (diff) | |
download | profani-tty-b960b76034c2655d0c69219f8bcb90fec08ab1b4.tar.gz |
Added basic /rooms command to get chat room list
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c index fd8747d9..b5f8fe40 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -101,6 +101,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_rooms(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_beep(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_notify(gchar **args, struct cmd_help_t help); static gboolean _cmd_set_log(gchar **args, struct cmd_help_t help); @@ -334,6 +335,19 @@ static struct cmd_t main_commands[] = "Example : /join jdev@conference.jabber.org mynick", NULL } } }, + { "/rooms", + _cmd_rooms, parse_args, 0, 1, + { "/rooms [conference-node]", "List chat rooms.", + { "/rooms [conference-node]", + "------------------------", + "List the chat rooms available at the specified conference node", + "If no argument is supplied, the domainpart of the current logged in JID is used,", + "with a prefix of 'conference'.", + "", + "Example : /rooms conference.jabber.org", + "Example : /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)", + NULL } } }, + { "/nick", _cmd_nick, parse_args_with_freetext, 1, 1, { "/nick nickname", "Change nickname in chat room.", @@ -2058,6 +2072,29 @@ _cmd_join(gchar **args, struct cmd_help_t help) } static gboolean +_cmd_rooms(gchar **args, struct cmd_help_t help) +{ + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + if (conn_status != JABBER_CONNECTED) { + cons_show("You are currenlty connect."); + return TRUE; + } + + if (args[0] == NULL) { + Jid *jid = jid_create(jabber_get_jid()); + GString *conference_node = g_string_new("conference."); + g_string_append(conference_node, jid->domainpart); + iq_room_list_request(conference_node->str); + g_string_free(conference_node, TRUE); + } else { + iq_room_list_request(args[0]); + } + + return TRUE; +} + +static gboolean _cmd_nick(gchar **args, struct cmd_help_t help) { jabber_conn_status_t conn_status = jabber_get_connection_status(); |