annotate lisp/net/dbus.el @ 87281:c0a3e33f65b9

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Sat, 15 Dec 2007 10:09:17 +0000
parents d5feab53f4f8
children eed31b4b1ca4
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 ;;; -*- no-byte-compile: t; -*-
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
2 ;;; dbus.el --- Elisp bindings for D-Bus.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
3
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
4 ;; Copyright (C) 2007 Free Software Foundation, Inc.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
5
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
6 ;; Author: Michael Albinus <michael.albinus@gmx.de>
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
7 ;; Keywords: comm, hardware
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
8
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
10
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
14 ;; any later version.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
15
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
16 ;; 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
17 ;; 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
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19 ;; GNU General Public License for more details.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
20
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, see
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23 ;; <http://www.gnu.org/licenses/>.
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 ;;; Commentary:
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 ;; 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
28 ;; 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
29 ;; one another. See <http://dbus.freedesktop.org/> for details.
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 ;; 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
32
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 ;;; Code:
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
34
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
35 (require 'xml)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
36
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 (defconst dbus-service-dbus "org.freedesktop.DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 "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
39
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40 (defconst dbus-path-dbus "/org/freedesktop/DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41 "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
42
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 (defconst dbus-interface-dbus "org.freedesktop.DBus"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44 "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
45
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46 (defconst dbus-interface-introspectable "org.freedesktop.DBus.Introspectable"
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 "The interface supported by introspectable objects.")
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
48
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
49
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
50 ;;; Hash table of registered functions.
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
51
87176
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
52 ;; 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
53 ;; 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
54 (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
55
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
56 (defun dbus-list-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
57 "Returns all registered signal registrations to D-Bus.
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
58 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
59 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
60 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
61 (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
62 (maphash
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
63 '(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
64 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
65 result))
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
66
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
67 (defun dbus-name-owner-changed-handler (service old-owner new-owner)
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
68 "Reapplies all signal registrations to D-Bus.
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
69 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
70 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
71 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
72 empty string if SERVICE was not owned yet. NEW-OWNER is the new
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
73 owner of SERVICE, or the empty string if SERVICE looses any name owner."
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
74 (save-match-data
87176
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
75 ;; Check whether SERVICE is a known name.
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
76 (when (and (stringp service) (not (string-match "^:" service))
87176
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
77 (stringp old-owner) (stringp new-owner))
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
78 (maphash
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
79 '(lambda (key value)
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
80 (dolist (elt value)
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
81 ;; key has the structure (BUS INTERFACE SIGNAL).
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
82 ;; elt has the structure (SERVICE UNAME PATH HANDLER).
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
83 (when (string-equal old-owner (cadr elt))
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
84 ;; Remove old key, and add new entry with changed name.
87176
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
85 (when dbus-debug (message "Remove rule for %s %s" key elt))
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
86 ;(dbus-unregister-signal key)
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
87 (setcar (cdr elt) new-owner)
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
88 (when dbus-debug (message "Add rule for %s %s" key elt))
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
89 ;; Maybe we could arrange the lists a little bit better
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
90 ;; that we don't need to extract every single element?
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
91 (when (not (zerop (length new-owner)))
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
92 (dbus-register-signal
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
93 ;; BUS SERVICE PATH
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
94 (nth 0 key) (nth 0 elt) (nth 2 elt)
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
95 ;; INTERFACE SIGNAL HANDLER
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
96 (nth 1 key) (nth 2 key) (nth 3 elt))))))
d5feab53f4f8 * net/dbus.el (dbus-hash-table=): Remove function. We cannot
Michael Albinus <michael.albinus@gmx.de>
parents: 87159
diff changeset
97 (copy-hash-table dbus-registered-functions-table)))))
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
98
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
99 ;; Register the handler.
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
100 (condition-case nil
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
101 (progn
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
102 (dbus-register-signal
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
103 :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
104 "NameOwnerChanged" 'dbus-name-owner-changed-handler)
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
105 (dbus-register-signal
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
106 :session dbus-service-dbus dbus-path-dbus dbus-interface-dbus
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
107 "NameOwnerChanged" 'dbus-name-owner-changed-handler))
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
108 (dbus-error))
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
109
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
110
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
111 ;;; D-Bus events.
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
112
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113 (defun dbus-check-event (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 "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
115 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
116
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
117 (dbus-event BUS SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS)
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
119 BUS identifies the D-Bus the signal is coming from. It is either
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
120 the symbol `:system' or the symbol `:session'. SERVICE and PATH
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
121 are the unique name and the object path of the D-Bus object
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
122 emitting the signal. INTERFACE and MEMBER denote the signal
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
123 which has been sent. HANDLER is the function which has been
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
124 registered for this signal. ARGS are the arguments passed to
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
125 HANDLER, when it is called during event handling in
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
126 `dbus-handle-event'.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 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
129 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 (when dbus-debug (message "DBus-Event %s" event))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 (unless (and (listp event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132 (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
133 ;; 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
134 (symbolp (nth 1 event))
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
135 ;; Service.
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
136 (stringp (nth 2 event))
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
137 ;; Object path.
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
138 (stringp (nth 3 event))
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
139 ;; Interface.
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
140 (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
141 ;; Member.
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
142 (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
143 ;; Handler.
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
144 (functionp (nth 6 event)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
145 (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
146
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147 ;;;###autoload
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148 (defun dbus-handle-event (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
149 "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
150 EVENT is a D-Bus event, see `dbus-check-event'. HANDLER, being
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
151 part of the event, is called with arguments ARGS."
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
152 (interactive "e")
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
153 ;; We don't want to raise an error, because this function is called
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
154 ;; in the event handling loop.
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
155 (condition-case nil
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
156 (progn
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
157 (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
158 (apply (nth 6 event) (nthcdr 7 event)))
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
159 (dbus-error)))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
160
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
161 (defun dbus-event-bus-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
162 "Return the bus name the event is coming from.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
163 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
164 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
165 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
166 formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
167 (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
168 (nth 1 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
170 (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
171 "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
172 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
173 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
174 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
175 (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
176 (nth 2 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
177
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178 (defun dbus-event-path-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 "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
180 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
181 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
182 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 (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
184 (nth 3 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186 (defun dbus-event-interface-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 "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
188 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
189 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
190 not well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 (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
192 (nth 4 event))
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 (defun dbus-event-member-name (event)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 "Return the member name the event is coming from.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196 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
197 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
198 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
199 well formed."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 (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
201 (nth 5 event))
87050
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
202
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
203
7d80e0f3d8f8 * net/dbus.el (dbus-hash-table=): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents: 86941
diff changeset
204 ;;; D-Bus registered names.
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 (defun dbus-list-activatable-names ()
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 "Return the D-Bus service names which can be activated as list.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 The result is a list of strings, which is nil when there are no
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 activatable service names at all."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 (dbus-call-method
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
212 :system dbus-service-dbus
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
213 dbus-path-dbus dbus-interface-dbus "ListActivatableNames")
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 (dbus-error)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 (defun dbus-list-names (bus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
217 "Return the service names registered at D-Bus BUS.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 The result is a list of strings, which is nil when there are no
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 registered service names at all. Well known names are strings like
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 \"org.freedesktop.DBus\". Names starting with \":\" are unique names
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 for services."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
223 (dbus-call-method
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
224 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
225 (dbus-error)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
226
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227 (defun dbus-list-known-names (bus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 "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
229 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
230 (let (result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
231 (dolist (name (dbus-list-names bus) result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 (unless (string-equal ":" (substring name 0 1))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
233 (add-to-list 'result name 'append)))))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
234
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235 (defun dbus-list-queued-owners (bus service)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236 "Return the unique names registered at D-Bus BUS and queued for SERVICE.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237 The result is a list of strings, or nil when there are no queued name
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238 owners service names at all."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
240 (dbus-call-method
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
241 bus dbus-service-dbus dbus-path-dbus
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
242 dbus-interface-dbus "ListQueuedOwners" service)
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
243 (dbus-error)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
244
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
245 (defun dbus-get-name-owner (bus service)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
246 "Return the name owner of SERVICE registered at D-Bus BUS.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
247 The result is either a string, or nil if there is no name owner."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
248 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
249 (dbus-call-method
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
250 bus dbus-service-dbus dbus-path-dbus
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
251 dbus-interface-dbus "GetNameOwner" service)
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
252 (dbus-error)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
253
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
254 (defun dbus-introspect (bus service path)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
255 "Return the introspection data of SERVICE in D-Bus BUS at object path PATH.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
256 The data are in XML format.
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 Example:
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
259
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
260 \(dbus-introspect
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
261 :system \"org.freedesktop.Hal\"
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
262 \"/org/freedesktop/Hal/devices/computer\")"
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
263 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
264 (dbus-call-method
87159
bcf59f3d73d7 * net/dbus.el (dbus-hash-table=): Fix for new hash table key
Michael Albinus <michael.albinus@gmx.de>
parents: 87093
diff changeset
265 bus service path dbus-interface-introspectable "Introspect")
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
266 (dbus-error)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
267
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
268 (if nil ;; Must be reworked. Shall we offer D-Bus signatures at all?
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
269 (defun dbus-get-signatures (bus interface signal)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
270 "Retrieve SIGNAL's type signatures from D-Bus.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
271 The result is a list of SIGNAL's type signatures. Example:
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
272
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
273 \(\"s\" \"b\" \"ai\"\)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
274
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
275 This list represents 3 parameters of SIGNAL. The first parameter
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
276 is of type string, the second parameter is of type boolean, and
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
277 the third parameter is of type array of integer.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
278
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
279 If INTERFACE or SIGNAL do not exist, or if they do not support
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
280 the D-Bus method org.freedesktop.DBus.Introspectable.Introspect,
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
281 the function returns nil."
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
282 (condition-case nil
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
283 (let ((introspect-xml
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
284 (with-temp-buffer
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
285 (insert (dbus-introspect bus interface))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
286 (xml-parse-region (point-min) (point-max))))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
287 node interfaces signals args result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
288 ;; Get the root node.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
289 (setq node (xml-node-name introspect-xml))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
290 ;; Get all interfaces.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
291 (setq interfaces (xml-get-children node 'interface))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
292 (while interfaces
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
293 (when (string-equal (xml-get-attribute (car interfaces) 'name)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
294 interface)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
295 ;; That's the requested interface. Check for signals.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 (setq signals (xml-get-children (car interfaces) 'signal))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
297 (while signals
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
298 (when (string-equal (xml-get-attribute (car signals) 'name)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
299 signal)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
300 ;; The signal we are looking for.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
301 (setq args (xml-get-children (car signals) 'arg))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
302 (while args
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
303 (unless (xml-get-attribute (car args) 'type)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
304 ;; This shouldn't happen, let's escape.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
305 (signal 'dbus-error ""))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
306 ;; We append the signature.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
307 (setq
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
308 result (append result
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309 (list (xml-get-attribute (car args) 'type))))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
310 (setq args (cdr args)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 (setq signals nil))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
312 (setq signals (cdr signals)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
313 (setq interfaces nil))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314 (setq interfaces (cdr interfaces)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
315 result)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
316 ;; We ignore `dbus-error'. There might be no introspectable interface.
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
317 (dbus-error nil)))
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
318 ) ;; (if nil ...
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
319
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
320 (provide 'dbus)
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
321
87053
f767f1ba8301 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87050
diff changeset
322 ;; arch-tag: a47caf84-9162-4811-90cc-5d388e37b9bd
86941
cbc23e728425 * net/dbus.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
323 ;;; dbus.el ends here