about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-05 20:29:41 +0000
committerJames Booth <boothj5@gmail.com>2014-03-05 20:29:41 +0000
commit65432c8d64b48791301ca7188a9562729d441165 (patch)
treee84fe7ab03b5294a6349dc95171736708337921c /src/command
parentd68c5941503e7bbc1a6dbaf56a5ad83d1c9ba744 (diff)
parent7c6755b62cf35deac7a98e30d91765fad3ca2d7f (diff)
downloadprofani-tty-65432c8d64b48791301ca7188a9562729d441165.tar.gz
Merge remote-tracking branch 'kmwhite/adding_support_for_private_confs'
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c9
-rw-r--r--src/command/commands.c44
2 files changed, 43 insertions, 10 deletions
diff --git a/src/command/command.c b/src/command/command.c
index d8f55205..5a1960ad 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -235,9 +235,9 @@ static struct cmd_t command_defs[] =
           NULL } } },
 
     { "/join",
-        cmd_join, parse_args_with_freetext, 1, 2, NULL,
-        { "/join room[@server] [nick]", "Join a chat room.",
-        { "/join room[@server] [nick]",
+        cmd_join, parse_args, 1, 5, NULL,
+        { "/join room[@server] [nick value] [passwd value]", "Join a chat room.",
+        { "/join room[@server] [nick value] [passwd value]",
           "--------------------------",
           "Join a chat room at the conference server.",
           "If nick is specified you will join with this nickname.",
@@ -246,7 +246,8 @@ static struct cmd_t command_defs[] =
           "If the room doesn't exist, and the server allows it, a new one will be created.",
           "",
           "Example : /join jdev@conference.jabber.org",
-          "Example : /join jdev@conference.jabber.org mynick",
+          "Example : /join jdev@conference.jabber.org nick mynick",
+          "Example : /join private@conference.jabber.org nick mynick passwd mypassword",
           "Example : /join jdev (as user@jabber.org will join jdev@conference.jabber.org)",
           NULL } } },
 
diff --git a/src/command/commands.c b/src/command/commands.c
index da360da8..9f4882fa 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1594,6 +1594,7 @@ cmd_join(gchar **args, struct cmd_help_t help)
     int num_args = g_strv_length(args);
     char *room = NULL;
     char *nick = NULL;
+    char *passwd = NULL;
     GString *room_str = g_string_new("");
     Jid *my_jid = jid_create(jabber_get_fulljid());
 
@@ -1609,19 +1610,50 @@ cmd_join(gchar **args, struct cmd_help_t help)
         room = room_str->str;
     }
 
-    // nick supplied
-    if (num_args == 2) {
-        nick = args[1];
+    // Additional args supplied
+    if (num_args > 1) {
+        char *opt1 = args[1];
+        char *opt1val = args[2];
+        char *opt2 = args[3];
+        char *opt2val = args[4];
+        if (opt1 != NULL) {
+            if (opt1val == NULL) {
+                cons_show("Usage: %s", help.usage);
+                cons_show("");
+                return TRUE;
+            }
+            if (strcmp(opt1, "nick") == 0) {
+                nick = opt1val;
+            } else if (strcmp(opt1, "passwd") == 0) {
+                passwd = opt1val;
+            } else {
+                cons_show("Usage: %s", help.usage);
+                cons_show("");
+                return TRUE;
+            }
+            if (opt2 != NULL) {
+                if (strcmp(opt2, "nick") == 0) {
+                    nick = opt2val;
+                } else if (strcmp(opt2, "passwd") == 0) {
+                    passwd = opt2val;
+                } else {
+                    cons_show("Usage: %s", help.usage);
+                    cons_show("");
+                    return TRUE;
+                }
+            }
+        }
+    }
 
-    // otherwise use account preference
-    } else {
+    // In the case that a nick wasn't provided by the optional args...
+    if (nick == NULL) {
         nick = account->muc_nick;
     }
 
     Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
 
     if (!muc_room_is_active(room_jid)) {
-        presence_join_room(room_jid);
+        presence_join_room(room_jid, passwd);
     }
     ui_room_join(room_jid);
     muc_remove_invite(room);