annotate lisp/net/dbus.el @ 97582:fdc98979ca2b

Revert last change.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 20 Aug 2008 23:06:30 +0000
parents d5e87cca37af
children 2a8cbdcbe61d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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")
97261
d5e87cca37af * net/dbus.el (dbus-call-method-asynchronously): Declare
Michael Albinus <michael.albinus@gmx.de>
parents: 97260
diff changeset
36 (declare-function dbus-call-method-asynchronously "dbusbind.c")
97260
409001287195 * net/dbus.el (dbus-method-return-internal)
Michael Albinus <michael.albinus@gmx.de>
parents: 97213
diff changeset
37 (declare-function dbus-method-return-internal "dbusbind.c")
409001287195 * net/dbus.el (dbus-method-return-internal)
Michael Albinus <michael.albinus@gmx.de>
parents: 97213
diff changeset
38 (declare-function dbus-method-error-internal "dbusbind.c")
91728
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
39 (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
40 (defvar dbus-debug)
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
41 (defvar dbus-registered-functions-table)
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
42
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
43 ;; Pacify byte compiler.
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
44 (eval-when-compile
58bf306db72e * net/dbus.el: Remove `no-byte-compile' cookie.
Michael Albinus <michael.albinus@gmx.de>
parents: 91589
diff changeset
45 (require 'cl))
91484
7ddf7059d131 * dbus.el (top): Check (featurep 'dbusbind).
Michael Albinus <michael.albinus@gmx.de>
parents: 87885
diff changeset
46
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 (require 'xml)
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-service-dbus "org.freedesktop.DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 "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
51
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
52 (defconst dbus-path-dbus "/org/freedesktop/DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53 "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
54
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55 (defconst dbus-interface-dbus "org.freedesktop.DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56 "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
57
91588
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
58 (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
59 "The interface for peer objects.")
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
60
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
61 (defconst dbus-interface-introspectable
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
62 (concat dbus-interface-dbus ".Introspectable")
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 "The interface supported by introspectable objects.")
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
65 (defconst dbus-interface-properties (concat dbus-interface-dbus ".Properties")
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
66 "The interface for property objects.")
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
67
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
68 (defconst dbus-message-type-invalid 0
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
69 "This value is never a valid message type.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
70
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
71 (defconst dbus-message-type-method-call 1
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
72 "Message type of a method call message.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
73
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
74 (defconst dbus-message-type-method-return 2
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
75 "Message type of a method return message.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
76
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
77 (defconst dbus-message-type-error 3
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
78 "Message type of an error reply message.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
79
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
80 (defconst dbus-message-type-signal 4
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
81 "Message type of a signal message.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
82
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
83 (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
84 "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
85 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
86 `(condition-case err
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
87 (progn ,@body)
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
88 (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
89
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
90 (put 'dbus-ignore-errors 'lisp-indent-function 0)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
91 (put 'dbus-ignore-errors 'edebug-form-spec '(form body))
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
92 (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
93
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
94
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
95 ;;; Hash table of registered functions.
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
96
87176
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
97 ;; 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
98 ;; 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
99 (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
100
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
101 (defvar dbus-return-values-table (make-hash-table :test 'equal)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
102 "Hash table for temporary storing arguments of reply messages.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
103 A key in this hash table is a list (BUS SERIAL). BUS is either the
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
104 symbol `:system' or the symbol `:session'. SERIAL is the serial number
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
105 of the reply message. See `dbus-call-method-non-blocking-handler' and
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
106 `dbus-call-method-non-blocking'.")
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
107
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
108 (defun dbus-list-hash-table ()
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
109 "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
110 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
111 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
112 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
113 (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
114 (maphash
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
115 '(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
116 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
117 result))
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
118
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
119 (defun dbus-unregister-object (object)
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
120 "Unregister OBJECT from D-Bus.
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
121 OBJECT must be the result of a preceding `dbus-register-method'
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
122 or `dbus-register-signal' call. It returns `t' if OBJECT has
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
123 been unregistered, `nil' otherwise."
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
124 ;; Check parameter.
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
125 (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
126 (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
127
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
128 ;; 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
129 (let* ((key (car object))
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
130 (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
131 ;; Loop over the registered functions.
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
132 (while (consp value)
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
133 ;; (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
134 ;; (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
135 (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
136 (setq value (cdr value))
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
137 ;; 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
138 ;; hash table.
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
139 (unless
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
140 (puthash
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
141 key
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
142 (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
143 dbus-registered-functions-table)
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
144 (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
145 (setq value t)))
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
146 value))
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
147
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
148 (defun dbus-call-method-non-blocking-handler (&rest args)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
149 "Handler for reply messages of asynchronous D-Bus message calls.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
150 It calls the function stored in `dbus-registered-functions-table'.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
151 The result will be made available in `dbus-return-values-table'."
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
152 (puthash (list (dbus-event-bus-name last-input-event)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
153 (dbus-event-serial-number last-input-event))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
154 (if (= (length args) 1) (car args) args)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
155 dbus-return-values-table))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
156
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
157 (defun dbus-call-method-non-blocking
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
158 (bus service path interface method &rest args)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
159 "Call METHOD on the D-Bus BUS, but don't block the event queue.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
160 This is necessary for communicating to registered D-Bus methods,
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
161 which are running in the same Emacs process.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
162
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
163 The arguments are the same as in `dbus-call-method'.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
164
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
165 usage: (dbus-call-method-non-blocking
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
166 BUS SERVICE PATH INTERFACE METHOD
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
167 &optional :timeout TIMEOUT &rest ARGS)"
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
168
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
169 (let ((key
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
170 (apply
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
171 'dbus-call-method-asynchronously
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
172 bus service path interface method
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
173 'dbus-call-method-non-blocking-handler args)))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
174 ;; Wait until `dbus-call-method-non-blocking-handler' has put the
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
175 ;; result into `dbus-return-values-table'.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
176 (while (not (gethash key dbus-return-values-table nil))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
177 (read-event nil nil 0.1))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
178
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
179 ;; Cleanup `dbus-return-values-table'. Return the result.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
180 (prog1
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
181 (gethash key dbus-return-values-table nil)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
182 (remhash key dbus-return-values-table))))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
183
87492
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
184 (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
185 "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
186 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
187 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
188 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
189 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
190 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
191
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
192 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
193 (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
194 ;; 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
195 ;; are wrong.
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
196 (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
197 (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
198 (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
199 (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
200 (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
201 (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
202 (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
203 ;; 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
204 (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
205 (maphash
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
206 '(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
207 (dolist (elt value)
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
208 ;; 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
209 ;; 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
210 (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
211 ;; 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
212 (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
213 ;; 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
214 ;; 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
215 (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
216 ;; 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
217 (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
218 ;; 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
219 (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
220 (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
221 ;; 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
222 (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
223 (signal
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
224 'dbus-error
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
225 (cons
bb538e56f976 * net/dbus.el (dbus-name-owner-changed-handler): Make the function
Michael Albinus <michael.albinus@gmx.de>
parents: 87308
diff changeset
226 (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
227 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
228
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
229 ;; Register the handler.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
230 (when nil ;ignore-errors
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
231 (dbus-register-signal
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
232 :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
233 "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
234 (dbus-register-signal
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
235 :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
236 "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
237
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
238
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
239 ;;; D-Bus events.
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
240
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 (defun dbus-check-event (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
242 "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
243 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
244
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
245 (dbus-event BUS TYPE SERIAL SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS)
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
246
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
247 BUS identifies the D-Bus the message is coming from. It is
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
248 either the symbol `:system' or the symbol `:session'. TYPE is
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
249 the D-Bus message type which has caused the event, SERIAL is the
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
250 serial number of the received D-Bus message. SERVICE and PATH
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
251 are the unique name and the object path of the D-Bus object
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
252 emitting the message. INTERFACE and MEMBER denote the message
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
253 which has been sent. HANDLER is the function which has been
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
254 registered for this message. ARGS are the arguments passed to
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
255 HANDLER, when it is called during event handling in
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
256 `dbus-handle-event'.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
257
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
258 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
259 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
260 (when dbus-debug (message "DBus-Event %s" event))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
261 (unless (and (listp event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
262 (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
263 ;; 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
264 (symbolp (nth 1 event))
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
265 ;; Type.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
266 (and (natnump (nth 2 event))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
267 (< dbus-message-type-invalid (nth 2 event)))
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
268 ;; Serial.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
269 (natnump (nth 3 event))
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
270 ;; Service.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
271 (or (= dbus-message-type-method-return (nth 2 event))
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
272 (= dbus-message-type-error (nth 2 event))
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
273 (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
274 ;; Object path.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
275 (or (= dbus-message-type-method-return (nth 2 event))
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
276 (= dbus-message-type-error (nth 2 event))
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
277 (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
278 ;; Interface.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
279 (or (= dbus-message-type-method-return (nth 2 event))
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
280 (= dbus-message-type-error (nth 2 event))
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
281 (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
282 ;; Member.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
283 (or (= dbus-message-type-method-return (nth 2 event))
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
284 (= dbus-message-type-error (nth 2 event))
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
285 (stringp (nth 7 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
286 ;; Handler.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
287 (functionp (nth 8 event)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
288 (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
289
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
290 ;;;###autoload
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
291 (defun dbus-handle-event (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
292 "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
293 EVENT is a D-Bus event, see `dbus-check-event'. HANDLER, being
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
294 part of the event, is called with arguments ARGS.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
295 If the HANDLER returns an `dbus-error', it is propagated as return message."
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 (interactive "e")
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
297 (condition-case err
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
298 (let (result)
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
299 ;; We ignore not well-formed events.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
300 (dbus-check-event event)
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
301 ;; Error messages must be propagated.
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
302 (when (= dbus-message-type-error (nth 2 event))
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
303 (signal 'dbus-error (nthcdr 9 event)))
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
304 ;; Apply the handler.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
305 (setq result (apply (nth 8 event) (nthcdr 9 event)))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
306 ;; Return a message when it is a message call.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
307 (when (= dbus-message-type-method-call (nth 2 event))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
308 (dbus-ignore-errors
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
309 (dbus-method-return-internal
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
310 (nth 1 event) (nth 3 event) (nth 4 event) result))))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
311 ;; Error handling.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
312 (dbus-error
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
313 ;; Return an error message when it is a message call.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
314 (when (= dbus-message-type-method-call (nth 2 event))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
315 (dbus-ignore-errors
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
316 (dbus-method-error-internal
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
317 (nth 1 event) (nth 3 event) (nth 4 event) (cadr err))))
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
318 ;; Propagate D-Bus error messages.
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
319 (when (or dbus-debug (= dbus-message-type-error (nth 2 event)))
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
320 (signal (car err) (cdr err))))))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
321
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
322 (defun dbus-event-bus-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
323 "Return the bus name the event is coming from.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
324 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
325 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
326 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
327 formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
328 (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
329 (nth 1 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
330
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
331 (defun dbus-event-message-type (event)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
332 "Return the message type of the corresponding D-Bus message.
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
333 The result is a number. EVENT is a D-Bus event, see
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
334 `dbus-check-event'. This function raises a `dbus-error' signal
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
335 in case the event is not well formed."
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
336 (dbus-check-event event)
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
337 (nth 2 event))
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
338
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
339 (defun dbus-event-serial-number (event)
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
340 "Return the serial number of the corresponding D-Bus message.
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
341 The result is a number. The serial number is needed for
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
342 generating a reply message. EVENT is a D-Bus event, see
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
343 `dbus-check-event'. This function raises a `dbus-error' signal
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
344 in case the event is not well formed."
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
345 (dbus-check-event event)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
346 (nth 3 event))
87586
9554989ee375 * net/dbus.el (dbus-list-hash-table)
Michael Albinus <michael.albinus@gmx.de>
parents: 87537
diff changeset
347
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
348 (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
349 "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
350 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
351 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
352 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
353 (dbus-check-event event)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
354 (nth 4 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
355
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
356 (defun dbus-event-path-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
357 "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
358 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
359 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
360 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
361 (dbus-check-event event)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
362 (nth 5 event))
86941
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 (defun dbus-event-interface-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
365 "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
366 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
367 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
368 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
369 (dbus-check-event event)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
370 (nth 6 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
371
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
372 (defun dbus-event-member-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
373 "Return the member name the event is coming from.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
374 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
375 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
376 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
377 well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
378 (dbus-check-event event)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
379 (nth 7 event))
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
380
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
381
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
382 ;;; D-Bus registered names.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
383
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
384 (defun dbus-list-activatable-names ()
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
385 "Return the D-Bus service names which can be activated as list.
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
386 The result is a list of strings, which is `nil' when there are no
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
387 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
388 (dbus-ignore-errors
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
389 (dbus-call-method
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
390 :system dbus-service-dbus
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
391 dbus-path-dbus dbus-interface-dbus "ListActivatableNames")))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
392
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
393 (defun dbus-list-names (bus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
394 "Return the service names registered at D-Bus BUS.
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
395 The result is a list of strings, which is `nil' when there are no
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
396 registered service names at all. Well known names are strings
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
397 like \"org.freedesktop.DBus\". Names starting with \":\" are
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
398 unique names for services."
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
399 (dbus-ignore-errors
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
400 (dbus-call-method
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
401 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
402
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
403 (defun dbus-list-known-names (bus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
404 "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
405 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
406 (let (result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
407 (dolist (name (dbus-list-names bus) result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
408 (unless (string-equal ":" (substring name 0 1))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
409 (add-to-list 'result name 'append)))))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
410
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
411 (defun dbus-list-queued-owners (bus service)
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
412 "Return the unique names registered at D-Bus BUS and queued for SERVICE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
413 The result is a list of strings, or `nil' when there are no
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
414 queued name 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
415 (dbus-ignore-errors
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
416 (dbus-call-method
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
417 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
418 dbus-interface-dbus "ListQueuedOwners" service)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
419
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
420 (defun dbus-get-name-owner (bus service)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
421 "Return the name owner of SERVICE registered at D-Bus BUS.
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
422 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
423 (dbus-ignore-errors
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
424 (dbus-call-method
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
425 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
426 dbus-interface-dbus "GetNameOwner" service)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
427
91588
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
428 (defun dbus-ping (bus service)
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
429 "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
430 ;; "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
431 ;; 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
432 (condition-case nil
91589
12b2f1526656 * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91588
diff changeset
433 (not
12b2f1526656 * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91588
diff changeset
434 (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
435 (dbus-error nil)))
83afe69ce25e * net/dbus.el (dbus-interface-peer): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 91484
diff changeset
436
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
437
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
438 ;;; D-Bus introspection.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
439
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
440 (defun dbus-introspect (bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
441 "This function returns all interfaces and sub-nodes of SERVICE,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
442 registered at object path PATH at bus BUS.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
443
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
444 BUS must be either the symbol `:system' or the symbol `:session'.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
445 SERVICE must be a known service name, and PATH must be a valid
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
446 object path. The last two parameters are strings. The result,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
447 the introspection data, is a string in XML format."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
448 ;; We don't want to raise errors.
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
449 (dbus-ignore-errors
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
450 (dbus-call-method
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
451 bus service path dbus-interface-introspectable "Introspect")))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
452
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
453 (defun dbus-introspect-xml (bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
454 "Return the introspection data of SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
455 The data are a parsed list. The root object is a \"node\",
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
456 representing the object path PATH. The root object can contain
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
457 \"interface\" and further \"node\" objects."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
458 ;; We don't want to raise errors.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
459 (xml-node-name
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
460 (ignore-errors
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
461 (with-temp-buffer
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
462 (insert (dbus-introspect bus service path))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
463 (xml-parse-region (point-min) (point-max))))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
464
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
465 (defun dbus-introspect-get-attribute (object attribute)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
466 "Return the ATTRIBUTE value of D-Bus introspection OBJECT.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
467 ATTRIBUTE must be a string according to the attribute names in
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
468 the D-Bus specification."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
469 (xml-get-attribute-or-nil object (intern attribute)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
470
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
471 (defun dbus-introspect-get-node-names (bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
472 "Return all node names of SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
473 It returns a list of strings. The node names stand for further
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
474 object paths of the D-Bus service."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
475 (let ((object (dbus-introspect-xml bus service path))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
476 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
477 (dolist (elt (xml-get-children object 'node) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
478 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
479 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
480
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
481 (defun dbus-introspect-get-all-nodes (bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
482 "Return all node names of SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
483 It returns a list of strings, which are further object paths of SERVICE."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
484 (let ((result (list path)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
485 (dolist (elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
486 (dbus-introspect-get-node-names bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
487 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
488 (setq elt (expand-file-name elt path))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
489 (setq result
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
490 (append result (dbus-introspect-get-all-nodes bus service elt))))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
491
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
492 (defun dbus-introspect-get-interface-names (bus service path)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
493 "Return all interface names of SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
494 It returns a list of strings.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
495
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
496 There will be always the default interface
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
497 \"org.freedesktop.DBus.Introspectable\". Another default
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
498 interface is \"org.freedesktop.DBus.Properties\". If present,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
499 \"interface\" objects can also have \"property\" objects as
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
500 children, beside \"method\" and \"signal\" objects."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
501 (let ((object (dbus-introspect-xml bus service path))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
502 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
503 (dolist (elt (xml-get-children object 'interface) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
504 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
505 'result (dbus-introspect-get-attribute elt "name") 'append))))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
506
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
507 (defun dbus-introspect-get-interface (bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
508 "Return the INTERFACE of SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
509 The return value is an XML object. INTERFACE must be a string,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
510 element of the list returned by
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
511 `dbus-introspect-get-interface-names'. The resulting
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
512 \"interface\" object can contain \"method\", \"signal\",
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
513 \"property\" and \"annotation\" children."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
514 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
515 (dbus-introspect-xml bus service path) 'interface)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
516 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
517 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
518 interface
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
519 (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
520 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
521 (car elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
522
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
523 (defun dbus-introspect-get-method-names (bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
524 "Return a list of strings of all method names of INTERFACE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
525 SERVICE is a service of D-Bus BUS at object path PATH."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
526 (let ((object (dbus-introspect-get-interface bus service path interface))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
527 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
528 (dolist (elt (xml-get-children object 'method) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
529 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
530 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
531
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
532 (defun dbus-introspect-get-method (bus service path interface method)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
533 "Return method METHOD of interface INTERFACE as XML object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
534 It must be located at SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
535 METHOD must be a string, element of the list returned by
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
536 `dbus-introspect-get-method-names'. The resulting \"method\"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
537 object can contain \"arg\" and \"annotation\" children."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
538 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
539 (dbus-introspect-get-interface bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
540 'method)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
541 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
542 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
543 method (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
544 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
545 (car elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
546
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
547 (defun dbus-introspect-get-signal-names (bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
548 "Return a list of strings of all signal names of INTERFACE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
549 SERVICE is a service of D-Bus BUS at object path PATH."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
550 (let ((object (dbus-introspect-get-interface bus service path interface))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
551 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
552 (dolist (elt (xml-get-children object 'signal) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
553 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
554 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
555
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
556 (defun dbus-introspect-get-signal (bus service path interface signal)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
557 "Return signal SIGNAL of interface INTERFACE as XML object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
558 It must be located at SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
559 SIGNAL must be a string, element of the list returned by
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
560 `dbus-introspect-get-signal-names'. The resulting \"signal\"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
561 object can contain \"arg\" and \"annotation\" children."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
562 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
563 (dbus-introspect-get-interface bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
564 'signal)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
565 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
566 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
567 signal (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
568 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
569 (car elt)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
570
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
571 (defun dbus-introspect-get-property-names (bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
572 "Return a list of strings of all property names of INTERFACE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
573 SERVICE is a service of D-Bus BUS at object path PATH."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
574 (let ((object (dbus-introspect-get-interface bus service path interface))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
575 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
576 (dolist (elt (xml-get-children object 'property) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
577 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
578 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
579
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
580 (defun dbus-introspect-get-property (bus service path interface property)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
581 "This function returns PROPERTY of INTERFACE as XML object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
582 It must be located at SERVICE in D-Bus BUS at object path PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
583 PROPERTY must be a string, element of the list returned by
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
584 `dbus-introspect-get-property-names'. The resulting PROPERTY
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
585 object can contain \"annotation\" children."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
586 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
587 (dbus-introspect-get-interface bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
588 'property)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
589 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
590 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
591 property
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
592 (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
593 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
594 (car elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
595
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
596 (defun dbus-introspect-get-annotation-names
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
597 (bus service path interface &optional name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
598 "Return all annotation names as list of strings.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
599 If NAME is `nil', the annotations are children of INTERFACE,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
600 otherwise NAME must be a \"method\", \"signal\", or \"property\"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
601 object, where the annotations belong to."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
602 (let ((object
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
603 (if name
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
604 (or (dbus-introspect-get-method bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
605 (dbus-introspect-get-signal bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
606 (dbus-introspect-get-property bus service path interface name))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
607 (dbus-introspect-get-interface bus service path interface)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
608 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
609 (dolist (elt (xml-get-children object 'annotation) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
610 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
611 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
612
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
613 (defun dbus-introspect-get-annotation
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
614 (bus service path interface name annotation)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
615 "Return ANNOTATION as XML object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
616 If NAME is `nil', ANNOTATION is a child of INTERFACE, otherwise
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
617 NAME must be the name of a \"method\", \"signal\", or
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
618 \"property\" object, where the ANNOTATION belongs to."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
619 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
620 (if name
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
621 (or (dbus-introspect-get-method
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
622 bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
623 (dbus-introspect-get-signal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
624 bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
625 (dbus-introspect-get-property
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
626 bus service path interface name))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
627 (dbus-introspect-get-interface bus service path interface))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
628 'annotation)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
629 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
630 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
631 annotation
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
632 (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
633 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
634 (car elt)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
635
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
636 (defun dbus-introspect-get-argument-names (bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
637 "Return a list of all argument names as list of strings.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
638 NAME must be a \"method\" or \"signal\" object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
639
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
640 Argument names are optional, the function can return `nil'
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
641 therefore, even if the method or signal has arguments."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
642 (let ((object
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
643 (or (dbus-introspect-get-method bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
644 (dbus-introspect-get-signal bus service path interface name)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
645 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
646 (dolist (elt (xml-get-children object 'arg) result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
647 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
648 'result (dbus-introspect-get-attribute elt "name") 'append))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
649
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
650 (defun dbus-introspect-get-argument (bus service path interface name arg)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
651 "Return argument ARG as XML object.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
652 NAME must be a \"method\" or \"signal\" object. ARG must be a
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
653 string, element of the list returned by `dbus-introspect-get-argument-names'."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
654 (let ((elt (xml-get-children
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
655 (or (dbus-introspect-get-method bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
656 (dbus-introspect-get-signal bus service path interface name))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
657 'arg)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
658 (while (and elt
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
659 (not (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
660 arg (dbus-introspect-get-attribute (car elt) "name"))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
661 (setq elt (cdr elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
662 (car elt)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
663
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
664 (defun dbus-introspect-get-signature
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
665 (bus service path interface name &optional direction)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
666 "Return signature of a `method' or `signal', represented by NAME, as string.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
667 If NAME is a `method', DIRECTION can be either \"in\" or \"out\".
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
668 If DIRECTION is `nil', \"in\" is assumed.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
669
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
670 If NAME is a `signal', and DIRECTION is non-`nil', DIRECTION must
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
671 be \"out\"."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
672 ;; For methods, we use "in" as default direction.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
673 (let ((object (or (dbus-introspect-get-method
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
674 bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
675 (dbus-introspect-get-signal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
676 bus service path interface name))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
677 (when (and (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
678 "method" (dbus-introspect-get-attribute object "name"))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
679 (not (stringp direction)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
680 (setq direction "in"))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
681 ;; In signals, no direction is given.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
682 (when (string-equal "signal" (dbus-introspect-get-attribute object "name"))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
683 (setq direction nil))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
684 ;; Collect the signatures.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
685 (mapconcat
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
686 '(lambda (x)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
687 (let ((arg (dbus-introspect-get-argument
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
688 bus service path interface name x)))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
689 (if (or (not (stringp direction))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
690 (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
691 direction
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
692 (dbus-introspect-get-attribute arg "direction")))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
693 (dbus-introspect-get-attribute arg "type")
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
694 "")))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
695 (dbus-introspect-get-argument-names bus service path interface name)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
696 "")))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
697
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
698
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
699 ;;; D-Bus properties.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
700
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
701 (defun dbus-get-property (bus service path interface property)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
702 "Return the value of PROPERTY of INTERFACE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
703 It will be checked at BUS, SERVICE, PATH. The result can be any
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
704 valid D-Bus value, or `nil' if there is no PROPERTY."
87885
b560a1744534 * net/dbus.el (dbus-ignore-errors): New macro.
Michael Albinus <michael.albinus@gmx.de>
parents: 87586
diff changeset
705 (dbus-ignore-errors
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
706 ;; We must check, whether the "org.freedesktop.DBus.Properties"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
707 ;; interface is supported; otherwise the call blocks.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
708 (when
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
709 (member
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
710 "Get"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
711 (dbus-introspect-get-method-names
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
712 bus service path "org.freedesktop.DBus.Properties"))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
713 ;; "Get" returns a variant, so we must use the car.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
714 (car
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
715 (dbus-call-method
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
716 bus service path dbus-interface-properties
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
717 "Get" interface property)))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
718
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
719 (defun dbus-set-property (bus service path interface property value)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
720 "Set value of PROPERTY of INTERFACE to VALUE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
721 It will be checked at BUS, SERVICE, PATH. When the value has
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
722 been set successful, the result is VALUE. Otherwise, `nil' is
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
723 returned."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
724 (dbus-ignore-errors
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
725 (when
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
726 (and
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
727 ;; We must check, whether the
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
728 ;; "org.freedesktop.DBus.Properties" interface is supported;
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
729 ;; otherwise the call blocks.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
730 (member
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
731 "Set"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
732 (dbus-introspect-get-method-names
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
733 bus service path "org.freedesktop.DBus.Properties"))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
734 ;; PROPERTY must be writable.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
735 (string-equal
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
736 "readwrite"
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
737 (dbus-introspect-get-attribute
97213
f7035abd999b * net/dbus.el (dbus-check-event, dbus-handle-event): Handle D-Bus
Michael Albinus <michael.albinus@gmx.de>
parents: 97167
diff changeset
738 (dbus-introspect-get-property bus service path interface property)
97167
125ed717ddbb * net/dbus.el (top): Don't register for "NameOwnerChanged".
Michael Albinus <michael.albinus@gmx.de>
parents: 96801
diff changeset
739 "access")))
96801
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
740 ;; "Set" requires a variant.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
741 (dbus-call-method
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
742 bus service path dbus-interface-properties
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
743 "Set" interface property (list :variant value))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
744 ;; Return VALUE.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
745 (dbus-get-property bus service path interface property))))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
746
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
747 (defun dbus-get-all-properties (bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
748 "Return all properties of INTERFACE at BUS, SERVICE, PATH.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
749 The result is a list of entries. Every entry is a cons of the
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
750 name of the property, and its value. If there are no properties,
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
751 `nil' is returned."
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
752 ;; "org.freedesktop.DBus.Properties.GetAll" is not supported at
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
753 ;; all interfaces. Therefore, we do it ourselves.
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
754 (dbus-ignore-errors
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
755 (let (result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
756 (dolist (property
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
757 (dbus-introspect-get-property-names
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
758 bus service path interface)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
759 result)
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
760 (add-to-list
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
761 'result
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
762 (cons property (dbus-get-property bus service path interface property))
282e0881421e * net/dbus.el (dbus-interface-properties): New defconst.
Michael Albinus <michael.albinus@gmx.de>
parents: 94677
diff changeset
763 'append)))))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
764
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
765 (provide 'dbus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
766
87053
f767f1ba8301 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87050
diff changeset
767 ;; arch-tag: a47caf84-9162-4811-90cc-5d388e37b9bd
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
768 ;;; dbus.el ends here