aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2012-12-22 23:03:18 +0100
committerMichael Albinus2012-12-22 23:03:18 +0100
commit1ef5f225db2fa70aa02a814b1c2c473ea03f008d (patch)
tree68373a3a036601bd51d80239562029326b774f84
parentd9b03add86a53b67dd04bbfa9645f4948e43484a (diff)
downloademacs-1ef5f225db2fa70aa02a814b1c2c473ea03f008d.tar.gz
emacs-1ef5f225db2fa70aa02a814b1c2c473ea03f008d.zip
* notifications.el (notifications-notify): Protect body with
`with-demoted-errors'.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/notifications.el274
2 files changed, 141 insertions, 136 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c256c7f8179..fa5985de74d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12012-12-22 Michael Albinus <michael.albinus@gmx.de> 12012-12-22 Michael Albinus <michael.albinus@gmx.de>
2 2
3 * notifications.el (notifications-notify): Protect body with
4 `with-demoted-errors'.
5
3 * net/tramp-adb.el (tramp-adb-maybe-open-connection): Check 6 * net/tramp-adb.el (tramp-adb-maybe-open-connection): Check
4 properties of remote device. Restart connection, if there is a 7 properties of remote device. Restart connection, if there is a
5 change. 8 change.
diff --git a/lisp/notifications.el b/lisp/notifications.el
index 6f477eb4cdd..c77916e463a 100644
--- a/lisp/notifications.el
+++ b/lisp/notifications.el
@@ -202,142 +202,144 @@ This function returns a notification id, an integer, which can be
202used to manipulate the notification item with 202used to manipulate the notification item with
203`notifications-close-notification' or the `:replaces-id' argument 203`notifications-close-notification' or the `:replaces-id' argument
204of another `notifications-notify' call." 204of another `notifications-notify' call."
205 (let ((bus (or (plist-get params :bus) :session)) 205 (with-demoted-errors
206 (title (plist-get params :title)) 206 (let ((bus (or (plist-get params :bus) :session))
207 (body (plist-get params :body)) 207 (title (plist-get params :title))
208 (app-name (plist-get params :app-name)) 208 (body (plist-get params :body))
209 (replaces-id (plist-get params :replaces-id)) 209 (app-name (plist-get params :app-name))
210 (app-icon (plist-get params :app-icon)) 210 (replaces-id (plist-get params :replaces-id))
211 (actions (plist-get params :actions)) 211 (app-icon (plist-get params :app-icon))
212 (timeout (plist-get params :timeout)) 212 (actions (plist-get params :actions))
213 ;; Hints 213 (timeout (plist-get params :timeout))
214 (hints '()) 214 ;; Hints
215 (urgency (plist-get params :urgency)) 215 (hints '())
216 (category (plist-get params :category)) 216 (urgency (plist-get params :urgency))
217 (desktop-entry (plist-get params :desktop-entry)) 217 (category (plist-get params :category))
218 (image-data (plist-get params :image-data)) 218 (desktop-entry (plist-get params :desktop-entry))
219 (image-path (plist-get params :image-path)) 219 (image-data (plist-get params :image-data))
220 (action-items (plist-get params :action-items)) 220 (image-path (plist-get params :image-path))
221 (sound-file (plist-get params :sound-file)) 221 (action-items (plist-get params :action-items))
222 (sound-name (plist-get params :sound-name)) 222 (sound-file (plist-get params :sound-file))
223 (suppress-sound (plist-get params :suppress-sound)) 223 (sound-name (plist-get params :sound-name))
224 (resident (plist-get params :resident)) 224 (suppress-sound (plist-get params :suppress-sound))
225 (transient (plist-get params :transient)) 225 (resident (plist-get params :resident))
226 (x (plist-get params :x)) 226 (transient (plist-get params :transient))
227 (y (plist-get params :y)) 227 (x (plist-get params :x))
228 id) 228 (y (plist-get params :y))
229 ;; Build hints array 229 id)
230 (when urgency 230 ;; Build hints array
231 (add-to-list 'hints `(:dict-entry 231 (when urgency
232 "urgency" 232 (add-to-list 'hints `(:dict-entry
233 (:variant :byte ,(pcase urgency 233 "urgency"
234 (`low 0) 234 (:variant :byte ,(pcase urgency
235 (`critical 2) 235 (`low 0)
236 (_ 1)))) t)) 236 (`critical 2)
237 (when category 237 (_ 1)))) t))
238 (add-to-list 'hints `(:dict-entry 238 (when category
239 "category" 239 (add-to-list 'hints `(:dict-entry
240 (:variant :string ,category)) t)) 240 "category"
241 (when desktop-entry 241 (:variant :string ,category)) t))
242 (add-to-list 'hints `(:dict-entry 242 (when desktop-entry
243 "desktop-entry" 243 (add-to-list 'hints `(:dict-entry
244 (:variant :string ,desktop-entry)) t)) 244 "desktop-entry"
245 (when image-data 245 (:variant :string ,desktop-entry)) t))
246 (add-to-list 'hints `(:dict-entry 246 (when image-data
247 "image-data" 247 (add-to-list 'hints `(:dict-entry
248 (:variant :struct ,image-data)) t)) 248 "image-data"
249 (when image-path 249 (:variant :struct ,image-data)) t))
250 (add-to-list 'hints `(:dict-entry 250 (when image-path
251 "image-path" 251 (add-to-list 'hints `(:dict-entry
252 (:variant :string ,image-path)) t)) 252 "image-path"
253 (when action-items 253 (:variant :string ,image-path)) t))
254 (add-to-list 'hints `(:dict-entry 254 (when action-items
255 "action-items" 255 (add-to-list 'hints `(:dict-entry
256 (:variant :boolean ,action-items)) t)) 256 "action-items"
257 (when sound-file 257 (:variant :boolean ,action-items)) t))
258 (add-to-list 'hints `(:dict-entry 258 (when sound-file
259 "sound-file" 259 (add-to-list 'hints `(:dict-entry
260 (:variant :string ,sound-file)) t)) 260 "sound-file"
261 (when sound-name 261 (:variant :string ,sound-file)) t))
262 (add-to-list 'hints `(:dict-entry 262 (when sound-name
263 "sound-name" 263 (add-to-list 'hints `(:dict-entry
264 (:variant :string ,sound-name)) t)) 264 "sound-name"
265 (when suppress-sound 265 (:variant :string ,sound-name)) t))
266 (add-to-list 'hints `(:dict-entry 266 (when suppress-sound
267 "suppress-sound" 267 (add-to-list 'hints `(:dict-entry
268 (:variant :boolean ,suppress-sound)) t)) 268 "suppress-sound"
269 (when resident 269 (:variant :boolean ,suppress-sound)) t))
270 (add-to-list 'hints `(:dict-entry 270 (when resident
271 "resident" 271 (add-to-list 'hints `(:dict-entry
272 (:variant :boolean ,resident)) t)) 272 "resident"
273 (when transient 273 (:variant :boolean ,resident)) t))
274 (add-to-list 'hints `(:dict-entry 274 (when transient
275 "transient" 275 (add-to-list 'hints `(:dict-entry
276 (:variant :boolean ,transient)) t)) 276 "transient"
277 (when x 277 (:variant :boolean ,transient)) t))
278 (add-to-list 'hints `(:dict-entry "x" (:variant :int32 ,x)) t)) 278 (when x
279 (when y 279 (add-to-list 'hints `(:dict-entry "x" (:variant :int32 ,x)) t))
280 (add-to-list 'hints `(:dict-entry "y" (:variant :int32 ,y)) t)) 280 (when y
281 281 (add-to-list 'hints `(:dict-entry "y" (:variant :int32 ,y)) t))
282 ;; Call Notify method. 282
283 (setq id 283 ;; Call Notify method.
284 (dbus-call-method bus 284 (setq id
285 notifications-service 285 (dbus-call-method bus
286 notifications-path 286 notifications-service
287 notifications-interface 287 notifications-path
288 notifications-notify-method 288 notifications-interface
289 :string (or app-name 289 notifications-notify-method
290 notifications-application-name) 290 :string (or app-name
291 :uint32 (or replaces-id 0) 291 notifications-application-name)
292 :string (if app-icon 292 :uint32 (or replaces-id 0)
293 (expand-file-name app-icon) 293 :string (if app-icon
294 ;; If app-icon is nil because user 294 (expand-file-name app-icon)
295 ;; requested it to be so, send the 295 ;; If app-icon is nil because user
296 ;; empty string 296 ;; requested it to be so, send the
297 (if (plist-member params :app-icon) 297 ;; empty string
298 "" 298 (if (plist-member params :app-icon)
299 ;; Otherwise send the default icon path 299 ""
300 notifications-application-icon)) 300 ;; Otherwise send the
301 :string (or title "") 301 ;; default icon path
302 :string (or body "") 302 notifications-application-icon))
303 `(:array ,@actions) 303 :string (or title "")
304 (or hints '(:array :signature "{sv}")) 304 :string (or body "")
305 :int32 (or timeout -1))) 305 `(:array ,@actions)
306 306 (or hints '(:array :signature "{sv}"))
307 ;; Register close/action callback function. We must also remember 307 :int32 (or timeout -1)))
308 ;; the daemon's unique name, because the daemon could have 308
309 ;; restarted. 309 ;; Register close/action callback function. We must also
310 (let ((on-action (plist-get params :on-action)) 310 ;; remember the daemon's unique name, because the daemon could
311 (on-close (plist-get params :on-close)) 311 ;; have restarted.
312 (unique-name (dbus-get-name-owner bus notifications-service))) 312 (let ((on-action (plist-get params :on-action))
313 (when on-action 313 (on-close (plist-get params :on-close))
314 (add-to-list 'notifications-on-action-map 314 (unique-name (dbus-get-name-owner bus notifications-service)))
315 (list (list bus unique-name id) on-action)) 315 (when on-action
316 (unless notifications-on-action-object 316 (add-to-list 'notifications-on-action-map
317 (setq notifications-on-action-object 317 (list (list bus unique-name id) on-action))
318 (dbus-register-signal 318 (unless notifications-on-action-object
319 bus 319 (setq notifications-on-action-object
320 nil 320 (dbus-register-signal
321 notifications-path 321 bus
322 notifications-interface 322 nil
323 notifications-action-signal 323 notifications-path
324 'notifications-on-action-signal)))) 324 notifications-interface
325 325 notifications-action-signal
326 (when on-close 326 'notifications-on-action-signal))))
327 (add-to-list 'notifications-on-close-map 327
328 (list (list bus unique-name id) on-close)) 328 (when on-close
329 (unless notifications-on-close-object 329 (add-to-list 'notifications-on-close-map
330 (setq notifications-on-close-object 330 (list (list bus unique-name id) on-close))
331 (dbus-register-signal 331 (unless notifications-on-close-object
332 bus 332 (setq notifications-on-close-object
333 nil 333 (dbus-register-signal
334 notifications-path 334 bus
335 notifications-interface 335 nil
336 notifications-closed-signal 336 notifications-path
337 'notifications-on-closed-signal))))) 337 notifications-interface
338 338 notifications-closed-signal
339 ;; Return notification id 339 'notifications-on-closed-signal)))))
340 id)) 340
341 ;; Return notification id
342 id)))
341 343
342(defun notifications-close-notification (id &optional bus) 344(defun notifications-close-notification (id &optional bus)
343 "Close a notification with identifier ID. 345 "Close a notification with identifier ID.