escape-xml for libnotify

This commit is contained in:
Kirill A. Korinskiy 2010-01-08 18:26:25 +03:00
parent 532939f971
commit a833563e55
1 changed files with 19 additions and 20 deletions

View File

@ -62,21 +62,23 @@
(defun jabber-libnotify-message (text &optional title)
"Show MSG using libnotify"
(cond
((eq jabber-libnotify-method 'shell)
(let
((body (jabber-escape-xml text))
(head (jabber-escape-xml
(or title
(or jabber-libnotify-message-header " ")
text))))
;; Possible errors include not finding the notify-send binary.
(condition-case e
(cond
((eq jabber-libnotify-method 'shell)
(let ((process-connection-type nil))
(start-process "notification" nil "notify-send"
"-t" (format "%s" jabber-libnotify-timeout)
"-i" (or jabber-libnotify-icon "\"\"")
"-u" jabber-libnotify-urgency
(or title
(or jabber-libnotify-message-header " ")
text))
(error nil))))
head body)))
((eq jabber-libnotify-method 'dbus)
(condition-case e
(dbus-call-method
:session ; use the session (not system) bus
"org.freedesktop.Notifications" ; service name
@ -85,14 +87,11 @@
jabber-libnotify-app
(jabber-libnotify-next-id)
jabber-libnotify-icon
':string (encode-coding-string
(or title jabber-libnotify-message-header)
'utf-8)
':string (encode-coding-string text 'utf-8)
':string (encode-coding-string head 'utf-8)
':string (encode-coding-string body 'utf-8)
'(:array)
'(:array :signature "{sv}")
':int32 jabber-libnotify-timeout)
(error nil)))))
':int32 jabber-libnotify-timeout))))))
(define-jabber-alert libnotify "Show a message through the libnotify interface"
'jabber-libnotify-message)