branch: elpa/jabber
commit f423dae00bef1e4b52ef3feb410b1018e1e793ff
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>

    omemo: Add jabber-omemo-enable defcustom
    
    Users without the build toolchain can set this to nil to skip
    module loading entirely, avoiding the build prompt and warning
    messages on connect.
---
 lisp/jabber-omemo.el | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/lisp/jabber-omemo.el b/lisp/jabber-omemo.el
index 41a1e22ea6..948b66b51b 100644
--- a/lisp/jabber-omemo.el
+++ b/lisp/jabber-omemo.el
@@ -60,6 +60,14 @@
   (id &rest props))
 (declare-function jabber-chat--set-body "jabber-chat" (xml-data text))
 
+(defcustom jabber-omemo-enable t
+  "Whether to enable OMEMO encryption support.
+When nil, the native module is not loaded and OMEMO features are
+disabled.  Set to nil if you do not have the build toolchain to
+compile jabber-omemo-core."
+  :type 'boolean
+  :group 'jabber)
+
 (defcustom jabber-omemo-skipped-key-max-age (* 30 86400)
   "Maximum age in seconds for OMEMO skipped message keys.
 Keys older than this are deleted on connect."
@@ -112,21 +120,23 @@ the resulting module.  Signals an error on build failure."
   "Non-nil when the jabber-omemo-core native module is loaded.")
 
 (cl-eval-when (load eval)
-  (if (require 'jabber-omemo-core nil t)
-      (setq jabber-omemo--available t)
-    (let ((src-dir (expand-file-name
-                    "../src"
-                    (file-name-directory
-                     (or load-file-name buffer-file-name)))))
-      (if (and (file-exists-p (expand-file-name "jabber-omemo-core.c" src-dir))
-               (or noninteractive
-                   (yes-or-no-p
-                    "jabber-omemo-core module not found.  Build it now? ")))
-          (progn
-            (jabber-omemo--build-module
-             (file-name-directory (directory-file-name src-dir)))
-            (setq jabber-omemo--available t))
-        (message "OMEMO: native module not available, encryption disabled")))))
+  (if (not jabber-omemo-enable)
+      (message "OMEMO: disabled by jabber-omemo-enable")
+    (if (require 'jabber-omemo-core nil t)
+        (setq jabber-omemo--available t)
+      (let ((src-dir (expand-file-name
+                      "../src"
+                      (file-name-directory
+                       (or load-file-name buffer-file-name)))))
+        (if (and (file-exists-p (expand-file-name "jabber-omemo-core.c" 
src-dir))
+                 (or noninteractive
+                     (yes-or-no-p
+                      "jabber-omemo-core module not found.  Build it now? ")))
+            (progn
+              (jabber-omemo--build-module
+               (file-name-directory (directory-file-name src-dir)))
+              (setq jabber-omemo--available t))
+          (message "OMEMO: native module not available, encryption 
disabled"))))))
 
 ;; Declare internal C functions from the dynamic module for the byte-compiler.
 ;; "ext:" prefix tells check-declare to skip file verification.

Reply via email to