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

    notifications: Guard D-Bus requirement to fix Windows
    
    On systems without D-Bus (Windows), jabber-notifications loaded and
    registered hooks that threw dbus-error on every message, killing the
    entire alert chain and suppressing all message indications.
    
    Guard the require in jabber.el with (featurep 'dbusbind), wrap
    notifications-notify in condition-case for runtime failures, and
    remove autoload cookies that could bypass the guard.
    
    Fixes: #115 (codeberg)
---
 lisp/jabber-notifications.el | 28 ++++++++++++++--------------
 lisp/jabber.el               |  3 ++-
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/jabber-notifications.el b/lisp/jabber-notifications.el
index 6bab8d3954..186371cfe1 100644
--- a/lisp/jabber-notifications.el
+++ b/lisp/jabber-notifications.el
@@ -75,22 +75,22 @@ nil disables MUC notifications entirely."
 
 ;;
 
-;;;###autoload
 (defun jabber-message-notifications (from _buffer text title)
   "Show a message through the notifications.el interface."
-  (let
-      ((body (or (jabber-escape-xml text) " "))
-       (avatar-hash (get (jabber-jid-symbol from) 'avatar-hash)))
-    (notifications-notify
-     :title title
-     :body body
-     :app-icon (or (and avatar-hash (jabber-avatar-find-cached avatar-hash))
-                   jabber-notifications-icon)
-     :app-name jabber-notifications-app
-     :category "jabber.message"
-     :timeout jabber-notifications-timeout)))
-
-;;;###autoload
+  (let ((body (or (jabber-escape-xml text) " "))
+        (avatar-hash (get (jabber-jid-symbol from) 'avatar-hash)))
+    (condition-case err
+        (notifications-notify
+         :title title
+         :body body
+         :app-icon (or (and avatar-hash (jabber-avatar-find-cached 
avatar-hash))
+                       jabber-notifications-icon)
+         :app-name jabber-notifications-app
+         :category "jabber.message"
+         :timeout jabber-notifications-timeout)
+      (dbus-error
+       (message "jabber-notifications: D-Bus error: %s" (error-message-string 
err))))))
+
 (defun jabber-muc-notifications (nick group buffer text title)
   "Show MUC message through the notifications.el interface.
 Controlled by `jabber-notifications-muc': notify for all messages,
diff --git a/lisp/jabber.el b/lisp/jabber.el
index 63546c3761..d0f726a60d 100644
--- a/lisp/jabber.el
+++ b/lisp/jabber.el
@@ -200,7 +200,8 @@ configure a Google Talk account like this:
 (require 'jabber-autoaway)
 (require 'jabber-time)
 (require 'jabber-truncate)
-(require 'jabber-notifications nil t)
+(when (featurep 'dbusbind)
+  (require 'jabber-notifications nil t))
 
 ;;;###autoload
 (defvar *jabber-current-status* nil

Reply via email to