about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-17 02:58:03 +0000
committerJames Booth <boothj5@gmail.com>2013-02-17 02:58:03 +0000
commit1edb84efbcf982f4324827436c00975c3d138220 (patch)
treed82e08688baef4446a26c26e1669032f8989e2c5
parent50b7edbfb5f244a58e61017335af215c14e98d7e (diff)
downloadprofani-tty-1edb84efbcf982f4324827436c00975c3d138220.tar.gz
Added /software command handling to chat rooms and private chat
-rw-r--r--src/command/command.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 6dd6b46e..d88414e1 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -987,6 +987,7 @@ _cmd_complete_parameters(char *input, int *size)
             _parameter_autocomplete_with_ac(input, size, "/info", nick_ac);
             _parameter_autocomplete_with_ac(input, size, "/caps", nick_ac);
             _parameter_autocomplete_with_ac(input, size, "/status", nick_ac);
+            _parameter_autocomplete_with_ac(input, size, "/software", nick_ac);
         }
     } else {
         _parameter_autocomplete(input, size, "/msg",
@@ -1957,18 +1958,42 @@ _cmd_software(gchar **args, struct cmd_help_t help)
 
     if (conn_status != JABBER_CONNECTED) {
         cons_show("You are not currently connected.");
-        return TRUE;
-    }
-
-    Jid *jid = jid_create(args[0]);
-
-    if (jid->fulljid == NULL) {
-        cons_show("You must provide a full jid to the /software command.");
-        return TRUE;
     } else {
-        iq_send_software_version(jid->fulljid);
-        return TRUE;
+        if (win_current_is_groupchat()) {
+            if (args[0] != NULL) {
+                PContact pcontact = muc_get_participant(win_current_get_recipient(), args[0]);
+                if (pcontact != NULL) {
+                    Jid *jid = jid_create_from_bare_and_resource(win_current_get_recipient(), args[0]);
+                    iq_send_software_version(jid->fulljid);
+                    jid_destroy(jid);
+                } else {
+                    cons_show("No such participant \"%s\" in room.", args[0]);
+                }
+            } else {
+                cons_show("No nickname supplied to /software in chat room.");
+            }
+        } else if (win_current_is_chat() || win_current_is_console()) {
+            if (args[0] != NULL) {
+                Jid *jid = jid_create(args[0]);
+
+                if (jid->fulljid == NULL) {
+                    cons_show("You must provide a full jid to the /software command.");
+                } else {
+                    iq_send_software_version(jid->fulljid);
+                }
+            } else {
+                cons_show("You must provide a jid to the /software command.");
+            }
+        } else { // private chat
+            if (args[0] != NULL) {
+                cons_show("No parameter needed to /software when in private chat.");
+            } else {
+                iq_send_software_version(win_current_get_recipient());
+            }
+        }
     }
+
+    return TRUE;
 }
 
 static gboolean