Mercurial > emacs
annotate src/dbusbind.c @ 91224:3ce31df2ea58
(fontset_find_font): Don't prefer a font of
supplementary charset.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 10 Dec 2007 06:23:41 +0000 |
parents | 1ddad0de60e5 |
children | e0ab56e63db8 |
rev | line source |
---|---|
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
1 /* Elisp bindings for D-Bus. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
2 Copyright (C) 2007 Free Software Foundation, Inc. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
3 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
4 This file is part of GNU Emacs. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
5 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 3, or (at your option) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
9 any later version. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
10 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
14 GNU General Public License for more details. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
15 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
19 Boston, MA 02110-1301, USA. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
20 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
21 #include "config.h" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
22 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
23 #ifdef HAVE_DBUS |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
24 #include <stdlib.h> |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
25 #include <dbus/dbus.h> |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
26 #include "lisp.h" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
27 #include "frame.h" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
28 #include "termhooks.h" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
29 #include "keyboard.h" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
30 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
31 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
32 /* Subroutines. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
33 Lisp_Object Qdbus_get_unique_name; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
34 Lisp_Object Qdbus_call_method; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
35 Lisp_Object Qdbus_send_signal; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
36 Lisp_Object Qdbus_register_signal; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
37 Lisp_Object Qdbus_unregister_signal; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
38 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
39 /* D-Bus error symbol. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
40 Lisp_Object Qdbus_error; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
41 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
42 /* Lisp symbols of the system and session buses. */ |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
43 Lisp_Object QCdbus_system_bus, QCdbus_session_bus; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
44 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
45 /* Hash table which keeps function definitions. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
46 Lisp_Object Vdbus_registered_functions_table; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
47 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
48 /* Whether to debug D-Bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
49 Lisp_Object Vdbus_debug; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
50 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
51 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
52 /* We use "xd_" and "XD_" as prefix for all internal symbols, because |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
53 we don't want to poison other namespaces with "dbus_". */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
54 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
55 /* Raise a Lisp error from a D-Bus error. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
56 #define XD_ERROR(error) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
57 { \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
58 char s[1024]; \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
59 strcpy (s, error.message); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
60 dbus_error_free (&error); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
61 /* Remove the trailing newline. */ \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
62 if (strchr (s, '\n') != NULL) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
63 s[strlen (s) - 1] = '\0'; \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
64 xsignal1 (Qdbus_error, build_string (s)); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
65 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
66 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
67 /* Macros for debugging. In order to enable them, build with |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
68 "make MYCPPFLAGS='-DDBUS_DEBUG'". */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
69 #ifdef DBUS_DEBUG |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
70 #define XD_DEBUG_MESSAGE(...) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
71 { \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
72 char s[1024]; \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
73 sprintf (s, __VA_ARGS__); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
74 printf ("%s: %s\n", __func__, s); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
75 message ("%s: %s", __func__, s); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
76 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
77 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
78 if (!valid_lisp_object_p (object)) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
79 { \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
80 XD_DEBUG_MESSAGE ("%s Assertion failure", __LINE__); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
81 xsignal1 (Qdbus_error, build_string ("Assertion failure")); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
82 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
83 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
84 #else /* !DBUS_DEBUG */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
85 #define XD_DEBUG_MESSAGE(...) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
86 if (!NILP (Vdbus_debug)) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
87 { \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
88 char s[1024]; \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
89 sprintf (s, __VA_ARGS__); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
90 message ("%s: %s", __func__, s); \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
91 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
92 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
93 #endif |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
94 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
95 /* Determine the DBusType of a given Lisp object. It is used to |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
96 convert Lisp objects, being arguments of `dbus-call-method' or |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
97 `dbus-send-signal', into corresponding C values appended as |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
98 arguments to a D-Bus message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
99 #define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
100 (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
101 (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
102 (INTEGERP (object)) ? DBUS_TYPE_INT32 : \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
103 (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
104 (STRINGP (object)) ? DBUS_TYPE_STRING : \ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
105 DBUS_TYPE_INVALID |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
106 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
107 /* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
108 as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
109 supported (yet). It is used to convert Lisp objects, being |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
110 arguments of `dbus-call-method' or `dbus-send-signal', into |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
111 corresponding C values appended as arguments to a D-Bus |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
112 message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
113 char * |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
114 xd_retrieve_value (dtype, object) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
115 uint dtype; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
116 Lisp_Object object; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
117 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
118 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
119 XD_DEBUG_VALID_LISP_OBJECT_P (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
120 switch (dtype) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
121 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
122 case DBUS_TYPE_BOOLEAN: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
123 XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
124 return (NILP (object)) ? (char *) FALSE : (char *) TRUE; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
125 case DBUS_TYPE_UINT32: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
126 XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
127 return (char *) XUINT (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
128 case DBUS_TYPE_INT32: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
129 XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
130 return (char *) XINT (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
131 case DBUS_TYPE_DOUBLE: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
132 XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
133 return (char *) XFLOAT (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
134 case DBUS_TYPE_STRING: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
135 XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
136 return SDATA (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
137 default: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
138 XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
139 return NULL; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
140 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
141 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
142 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
143 /* Retrieve C value from a DBusMessageIter structure ITER, and return |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
144 a converted Lisp object. The type DTYPE of the argument of the |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
145 D-Bus message must be a valid DBusType. Compound D-Bus types are |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
146 partly supported; they result always in a Lisp list. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
147 Lisp_Object |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
148 xd_retrieve_arg (dtype, iter) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
149 uint dtype; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
150 DBusMessageIter *iter; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
151 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
152 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
153 switch (dtype) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
154 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
155 case DBUS_TYPE_BOOLEAN: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
156 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
157 dbus_bool_t val; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
158 dbus_message_iter_get_basic (iter, &val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
159 XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
160 return (val == FALSE) ? Qnil : Qt; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
161 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
162 case DBUS_TYPE_INT32: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
163 case DBUS_TYPE_UINT32: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
164 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
165 dbus_uint32_t val; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
166 dbus_message_iter_get_basic (iter, &val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
167 XD_DEBUG_MESSAGE ("%d %d", dtype, val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
168 return make_number (val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
169 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
170 case DBUS_TYPE_STRING: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
171 case DBUS_TYPE_OBJECT_PATH: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
172 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
173 char *val; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
174 dbus_message_iter_get_basic (iter, &val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
175 XD_DEBUG_MESSAGE ("%d %s", dtype, val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
176 return build_string (val); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
177 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
178 case DBUS_TYPE_ARRAY: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
179 case DBUS_TYPE_VARIANT: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
180 case DBUS_TYPE_STRUCT: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
181 case DBUS_TYPE_DICT_ENTRY: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
182 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
183 Lisp_Object result; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
184 struct gcpro gcpro1; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
185 result = Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
186 GCPRO1 (result); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
187 DBusMessageIter subiter; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
188 int subtype; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
189 dbus_message_iter_recurse (iter, &subiter); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
190 while ((subtype = dbus_message_iter_get_arg_type (&subiter)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
191 != DBUS_TYPE_INVALID) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
192 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
193 result = Fcons (xd_retrieve_arg (subtype, &subiter), result); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
194 dbus_message_iter_next (&subiter); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
195 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
196 RETURN_UNGCPRO (Fnreverse (result)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
197 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
198 default: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
199 XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
200 return Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
201 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
202 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
203 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
204 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
205 /* Initialize D-Bus connection. BUS is a Lisp symbol, either :system |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
206 or :session. It tells which D-Bus to be initialized. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
207 DBusConnection * |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
208 xd_initialize (bus) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
209 Lisp_Object bus; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
210 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
211 DBusConnection *connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
212 DBusError derror; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
213 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
214 /* Parameter check. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
215 CHECK_SYMBOL (bus); |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
216 if (!((EQ (bus, QCdbus_system_bus)) || (EQ (bus, QCdbus_session_bus)))) |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
217 xsignal2 (Qdbus_error, build_string ("Wrong bus name"), bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
218 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
219 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
220 dbus_error_init (&derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
221 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
222 if (EQ (bus, QCdbus_system_bus)) |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
223 connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
224 else |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
225 connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
226 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
227 if (dbus_error_is_set (&derror)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
228 XD_ERROR (derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
229 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
230 if (connection == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
231 xsignal2 (Qdbus_error, build_string ("No connection"), bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
232 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
233 /* Return the result. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
234 return connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
235 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
236 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
237 DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
238 1, 1, 0, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
239 doc: /* Return the unique name of Emacs registered at D-Bus BUS as string. */) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
240 (bus) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
241 Lisp_Object bus; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
242 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
243 DBusConnection *connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
244 char name[1024]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
245 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
246 /* Check parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
247 CHECK_SYMBOL (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
248 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
249 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
250 connection = xd_initialize (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
251 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
252 /* Request the name. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
253 strcpy (name, dbus_bus_get_unique_name (connection)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
254 if (name == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
255 xsignal1 (Qdbus_error, build_string ("No unique name available")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
256 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
257 /* Return. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
258 return build_string (name); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
259 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
260 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
261 DEFUN ("dbus-call-method", Fdbus_call_method, Sdbus_call_method, 5, MANY, 0, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
262 doc: /* Call METHOD on the D-Bus BUS. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
263 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
264 BUS is either the symbol `:system' or the symbol `:session'. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
265 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
266 SERVICE is the D-Bus service name to be used. PATH is the D-Bus |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
267 object path SERVICE is registered at. INTERFACE is an interface |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
268 offered by SERVICE. It must provide METHOD. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
269 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
270 All other arguments ARGS are passed to METHOD as arguments. They are |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
271 converted into D-Bus types via the following rules: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
272 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
273 t and nil => DBUS_TYPE_BOOLEAN |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
274 number => DBUS_TYPE_UINT32 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
275 integer => DBUS_TYPE_INT32 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
276 float => DBUS_TYPE_DOUBLE |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
277 string => DBUS_TYPE_STRING |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
278 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
279 Other Lisp objects are not supported as input arguments of METHOD. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
280 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
281 `dbus-call-method' returns the resulting values of METHOD as a list of |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
282 Lisp objects. The type conversion happens the other direction as for |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
283 input arguments. Additionally to the types supported for input |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
284 arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
285 DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
286 are converted into a list of Lisp objects which correspond to the |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
287 elements of the D-Bus container. Example: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
288 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
289 \(dbus-call-method |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
290 :session "GetKeyField" "org.gnome.seahorse" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
291 "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
292 "openpgp:657984B8C7A966DD" "simple-name") |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
293 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
294 => (t ("Philip R. Zimmermann")) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
295 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
296 If the result of the METHOD call is just one value, the converted Lisp |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
297 object is returned instead of a list containing this single Lisp object. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
298 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
299 \(dbus-call-method |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
300 :system "GetPropertyString" "org.freedesktop.Hal" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
301 "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
302 "system.kernel.machine") |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
303 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
304 => "i686" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
305 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
306 usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
307 (nargs, args) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
308 int nargs; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
309 register Lisp_Object *args; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
310 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
311 Lisp_Object bus, method, service, path, interface; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
312 Lisp_Object result; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
313 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
314 DBusConnection *connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
315 DBusMessage *dmessage; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
316 DBusMessage *reply; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
317 DBusMessageIter iter; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
318 DBusError derror; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
319 uint dtype; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
320 int i; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
321 char *value; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
322 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
323 /* Check parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
324 bus = args[0]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
325 method = args[1]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
326 service = args[2]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
327 path = args[3]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
328 interface = args[4]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
329 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
330 CHECK_SYMBOL (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
331 CHECK_STRING (method); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
332 CHECK_STRING (service); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
333 CHECK_STRING (path); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
334 CHECK_STRING (interface); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
335 GCPRO5 (bus, method, service, path, interface); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
336 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
337 XD_DEBUG_MESSAGE ("%s %s %s %s", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
338 SDATA (method), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
339 SDATA (service), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
340 SDATA (path), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
341 SDATA (interface)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
342 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
343 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
344 connection = xd_initialize (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
345 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
346 /* Create the message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
347 dmessage = dbus_message_new_method_call (SDATA (service), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
348 SDATA (path), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
349 SDATA (interface), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
350 SDATA (method)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
351 if (dmessage == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
352 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
353 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
354 xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
355 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
356 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
357 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
358 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
359 /* Append parameters to the message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
360 for (i = 5; i < nargs; ++i) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
361 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
362 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
363 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
364 XD_DEBUG_MESSAGE ("Parameter%d %s", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
365 i-4, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
366 SDATA (format2 ("%s", args[i], Qnil))); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
367 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
368 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
369 if (dtype == DBUS_TYPE_INVALID) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
370 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
371 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
372 value = (char *) xd_retrieve_value (dtype, args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
373 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
374 if (!dbus_message_append_args (dmessage, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
375 dtype, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
376 &value, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
377 DBUS_TYPE_INVALID)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
378 xsignal2 (Qdbus_error, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
379 build_string ("Unable to append argument"), args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
380 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
381 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
382 /* Send the message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
383 dbus_error_init (&derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
384 reply = dbus_connection_send_with_reply_and_block (connection, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
385 dmessage, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
386 -1, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
387 &derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
388 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
389 if (dbus_error_is_set (&derror)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
390 XD_ERROR (derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
391 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
392 if (reply == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
393 xsignal1 (Qdbus_error, build_string ("No reply")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
394 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
395 XD_DEBUG_MESSAGE ("Message sent"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
396 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
397 /* Collect the results. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
398 result = Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
399 GCPRO1 (result); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
400 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
401 if (!dbus_message_iter_init (reply, &iter)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
402 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
403 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
404 xsignal1 (Qdbus_error, build_string ("Cannot read reply")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
405 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
406 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
407 /* Loop over the parameters of the D-Bus reply message. Construct a |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
408 Lisp list, which is returned by `dbus-call-method'. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
409 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
410 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
411 result = Fcons (xd_retrieve_arg (dtype, &iter), result); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
412 dbus_message_iter_next (&iter); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
413 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
414 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
415 /* Cleanup. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
416 dbus_message_unref (dmessage); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
417 dbus_message_unref (reply); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
418 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
419 /* Return the result. If there is only one single Lisp object, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
420 return it as-it-is, otherwise return the reversed list. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
421 if (XUINT (Flength (result)) == 1) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
422 RETURN_UNGCPRO (XCAR (result)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
423 else |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
424 RETURN_UNGCPRO (Fnreverse (result)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
425 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
426 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
427 DEFUN ("dbus-send-signal", Fdbus_send_signal, Sdbus_send_signal, 5, MANY, 0, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
428 doc: /* Send signal SIGNAL on the D-Bus BUS. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
429 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
430 BUS is either the symbol `:system' or the symbol `:session'. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
431 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
432 SERVICE is the D-Bus service name SIGNAL is sent from. PATH is the |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
433 D-Bus object path SERVICE is registered at. INTERFACE is an interface |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
434 offered by SERVICE. It must provide signal SIGNAL. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
435 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
436 All other arguments ARGS are passed to SIGNAL as arguments. They are |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
437 converted into D-Bus types via the following rules: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
438 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
439 t and nil => DBUS_TYPE_BOOLEAN |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
440 number => DBUS_TYPE_UINT32 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
441 integer => DBUS_TYPE_INT32 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
442 float => DBUS_TYPE_DOUBLE |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
443 string => DBUS_TYPE_STRING |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
444 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
445 Other Lisp objects are not supported as arguments of SIGNAL. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
446 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
447 Example: |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
448 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
449 \(dbus-send-signal |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
450 :session "Started" "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.emacs"))) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
451 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
452 usage: (dbus-send-signal BUS SIGNAL SERVICE PATH INTERFACE &rest ARGS) */) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
453 (nargs, args) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
454 int nargs; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
455 register Lisp_Object *args; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
456 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
457 Lisp_Object bus, signal, service, path, interface; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
458 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
459 DBusConnection *connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
460 DBusMessage *dmessage; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
461 uint dtype; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
462 int i; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
463 char *value; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
464 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
465 /* Check parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
466 bus = args[0]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
467 signal = args[1]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
468 service = args[2]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
469 path = args[3]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
470 interface = args[4]; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
471 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
472 CHECK_SYMBOL (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
473 CHECK_STRING (signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
474 CHECK_STRING (service); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
475 CHECK_STRING (path); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
476 CHECK_STRING (interface); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
477 GCPRO5 (bus, signal, service, path, interface); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
478 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
479 XD_DEBUG_MESSAGE ("%s %s %s %s", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
480 SDATA (signal), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
481 SDATA (service), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
482 SDATA (path), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
483 SDATA (interface)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
484 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
485 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
486 connection = xd_initialize (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
487 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
488 /* Create the message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
489 dmessage = dbus_message_new_signal (SDATA (path), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
490 SDATA (interface), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
491 SDATA (signal)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
492 if (dmessage == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
493 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
494 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
495 xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
496 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
497 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
498 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
499 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
500 /* Append parameters to the message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
501 for (i = 5; i < nargs; ++i) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
502 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
503 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
504 XD_DEBUG_MESSAGE ("Parameter%d %s", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
505 i-4, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
506 SDATA (format2 ("%s", args[i], Qnil))); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
507 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
508 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
509 if (dtype == DBUS_TYPE_INVALID) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
510 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
511 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
512 value = (char *) xd_retrieve_value (dtype, args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
513 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
514 if (!dbus_message_append_args (dmessage, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
515 dtype, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
516 &value, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
517 DBUS_TYPE_INVALID)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
518 xsignal2 (Qdbus_error, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
519 build_string ("Unable to append argument"), args[i]); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
520 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
521 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
522 /* Send the message. The message is just added to the outgoing |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
523 message queue. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
524 if (!dbus_connection_send (connection, dmessage, NULL)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
525 xsignal1 (Qdbus_error, build_string ("Cannot send message")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
526 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
527 /* Flush connection to ensure the message is handled. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
528 dbus_connection_flush (connection); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
529 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
530 XD_DEBUG_MESSAGE ("Signal sent"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
531 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
532 /* Cleanup. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
533 dbus_message_unref (dmessage); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
534 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
535 /* Return. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
536 return Qt; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
537 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
538 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
539 /* Read queued incoming message of the D-Bus BUS. BUS is a Lisp |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
540 symbol, either :system or :session. */ |
87092
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
541 Lisp_Object |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
542 xd_read_message (bus) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
543 Lisp_Object bus; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
544 { |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
545 Lisp_Object key; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
546 struct gcpro gcpro1; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
547 static struct input_event event; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
548 DBusConnection *connection; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
549 DBusMessage *dmessage; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
550 DBusMessageIter iter; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
551 uint dtype; |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
552 char service[1024], path[1024], interface[1024], member[1024]; |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
553 |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
554 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
555 connection = xd_initialize (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
556 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
557 /* Non blocking read of the next available message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
558 dbus_connection_read_write (connection, 0); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
559 dmessage = dbus_connection_pop_message (connection); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
560 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
561 /* Return if there is no queued message. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
562 if (dmessage == NULL) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
563 return; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
564 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
565 /* There is a message in the queue. Construct the D-Bus event. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
566 XD_DEBUG_MESSAGE ("Event received"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
567 EVENT_INIT (event); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
568 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
569 event.kind = DBUS_EVENT; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
570 event.frame_or_window = Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
571 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
572 /* Collect the parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
573 event.arg = Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
574 GCPRO1 (event.arg); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
575 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
576 if (!dbus_message_iter_init (dmessage, &iter)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
577 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
578 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
579 XD_DEBUG_MESSAGE ("Cannot read event"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
580 return; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
581 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
582 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
583 /* Loop over the resulting parameters. Construct a list. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
584 while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
585 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
586 event.arg = Fcons (xd_retrieve_arg (dtype, &iter), event.arg); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
587 dbus_message_iter_next (&iter); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
588 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
589 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
590 /* The arguments are stored in reverse order. Reorder them. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
591 event.arg = Fnreverse (event.arg); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
592 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
593 /* Read service, object path interface and member from the |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
594 message. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
595 strcpy (service, dbus_message_get_sender (dmessage)); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
596 strcpy (path, dbus_message_get_path (dmessage)); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
597 strcpy (interface, dbus_message_get_interface (dmessage)); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
598 strcpy (member, dbus_message_get_member (dmessage)); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
599 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
600 /* Add them to the event. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
601 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
602 event.arg); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
603 event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
604 event.arg); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
605 event.arg = Fcons ((path == NULL ? Qnil : build_string (path)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
606 event.arg); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
607 event.arg = Fcons ((service == NULL ? Qnil : build_string (service)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
608 event.arg); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
609 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
610 /* Add the bus symbol to the event. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
611 event.arg = Fcons (bus, event.arg); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
612 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
613 /* Add the registered function of the message. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
614 key = list3 (bus, |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
615 (interface == NULL ? Qnil : build_string (interface)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
616 (member == NULL ? Qnil : build_string (member))); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
617 event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
618 event.arg); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
619 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
620 /* Store it into the input event queue. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
621 kbd_buffer_store_event (&event); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
622 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
623 /* Cleanup. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
624 dbus_message_unref (dmessage); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
625 UNGCPRO; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
626 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
627 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
628 /* Read queued incoming messages from the system and session buses. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
629 void |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
630 xd_read_queued_messages () |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
631 { |
87092
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
632 |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
633 /* Vdbus_registered_functions_table will be made as hash table in |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
634 dbus.el. When it isn't loaded yet, it doesn't make sense to |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
635 handle D-Bus messages. Furthermore, we ignore all Lisp errors |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
636 during the call. */ |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
637 if (HASH_TABLE_P (Vdbus_registered_functions_table)) |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
638 { |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
639 internal_condition_case_1 (xd_read_message, QCdbus_system_bus, |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
640 Qerror, Fidentity); |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
641 internal_condition_case_1 (xd_read_message, QCdbus_session_bus, |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
642 Qerror, Fidentity); |
1ddad0de60e5
* dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents:
87053
diff
changeset
|
643 } |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
644 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
645 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
646 DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
647 6, 6, 0, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
648 doc: /* Register for signal SIGNAL on the D-Bus BUS. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
649 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
650 BUS is either the symbol `:system' or the symbol `:session'. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
651 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
652 SERVICE is the D-Bus service name used by the sending D-Bus object. |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
653 It can be either a known name or the unique name of the D-Bus object |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
654 sending the signal. When SERVICE is nil, related signals from all |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
655 D-Bus objects shall be accepted. |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
656 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
657 PATH is the D-Bus object path SERVICE is registered. It can also be |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
658 nil if the path name of incoming signals shall not be checked. |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
659 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
660 INTERFACE is an interface offered by SERVICE. It must provide SIGNAL. |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
661 HANDLER is a Lisp function to be called when the signal is received. |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
662 It must accept as arguments the values SIGNAL is sending. INTERFACE, |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
663 SIGNAL and HANDLER must not be nil. Example: |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
664 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
665 \(defun my-signal-handler (device) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
666 (message "Device %s added" device)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
667 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
668 \(dbus-register-signal |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
669 :system "DeviceAdded" |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
670 (dbus-get-name-owner :system "org.freedesktop.Hal") |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
671 "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager" |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
672 'my-signal-handler) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
673 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
674 => (:system "org.freedesktop.Hal.Manager" "DeviceAdded") |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
675 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
676 `dbus-register-signal' returns an object, which can be used in |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
677 `dbus-unregister-signal' for removing the registration. */) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
678 (bus, signal, service, path, interface, handler) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
679 Lisp_Object bus, signal, service, path, interface, handler; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
680 { |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
681 Lisp_Object key; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
682 DBusConnection *connection; |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
683 char rule[1024]; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
684 DBusError derror; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
685 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
686 /* Check parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
687 CHECK_SYMBOL (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
688 CHECK_STRING (signal); |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
689 if (!NILP (service)) CHECK_STRING (service); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
690 if (!NILP (path)) CHECK_STRING (path); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
691 CHECK_STRING (interface); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
692 CHECK_SYMBOL (handler); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
693 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
694 /* Open a connection to the bus. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
695 connection = xd_initialize (bus); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
696 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
697 /* Create a rule to receive related signals. */ |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
698 sprintf (rule, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
699 "type='signal',interface='%s',member=%s%", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
700 SDATA (interface), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
701 SDATA (signal)); |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
702 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
703 /* Add service and path to the rule if they are non-nil. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
704 if (!NILP (service)) |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
705 sprintf (rule, "%s,sender='%s'%", rule, SDATA (service)); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
706 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
707 if (!NILP (path)) |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
708 sprintf (rule, "%s,path='%s'", rule, SDATA (path)); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
709 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
710 /* Add the rule to the bus. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
711 dbus_error_init (&derror); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
712 dbus_bus_add_match (connection, rule, &derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
713 if (dbus_error_is_set (&derror)) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
714 XD_ERROR (derror); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
715 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
716 XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
717 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
718 /* Create a hash table entry. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
719 key = list3 (bus, interface, signal); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
720 Fputhash (key, handler, Vdbus_registered_functions_table); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
721 XD_DEBUG_MESSAGE ("\"%s\" registered with handler \"%s\"", |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
722 SDATA (format2 ("%s", key, Qnil)), |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
723 SDATA (format2 ("%s", handler, Qnil))); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
724 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
725 /* Return key. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
726 return key; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
727 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
728 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
729 DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
730 1, 1, 0, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
731 doc: /* Unregister OBJECT from the D-Bus. |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
732 OBJECT must be the result of a preceding `dbus-register-signal' call. */) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
733 (object) |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
734 Lisp_Object object; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
735 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
736 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
737 /* Check parameters. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
738 CHECK_SYMBOL (object); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
739 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
740 XD_DEBUG_MESSAGE ("\"%s\" unregistered with handler \"%s\"", |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
741 SDATA (format2 ("%s", object, Qnil)), |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
742 SDATA (format2 ("%s", Fsymbol_function (object), Qnil))); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
743 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
744 /* Unintern the signal symbol. */ |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
745 Fremhash (object, Vdbus_registered_functions_table); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
746 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
747 /* Return. */ |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
748 return Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
749 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
750 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
751 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
752 void |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
753 syms_of_dbusbind () |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
754 { |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
755 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
756 Qdbus_get_unique_name = intern ("dbus-get-unique-name"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
757 staticpro (&Qdbus_get_unique_name); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
758 defsubr (&Sdbus_get_unique_name); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
759 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
760 Qdbus_call_method = intern ("dbus-call-method"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
761 staticpro (&Qdbus_call_method); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
762 defsubr (&Sdbus_call_method); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
763 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
764 Qdbus_send_signal = intern ("dbus-send-signal"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
765 staticpro (&Qdbus_send_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
766 defsubr (&Sdbus_send_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
767 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
768 Qdbus_register_signal = intern ("dbus-register-signal"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
769 staticpro (&Qdbus_register_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
770 defsubr (&Sdbus_register_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
771 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
772 Qdbus_unregister_signal = intern ("dbus-unregister-signal"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
773 staticpro (&Qdbus_unregister_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
774 defsubr (&Sdbus_unregister_signal); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
775 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
776 Qdbus_error = intern ("dbus-error"); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
777 staticpro (&Qdbus_error); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
778 Fput (Qdbus_error, Qerror_conditions, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
779 list2 (Qdbus_error, Qerror)); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
780 Fput (Qdbus_error, Qerror_message, |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
781 build_string ("D-Bus error")); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
782 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
783 QCdbus_system_bus = intern (":system"); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
784 staticpro (&QCdbus_system_bus); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
785 |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
786 QCdbus_session_bus = intern (":session"); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
787 staticpro (&QCdbus_session_bus); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
788 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
789 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
790 doc: /* Hash table of registered functions for D-Bus. |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
791 The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
792 either the symbol `:system' or the symbol `:session'. INTERFACE is a |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
793 string which denotes a D-Bus interface, and MEMBER, also a string, is |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
794 either a method or a signal INTERFACE is offering. |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
795 |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
796 The value in the hash table a the function to be called when a D-Bus |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
797 message, which matches the key criteria, arrives. */); |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
798 /* We initialize Vdbus_registered_functions_table in dbus.el, |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
799 because we need to define a hash table function first. */ |
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
800 Vdbus_registered_functions_table = Qnil; |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
801 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
802 DEFVAR_LISP ("dbus-debug", &Vdbus_debug, |
87051
1da959e791de
* dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents:
86940
diff
changeset
|
803 doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); |
86940
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
804 #ifdef DBUS_DEBUG |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
805 Vdbus_debug = Qt; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
806 #else |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
807 Vdbus_debug = Qnil; |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
808 #endif |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
809 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
810 Fprovide (intern ("dbusbind"), Qnil); |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
811 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
812 } |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
813 |
2dd672d9fe75
* config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
814 #endif /* HAVE_DBUS */ |
87053 | 815 |
816 /* arch-tag: 0e828477-b571-4fe4-b559-5c9211bc14b8 | |
817 (do not change this comment) */ |