about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-03-14 21:29:04 +0000
committerJames Booth <boothj5@gmail.com>2013-03-14 21:29:04 +0000
commitd7bcda0e1cb7fbfc8ce65035c37cb7a3a741b081 (patch)
treedb5949246fc82263b5a4441539f22a5d8fc3ff7d /src
parent816c019ef86e71157b319c7cf4b0bd632996b87c (diff)
downloadprofani-tty-d7bcda0e1cb7fbfc8ce65035c37cb7a3a741b081.tar.gz
Use domain part of current jid when no jid passed to /disco
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 037b0a3d..8ea7769e 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -350,7 +350,7 @@ static struct cmd_t main_commands[] =
           NULL } } },
 
     { "/disco",
-        _cmd_disco, parse_args, 2, 2,
+        _cmd_disco, parse_args, 1, 2,
         { "/disco command entity", "Service discovery.",
         { "/disco command entity",
           "---------------------",
@@ -2111,7 +2111,8 @@ _cmd_rooms(gchar **args, struct cmd_help_t help)
     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);
+        g_string_append(conference_node, strdup(jid->domainpart));
+        jid_destroy(jid);
         iq_room_list_request(conference_node->str);
         g_string_free(conference_node, TRUE);
     } else {
@@ -2131,12 +2132,23 @@ _cmd_disco(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
+    GString *jid = g_string_new("");
+    if (args[1] != NULL) {
+        jid = g_string_append(jid, args[1]);
+    } else {
+        Jid *jidp = jid_create(jabber_get_jid());
+        jid = g_string_append(jid, strdup(jidp->domainpart));
+        jid_destroy(jidp);
+    }
+
     if (g_strcmp0(args[0], "info") == 0) {
-        iq_disco_info_request(args[1]);
+        iq_disco_info_request(jid->str);
     } else {
-        iq_disco_items_request(args[1]);
+        iq_disco_items_request(jid->str);
     }
 
+    g_string_free(jid, TRUE);
+
     return TRUE;
 }