about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-15 22:25:15 +0000
committerJames Booth <boothj5@gmail.com>2014-03-15 22:25:15 +0000
commit2af418fd8da7bce971f84b98be945f8d5a858f9d (patch)
treec03440bd0dd9a31c694a10dbe2585584c3907ab2 /src
parent26726b207a344a79633f0420ff8be9c83aca3934 (diff)
downloadprofani-tty-2af418fd8da7bce971f84b98be945f8d5a858f9d.tar.gz
Command '/statuses muc' now allows 'all', 'online' and 'none' settings
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c40
-rw-r--r--src/command/commands.c32
-rw-r--r--src/config/preferences.c3
-rw-r--r--src/server_events.c20
-rw-r--r--src/ui/console.c13
5 files changed, 49 insertions, 59 deletions
diff --git a/src/command/command.c b/src/command/command.c
index c3f87516..a9bab0ef 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -780,21 +780,11 @@ static struct cmd_t command_defs[] =
         { "/statuses console|chat|muc setting",
           "----------------------------------",
           "Configure how presence changes are displayed in various windows.",
-          "Settings for the console:",
-          "  all - Show all presence changes in the console",
-          "  online - Show only when contacts log in/out.",
-          "  none - Don't show any presence changes in the console.",
-          "Settings for chat windows:",
-          "  all - Show all presence changes in the contact's chat window if one is open.",
-          "  online - Show only when contacts log in/out.",
-          "  none - Don't show any presence changes in the chat windows.",
-          "Settings for chat room windows:",
-          "  on - Show presence changes in chat rooms.",
-          "  off - Do not show presence changes in chat rooms.",
-          "The defaults are:",
-          "  console - all",
-          "  chat - all",
-          "  muc - on",
+          "Settings:",
+          "  all - Show all presence changes.",
+          "  online - Show only online/offline changes.",
+          "  none - Don't show any presence changes.",
+          "The default is 'all' for all windows.",
           NULL } } },
 
     { "/away",
@@ -879,7 +869,7 @@ static Autocomplete otr_ac;
 static Autocomplete otr_log_ac;
 static Autocomplete connect_property_ac;
 static Autocomplete statuses_ac;
-static Autocomplete statuses_cons_chat_ac;
+static Autocomplete statuses_setting_ac;
 static Autocomplete alias_ac;
 static Autocomplete aliases_ac;
 static Autocomplete join_property_ac;
@@ -1080,10 +1070,10 @@ cmd_init(void)
     autocomplete_add(statuses_ac, "chat");
     autocomplete_add(statuses_ac, "muc");
 
-    statuses_cons_chat_ac = autocomplete_new();
-    autocomplete_add(statuses_cons_chat_ac, "all");
-    autocomplete_add(statuses_cons_chat_ac, "online");
-    autocomplete_add(statuses_cons_chat_ac, "none");
+    statuses_setting_ac = autocomplete_new();
+    autocomplete_add(statuses_setting_ac, "all");
+    autocomplete_add(statuses_setting_ac, "online");
+    autocomplete_add(statuses_setting_ac, "none");
 
     alias_ac = autocomplete_new();
     autocomplete_add(alias_ac, "add");
@@ -1124,7 +1114,7 @@ cmd_uninit(void)
     autocomplete_free(otr_log_ac);
     autocomplete_free(connect_property_ac);
     autocomplete_free(statuses_ac);
-    autocomplete_free(statuses_cons_chat_ac);
+    autocomplete_free(statuses_setting_ac);
     autocomplete_free(alias_ac);
     autocomplete_free(aliases_ac);
     autocomplete_free(join_property_ac);
@@ -1247,7 +1237,7 @@ cmd_reset_autocomplete()
     autocomplete_reset(otr_log_ac);
     autocomplete_reset(connect_property_ac);
     autocomplete_reset(statuses_ac);
-    autocomplete_reset(statuses_cons_chat_ac);
+    autocomplete_reset(statuses_setting_ac);
     autocomplete_reset(alias_ac);
     autocomplete_reset(aliases_ac);
     autocomplete_reset(join_property_ac);
@@ -1790,17 +1780,17 @@ _statuses_autocomplete(char *input, int *size)
 {
     char *result = NULL;
 
-    result = autocomplete_param_with_ac(input, size, "/statuses console", statuses_cons_chat_ac);
+    result = autocomplete_param_with_ac(input, size, "/statuses console", statuses_setting_ac);
     if (result != NULL) {
         return result;
     }
 
-    result = autocomplete_param_with_ac(input, size, "/statuses chat", statuses_cons_chat_ac);
+    result = autocomplete_param_with_ac(input, size, "/statuses chat", statuses_setting_ac);
     if (result != NULL) {
         return result;
     }
 
-    result = autocomplete_param_with_func(input, size, "/statuses muc", prefs_autocomplete_boolean_choice);
+    result = autocomplete_param_with_ac(input, size, "/statuses muc", statuses_setting_ac);
     if (result != NULL) {
         return result;
     }
diff --git a/src/command/commands.c b/src/command/commands.c
index e63d9893..c7a8e0d5 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2424,23 +2424,14 @@ cmd_statuses(gchar **args, struct cmd_help_t help)
             strcmp(args[0], "chat") != 0 &&
             strcmp(args[0], "muc") != 0) {
         cons_show("Usage: %s", help.usage);
+        return TRUE;
     }
 
-    if (strcmp(args[0], "console") == 0 || strcmp(args[0], "chat") == 0) {
-        if (strcmp(args[1], "all") != 0 &&
-                strcmp(args[1], "online") != 0 &&
-                strcmp(args[1], "none") != 0) {
-            cons_show("Usage: %s", help.usage);
-            return TRUE;
-        }
-
-    }
-
-    if (strcmp(args[0], "muc") == 0) {
-        if (strcmp(args[1], "on") != 0 && strcmp(args[1], "off") != 0) {
-            cons_show("Usage: %s", help.usage);
-            return TRUE;
-        }
+    if (strcmp(args[1], "all") != 0 &&
+            strcmp(args[1], "online") != 0 &&
+            strcmp(args[1], "none") != 0) {
+        cons_show("Usage: %s", help.usage);
+        return TRUE;
     }
 
     if (strcmp(args[0], "console") == 0) {
@@ -2466,9 +2457,16 @@ cmd_statuses(gchar **args, struct cmd_help_t help)
     }
 
     if (strcmp(args[0], "muc") == 0) {
-        _cmd_set_boolean_preference(args[1], help,
-            "Chat room presence updates", PREF_STATUSES_MUC);
+        prefs_set_string(PREF_STATUSES_MUC, args[1]);
+        if (strcmp(args[1], "all") == 0) {
+            cons_show("All presence updates will appear in chat room windows.");
+        } else if (strcmp(args[1], "online") == 0) {
+            cons_show("Only join/leave presence updates will appear in chat room windows.");
+        } else {
+            cons_show("Presence updates will not appear in chat room windows.");
+        }
     }
+
     return TRUE;
 }
 
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 8744acdf..02bb0833 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -477,8 +477,6 @@ _get_default_boolean(preference_t pref)
         case PREF_STATUSES:
         case PREF_AUTOAWAY_CHECK:
         case PREF_OTR_WARN:
-        case PREF_STATUSES_MUC:
-            return TRUE;
         default:
             return FALSE;
     }
