about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
index 229d0145..a2398874 100644
--- a/src/command.c
+++ b/src/command.c
@@ -130,6 +130,7 @@ static gboolean _cmd_info(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_wins(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_nick(gchar **args, struct cmd_help_t help);
 static gboolean _cmd_theme(gchar **args, struct cmd_help_t help);
+static gboolean _cmd_status(gchar **args, struct cmd_help_t help);
 
 /*
  * The commands are broken down into three groups:
@@ -263,6 +264,15 @@ static struct cmd_t main_commands[] =
           "If in a chat window the parameter is not required, the current recipient will be used.",
           NULL } } },
 
+    { "/status",
+        _cmd_status, parse_args, 0, 1,
+        { "/status [jid|nick]", "Find out a contacts presence information.",
+        { "/status [jid|nick]",
+          "------------------",
+          "Find out a contact, or room members presence information.",
+          "If in a chat window the parameter is not required, the current recipient will be used.",
+          NULL } } },
+
     { "/join",
         _cmd_join, parse_args_with_freetext, 1, 2,
         { "/join room [nick]", "Join a chat room.",
@@ -935,12 +945,15 @@ _cmd_complete_parameters(char *input, int *size)
         if (nick_ac != NULL) {
             _parameter_autocomplete_with_ac(input, size, "/msg", nick_ac);
             _parameter_autocomplete_with_ac(input, size, "/info", nick_ac);
+            _parameter_autocomplete_with_ac(input, size, "/status", nick_ac);
         }
     } else {
         _parameter_autocomplete(input, size, "/msg",
             contact_list_find_contact);
         _parameter_autocomplete(input, size, "/info",
             contact_list_find_contact);
+        _parameter_autocomplete(input, size, "/status",
+            contact_list_find_contact);
     }
 
     _parameter_autocomplete(input, size, "/connect",
@@ -1663,6 +1676,46 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
 }
 
 static gboolean
+_cmd_status(gchar **args, struct cmd_help_t help)
+{
+    char *usr = args[0];
+
+    jabber_conn_status_t conn_status = jabber_get_connection_status();
+
+    if (conn_status != JABBER_CONNECTED) {
+        cons_show("You are not currently connected.");
+    } else {
+        if (win_current_is_groupchat()) {
+            if (usr != NULL) {
+                win_room_show_status(usr);
+            } else {
+                win_current_show("You must specify a nickname.");
+            }
+        } else if (win_current_is_chat()) {
+            if (usr != NULL) {
+                win_current_show("No parameter required when in chat.");
+            } else {
+                win_show_status();
+            }
+        } else if (win_current_is_private()) {
+            if (usr != NULL) {
+                win_current_show("No parameter required when in chat.");
+            } else {
+                win_private_show_status();
+            }
+        } else {
+            if (usr != NULL) {
+                cons_show_status(usr);
+            } else {
+                cons_show("Usage: %s", help.usage);
+            }
+        }
+    }
+
+    return TRUE;
+}
+
+static gboolean
 _cmd_info(gchar **args, struct cmd_help_t help)
 {
     char *usr = args[0];