about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_ac.c2
-rw-r--r--src/command/cmd_defs.c2
-rw-r--r--src/command/cmd_funcs.c10
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/xmpp/session.c10
6 files changed, 26 insertions, 3 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 531d189b..d8121d65 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -1079,6 +1079,8 @@ cmd_ac_init(void)
     mood_ac = autocomplete_new();
     autocomplete_add(mood_ac, "set");
     autocomplete_add(mood_ac, "clear");
+    autocomplete_add(mood_ac, "on");
+    autocomplete_add(mood_ac, "off");
     mood_type_ac = autocomplete_new();
     autocomplete_add(mood_type_ac, "afraid");
     autocomplete_add(mood_type_ac, "amazed");
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 411de396..8c9767d4 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2720,11 +2720,13 @@ static struct cmd_t command_defs[] = {
       CMD_TAGS(
               CMD_TAG_CHAT)
       CMD_SYN(
+              "/mood on|off",
               "/mood set <mood> [text]",
               "/mood clear")
       CMD_DESC(
               "Set your mood (XEP-0107).")
       CMD_ARGS(
+              { "on|off", "Enable or disable displaying the mood of other users. On by default."},
               { "set <mood> [text]", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predfined moods." },
               { "clear", "Clear your user mood." })
       CMD_EXAMPLES(
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index bd025886..bfe65d6a 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -90,6 +90,7 @@
 #include "xmpp/muc.h"
 #include "xmpp/chat_session.h"
 #include "xmpp/avatar.h"
+#include "xmpp/stanza.h"
 
 #ifdef HAVE_LIBOTR
 #include "otr/otr.h"
@@ -9769,7 +9770,13 @@ cmd_register(ProfWin* window, const char* const command, gchar** args)
 gboolean
 cmd_mood(ProfWin* window, const char* const command, gchar** args)
 {
-    if (g_strcmp0(args[0], "set") == 0) {
+    if (g_strcmp0(args[0], "on") == 0) {
+        _cmd_set_boolean_preference(args[0], command, "User mood", PREF_MOOD);
+        caps_add_feature(STANZA_NS_MOOD_NOTIFY);
+    }  else if (g_strcmp0(args[0], "off") == 0) {
+        _cmd_set_boolean_preference(args[0], command, "User mood", PREF_MOOD);
+        caps_remove_feature(STANZA_NS_MOOD_NOTIFY);
+    } else if (g_strcmp0(args[0], "set") == 0) {
         if (args[1]) {
             cons_show("Your mood: %s", args[1]);
             if (args[2]) {
@@ -9782,5 +9789,6 @@ cmd_mood(ProfWin* window, const char* const command, gchar** args)
         cons_show("Clearing the user mood.");
         publish_user_mood(NULL, NULL);
     }
+
     return TRUE;
 }
diff --git a/src/config/preferences.c b/src/config/preferences.c
index b2b7f094..c762f4d8 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1867,6 +1867,7 @@ _get_group(preference_t pref)
     case PREF_CORRECTION_ALLOW:
     case PREF_MAM:
     case PREF_SILENCE_NON_ROSTER:
+    case PREF_MOOD:
         return PREF_GROUP_CONNECTION;
     case PREF_OTR_LOG:
     case PREF_OTR_POLICY:
@@ -2157,6 +2158,8 @@ _get_key(preference_t pref)
         return "stamp.incoming";
     case PREF_OX_LOG:
         return "log";
+    case PREF_MOOD:
+        return "mood";
     default:
         return NULL;
     }
@@ -2208,6 +2211,7 @@ _get_default_boolean(preference_t pref)
     case PREF_INTYPE:
     case PREF_INTYPE_CONSOLE:
     case PREF_NOTIFY_MENTION_WHOLE_WORD:
+    case PREF_MOOD:
         return TRUE;
     default:
         return FALSE;
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 1070dace..2ef6204f 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -180,6 +180,7 @@ typedef enum {
     PREF_INCOMING_STAMP,
     PREF_NOTIFY_ROOM_OFFLINE,
     PREF_OX_LOG,
+    PREF_MOOD,
 } preference_t;
 
 typedef struct prof_alias_t
diff --git a/src/xmpp/session.c b/src/xmpp/session.c
index 1dd5bdde..3bec1ab2 100644
--- a/src/xmpp/session.c
+++ b/src/xmpp/session.c
@@ -286,9 +286,13 @@ session_get_account_name(void)
     return saved_account.name;
 }
 
-static int
+static gboolean
 _receive_mood(xmpp_stanza_t* const stanza, void* const userdata)
 {
+    if (!prefs_get_boolean(PREF_MOOD)) {
+        return TRUE;
+    }
+
     const char* from = xmpp_stanza_get_from(stanza);
     xmpp_stanza_t* event = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT);
     if (event) {
@@ -362,7 +366,9 @@ session_login_success(gboolean secured)
     }
 
     message_pubsub_event_handler_add(STANZA_NS_MOOD, _receive_mood, NULL, NULL);
-    caps_add_feature(STANZA_NS_MOOD_NOTIFY);
+    if (prefs_get_boolean(PREF_MOOD)) {
+        caps_add_feature(STANZA_NS_MOOD_NOTIFY);
+    }
 }
 
 void