@@ -495,6 +493,7 @@ _get_default_string(preference_t pref)
             return "redact";
         case PREF_STATUSES_CONSOLE:
         case PREF_STATUSES_CHAT:
+        case PREF_STATUSES_MUC:
             return "all";
         default:
             return NULL;
diff --git a/src/server_events.c b/src/server_events.c
index 012291f0..01da55c7 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -427,8 +427,8 @@ handle_room_member_presence(const char * const room,
     gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str);
 
     if (updated) {
-        gboolean show_muc = prefs_get_boolean(PREF_STATUSES_MUC);
-        if (show_muc) {
+        char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
+        if (g_strcmp0(muc_status_pref, "all") == 0) {
             ui_room_member_presence(room, nick, show, status);
             ui_current_page_off();
         }
@@ -441,8 +441,12 @@ handle_room_member_online(const char * const room, const char * const nick,
     const char * const caps_str)
 {
     muc_add_to_roster(room, nick, show, status, caps_str);
-    ui_room_member_online(room, nick, show, status);
-    ui_current_page_off();
+
+    char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
+    if (g_strcmp0(muc_status_pref, "none") != 0) {
+        ui_room_member_online(room, nick, show, status);
+        ui_current_page_off();
+    }
 }
 
 void
@@ -450,8 +454,12 @@ handle_room_member_offline(const char * const room, const char * const nick,
     const char * const show, const char * const status)
 {
     muc_remove_from_roster(room, nick);
-    ui_room_member_offline(room, nick);
-    ui_current_page_off();
+
+    char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC);
+    if (g_strcmp0(muc_status_pref, "none") != 0) {
+        ui_room_member_offline(room, nick);
+        ui_current_page_off();
+    }
 }
 
 void
diff --git a/src/ui/console.c b/src/ui/console.c
index 1308003e..8a777204 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -992,16 +992,11 @@ _cons_statuses_setting(void)
 {
     char *console = prefs_get_string(PREF_STATUSES_CONSOLE);
     char *chat = prefs_get_string(PREF_STATUSES_CHAT);
-    gboolean muc = prefs_get_boolean(PREF_STATUSES_MUC);
+    char *muc = prefs_get_string(PREF_STATUSES_MUC);
 
-    cons_show("Console statuses (/statuses)  : %s", console);
-    cons_show("Chat win statuses (/statuses) : %s", chat);
-
-    if (muc) {
-        cons_show("MUC statuses (/statuses)      : ON");
-    } else {
-        cons_show("MUC statuses (/statuses)      : OFF");
-    }
+    cons_show("Console statuses (/statuses)   : %s", console);
+    cons_show("Chat win statuses (/statuses)  : %s", chat);
+    cons_show("Chat room statuses (/statuses) : %s", muc);
 }
 
 static void