about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-12 01:10:46 +0100
committerJames Booth <boothj5@gmail.com>2014-10-12 01:10:46 +0100
commit77684cda007391ba57cfbaea22bde071bee2925d (patch)
treef2e81c7984f861a618d90d4cd5f55c7e27f08fc8
parent8b1d0bdc3f4b1577a0fff767f670174c2b20113d (diff)
downloadprofani-tty-77684cda007391ba57cfbaea22bde071bee2925d.tar.gz
Allow /role list and /affiliation list with no args
-rw-r--r--TODO_ROLES2
-rw-r--r--src/command/command.c4
-rw-r--r--src/command/commands.c23
-rw-r--r--src/ui/core.c2
4 files changed, 23 insertions, 8 deletions
diff --git a/TODO_ROLES b/TODO_ROLES
index ec76a229..71f320b2 100644
--- a/TODO_ROLES
+++ b/TODO_ROLES
@@ -1,5 +1,3 @@
-Reorganise/simplify room commands
-Add /room affiliation|role list with no arg to show all
 Fix room commands help
 Show role/affiliation on join
 Show role/affiliation on update
diff --git a/src/command/command.c b/src/command/command.c
index c09bf63e..7d35c609 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -354,7 +354,7 @@ static struct cmd_t command_defs[] =
         { "/affiliation set|list [affiliation] [jid]",
           "-----------------------------------------",
           "set affiliation jid - Set the affiliation of user with jid.",
-          "list affiliation    - List all users with the specified affiliation.",
+          "list [affiliation]  - List all users with the specified affiliation, or all if none specified.",
           "The affiliation may be one of owner, admin, member, outcast or none.",
           NULL } } },
 
@@ -364,7 +364,7 @@ static struct cmd_t command_defs[] =
         { "/role set|list [role] [nick]",
           "----------------------------",
           "set role nick - Set the role of occupant with nick.",
-          "list role     - List all occupants with the specified role.",
+          "list [role]   - List all occupants with the specified role, or all if none specified.",
           "The role may be one of moderator, participant, visitor or none.",
           NULL } } },
 
diff --git a/src/command/commands.c b/src/command/commands.c
index 9530b370..3e8d58d3 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2244,7 +2244,17 @@ cmd_affiliation(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
+    char *room = ui_current_recipient();
+
     char *affiliation = args[1];
+    if (!affiliation) {
+        iq_room_affiliation_list(room, "owner");
+        iq_room_affiliation_list(room, "admin");
+        iq_room_affiliation_list(room, "member");
+        iq_room_affiliation_list(room, "outcast");
+        return TRUE;
+    }
+
     if ((g_strcmp0(affiliation, "owner") != 0) &&
             (g_strcmp0(affiliation, "admin") != 0) &&
             (g_strcmp0(affiliation, "member") != 0) &&
@@ -2254,7 +2264,6 @@ cmd_affiliation(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
-    char *room = ui_current_recipient();
     ProfWin *window = wins_get_by_recipient(room);
 
     if (g_strcmp0(cmd, "list") == 0) {
@@ -2303,7 +2312,16 @@ cmd_role(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
+    char *room = ui_current_recipient();
+
     char *role = args[1];
+    if (!role) {
+        iq_room_role_list(room, "moderator");
+        iq_room_role_list(room, "participant");
+        iq_room_role_list(room, "visitor");
+        return TRUE;
+    }
+
     if ((g_strcmp0(role, "visitor") != 0) &&
             (g_strcmp0(role, "participant") != 0) &&
             (g_strcmp0(role, "moderator") != 0) &&
@@ -2312,14 +2330,11 @@ cmd_role(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
-    char *room = ui_current_recipient();
     ProfWin *window = wins_get_by_recipient(room);
 
     if (g_strcmp0(cmd, "list") == 0) {
         if (g_strcmp0(role, "none") == 0) {
             win_save_print(window, '!', NULL, 0, 0, "", "Cannot list users with no role.");
-        } else if (g_strcmp0(role, "visitor") == 0) {
-            win_save_print(window, '!', NULL, 0, 0, "", "Cannot list users with visitor role.");
         } else {
             iq_room_role_list(room, role);
         }
diff --git a/src/ui/core.c b/src/ui/core.c
index 58434eab..016a61e7 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1936,6 +1936,7 @@ _ui_handle_room_affiliation_list(const char * const room, const char * const aff
             win_save_print(window, '!', NULL, 0, 0, "", "");
         } else {
             win_save_vprint(window, '!', NULL, 0, 0, "", "No users found with affiliation: %s", affiliation);
+            win_save_print(window, '!', NULL, 0, 0, "", "");
         }
     }
 }
@@ -1974,6 +1975,7 @@ _ui_handle_room_role_list(const char * const room, const char * const role, GSLi
             win_save_print(window, '!', NULL, 0, 0, "", "");
         } else {
             win_save_vprint(window, '!', NULL, 0, 0, "", "No occupants found with role: %s", role);
+            win_save_print(window, '!', NULL, 0, 0, "", "");
         }
     }
 }