about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-01-23 23:35:46 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-01-23 23:35:46 +0100
commit8c34f2ce01480f8acaa7d45dd29343e3741a3242 (patch)
tree4960465f1f4be30f123e125e1eacdcd47eb72d63
parentcb1dbb2732e985ac8993b84ac3188b4a8bcda3e6 (diff)
downloadprofani-tty-8c34f2ce01480f8acaa7d45dd29343e3741a3242.tar.gz
xep-0092: add config option to set whether OS is revealed
Default is on. `revail.os=false` in the `connection` section of the
config can disable it.
A command to configure this will follow.
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/xmpp/iq.c36
3 files changed, 27 insertions, 14 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 2b2c7191..c872627b 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1758,6 +1758,7 @@ _get_group(preference_t pref)
         case PREF_CARBONS:
         case PREF_RECEIPTS_SEND:
         case PREF_RECEIPTS_REQUEST:
+        case PREF_REVEAL_OS:
         case PREF_TLS_CERTPATH:
             return PREF_GROUP_CONNECTION;
         case PREF_OTR_LOG:
@@ -1817,6 +1818,8 @@ _get_key(preference_t pref)
             return "receipts.send";
         case PREF_RECEIPTS_REQUEST:
             return "receipts.request";
+        case PREF_REVEAL_OS:
+            return "reveal.os";
         case PREF_OCCUPANTS:
             return "occupants";
         case PREF_OCCUPANTS_JID:
@@ -2056,6 +2059,7 @@ _get_default_boolean(preference_t pref)
         case PREF_BOOKMARK_INVITE:
         case PREF_ROOM_LIST_CACHE:
         case PREF_STATUSBAR_SHOW_NUMBER:
+        case PREF_REVEAL_OS:
             return TRUE;
         default:
             return FALSE;
diff --git a/src/config/preferences.h b/src/config/preferences.h
index f0d49e60..66659bd3 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -63,6 +63,7 @@ typedef enum {
     PREF_CARBONS,
     PREF_RECEIPTS_SEND,
     PREF_RECEIPTS_REQUEST,
+    PREF_REVEAL_OS,
     PREF_OCCUPANTS,
     PREF_OCCUPANTS_SIZE,
     PREF_OCCUPANTS_JID,
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 5cdf29b1..3104aa6c 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1598,29 +1598,37 @@ _version_get_handler(xmpp_stanza_t *const stanza)
         xmpp_stanza_set_text(version_txt, version_str->str);
         xmpp_stanza_add_child(version, version_txt);
 
-        xmpp_stanza_t *os = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(os, "os");
-        xmpp_stanza_t *os_txt = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *os;
+        xmpp_stanza_t *os_txt;
+
+        bool include_os = prefs_get_boolean(PREF_REVEAL_OS);
+        if (include_os) {
+            os = xmpp_stanza_new(ctx);
+            xmpp_stanza_set_name(os, "os");
+
+            os_txt = xmpp_stanza_new(ctx);
+
 #if defined(_WIN32) || defined(__CYGWIN__) || defined(PLATFORM_CYGWIN)
-        xmpp_stanza_set_text(os_txt, "Windows");
+            xmpp_stanza_set_text(os_txt, "Windows");
 #elif defined(__linux__)
-        xmpp_stanza_set_text(os_txt, "Linux");
+            xmpp_stanza_set_text(os_txt, "Linux");
 #elif defined(__APPLE__)
-        xmpp_stanza_set_text(os_txt, "Apple");
+            xmpp_stanza_set_text(os_txt, "Apple");
 #elif defined(__FreeBSD__)
-        xmpp_stanza_set_text(os_txt, "FreeBSD");
+            xmpp_stanza_set_text(os_txt, "FreeBSD");
 #elif defined(__NetBSD__)
-        xmpp_stanza_set_text(os_txt, "__NetBSD__");
+            xmpp_stanza_set_text(os_txt, "__NetBSD__");
 #elif defined(__OpenBSD__)
-        xmpp_stanza_set_text(os_txt, "__OpenBSD__");
+            xmpp_stanza_set_text(os_txt, "__OpenBSD__");
 #else
-        xmpp_stanza_set_text(os_txt, "Unknown");
+            xmpp_stanza_set_text(os_txt, "Unknown");
 #endif
-        xmpp_stanza_add_child(os, os_txt);
+            xmpp_stanza_add_child(os, os_txt);
+        }
 
         xmpp_stanza_add_child(query, name);
         xmpp_stanza_add_child(query, version);
-        xmpp_stanza_add_child(query, os);
+        if (include_os) {xmpp_stanza_add_child(query, os);}
         xmpp_stanza_add_child(response, query);
 
         iq_send_stanza(response);
@@ -1628,10 +1636,10 @@ _version_get_handler(xmpp_stanza_t *const stanza)
         g_string_free(version_str, TRUE);
         xmpp_stanza_release(name_txt);
         xmpp_stanza_release(version_txt);
-        xmpp_stanza_release(os_txt);
+        if (include_os) {xmpp_stanza_release(os_txt);}
         xmpp_stanza_release(name);
         xmpp_stanza_release(version);
-        xmpp_stanza_release(os);
+        if (include_os) {xmpp_stanza_release(os);}
         xmpp_stanza_release(query);
         xmpp_stanza_release(response);
     }