diff options
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c index e9f40409..7892e78a 100644 --- a/src/command.c +++ b/src/command.c @@ -82,6 +82,7 @@ static gboolean _cmd_prefs(const char * const inp, struct cmd_help_t help); static gboolean _cmd_who(const char * const inp, struct cmd_help_t help); static gboolean _cmd_connect(const char * const inp, struct cmd_help_t help); static gboolean _cmd_disconnect(const char * const inp, struct cmd_help_t help); +static gboolean _cmd_sub(const char * const inp, struct cmd_help_t help); static gboolean _cmd_msg(const char * const inp, struct cmd_help_t help); static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help); static gboolean _cmd_close(const char * const inp, struct cmd_help_t help); @@ -178,6 +179,16 @@ static struct cmd_t main_commands[] = "Example : /msg boothj5@gmail.com Hey, here's a message!", NULL } } }, + { "/sub", + _cmd_sub, + { "/sub user@host", "Subscribe to presence notifications of user.", + { "/sub user@host", + "------------------", + "Send a subscription request to the user to be informed of their presence.", + "", + "Example: /sub myfriend@jabber.org", + NULL } } }, + { "/tiny", _cmd_tiny, { "/tiny url", "Send url as tinyurl in current chat.", @@ -692,6 +703,31 @@ _cmd_connect(const char * const inp, struct cmd_help_t help) } static gboolean +_cmd_sub(const char * const inp, struct cmd_help_t help) +{ + gboolean result = FALSE; + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + if (conn_status != JABBER_CONNECTED) { + cons_show("You are currently not connected."); + result = TRUE; + } else if (strlen(inp) < 6) { + cons_show("Usage: %s", help.usage); + result = TRUE; + } else { + char *user, *lower; + user = strndup(inp+5, strlen(inp)-5); + lower = g_utf8_strdown(user, -1); + + jabber_subscribe(lower); + + result = TRUE; + } + + return result; +} + +static gboolean _cmd_disconnect(const char * const inp, struct cmd_help_t help) { if (jabber_get_connection_status() == JABBER_CONNECTED) { |