Mercurial > emacs
annotate lisp/net/dbus.el @ 95049:438808a998aa
Improved extra-headers method for CVS.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Fri, 16 May 2008 19:15:26 +0000 |
parents | 91e5880a36c1 |
children | 282e0881421e |
rev | line source |
---|---|
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
1 ;;; dbus.el --- Elisp bindings for D-Bus. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
2 |
87537
84ece2f8e012
* net/dbus.el (dbus-name-owner-changed-handler): Use
Magnus Henoch <mange@freemail.hu>
parents:
87492
diff
changeset
|
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
4 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
5 ;; Author: Michael Albinus <michael.albinus@gmx.de> |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
6 ;; Keywords: comm, hardware |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
7 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
9 |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91728
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91728
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91728
diff
changeset
|
13 ;; (at your option) any later version. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
14 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
19 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91728
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
22 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
23 ;;; Commentary: |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
24 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
25 ;; This package provides language bindings for the D-Bus API. D-Bus |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
26 ;; is a message bus system, a simple way for applications to talk to |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
27 ;; one another. See <http://dbus.freedesktop.org/> for details. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
28 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
29 ;; Low-level language bindings are implemented in src/dbusbind.c. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
30 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
31 ;;; Code: |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
32 |
91484
7ddf7059d131
* dbus.el (top): Check (featurep 'dbusbind).
Michael Albinus <michael.albinus@gmx.de>
parents:
87885
diff
changeset
|
33 ;; D-Bus support in the Emacs core can be disabled with configuration |
91728
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
34 ;; option "--without-dbus". Declare used subroutines and variables. |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
35 (declare-function dbus-call-method "dbusbind.c") |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
36 (declare-function dbus-register-signal "dbusbind.c") |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
37 (defvar dbus-debug) |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
38 (defvar dbus-registered-functions-table) |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
39 |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
40 ;; Pacify byte compiler. |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
41 (eval-when-compile |
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
42 (require 'cl)) |
91484
7ddf7059d131
* dbus.el (top): Check (featurep 'dbusbind).
Michael Albinus <michael.albinus@gmx.de>
parents:
87885
diff
changeset
|
43 |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
44 (require 'xml) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
45 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
46 (defconst dbus-service-dbus "org.freedesktop.DBus" |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
47 "The bus name used to talk to the bus itself.") |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
48 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
49 (defconst dbus-path-dbus "/org/freedesktop/DBus" |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
50 "The object path used to talk to the bus itself.") |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
51 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
52 (defconst dbus-interface-dbus "org.freedesktop.DBus" |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
53 "The interface exported by the object with `dbus-service-dbus' and `dbus-path-dbus'.") |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
54 |
91588
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
55 (defconst dbus-interface-peer (concat dbus-interface-dbus ".Peer") |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
56 "The interface for peer objects.") |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
57 |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
58 (defconst dbus-interface-introspectable |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
59 (concat dbus-interface-dbus ".Introspectable") |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
60 "The interface supported by introspectable objects.") |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
61 |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
62 (defmacro dbus-ignore-errors (&rest body) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
63 "Execute BODY; signal D-Bus error when `dbus-debug' is non-nil. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
64 Otherwise, return result of last form in BODY, or all other errors." |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
65 `(condition-case err |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
66 (progn ,@body) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
67 (dbus-error (when dbus-debug (signal (car err) (cdr err)))))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
68 |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
69 (put 'dbus-ignore-errors 'lisp-indent-function 0) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
70 (put 'dbus-ignore-errors 'edebug-form-spec '(form symbolp body)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
71 (font-lock-add-keywords 'emacs-lisp-mode '("\\<dbus-ignore-errors\\>")) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
72 |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
73 |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
74 ;;; Hash table of registered functions. |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
75 |
87176
d5feab53f4f8
* net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents:
87159
diff
changeset
|
76 ;; We create it here. So we have a simple test in dbusbind.c, whether |
d5feab53f4f8
* net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents:
87159
diff
changeset
|
77 ;; the Lisp code has been loaded. |
d5feab53f4f8
* net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents:
87159
diff
changeset
|
78 (setq dbus-registered-functions-table (make-hash-table :test 'equal)) |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
79 |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
80 (defun dbus-list-hash-table () |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
81 "Returns all registered member registrations to D-Bus. |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
82 The return value is a list, with elements of kind (KEY . VALUE). |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
83 See `dbus-registered-functions-table' for a description of the |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
84 hash table." |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
85 (let (result) |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
86 (maphash |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
87 '(lambda (key value) (add-to-list 'result (cons key value) 'append)) |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
88 dbus-registered-functions-table) |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
89 result)) |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
90 |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
91 (defun dbus-unregister-object (object) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
92 "Unregister OBJECT from D-Bus. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
93 OBJECT must be the result of a preceding `dbus-register-method' |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
94 or `dbus-register-signal' call. It returns t if OBJECT has been |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
95 unregistered, nil otherwise." |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
96 ;; Check parameter. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
97 (unless (and (consp object) (not (null (car object))) (consp (cdr object))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
98 (signal 'wrong-type-argument (list 'D-Bus object))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
99 |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
100 ;; Find the corresponding entry in the hash table. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
101 (let* ((key (car object)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
102 (value (gethash key dbus-registered-functions-table))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
103 ;; Loop over the registered functions. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
104 (while (consp value) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
105 ;; (car value) has the structure (UNAME SERVICE PATH HANDLER). |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
106 ;; (cdr object) has the structure ((SERVICE PATH HANDLER) ...). |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
107 (if (not (equal (cdr (car value)) (car (cdr object)))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
108 (setq value (cdr value)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
109 ;; Compute new hash value. If it is empty, remove it from |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
110 ;; hash table. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
111 (unless |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
112 (puthash |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
113 key |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
114 (delete (car value) (gethash key dbus-registered-functions-table)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
115 dbus-registered-functions-table) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
116 (remhash key dbus-registered-functions-table)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
117 (setq value t))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
118 value)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
119 |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
120 (defun dbus-name-owner-changed-handler (&rest args) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
121 "Reapplies all member registrations to D-Bus. |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
122 This handler is applied when a \"NameOwnerChanged\" signal has |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
123 arrived. SERVICE is the object name for which the name owner has |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
124 been changed. OLD-OWNER is the previous owner of SERVICE, or the |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
125 empty string if SERVICE was not owned yet. NEW-OWNER is the new |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
126 owner of SERVICE, or the empty string if SERVICE looses any name owner. |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
127 |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
128 usage: (dbus-name-owner-changed-handler service old-owner new-owner)" |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
129 (save-match-data |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
130 ;; Check the arguments. We should silently ignore it when they |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
131 ;; are wrong. |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
132 (if (and (= (length args) 3) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
133 (stringp (car args)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
134 (stringp (cadr args)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
135 (stringp (caddr args))) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
136 (let ((service (car args)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
137 (old-owner (cadr args)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
138 (new-owner (caddr args))) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
139 ;; Check whether SERVICE is a known name. |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
140 (when (not (string-match "^:" service)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
141 (maphash |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
142 '(lambda (key value) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
143 (dolist (elt value) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
144 ;; key has the structure (BUS INTERFACE MEMBER). |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
145 ;; elt has the structure (UNAME SERVICE PATH HANDLER). |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
146 (when (string-equal old-owner (car elt)) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
147 ;; Remove old key, and add new entry with changed name. |
87537
84ece2f8e012
* net/dbus.el (dbus-name-owner-changed-handler): Use
Magnus Henoch <mange@freemail.hu>
parents:
87492
diff
changeset
|
148 (dbus-unregister-object (list key (cdr elt))) |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
149 ;; Maybe we could arrange the lists a little bit better |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
150 ;; that we don't need to extract every single element? |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
151 (dbus-register-signal |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
152 ;; BUS SERVICE PATH |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
153 (nth 0 key) (nth 1 elt) (nth 2 elt) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
154 ;; INTERFACE MEMBER HANDLER |
87492
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
155 (nth 1 key) (nth 2 key) (nth 3 elt))))) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
156 (copy-hash-table dbus-registered-functions-table)))) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
157 ;; The error is reported only in debug mode. |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
158 (when dbus-debug |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
159 (signal |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
160 'dbus-error |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
161 (cons |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
162 (format "Wrong arguments of %s.NameOwnerChanged" dbus-interface-dbus) |
bb538e56f976
* net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents:
87308
diff
changeset
|
163 args)))))) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
164 |
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
165 ;; Register the handler. |
91728
58bf306db72e
* net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents:
91589
diff
changeset
|
166 (ignore-errors |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
167 (dbus-register-signal |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
168 :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
169 "NameOwnerChanged" 'dbus-name-owner-changed-handler) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
170 (dbus-register-signal |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
171 :session dbus-service-dbus dbus-path-dbus dbus-interface-dbus |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
172 "NameOwnerChanged" 'dbus-name-owner-changed-handler)) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
173 |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
174 |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
175 ;;; D-Bus events. |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
176 |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
177 (defun dbus-check-event (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
178 "Checks whether EVENT is a well formed D-Bus event. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
179 EVENT is a list which starts with symbol `dbus-event': |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
180 |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
181 (dbus-event BUS SERIAL SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
182 |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
183 BUS identifies the D-Bus the message is coming from. It is |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
184 either the symbol `:system' or the symbol `:session'. SERIAL is |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
185 the serial number of the received D-Bus message if it is a method |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
186 call, or nil. SERVICE and PATH are the unique name and the |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
187 object path of the D-Bus object emitting the message. INTERFACE |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
188 and MEMBER denote the message which has been sent. HANDLER is |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
189 the function which has been registered for this message. ARGS |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
190 are the arguments passed to HANDLER, when it is called during |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
191 event handling in `dbus-handle-event'. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
192 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
193 This function raises a `dbus-error' signal in case the event is |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
194 not well formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
195 (when dbus-debug (message "DBus-Event %s" event)) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
196 (unless (and (listp event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
197 (eq (car event) 'dbus-event) |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
198 ;; Bus symbol. |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
199 (symbolp (nth 1 event)) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
200 ;; Serial. |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
201 (or (natnump (nth 2 event)) (null (nth 2 event))) |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
202 ;; Service. |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
203 (stringp (nth 3 event)) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
204 ;; Object path. |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
205 (stringp (nth 4 event)) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
206 ;; Interface. |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
207 (stringp (nth 5 event)) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
208 ;; Member. |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
209 (stringp (nth 6 event)) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
210 ;; Handler. |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
211 (functionp (nth 7 event))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
212 (signal 'dbus-error (list "Not a valid D-Bus event" event)))) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
213 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
214 ;;;###autoload |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
215 (defun dbus-handle-event (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
216 "Handle events from the D-Bus. |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
217 EVENT is a D-Bus event, see `dbus-check-event'. HANDLER, being |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
218 part of the event, is called with arguments ARGS." |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
219 (interactive "e") |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
220 ;; We don't want to raise an error, because this function is called |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
221 ;; in the event handling loop. |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
222 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
223 (let (result) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
224 (dbus-check-event event) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
225 (setq result (apply (nth 7 event) (nthcdr 8 event))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
226 (unless (consp result) (setq result (cons result nil))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
227 ;; Return a message when serial is not nil. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
228 (when (not (null (nth 2 event))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
229 (apply 'dbus-method-return-internal |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
230 (nth 1 event) (nth 2 event) (nth 3 event) result))))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
231 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
232 (defun dbus-event-bus-name (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
233 "Return the bus name the event is coming from. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
234 The result is either the symbol `:system' or the symbol `:session'. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
235 EVENT is a D-Bus event, see `dbus-check-event'. This function |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
236 raises a `dbus-error' signal in case the event is not well |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
237 formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
238 (dbus-check-event event) |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
239 (nth 1 event)) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
240 |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
241 (defun dbus-event-serial-number (event) |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
242 "Return the serial number of the corresponding D-Bus message. |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
243 The result is a number in case the D-Bus message is a method |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
244 call, or nil for all other mesage types. The serial number is |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
245 needed for generating a reply message. EVENT is a D-Bus event, |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
246 see `dbus-check-event'. This function raises a `dbus-error' |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
247 signal in case the event is not well formed." |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
248 (dbus-check-event event) |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
249 (nth 2 event)) |
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
250 |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
251 (defun dbus-event-service-name (event) |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
252 "Return the name of the D-Bus object the event is coming from. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
253 The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
254 This function raises a `dbus-error' signal in case the event is |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
255 not well formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
256 (dbus-check-event event) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
257 (nth 3 event)) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
258 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
259 (defun dbus-event-path-name (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
260 "Return the object path of the D-Bus object the event is coming from. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
261 The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
262 This function raises a `dbus-error' signal in case the event is |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
263 not well formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
264 (dbus-check-event event) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
265 (nth 4 event)) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
266 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
267 (defun dbus-event-interface-name (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
268 "Return the interface name of the D-Bus object the event is coming from. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
269 The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
270 This function raises a `dbus-error' signal in case the event is |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
271 not well formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
272 (dbus-check-event event) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
273 (nth 5 event)) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
274 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
275 (defun dbus-event-member-name (event) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
276 "Return the member name the event is coming from. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
277 It is either a signal name or a method name. The result is is a |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
278 string. EVENT is a D-Bus event, see `dbus-check-event'. This |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
279 function raises a `dbus-error' signal in case the event is not |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
280 well formed." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
281 (dbus-check-event event) |
87586
9554989ee375
* net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents:
87537
diff
changeset
|
282 (nth 6 event)) |
87050
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
283 |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
284 |
7d80e0f3d8f8
* net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
86941
diff
changeset
|
285 ;;; D-Bus registered names. |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
286 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
287 (defun dbus-list-activatable-names () |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
288 "Return the D-Bus service names which can be activated as list. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
289 The result is a list of strings, which is nil when there are no |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
290 activatable service names at all." |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
291 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
292 (dbus-call-method |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
293 :system dbus-service-dbus |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
294 dbus-path-dbus dbus-interface-dbus "ListActivatableNames"))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
295 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
296 (defun dbus-list-names (bus) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
297 "Return the service names registered at D-Bus BUS. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
298 The result is a list of strings, which is nil when there are no |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
299 registered service names at all. Well known names are strings like |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
300 \"org.freedesktop.DBus\". Names starting with \":\" are unique names |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
301 for services." |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
302 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
303 (dbus-call-method |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
304 bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus "ListNames"))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
305 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
306 (defun dbus-list-known-names (bus) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
307 "Retrieve all services which correspond to a known name in BUS. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
308 A service has a known name if it doesn't start with \":\"." |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
309 (let (result) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
310 (dolist (name (dbus-list-names bus) result) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
311 (unless (string-equal ":" (substring name 0 1)) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
312 (add-to-list 'result name 'append))))) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
313 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
314 (defun dbus-list-queued-owners (bus service) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
315 "Return the unique names registered at D-Bus BUS and queued for SERVICE. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
316 The result is a list of strings, or nil when there are no queued name |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
317 owners service names at all." |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
318 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
319 (dbus-call-method |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
320 bus dbus-service-dbus dbus-path-dbus |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
321 dbus-interface-dbus "ListQueuedOwners" service))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
322 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
323 (defun dbus-get-name-owner (bus service) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
324 "Return the name owner of SERVICE registered at D-Bus BUS. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
325 The result is either a string, or nil if there is no name owner." |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
326 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
327 (dbus-call-method |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
328 bus dbus-service-dbus dbus-path-dbus |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
329 dbus-interface-dbus "GetNameOwner" service))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
330 |
91588
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
331 (defun dbus-ping (bus service) |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
332 "Check whether SERVICE is registered for D-Bus BUS." |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
333 ;; "Ping" raises a D-Bus error if SERVICE does not exist. |
91589
12b2f1526656
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91588
diff
changeset
|
334 ;; Otherwise, it returns silently with `nil'. |
91588
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
335 (condition-case nil |
91589
12b2f1526656
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91588
diff
changeset
|
336 (not |
12b2f1526656
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91588
diff
changeset
|
337 (dbus-call-method bus service dbus-path-dbus dbus-interface-peer "Ping")) |
91588
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
338 (dbus-error nil))) |
83afe69ce25e
* net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents:
91484
diff
changeset
|
339 |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
340 (defun dbus-introspect (bus service path) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
341 "Return the introspection data of SERVICE in D-Bus BUS at object path PATH. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
342 The data are in XML format. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
343 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
344 Example: |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
345 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
346 \(dbus-introspect |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
347 :system \"org.freedesktop.Hal\" |
87159
bcf59f3d73d7
* net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents:
87093
diff
changeset
|
348 \"/org/freedesktop/Hal/devices/computer\")" |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
349 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
350 (dbus-call-method |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
351 bus service path dbus-interface-introspectable "Introspect"))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
352 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
353 (if nil ;; Must be reworked. Shall we offer D-Bus signatures at all? |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
354 (defun dbus-get-signatures (bus interface signal) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
355 "Retrieve SIGNAL's type signatures from D-Bus. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
356 The result is a list of SIGNAL's type signatures. Example: |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
357 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
358 \(\"s\" \"b\" \"ai\"\) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
359 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
360 This list represents 3 parameters of SIGNAL. The first parameter |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
361 is of type string, the second parameter is of type boolean, and |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
362 the third parameter is of type array of integer. |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
363 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
364 If INTERFACE or SIGNAL do not exist, or if they do not support |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
365 the D-Bus method org.freedesktop.DBus.Introspectable.Introspect, |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
366 the function returns nil." |
87885
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
367 (dbus-ignore-errors |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
368 (let ((introspect-xml |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
369 (with-temp-buffer |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
370 (insert (dbus-introspect bus interface)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
371 (xml-parse-region (point-min) (point-max)))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
372 node interfaces signals args result) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
373 ;; Get the root node. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
374 (setq node (xml-node-name introspect-xml)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
375 ;; Get all interfaces. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
376 (setq interfaces (xml-get-children node 'interface)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
377 (while interfaces |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
378 (when (string-equal (xml-get-attribute (car interfaces) 'name) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
379 interface) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
380 ;; That's the requested interface. Check for signals. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
381 (setq signals (xml-get-children (car interfaces) 'signal)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
382 (while signals |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
383 (when (string-equal (xml-get-attribute (car signals) 'name) signal) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
384 ;; The signal we are looking for. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
385 (setq args (xml-get-children (car signals) 'arg)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
386 (while args |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
387 (unless (xml-get-attribute (car args) 'type) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
388 ;; This shouldn't happen, let's escape. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
389 (signal 'dbus-error nil)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
390 ;; We append the signature. |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
391 (setq |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
392 result (append result |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
393 (list (xml-get-attribute (car args) 'type)))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
394 (setq args (cdr args))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
395 (setq signals nil)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
396 (setq signals (cdr signals))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
397 (setq interfaces nil)) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
398 (setq interfaces (cdr interfaces))) |
b560a1744534
* net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents:
87586
diff
changeset
|
399 result))) |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
400 ) ;; (if nil ... |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
401 |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
402 (provide 'dbus) |
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
403 |
87053 | 404 ;; arch-tag: a47caf84-9162-4811-90cc-5d388e37b9bd |
86941
cbc23e728425
* net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
405 ;;; dbus.el ends here |