comparison doc/misc/dbus.texi @ 87049:cbcfa9b4201e

* dbus.texi (Signals): Precise `dbus-register-signal'. (Errors and Events): Rework events part, the internal structure of dbus-event has changed.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 04 Dec 2007 21:12:46 +0000
parents 0877a1d16074
children f767f1ba8301
comparison
equal deleted inserted replaced
87048:4edc602ab9b7 87049:cbcfa9b4201e
155 string. 155 string.
156 @end defun 156 @end defun
157 157
158 @defun dbus-get-name-owner bus service 158 @defun dbus-get-name-owner bus service
159 For a given service, registered at D-Bus @var{bus} under the name 159 For a given service, registered at D-Bus @var{bus} under the name
160 @var{service}, the unique name of the name owner is returned. The 160 @var{service}, the unique name of the name owner is returned. The result is a
161 result is a string, or @code{nil} when there exist no name owner of 161 string, or @code{nil} when there exist no name owner of @var{service}.
162 @var{service}.
163 162
164 @var{bus} must be either the symbol @code{:system} or the symbol 163 @var{bus} must be either the symbol @code{:system} or the symbol
165 @code{:session}. @var{service} must be a known service name as 164 @code{:session}. @var{service} must be a known service name as
166 string. 165 string.
167 @end defun 166 @end defun
436 D-Bus @var{bus}. 435 D-Bus @var{bus}.
437 436
438 @var{bus} is either the symbol @code{:system} or the symbol 437 @var{bus} is either the symbol @code{:system} or the symbol
439 @code{:session}. 438 @code{:session}.
440 439
441 @var{service} is the D-Bus service name of the object the signal is 440 @var{service} is the D-Bus service name used by the sending D-Bus
442 emitted from. @var{path} is the corresponding D-Bus object path, 441 object. It can be either a known name or the unique name of the D-Bus
443 @var{service} is registered at. @var{interface} is an interface 442 object sending the signal. In case of a unique name, signals won't be
444 offered by @var{service}. It must provide @var{signal}. 443 received any longer once the object owning this unique name has
444 disappeared, and a new queued object has replaced it.
445
446 When @var{service} is @code{nil}, related signals from all D-Bus
447 objects shall be accepted.
448
449 @var{path} is the corresponding D-Bus object path, @var{service} is
450 registered at. It can also be @code{nil} if the path name of incoming
451 signals shall not be checked.
452
453 @var{interface} is an interface offered by @var{service}. It must
454 provide @var{signal}.
445 455
446 @var{handler} is a Lisp function to be called when the @var{signal} is 456 @var{handler} is a Lisp function to be called when the @var{signal} is
447 received. It must accept as arguments the output parameters 457 received. It must accept as arguments the output parameters
448 @var{signal} is sending. Example: 458 @var{signal} is sending. Example:
449 459
450 @example 460 @example
451 (defun my-dbus-signal-handler (device) 461 (defun my-dbus-signal-handler (device)
452 (message "Device %s added" device)) 462 (message "Device %s added" device))
453 463
454 (dbus-register-signal 464 (dbus-register-signal
455 :system "DeviceAdded" "org.freedesktop.Hal" 465 :system "DeviceAdded"
466 (dbus-get-name-owner :system "org.freedesktop.Hal")
456 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager" 467 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager"
457 'my-dbus-signal-handler) 468 'my-dbus-signal-handler)
458 469
459 @result{} :system.org.freedesktop.Hal.Manager.DeviceAdded 470 @result{} (:system "org.freedesktop.Hal.Manager" "DeviceAdded")
460 @end example 471 @end example
461 472
462 As we know from the inspection data of interface 473 As we know from the inspection data of interface
463 @code{org.freedesktop.Hal.Manager}, the signal @code{DeviceAdded} 474 @code{org.freedesktop.Hal.Manager}, the signal @code{DeviceAdded}
464 provides one single parameter, which is mapped into a Lisp string. 475 provides one single parameter, which is mapped into a Lisp string.
486 All errors raised by D-Bus are signaled with the error symbol 497 All errors raised by D-Bus are signaled with the error symbol
487 @code{dbus-error}. As usual, such an error can be trapped with a 498 @code{dbus-error}. As usual, such an error can be trapped with a
488 @code{condition-case} form. If possible, error messages from D-Bus 499 @code{condition-case} form. If possible, error messages from D-Bus
489 are appended to the @code{dbus-error}. 500 are appended to the @code{dbus-error}.
490 501
491 Incoming D-Bus messages are handled as Emacs event (see @pxref{Misc 502 Incoming D-Bus messages are handled as Emacs events (see @pxref{Misc
492 Events, , , elisp}). The generated event has this form: 503 Events, , , elisp}). The generated event has this form:
493 504
494 @example 505 @example
495 (dbus-event @var{symbol} @var{service} @var{path} &rest @var{args}) 506 (dbus-event @var{handler} @var{bus} @var{service} @var{path} @var{interface} @var{member} &rest @var{args})
496 @end example 507 @end example
497 508
498 @var{symbol} is the interned Lisp symbol which has been generated 509 @var{handler} is the callback function which has been registered for
499 during signal registration (see @pxref{Signals}). Its function cell 510 this signal (see @pxref{Signals}). When a @code{dbus-event} event
500 is the argument @var{handler}, the callback function which was 511 arrives, @var{handler} is called with @var{args} as arguments.
501 provided by @code{dbus-register-signal}. When a @code{dbus-event} 512
502 event arrives, @var{handler} is called with @var{args} as arguments. 513 @var{bus} identifies the D-Bus the signal is coming from. It is
514 either the symbol @code{:system} or the symbol @code{:session}.
503 515
504 @var{service} and @var{path} are the unique name and the object path 516 @var{service} and @var{path} are the unique name and the object path
505 of the D-Bus object emitting the signal. 517 of the D-Bus object emitting the signal. @var{interface} and
518 @var{member} denote the signal which has been sent.
506 519
507 In order to inspect the @code{dbus-event} data, you could extend the 520 In order to inspect the @code{dbus-event} data, you could extend the
508 definition of the callback function in @ref{Signals}: 521 definition of the callback function in @ref{Signals}:
509 522
510 @example 523 @example