comparison lisp/net/dbus.el @ 109962:aa3e4f636621

* net/dbus.el: Accept UNIX domain sockets as bus address. (top): Don't initialize `dbus-registered-objects-table' anymore, this is done in dbusbind,c. (dbus-check-event): Adapt test for bus. (dbus-return-values-table, dbus-unregister-service) (dbus-event-bus-name, dbus-introspect, dbus-register-property): Adapt doc string.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 23 Aug 2010 15:08:54 +0200
parents 0f3ed79830e9
children c87f89486bb7
comparison
equal deleted inserted replaced
109961:25b9c8c975be 109962:aa3e4f636621
106 catched in `condition-case' by `dbus-error'.") 106 catched in `condition-case' by `dbus-error'.")
107 107
108 108
109 ;;; Hash table of registered functions. 109 ;;; Hash table of registered functions.
110 110
111 ;; We create it here. So we have a simple test in dbusbind.c, whether
112 ;; the Lisp code has been loaded.
113 (setq dbus-registered-objects-table (make-hash-table :test 'equal))
114
115 (defvar dbus-return-values-table (make-hash-table :test 'equal) 111 (defvar dbus-return-values-table (make-hash-table :test 'equal)
116 "Hash table for temporary storing arguments of reply messages. 112 "Hash table for temporary storing arguments of reply messages.
117 A key in this hash table is a list (BUS SERIAL). BUS is either the 113 A key in this hash table is a list (BUS SERIAL). BUS is either a
118 symbol `:system' or the symbol `:session'. SERIAL is the serial number 114 Lisp symbol, `:system' or `:session', or a string denoting the
119 of the reply message. See `dbus-call-method-non-blocking-handler' and 115 bus address. SERIAL is the serial number of the reply message.
116 See `dbus-call-method-non-blocking-handler' and
120 `dbus-call-method-non-blocking'.") 117 `dbus-call-method-non-blocking'.")
121 118
122 (defun dbus-list-hash-table () 119 (defun dbus-list-hash-table ()
123 "Returns all registered member registrations to D-Bus. 120 "Returns all registered member registrations to D-Bus.
124 The return value is a list, with elements of kind (KEY . VALUE). 121 The return value is a list, with elements of kind (KEY . VALUE).
185 ;; Return. 182 ;; Return.
186 ret)) 183 ret))
187 184
188 (defun dbus-unregister-service (bus service) 185 (defun dbus-unregister-service (bus service)
189 "Unregister all objects related to SERVICE from D-Bus BUS. 186 "Unregister all objects related to SERVICE from D-Bus BUS.
190 BUS must be either the symbol `:system' or the symbol `:session'. 187 BUS is either a Lisp symbol, `:system' or `:session', or a string
191 SERVICE must be a known service name." 188 denoting the bus address. SERVICE must be a known service name."
192 (maphash 189 (maphash
193 (lambda (key value) 190 (lambda (key value)
194 (dolist (elt value) 191 (dolist (elt value)
195 (ignore-errors 192 (ignore-errors
196 (when (and (equal bus (car key)) (string-equal service (cadr elt))) 193 (when (and (equal bus (car key)) (string-equal service (cadr elt)))
351 EVENT is a list which starts with symbol `dbus-event': 348 EVENT is a list which starts with symbol `dbus-event':
352 349
353 (dbus-event BUS TYPE SERIAL SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS) 350 (dbus-event BUS TYPE SERIAL SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS)
354 351
355 BUS identifies the D-Bus the message is coming from. It is 352 BUS identifies the D-Bus the message is coming from. It is
356 either the symbol `:system' or the symbol `:session'. TYPE is 353 either a Lisp symbol, `:system' or `:session', or a string
357 the D-Bus message type which has caused the event, SERIAL is the 354 denoting the bus address. TYPE is the D-Bus message type which
358 serial number of the received D-Bus message. SERVICE and PATH 355 has caused the event, SERIAL is the serial number of the received
359 are the unique name and the object path of the D-Bus object 356 D-Bus message. SERVICE and PATH are the unique name and the
360 emitting the message. INTERFACE and MEMBER denote the message 357 object path of the D-Bus object emitting the message. INTERFACE
361 which has been sent. HANDLER is the function which has been 358 and MEMBER denote the message which has been sent. HANDLER is
362 registered for this message. ARGS are the arguments passed to 359 the function which has been registered for this message. ARGS
363 HANDLER, when it is called during event handling in 360 are the arguments passed to HANDLER, when it is called during
364 `dbus-handle-event'. 361 event handling in `dbus-handle-event'.
365 362
366 This function raises a `dbus-error' signal in case the event is 363 This function raises a `dbus-error' signal in case the event is
367 not well formed." 364 not well formed."
368 (when dbus-debug (message "DBus-Event %s" event)) 365 (when dbus-debug (message "DBus-Event %s" event))
369 (unless (and (listp event) 366 (unless (and (listp event)
370 (eq (car event) 'dbus-event) 367 (eq (car event) 'dbus-event)
371 ;; Bus symbol. 368 ;; Bus symbol.
372 (symbolp (nth 1 event)) 369 (or (symbolp (nth 1 event))
370 (stringp (nth 1 event)))
373 ;; Type. 371 ;; Type.
374 (and (natnump (nth 2 event)) 372 (and (natnump (nth 2 event))
375 (< dbus-message-type-invalid (nth 2 event))) 373 (< dbus-message-type-invalid (nth 2 event)))
376 ;; Serial. 374 ;; Serial.
377 (natnump (nth 3 event)) 375 (natnump (nth 3 event))
432 (when (or dbus-debug (= dbus-message-type-error (nth 2 event))) 430 (when (or dbus-debug (= dbus-message-type-error (nth 2 event)))
433 (signal (car err) (cdr err)))))) 431 (signal (car err) (cdr err))))))
434 432
435 (defun dbus-event-bus-name (event) 433 (defun dbus-event-bus-name (event)
436 "Return the bus name the event is coming from. 434 "Return the bus name the event is coming from.
437 The result is either the symbol `:system' or the symbol `:session'. 435 The result is either a Lisp symbol, `:system' or `:session', or a
438 EVENT is a D-Bus event, see `dbus-check-event'. This function 436 string denoting the bus address. EVENT is a D-Bus event, see
439 raises a `dbus-error' signal in case the event is not well formed." 437 `dbus-check-event'. This function raises a `dbus-error' signal
438 in case the event is not well formed."
440 (dbus-check-event event) 439 (dbus-check-event event)
441 (nth 1 event)) 440 (nth 1 event))
442 441
443 (defun dbus-event-message-type (event) 442 (defun dbus-event-message-type (event)
444 "Return the message type of the corresponding D-Bus message. 443 "Return the message type of the corresponding D-Bus message.
564 563
565 (defun dbus-introspect (bus service path) 564 (defun dbus-introspect (bus service path)
566 "Return all interfaces and sub-nodes of SERVICE, 565 "Return all interfaces and sub-nodes of SERVICE,
567 registered at object path PATH at bus BUS. 566 registered at object path PATH at bus BUS.
568 567
569 BUS must be either the symbol `:system' or the symbol `:session'. 568 BUS is either a Lisp symbol, `:system' or `:session', or a string
570 SERVICE must be a known service name, and PATH must be a valid 569 denoting the bus address. SERVICE must be a known service name,
571 object path. The last two parameters are strings. The result, 570 and PATH must be a valid object path. The last two parameters
572 the introspection data, is a string in XML format." 571 are strings. The result, the introspection data, is a string in
572 XML format."
573 ;; We don't want to raise errors. `dbus-call-method-non-blocking' 573 ;; We don't want to raise errors. `dbus-call-method-non-blocking'
574 ;; is used, because the handler can be registered in our Emacs 574 ;; is used, because the handler can be registered in our Emacs
575 ;; instance; caller an callee would block each other. 575 ;; instance; caller an callee would block each other.
576 (dbus-ignore-errors 576 (dbus-ignore-errors
577 (funcall 577 (funcall
871 871
872 (defun dbus-register-property 872 (defun dbus-register-property
873 (bus service path interface property access value &optional emits-signal) 873 (bus service path interface property access value &optional emits-signal)
874 "Register property PROPERTY on the D-Bus BUS. 874 "Register property PROPERTY on the D-Bus BUS.
875 875
876 BUS is either the symbol `:system' or the symbol `:session'. 876 BUS is either a Lisp symbol, `:system' or `:session', or a string
877 denoting the bus address.
877 878
878 SERVICE is the D-Bus service name of the D-Bus. It must be a 879 SERVICE is the D-Bus service name of the D-Bus. It must be a
879 known name. 880 known name.
880 881
881 PATH is the D-Bus object path SERVICE is registered. INTERFACE 882 PATH is the D-Bus object path SERVICE is registered. INTERFACE