Function: dbus-monitor-handler
dbus-monitor-handler is a byte-compiled function defined in
dbus.el.gz.
Signature
(dbus-monitor-handler &rest ARGS)
Documentation
Default handler for the "Monitoring.BecomeMonitor" interface.
Its full name is "org.freedesktop.DBus.Monitoring.BecomeMonitor".
It will be applied for all objects created by dbus-register-monitor
which don't declare an own handler. The printed timestamps do
not reflect the time the D-Bus message has passed the D-Bus
daemon, it is rather the timestamp the corresponding D-Bus event
has been handled by this function.
Source Code
;; Defined in /usr/src/emacs/lisp/net/dbus.el.gz
(defun dbus-monitor-handler (&rest _args)
"Default handler for the \"Monitoring.BecomeMonitor\" interface.
Its full name is \"org.freedesktop.DBus.Monitoring.BecomeMonitor\".
It will be applied for all objects created by `dbus-register-monitor'
which don't declare an own handler. The printed timestamps do
not reflect the time the D-Bus message has passed the D-Bus
daemon, it is rather the timestamp the corresponding D-Bus event
has been handled by this function."
(with-current-buffer (get-buffer-create "*D-Bus Monitor*")
(special-mode)
(buffer-disable-undo)
;; Move forward and backward between messages.
(local-set-key [?n] #'forward-paragraph)
(local-set-key [?p] #'backward-paragraph)
;; Follow serial links.
(local-set-key (kbd "RET") #'dbus-monitor-goto-serial)
(local-set-key [mouse-2] #'dbus-monitor-goto-serial)
(let* ((inhibit-read-only t)
(text-quoting-style 'grave)
(point (point))
(eobp (eobp))
(event last-input-event)
(type (dbus-event-message-type event))
(sender (dbus-event-service-name event))
(destination (dbus-event-destination-name event))
(serial (dbus-event-serial-number event))
(path (dbus-event-path-name event))
(interface (dbus-event-interface-name event))
(member (dbus-event-member-name event))
(arguments (dbus-event-arguments event))
(time (time-to-seconds (current-time))))
(save-excursion
;; Check for matching method-call.
(goto-char (point-max))
(when (and (or (= type dbus-message-type-method-return)
(= type dbus-message-type-error))
(re-search-backward
(format
(concat
"^method-call time=\\(\\S-+\\) "
".*sender=%s .*serial=\\(%d\\) ")
destination serial)
nil 'noerror))
(setq serial
(propertize
(match-string 2) 'dbus-serial (match-beginning 0)
'help-echo "RET, mouse-1, mouse-2: goto method-call"
'face 'link 'follow-link 'mouse-face 'mouse-face 'highlight)
time (format "%f (%f)" time (- time (read (match-string 1)))))
(set-text-properties
(match-beginning 2) (match-end 2)
`(dbus-serial ,(point-max)
help-echo
,(format
"RET, mouse-1, mouse-2: goto %s"
(if (= type dbus-message-type-error) "error" "method-return"))
face link follow-link mouse-face mouse-face highlight)))
;; Insert D-Bus message.
(goto-char (point-max))
(insert
(format
(concat
"%s time=%s sender=%s -> destination=%s serial=%s "
"path=%s interface=%s member=%s\n")
(cond
((= type dbus-message-type-method-call) dbus-monitor-method-call)
((= type dbus-message-type-method-return) dbus-monitor-method-return)
((= type dbus-message-type-error) dbus-monitor-error)
((= type dbus-message-type-signal) dbus-monitor-signal))
time sender destination serial path interface member))
(dolist (arg arguments)
(pp (dbus-flatten-types arg) (current-buffer)))
(insert "\n")
;; Show byte arrays as string.
(goto-char point)
(while (re-search-forward
"(:array\\( :byte [[:digit:]]+\\)+)" nil 'noerror)
(put-text-property
(match-beginning 0) (match-end 0)
'help-echo (dbus-byte-array-to-string (read (match-string 0)))))
;; Show fixed numbers.
(goto-char point)
(while (re-search-forward
(concat
(regexp-opt
'(":int16" ":uint16" ":int32" ":uint32" ":int64" ":uint64"))
" \\([-+[:digit:]]+\\)")
nil 'noerror)
(put-text-property
(match-beginning 1) (match-end 1)
'help-echo
(format
"#o%o, #x%X" (read (match-string 1)) (read (match-string 1)))))
;; Show floating numbers.
(goto-char point)
(while (re-search-forward ":double \\([-+.[:digit:]]+\\)" nil 'noerror)
(put-text-property
(match-beginning 1) (match-end 1)
'help-echo (format "%e" (read (match-string 1))))))
(when eobp
(goto-char (point-max))))))