annotate src/dbusbind.c @ 103746:143908a11f1f

xterm.c (handle_one_xevent): Only call x_check_fullscreen on the first MapNotify.
author Jan Djärv <jan.h.d@swipnet.se>
date Tue, 07 Jul 2009 08:38:44 +0000
parents 25fc47c9b012
children 50effbe728da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
100951
e038c1a8307c Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 99098
diff changeset
2 Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
86940
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
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94057
diff changeset
6 GNU Emacs is free software: you can redistribute it and/or modify
86940
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
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94057
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94057
diff changeset
9 (at your option) any later version.
86940
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
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94057
diff changeset
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
18
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19 #include "config.h"
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 #ifdef HAVE_DBUS
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22 #include <stdlib.h>
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
23 #include <stdio.h>
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24 #include <dbus/dbus.h>
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25 #include "lisp.h"
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26 #include "frame.h"
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 #include "termhooks.h"
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28 #include "keyboard.h"
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29
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 /* Subroutines. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32 Lisp_Object Qdbus_get_unique_name;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 Lisp_Object Qdbus_call_method;
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
34 Lisp_Object Qdbus_call_method_asynchronously;
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
35 Lisp_Object Qdbus_method_return_internal;
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
36 Lisp_Object Qdbus_method_error_internal;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 Lisp_Object Qdbus_send_signal;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 Lisp_Object Qdbus_register_signal;
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
39 Lisp_Object Qdbus_register_method;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41 /* D-Bus error symbol. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
42 Lisp_Object Qdbus_error;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44 /* 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
45 Lisp_Object QCdbus_system_bus, QCdbus_session_bus;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
47 /* Lisp symbol for method call timeout. */
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
48 Lisp_Object QCdbus_timeout;
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
49
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
50 /* Lisp symbols of D-Bus types. */
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
51 Lisp_Object QCdbus_type_byte, QCdbus_type_boolean;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
52 Lisp_Object QCdbus_type_int16, QCdbus_type_uint16;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
53 Lisp_Object QCdbus_type_int32, QCdbus_type_uint32;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
54 Lisp_Object QCdbus_type_int64, QCdbus_type_uint64;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
55 Lisp_Object QCdbus_type_double, QCdbus_type_string;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
56 Lisp_Object QCdbus_type_object_path, QCdbus_type_signature;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
57 Lisp_Object QCdbus_type_array, QCdbus_type_variant;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
58 Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry;
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
59
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
60 /* 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
61 Lisp_Object Vdbus_registered_functions_table;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 /* Whether to debug D-Bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
64 Lisp_Object Vdbus_debug;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
66 /* Whether we are reading a D-Bus event. */
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
67 int xd_in_read_queued_messages = 0;
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
68
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
69
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
70 /* 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
71 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
72
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
73 /* Raise a signal. If we are reading events, we cannot signal; we
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
74 throw to xd_read_queued_messages then. */
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
75 #define XD_SIGNAL1(arg) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
76 do { \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
77 if (xd_in_read_queued_messages) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
78 Fthrow (Qdbus_error, Qnil); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
79 else \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
80 xsignal1 (Qdbus_error, arg); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
81 } while (0)
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
82
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
83 #define XD_SIGNAL2(arg1, arg2) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
84 do { \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
85 if (xd_in_read_queued_messages) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
86 Fthrow (Qdbus_error, Qnil); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
87 else \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
88 xsignal2 (Qdbus_error, arg1, arg2); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
89 } while (0)
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
90
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
91 #define XD_SIGNAL3(arg1, arg2, arg3) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
92 do { \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
93 if (xd_in_read_queued_messages) \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
94 Fthrow (Qdbus_error, Qnil); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
95 else \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
96 xsignal3 (Qdbus_error, arg1, arg2, arg3); \
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
97 } while (0)
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
98
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
99 /* Raise a Lisp error from a D-Bus ERROR. */
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100 #define XD_ERROR(error) \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
101 do { \
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102 char s[1024]; \
97797
14fccbb34a16 * dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and
Michael Albinus <michael.albinus@gmx.de>
parents: 97211
diff changeset
103 strncpy (s, error.message, 1023); \
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
104 dbus_error_free (&error); \
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
105 /* Remove the trailing newline. */ \
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106 if (strchr (s, '\n') != NULL) \
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
107 s[strlen (s) - 1] = '\0'; \
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
108 XD_SIGNAL1 (build_string (s)); \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
109 } while (0)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111 /* Macros for debugging. In order to enable them, build with
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
112 "make MYCPPFLAGS='-DDBUS_DEBUG -Wall'". */
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113 #ifdef DBUS_DEBUG
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114 #define XD_DEBUG_MESSAGE(...) \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
115 do { \
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116 char s[1024]; \
97797
14fccbb34a16 * dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and
Michael Albinus <michael.albinus@gmx.de>
parents: 97211
diff changeset
117 snprintf (s, 1023, __VA_ARGS__); \
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118 printf ("%s: %s\n", __func__, s); \
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
119 message ("%s: %s", __func__, s); \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
120 } while (0)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
122 do { \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
123 if (!valid_lisp_object_p (object)) \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
124 { \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
125 XD_DEBUG_MESSAGE ("%d Assertion failure", __LINE__); \
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
126 XD_SIGNAL1 (build_string ("Assertion failure")); \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
127 } \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
128 } while (0)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 #else /* !DBUS_DEBUG */
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
131 #define XD_DEBUG_MESSAGE(...) \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
132 do { \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
133 if (!NILP (Vdbus_debug)) \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
134 { \
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
135 char s[1024]; \
97797
14fccbb34a16 * dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and
Michael Albinus <michael.albinus@gmx.de>
parents: 97211
diff changeset
136 snprintf (s, 1023, __VA_ARGS__); \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
137 message ("%s: %s", __func__, s); \
87493
42bd83957313 *** empty log message ***
Michael Albinus <michael.albinus@gmx.de>
parents: 87490
diff changeset
138 } \
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
139 } while (0)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 #define XD_DEBUG_VALID_LISP_OBJECT_P(object)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
141 #endif
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
143 /* Check whether TYPE is a basic DBusType. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
144 #define XD_BASIC_DBUS_TYPE(type) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
145 ((type == DBUS_TYPE_BYTE) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
146 || (type == DBUS_TYPE_BOOLEAN) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
147 || (type == DBUS_TYPE_INT16) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
148 || (type == DBUS_TYPE_UINT16) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
149 || (type == DBUS_TYPE_INT32) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
150 || (type == DBUS_TYPE_UINT32) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
151 || (type == DBUS_TYPE_INT64) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
152 || (type == DBUS_TYPE_UINT64) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
153 || (type == DBUS_TYPE_DOUBLE) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
154 || (type == DBUS_TYPE_STRING) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
155 || (type == DBUS_TYPE_OBJECT_PATH) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
156 || (type == DBUS_TYPE_SIGNATURE))
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
157
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
158 /* This was a macro. On Solaris 2.11 it was said to compile for
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
159 hours, when optimzation is enabled. So we have transferred it into
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
160 a function. */
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
161 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
162 of the predefined D-Bus type symbols. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
163 static int
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
164 xd_symbol_to_dbus_type (object)
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
165 Lisp_Object object;
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
166 {
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
167 return
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
168 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
169 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
170 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
171 : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
172 : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
173 : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
174 : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
175 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
176 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
177 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
178 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
179 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
180 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
181 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
182 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
183 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
184 : DBUS_TYPE_INVALID);
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
185 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
186
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
187 /* Check whether a Lisp symbol is a predefined D-Bus type symbol. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
188 #define XD_DBUS_TYPE_P(object) \
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
189 (SYMBOLP (object) && ((xd_symbol_to_dbus_type (object) != DBUS_TYPE_INVALID)))
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
190
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
191 /* Determine the DBusType of a given Lisp OBJECT. It is used to
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192 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
193 `dbus-send-signal', into corresponding C values appended as
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 arguments to a D-Bus message. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
195 #define XD_OBJECT_TO_DBUS_TYPE(object) \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
196 ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
197 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
198 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
199 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
200 : (STRINGP (object)) ? DBUS_TYPE_STRING \
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
201 : (XD_DBUS_TYPE_P (object)) ? xd_symbol_to_dbus_type (object) \
98901
f98d4eaeba07 * dbusbind.c (XD_OBJECT_TO_DBUS_TYPE): Handle simple type symbols
Michael Albinus <michael.albinus@gmx.de>
parents: 98783
diff changeset
202 : (CONSP (object)) \
f98d4eaeba07 * dbusbind.c (XD_OBJECT_TO_DBUS_TYPE): Handle simple type symbols
Michael Albinus <michael.albinus@gmx.de>
parents: 98783
diff changeset
203 ? ((XD_DBUS_TYPE_P (CAR_SAFE (object))) \
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
204 ? ((XD_BASIC_DBUS_TYPE (xd_symbol_to_dbus_type (CAR_SAFE (object)))) \
98901
f98d4eaeba07 * dbusbind.c (XD_OBJECT_TO_DBUS_TYPE): Handle simple type symbols
Michael Albinus <michael.albinus@gmx.de>
parents: 98783
diff changeset
205 ? DBUS_TYPE_ARRAY \
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
206 : xd_symbol_to_dbus_type (CAR_SAFE (object))) \
98901
f98d4eaeba07 * dbusbind.c (XD_OBJECT_TO_DBUS_TYPE): Handle simple type symbols
Michael Albinus <michael.albinus@gmx.de>
parents: 98783
diff changeset
207 : DBUS_TYPE_ARRAY) \
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
208 : DBUS_TYPE_INVALID)
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
209
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
210 /* Return a list pointer which does not have a Lisp symbol as car. */
93156
3ef12fa772f2 * dbusbind.c (xd_read_message): Removed extra copying of message
Michael Albinus <michael.albinus@gmx.de>
parents: 87972
diff changeset
211 #define XD_NEXT_VALUE(object) \
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
212 ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object)
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
213
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
214 /* Compute SIGNATURE of OBJECT. It must have a form that it can be
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
215 used in dbus_message_iter_open_container. DTYPE is the DBusType
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
216 the object is related to. It is passed as argument, because it
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
217 cannot be detected in basic type objects, when they are preceded by
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
218 a type symbol. PARENT_TYPE is the DBusType of a container this
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
219 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
220 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
221 static void
97797
14fccbb34a16 * dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and
Michael Albinus <michael.albinus@gmx.de>
parents: 97211
diff changeset
222 xd_signature (signature, dtype, parent_type, object)
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
223 char *signature;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
224 unsigned int dtype, parent_type;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
225 Lisp_Object object;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
226 {
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
227 unsigned int subtype;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
228 Lisp_Object elt;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
229 char x[DBUS_MAXIMUM_SIGNATURE_LENGTH];
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
230
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
231 elt = object;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
232
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
233 switch (dtype)
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
234 {
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
235 case DBUS_TYPE_BYTE:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
236 case DBUS_TYPE_UINT16:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
237 case DBUS_TYPE_UINT32:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
238 case DBUS_TYPE_UINT64:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
239 CHECK_NATNUM (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
240 sprintf (signature, "%c", dtype);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
241 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
242
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
243 case DBUS_TYPE_BOOLEAN:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
244 if (!EQ (object, Qt) && !EQ (object, Qnil))
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
245 wrong_type_argument (intern ("booleanp"), object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
246 sprintf (signature, "%c", dtype);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
247 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
248
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
249 case DBUS_TYPE_INT16:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
250 case DBUS_TYPE_INT32:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
251 case DBUS_TYPE_INT64:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
252 CHECK_NUMBER (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
253 sprintf (signature, "%c", dtype);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
254 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
255
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
256 case DBUS_TYPE_DOUBLE:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
257 CHECK_FLOAT (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
258 sprintf (signature, "%c", dtype);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
259 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
260
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
261 case DBUS_TYPE_STRING:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
262 case DBUS_TYPE_OBJECT_PATH:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
263 case DBUS_TYPE_SIGNATURE:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
264 CHECK_STRING (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
265 sprintf (signature, "%c", dtype);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
266 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
267
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
268 case DBUS_TYPE_ARRAY:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
269 /* Check that all list elements have the same D-Bus type. For
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
270 complex element types, we just check the container type, not
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
271 the whole element's signature. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
272 CHECK_CONS (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
273
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
274 /* Type symbol is optional. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
275 if (EQ (QCdbus_type_array, CAR_SAFE (elt)))
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
276 elt = XD_NEXT_VALUE (elt);
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
277
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
278 /* If the array is empty, DBUS_TYPE_STRING is the default
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
279 element type. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
280 if (NILP (elt))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
281 {
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
282 subtype = DBUS_TYPE_STRING;
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
283 strcpy (x, DBUS_TYPE_STRING_AS_STRING);
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
284 }
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
285 else
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
286 {
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
287 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
288 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
289 }
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
290
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
291 /* If the element type is DBUS_TYPE_SIGNATURE, and this is the
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
292 only element, the value of this element is used as he array's
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
293 element signature. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
294 if ((subtype == DBUS_TYPE_SIGNATURE)
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
295 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt)))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
296 && NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
297 strcpy (x, SDATA (CAR_SAFE (XD_NEXT_VALUE (elt))));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
298
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
299 while (!NILP (elt))
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
300 {
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
301 if (subtype != XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
302 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
303 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
304 }
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
305
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
306 sprintf (signature, "%c%s", dtype, x);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
307 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
308
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
309 case DBUS_TYPE_VARIANT:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
310 /* Check that there is exactly one list element. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
311 CHECK_CONS (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
312
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
313 elt = XD_NEXT_VALUE (elt);
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
314 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
315 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
316
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
317 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
318 wrong_type_argument (intern ("D-Bus"),
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
319 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
320
87497
1d88fa50b198 * dbusbind.c (xd_signature): Signature of variant is just "v".
Magnus Henoch <mange@freemail.hu>
parents: 87493
diff changeset
321 sprintf (signature, "%c", dtype);
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
322 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
323
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
324 case DBUS_TYPE_STRUCT:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
325 /* A struct list might contain any number of elements with
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
326 different types. No further check needed. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
327 CHECK_CONS (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
328
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
329 elt = XD_NEXT_VALUE (elt);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
330
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
331 /* Compose the signature from the elements. It is enclosed by
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
332 parentheses. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
333 sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR );
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
334 while (!NILP (elt))
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
335 {
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
336 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
337 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
338 strcat (signature, x);
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
339 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
340 }
98434
e5f33aa05b97 * dbusbind.c (xd_signature): Use strcat instead of sprintf.
Michael Albinus <michael.albinus@gmx.de>
parents: 97797
diff changeset
341 strcat (signature, DBUS_STRUCT_END_CHAR_AS_STRING);
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
342 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
343
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
344 case DBUS_TYPE_DICT_ENTRY:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
345 /* Check that there are exactly two list elements, and the first
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
346 one is of basic type. The dictionary entry itself must be an
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
347 element of an array. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
348 CHECK_CONS (object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
349
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
350 /* Check the parent object type. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
351 if (parent_type != DBUS_TYPE_ARRAY)
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
352 wrong_type_argument (intern ("D-Bus"), object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
353
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
354 /* Compose the signature from the elements. It is enclosed by
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
355 curly braces. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
356 sprintf (signature, "%c", DBUS_DICT_ENTRY_BEGIN_CHAR);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
357
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
358 /* First element. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
359 elt = XD_NEXT_VALUE (elt);
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
360 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
361 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
362 strcat (signature, x);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
363
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
364 if (!XD_BASIC_DBUS_TYPE (subtype))
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
365 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt)));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
366
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
367 /* Second element. */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
368 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
369 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
370 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
371 strcat (signature, x);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
372
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
373 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
374 wrong_type_argument (intern ("D-Bus"),
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
375 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
376
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
377 /* Closing signature. */
98434
e5f33aa05b97 * dbusbind.c (xd_signature): Use strcat instead of sprintf.
Michael Albinus <michael.albinus@gmx.de>
parents: 97797
diff changeset
378 strcat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
379 break;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
380
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
381 default:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
382 wrong_type_argument (intern ("D-Bus"), object);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
383 }
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
384
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
385 XD_DEBUG_MESSAGE ("%s", signature);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
386 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
387
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
388 /* Append C value, extracted from Lisp OBJECT, to iteration ITER.
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
389 DTYPE must be a valid DBusType. It is used to convert Lisp
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
390 objects, being arguments of `dbus-call-method' or
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
391 `dbus-send-signal', into corresponding C values appended as
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
392 arguments to a D-Bus message. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
393 static void
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
394 xd_append_arg (dtype, object, iter)
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
395 unsigned int dtype;
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
396 Lisp_Object object;
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
397 DBusMessageIter *iter;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
398 {
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
399 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
400 DBusMessageIter subiter;
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
401
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
402 if (XD_BASIC_DBUS_TYPE (dtype))
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
403 switch (dtype)
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
404 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
405 case DBUS_TYPE_BYTE:
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
406 {
87533
d24ee3180427 * dbusbind.c (xd_append_arg): Use unsigned char instead of
Magnus Henoch <mange@freemail.hu>
parents: 87501
diff changeset
407 unsigned char val = XUINT (object) & 0xFF;
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
408 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
409 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
410 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
411 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
412 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
413
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
414 case DBUS_TYPE_BOOLEAN:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
415 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
416 dbus_bool_t val = (NILP (object)) ? FALSE : TRUE;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
417 XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
418 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
419 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
420 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
421 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
422
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
423 case DBUS_TYPE_INT16:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
424 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
425 dbus_int16_t val = XINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
426 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
427 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
428 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
429 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
430 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
431
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
432 case DBUS_TYPE_UINT16:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
433 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
434 dbus_uint16_t val = XUINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
435 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
436 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
437 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
438 return;
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
439 }
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
440
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
441 case DBUS_TYPE_INT32:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
442 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
443 dbus_int32_t val = XINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
444 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
445 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
446 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
447 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
448 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
449
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
450 case DBUS_TYPE_UINT32:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
451 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
452 dbus_uint32_t val = XUINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
453 XD_DEBUG_MESSAGE ("%c %u", dtype, val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
454 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
455 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
456 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
457 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
458
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
459 case DBUS_TYPE_INT64:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
460 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
461 dbus_int64_t val = XINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
462 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
463 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
464 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
465 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
466 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
467
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
468 case DBUS_TYPE_UINT64:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
469 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
470 dbus_uint64_t val = XUINT (object);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
471 XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
472 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
473 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
474 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
475 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
476
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
477 case DBUS_TYPE_DOUBLE:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
478 XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT_DATA (object));
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
479 if (!dbus_message_iter_append_basic (iter, dtype,
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
480 &XFLOAT_DATA (object)))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
481 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
482 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
483
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
484 case DBUS_TYPE_STRING:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
485 case DBUS_TYPE_OBJECT_PATH:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
486 case DBUS_TYPE_SIGNATURE:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
487 {
97797
14fccbb34a16 * dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and
Michael Albinus <michael.albinus@gmx.de>
parents: 97211
diff changeset
488 char *val = SDATA (Fstring_make_unibyte (object));
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
489 XD_DEBUG_MESSAGE ("%c %s", dtype, val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
490 if (!dbus_message_iter_append_basic (iter, dtype, &val))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
491 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
492 return;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
493 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
494 }
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
495
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
496 else /* Compound types. */
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
497 {
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
498
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
499 /* All compound types except array have a type symbol. For
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
500 array, it is optional. Skip it. */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
501 if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object))))
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
502 object = XD_NEXT_VALUE (object);
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
503
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
504 /* Open new subiteration. */
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
505 switch (dtype)
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
506 {
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
507 case DBUS_TYPE_ARRAY:
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
508 /* An array has only elements of the same type. So it is
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
509 sufficient to check the first element's signature
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
510 only. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
511
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
512 if (NILP (object))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
513 /* If the array is empty, DBUS_TYPE_STRING is the default
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
514 element type. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
515 strcpy (signature, DBUS_TYPE_STRING_AS_STRING);
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
516
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
517 else
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
518 /* If the element type is DBUS_TYPE_SIGNATURE, and this is
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
519 the only element, the value of this element is used as
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
520 the array's element signature. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
521 if ((XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
522 == DBUS_TYPE_SIGNATURE)
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
523 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object)))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
524 && NILP (CDR_SAFE (XD_NEXT_VALUE (object))))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
525 {
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
526 strcpy (signature, SDATA (CAR_SAFE (XD_NEXT_VALUE (object))));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
527 object = CDR_SAFE (XD_NEXT_VALUE (object));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
528 }
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
529
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
530 else
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
531 xd_signature (signature,
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
532 XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object)),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
533 dtype, CAR_SAFE (XD_NEXT_VALUE (object)));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
534
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
535 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
536 SDATA (format2 ("%s", object, Qnil)));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
537 if (!dbus_message_iter_open_container (iter, dtype,
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
538 signature, &subiter))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
539 XD_SIGNAL3 (build_string ("Cannot open container"),
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
540 make_number (dtype), build_string (signature));
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
541 break;
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
542
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
543 case DBUS_TYPE_VARIANT:
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
544 /* A variant has just one element. */
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
545 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object)),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
546 dtype, CAR_SAFE (XD_NEXT_VALUE (object)));
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
547
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
548 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
549 SDATA (format2 ("%s", object, Qnil)));
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
550 if (!dbus_message_iter_open_container (iter, dtype,
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
551 signature, &subiter))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
552 XD_SIGNAL3 (build_string ("Cannot open container"),
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
553 make_number (dtype), build_string (signature));
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
554 break;
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
555
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
556 case DBUS_TYPE_STRUCT:
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
557 case DBUS_TYPE_DICT_ENTRY:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
558 /* These containers do not require a signature. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
559 XD_DEBUG_MESSAGE ("%c %s", dtype,
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
560 SDATA (format2 ("%s", object, Qnil)));
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
561 if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
562 XD_SIGNAL2 (build_string ("Cannot open container"),
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
563 make_number (dtype));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
564 break;
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
565 }
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
566
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
567 /* Loop over list elements. */
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
568 while (!NILP (object))
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
569 {
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
570 dtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object));
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
571 object = XD_NEXT_VALUE (object);
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
572
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
573 xd_append_arg (dtype, CAR_SAFE (object), &subiter);
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
574
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
575 object = CDR_SAFE (object);
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
576 }
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
577
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
578 /* Close the subiteration. */
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
579 if (!dbus_message_iter_close_container (iter, &subiter))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
580 XD_SIGNAL2 (build_string ("Cannot close container"),
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
581 make_number (dtype));
86940
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 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
584
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
585 /* 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
586 a converted Lisp object. The type DTYPE of the argument of the
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
587 D-Bus message must be a valid DBusType. Compound D-Bus types
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
588 result always in a Lisp list. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
589 static Lisp_Object
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
590 xd_retrieve_arg (dtype, iter)
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
591 unsigned int dtype;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
592 DBusMessageIter *iter;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
593 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
594
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
595 switch (dtype)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
596 {
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
597 case DBUS_TYPE_BYTE:
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
598 {
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
599 unsigned int val;
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
600 dbus_message_iter_get_basic (iter, &val);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
601 val = val & 0xFF;
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
602 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
603 return make_number (val);
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
604 }
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
605
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
606 case DBUS_TYPE_BOOLEAN:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
607 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
608 dbus_bool_t val;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
609 dbus_message_iter_get_basic (iter, &val);
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
610 XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
611 return (val == FALSE) ? Qnil : Qt;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
612 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
613
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
614 case DBUS_TYPE_INT16:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
615 case DBUS_TYPE_UINT16:
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
616 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
617 dbus_uint16_t val;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
618 dbus_message_iter_get_basic (iter, &val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
619 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
620 return make_number (val);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
621 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
622
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
623 case DBUS_TYPE_INT32:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
624 case DBUS_TYPE_UINT32:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
625 {
87972
f42bf2712087 * dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
Michael Albinus <michael.albinus@gmx.de>
parents: 87887
diff changeset
626 /* Assignment to EMACS_INT stops GCC whining about limited
f42bf2712087 * dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
Michael Albinus <michael.albinus@gmx.de>
parents: 87887
diff changeset
627 range of data type. */
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
628 dbus_uint32_t val;
87972
f42bf2712087 * dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
Michael Albinus <michael.albinus@gmx.de>
parents: 87887
diff changeset
629 EMACS_INT val1;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
630 dbus_message_iter_get_basic (iter, &val);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
631 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
87972
f42bf2712087 * dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
Michael Albinus <michael.albinus@gmx.de>
parents: 87887
diff changeset
632 val1 = val;
f42bf2712087 * dbusbind.c (xd_retrieve_arg): Pacify GCC on x86_64 GNU/Linux.
Michael Albinus <michael.albinus@gmx.de>
parents: 87887
diff changeset
633 return make_fixnum_or_float (val1);
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
634 }
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
635
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
636 case DBUS_TYPE_INT64:
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
637 case DBUS_TYPE_UINT64:
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
638 {
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
639 dbus_uint64_t val;
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
640 dbus_message_iter_get_basic (iter, &val);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
641 XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val);
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
642 return make_fixnum_or_float (val);
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
643 }
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
644
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
645 case DBUS_TYPE_DOUBLE:
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
646 {
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
647 double val;
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
648 dbus_message_iter_get_basic (iter, &val);
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
649 XD_DEBUG_MESSAGE ("%c %f", dtype, val);
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
650 return make_float (val);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
651 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
652
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
653 case DBUS_TYPE_STRING:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
654 case DBUS_TYPE_OBJECT_PATH:
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
655 case DBUS_TYPE_SIGNATURE:
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
656 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
657 char *val;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
658 dbus_message_iter_get_basic (iter, &val);
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
659 XD_DEBUG_MESSAGE ("%c %s", dtype, val);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
660 return build_string (val);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
661 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
662
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
663 case DBUS_TYPE_ARRAY:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
664 case DBUS_TYPE_VARIANT:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
665 case DBUS_TYPE_STRUCT:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
666 case DBUS_TYPE_DICT_ENTRY:
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 Lisp_Object result;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
669 struct gcpro gcpro1;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
670 result = Qnil;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
671 GCPRO1 (result);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
672 DBusMessageIter subiter;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
673 int subtype;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
674 dbus_message_iter_recurse (iter, &subiter);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
675 while ((subtype = dbus_message_iter_get_arg_type (&subiter))
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
676 != DBUS_TYPE_INVALID)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
677 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
678 result = Fcons (xd_retrieve_arg (subtype, &subiter), result);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
679 dbus_message_iter_next (&subiter);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
680 }
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
681 XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", result, Qnil)));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
682 RETURN_UNGCPRO (Fnreverse (result));
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
683 }
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
684
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
685 default:
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
686 XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
687 return Qnil;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
688 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
689 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
690
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
691 /* 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
692 or :session. It tells which D-Bus to be initialized. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
693 static DBusConnection *
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
694 xd_initialize (bus)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
695 Lisp_Object bus;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
696 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
697 DBusConnection *connection;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
698 DBusError derror;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
699
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
700 /* Parameter check. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
701 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
702 if (!((EQ (bus, QCdbus_system_bus)) || (EQ (bus, QCdbus_session_bus))))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
703 XD_SIGNAL2 (build_string ("Wrong bus name"), bus);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
704
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
705 /* Open a connection to the bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
706 dbus_error_init (&derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
707
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
708 if (EQ (bus, QCdbus_system_bus))
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
709 connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
710 else
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
711 connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
712
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 if (connection == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
717 XD_SIGNAL2 (build_string ("No connection"), bus);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
718
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
719 /* Return the result. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
720 return connection;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
721 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
722
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
723 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
724 1, 1, 0,
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
725 doc: /* Return the unique name of Emacs registered at D-Bus BUS. */)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
726 (bus)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
727 Lisp_Object bus;
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 DBusConnection *connection;
94057
a5a4ff3b6cc3 * dbusbind.c (dbus-get-unique-name): Remove extra copying of name string.
Michael Albinus <michael.albinus@gmx.de>
parents: 93420
diff changeset
730 const char *name;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
731
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
732 /* Check parameters. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
733 CHECK_SYMBOL (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
734
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
735 /* Open a connection to the bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
736 connection = xd_initialize (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
737
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
738 /* Request the name. */
94057
a5a4ff3b6cc3 * dbusbind.c (dbus-get-unique-name): Remove extra copying of name string.
Michael Albinus <michael.albinus@gmx.de>
parents: 93420
diff changeset
739 name = dbus_bus_get_unique_name (connection);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
740 if (name == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
741 XD_SIGNAL1 (build_string ("No unique name available"));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
742
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
743 /* Return. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
744 return build_string (name);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
745 }
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 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
748 doc: /* Call METHOD on the D-Bus BUS.
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 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
751
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
752 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
753 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
754 offered by SERVICE. It must provide METHOD.
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
755
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
756 If the parameter `:timeout' is given, the following integer TIMEOUT
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
757 specifies the maximun number of milliseconds the method call must
94057
a5a4ff3b6cc3 * dbusbind.c (dbus-get-unique-name): Remove extra copying of name string.
Michael Albinus <michael.albinus@gmx.de>
parents: 93420
diff changeset
758 return. The default value is 25.000. If the method call doesn't
a5a4ff3b6cc3 * dbusbind.c (dbus-get-unique-name): Remove extra copying of name string.
Michael Albinus <michael.albinus@gmx.de>
parents: 93420
diff changeset
759 return in time, a D-Bus error is raised.
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
760
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
761 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
762 converted into D-Bus types via the following rules:
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 t and nil => DBUS_TYPE_BOOLEAN
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
765 number => DBUS_TYPE_UINT32
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
766 integer => DBUS_TYPE_INT32
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
767 float => DBUS_TYPE_DOUBLE
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
768 string => DBUS_TYPE_STRING
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
769 list => DBUS_TYPE_ARRAY
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
770
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
771 All arguments can be preceded by a type symbol. For details about
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
772 type symbols, see Info node `(dbus)Type Conversion'.
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
773
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
774 `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
775 Lisp objects. The type conversion happens the other direction as for
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
776 input arguments. It follows the mapping rules:
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
777
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
778 DBUS_TYPE_BOOLEAN => t or nil
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
779 DBUS_TYPE_BYTE => number
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
780 DBUS_TYPE_UINT16 => number
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
781 DBUS_TYPE_INT16 => integer
87363
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
782 DBUS_TYPE_UINT32 => number or float
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
783 DBUS_TYPE_INT32 => integer or float
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
784 DBUS_TYPE_UINT64 => number or float
28bc3dd3635f * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
Michael Albinus <michael.albinus@gmx.de>
parents: 87361
diff changeset
785 DBUS_TYPE_INT64 => integer or float
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
786 DBUS_TYPE_DOUBLE => float
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
787 DBUS_TYPE_STRING => string
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
788 DBUS_TYPE_OBJECT_PATH => string
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
789 DBUS_TYPE_SIGNATURE => string
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
790 DBUS_TYPE_ARRAY => list
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
791 DBUS_TYPE_VARIANT => list
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
792 DBUS_TYPE_STRUCT => list
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
793 DBUS_TYPE_DICT_ENTRY => list
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
794
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
795 Example:
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
796
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
797 \(dbus-call-method
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
798 :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
799 "org.gnome.seahorse.Keys" "GetKeyField"
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
800 "openpgp:657984B8C7A966DD" "simple-name")
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 => (t ("Philip R. Zimmermann"))
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
803
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
804 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
805 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
806
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
807 \(dbus-call-method
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
808 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer"
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
809 "org.freedesktop.Hal.Device" "GetPropertyString"
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
810 "system.kernel.machine")
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 => "i686"
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
813
98783
9ae4dbce33ae * dbusbind.c (Fdbus_call_method): Unbreak usage line.
Magnus Henoch <mange@freemail.hu>
parents: 98434
diff changeset
814 usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
815 (nargs, args)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
816 int nargs;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
817 register Lisp_Object *args;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
818 {
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
819 Lisp_Object bus, service, path, interface, method;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
820 Lisp_Object result;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
821 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
822 DBusConnection *connection;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
823 DBusMessage *dmessage;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
824 DBusMessage *reply;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
825 DBusMessageIter iter;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
826 DBusError derror;
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
827 unsigned int dtype;
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
828 int timeout = -1;
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
829 int i = 5;
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
830 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
831
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
832 /* Check parameters. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
833 bus = args[0];
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
834 service = args[1];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
835 path = args[2];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
836 interface = args[3];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
837 method = args[4];
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
838
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
839 CHECK_SYMBOL (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
840 CHECK_STRING (service);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
841 CHECK_STRING (path);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
842 CHECK_STRING (interface);
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
843 CHECK_STRING (method);
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
844 GCPRO5 (bus, service, path, interface, method);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
845
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
846 XD_DEBUG_MESSAGE ("%s %s %s %s",
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
847 SDATA (service),
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
848 SDATA (path),
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
849 SDATA (interface),
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
850 SDATA (method));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
851
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
852 /* Open a connection to the bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
853 connection = xd_initialize (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
854
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
855 /* Create the message. */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
856 dmessage = dbus_message_new_method_call (SDATA (service),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
857 SDATA (path),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
858 SDATA (interface),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
859 SDATA (method));
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
860 UNGCPRO;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
861 if (dmessage == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
862 XD_SIGNAL1 (build_string ("Unable to create a new message"));
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
863
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
864 /* Check for timeout parameter. */
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
865 if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout)))
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
866 {
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
867 CHECK_NATNUM (args[i+1]);
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
868 timeout = XUINT (args[i+1]);
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
869 i = i+2;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
870 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
871
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
872 /* Initialize parameter list of message. */
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
873 dbus_message_iter_init_append (dmessage, &iter);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
874
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
875 /* Append parameters to the message. */
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
876 for (; i < nargs; ++i)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
877 {
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
878 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
879 if (XD_DBUS_TYPE_P (args[i]))
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
880 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
881 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
882 XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
883 XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
884 SDATA (format2 ("%s", args[i], Qnil)),
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
885 SDATA (format2 ("%s", args[i+1], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
886 ++i;
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
887 }
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
888 else
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
889 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
890 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
891 XD_DEBUG_MESSAGE ("Parameter%d %s", i-4,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
892 SDATA (format2 ("%s", args[i], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
893 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
894
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
895 /* Check for valid signature. We use DBUS_TYPE_INVALID as
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
896 indication that there is no parent type. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
897 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
898
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
899 xd_append_arg (dtype, args[i], &iter);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
900 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
901
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
902 /* Send the message. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
903 dbus_error_init (&derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
904 reply = dbus_connection_send_with_reply_and_block (connection,
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
905 dmessage,
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
906 timeout,
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
907 &derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
908
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
909 if (dbus_error_is_set (&derror))
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
910 XD_ERROR (derror);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
911
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
912 if (reply == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
913 XD_SIGNAL1 (build_string ("No reply"));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
914
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
915 XD_DEBUG_MESSAGE ("Message sent");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
916
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
917 /* Collect the results. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
918 result = Qnil;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
919 GCPRO1 (result);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
920
87535
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
921 if (dbus_message_iter_init (reply, &iter))
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
922 {
87535
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
923 /* Loop over the parameters of the D-Bus reply message. Construct a
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
924 Lisp list, which is returned by `dbus-call-method'. */
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
925 while ((dtype = dbus_message_iter_get_arg_type (&iter))
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
926 != DBUS_TYPE_INVALID)
87535
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
927 {
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
928 result = Fcons (xd_retrieve_arg (dtype, &iter), result);
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
929 dbus_message_iter_next (&iter);
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
930 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
931 }
87535
6dcf49457032 * dbusbind.c (Fdbus_call_method): Handle the case of no returned
Magnus Henoch <mange@freemail.hu>
parents: 87533
diff changeset
932 else
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
933 {
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
934 /* No arguments: just return nil. */
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
935 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
936
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
937 /* Cleanup. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
938 dbus_message_unref (dmessage);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
939 dbus_message_unref (reply);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
941 /* 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
942 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
943 if (XUINT (Flength (result)) == 1)
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
944 RETURN_UNGCPRO (CAR_SAFE (result));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
945 else
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
946 RETURN_UNGCPRO (Fnreverse (result));
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
947 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
948
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
949 DEFUN ("dbus-call-method-asynchronously", Fdbus_call_method_asynchronously,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
950 Sdbus_call_method_asynchronously, 6, MANY, 0,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
951 doc: /* Call METHOD on the D-Bus BUS asynchronously.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
952
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
953 BUS is either the symbol `:system' or the symbol `:session'.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
954
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
955 SERVICE is the D-Bus service name to be used. PATH is the D-Bus
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
956 object path SERVICE is registered at. INTERFACE is an interface
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
957 offered by SERVICE. It must provide METHOD.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
958
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
959 HANDLER is a Lisp function, which is called when the corresponding
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
960 return message has arrived.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
961
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
962 If the parameter `:timeout' is given, the following integer TIMEOUT
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
963 specifies the maximun number of milliseconds the method call must
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
964 return. The default value is 25.000. If the method call doesn't
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
965 return in time, a D-Bus error is raised.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
966
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
967 All other arguments ARGS are passed to METHOD as arguments. They are
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
968 converted into D-Bus types via the following rules:
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
969
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
970 t and nil => DBUS_TYPE_BOOLEAN
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
971 number => DBUS_TYPE_UINT32
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
972 integer => DBUS_TYPE_INT32
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
973 float => DBUS_TYPE_DOUBLE
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
974 string => DBUS_TYPE_STRING
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
975 list => DBUS_TYPE_ARRAY
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
976
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
977 All arguments can be preceded by a type symbol. For details about
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
978 type symbols, see Info node `(dbus)Type Conversion'.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
979
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
980 The function returns a key into the hash table
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
981 `dbus-registered-functions-table'. The corresponding entry in the
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
982 hash table is removed, when the return message has been arrived, and
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
983 HANDLER is called.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
984
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
985 Example:
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
986
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
987 \(dbus-call-method-asynchronously
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
988 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer"
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
989 "org.freedesktop.Hal.Device" "GetPropertyString" 'message
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
990 "system.kernel.machine")
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
991
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
992 => (:system 2)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
993
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
994 -| i686
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
995
98783
9ae4dbce33ae * dbusbind.c (Fdbus_call_method): Unbreak usage line.
Magnus Henoch <mange@freemail.hu>
parents: 98434
diff changeset
996 usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */)
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
997 (nargs, args)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
998 int nargs;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
999 register Lisp_Object *args;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1000 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1001 Lisp_Object bus, service, path, interface, method, handler;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1002 Lisp_Object result;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1003 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1004 DBusConnection *connection;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1005 DBusMessage *dmessage;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1006 DBusMessageIter iter;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1007 unsigned int dtype;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1008 int timeout = -1;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1009 int i = 6;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1010 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1011
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1012 /* Check parameters. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1013 bus = args[0];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1014 service = args[1];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1015 path = args[2];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1016 interface = args[3];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1017 method = args[4];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1018 handler = args[5];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1019
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1020 CHECK_SYMBOL (bus);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1021 CHECK_STRING (service);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1022 CHECK_STRING (path);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1023 CHECK_STRING (interface);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1024 CHECK_STRING (method);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1025 if (!FUNCTIONP (handler))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1026 wrong_type_argument (intern ("functionp"), handler);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1027 GCPRO6 (bus, service, path, interface, method, handler);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1028
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1029 XD_DEBUG_MESSAGE ("%s %s %s %s",
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1030 SDATA (service),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1031 SDATA (path),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1032 SDATA (interface),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1033 SDATA (method));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1034
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1035 /* Open a connection to the bus. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1036 connection = xd_initialize (bus);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1037
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1038 /* Create the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1039 dmessage = dbus_message_new_method_call (SDATA (service),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1040 SDATA (path),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1041 SDATA (interface),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1042 SDATA (method));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1043 if (dmessage == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1044 XD_SIGNAL1 (build_string ("Unable to create a new message"));
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1045
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1046 /* Check for timeout parameter. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1047 if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout)))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1048 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1049 CHECK_NATNUM (args[i+1]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1050 timeout = XUINT (args[i+1]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1051 i = i+2;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1052 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1053
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1054 /* Initialize parameter list of message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1055 dbus_message_iter_init_append (dmessage, &iter);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1056
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1057 /* Append parameters to the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1058 for (; i < nargs; ++i)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1059 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1060 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1061 if (XD_DBUS_TYPE_P (args[i]))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1062 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1063 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1064 XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1065 XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1066 SDATA (format2 ("%s", args[i], Qnil)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1067 SDATA (format2 ("%s", args[i+1], Qnil)));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1068 ++i;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1069 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1070 else
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1071 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1072 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1073 XD_DEBUG_MESSAGE ("Parameter%d %s", i-4,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1074 SDATA (format2 ("%s", args[i], Qnil)));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1075 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1076
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1077 /* Check for valid signature. We use DBUS_TYPE_INVALID as
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1078 indication that there is no parent type. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1079 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1080
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1081 xd_append_arg (dtype, args[i], &iter);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1082 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1083
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1084 /* Send the message. The message is just added to the outgoing
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1085 message queue. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1086 if (!dbus_connection_send_with_reply (connection, dmessage, NULL, timeout))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1087 XD_SIGNAL1 (build_string ("Cannot send message"));
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1088
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1089 XD_DEBUG_MESSAGE ("Message sent");
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1090
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1091 /* The result is the key in Vdbus_registered_functions_table. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1092 result = (list2 (bus, make_number (dbus_message_get_serial (dmessage))));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1093
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1094 /* Create a hash table entry. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1095 Fputhash (result, handler, Vdbus_registered_functions_table);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1096
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1097 /* Cleanup. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1098 dbus_message_unref (dmessage);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1099
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1100 /* Return the result. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1101 RETURN_UNGCPRO (result);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1102 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1103
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1104 DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1105 Sdbus_method_return_internal,
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1106 3, MANY, 0,
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1107 doc: /* Return for message SERIAL on the D-Bus BUS.
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1108 This is an internal function, it shall not be used outside dbus.el.
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1109
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1110 usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */)
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1111 (nargs, args)
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1112 int nargs;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1113 register Lisp_Object *args;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1114 {
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1115 Lisp_Object bus, serial, service;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1116 struct gcpro gcpro1, gcpro2, gcpro3;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1117 DBusConnection *connection;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1118 DBusMessage *dmessage;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1119 DBusMessageIter iter;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1120 unsigned int dtype;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1121 int i;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1122 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1123
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1124 /* Check parameters. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1125 bus = args[0];
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1126 serial = args[1];
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1127 service = args[2];
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1128
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1129 CHECK_SYMBOL (bus);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1130 CHECK_NUMBER (serial);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1131 CHECK_STRING (service);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1132 GCPRO3 (bus, serial, service);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1133
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1134 XD_DEBUG_MESSAGE ("%d %s ", XUINT (serial), SDATA (service));
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1135
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1136 /* Open a connection to the bus. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1137 connection = xd_initialize (bus);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1138
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1139 /* Create the message. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1140 dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1141 if ((dmessage == NULL)
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1142 || (!dbus_message_set_reply_serial (dmessage, XUINT (serial)))
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1143 || (!dbus_message_set_destination (dmessage, SDATA (service))))
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1144 {
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1145 UNGCPRO;
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1146 XD_SIGNAL1 (build_string ("Unable to create a return message"));
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1147 }
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1148
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1149 UNGCPRO;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1150
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1151 /* Initialize parameter list of message. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1152 dbus_message_iter_init_append (dmessage, &iter);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1153
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1154 /* Append parameters to the message. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1155 for (i = 3; i < nargs; ++i)
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1156 {
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1157 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1158 if (XD_DBUS_TYPE_P (args[i]))
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1159 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1160 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1161 XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1162 XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1163 SDATA (format2 ("%s", args[i], Qnil)),
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1164 SDATA (format2 ("%s", args[i+1], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1165 ++i;
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1166 }
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1167 else
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1168 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1169 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1170 XD_DEBUG_MESSAGE ("Parameter%d %s", i-2,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1171 SDATA (format2 ("%s", args[i], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1172 }
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1173
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1174 /* Check for valid signature. We use DBUS_TYPE_INVALID as
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1175 indication that there is no parent type. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1176 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1177
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1178 xd_append_arg (dtype, args[i], &iter);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1179 }
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1180
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1181 /* Send the message. The message is just added to the outgoing
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1182 message queue. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1183 if (!dbus_connection_send (connection, dmessage, NULL))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1184 XD_SIGNAL1 (build_string ("Cannot send message"));
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1185
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1186 /* Flush connection to ensure the message is handled. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1187 dbus_connection_flush (connection);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1188
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1189 XD_DEBUG_MESSAGE ("Message sent");
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1190
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1191 /* Cleanup. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1192 dbus_message_unref (dmessage);
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1193
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1194 /* Return. */
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1195 return Qt;
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1196 }
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1197
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1198 DEFUN ("dbus-method-error-internal", Fdbus_method_error_internal,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1199 Sdbus_method_error_internal,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1200 3, MANY, 0,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1201 doc: /* Return error message for message SERIAL on the D-Bus BUS.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1202 This is an internal function, it shall not be used outside dbus.el.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1203
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1204 usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1205 (nargs, args)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1206 int nargs;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1207 register Lisp_Object *args;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1208 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1209 Lisp_Object bus, serial, service;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1210 struct gcpro gcpro1, gcpro2, gcpro3;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1211 DBusConnection *connection;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1212 DBusMessage *dmessage;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1213 DBusMessageIter iter;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1214 unsigned int dtype;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1215 int i;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1216 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1217
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1218 /* Check parameters. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1219 bus = args[0];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1220 serial = args[1];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1221 service = args[2];
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1222
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1223 CHECK_SYMBOL (bus);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1224 CHECK_NUMBER (serial);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1225 CHECK_STRING (service);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1226 GCPRO3 (bus, serial, service);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1227
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1228 XD_DEBUG_MESSAGE ("%d %s ", XUINT (serial), SDATA (service));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1229
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1230 /* Open a connection to the bus. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1231 connection = xd_initialize (bus);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1232
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1233 /* Create the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1234 dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1235 if ((dmessage == NULL)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1236 || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1237 || (!dbus_message_set_reply_serial (dmessage, XUINT (serial)))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1238 || (!dbus_message_set_destination (dmessage, SDATA (service))))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1239 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1240 UNGCPRO;
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1241 XD_SIGNAL1 (build_string ("Unable to create a error message"));
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1242 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1243
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1244 UNGCPRO;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1245
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1246 /* Initialize parameter list of message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1247 dbus_message_iter_init_append (dmessage, &iter);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1248
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1249 /* Append parameters to the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1250 for (i = 3; i < nargs; ++i)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1251 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1252 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1253 if (XD_DBUS_TYPE_P (args[i]))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1254 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1255 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1256 XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1257 XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1258 SDATA (format2 ("%s", args[i], Qnil)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1259 SDATA (format2 ("%s", args[i+1], Qnil)));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1260 ++i;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1261 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1262 else
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1263 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1264 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1265 XD_DEBUG_MESSAGE ("Parameter%d %s", i-2,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1266 SDATA (format2 ("%s", args[i], Qnil)));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1267 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1268
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1269 /* Check for valid signature. We use DBUS_TYPE_INVALID as
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1270 indication that there is no parent type. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1271 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1272
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1273 xd_append_arg (dtype, args[i], &iter);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1274 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1275
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1276 /* Send the message. The message is just added to the outgoing
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1277 message queue. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1278 if (!dbus_connection_send (connection, dmessage, NULL))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1279 XD_SIGNAL1 (build_string ("Cannot send message"));
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1280
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1281 /* Flush connection to ensure the message is handled. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1282 dbus_connection_flush (connection);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1283
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1284 XD_DEBUG_MESSAGE ("Message sent");
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1285
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1286 /* Cleanup. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1287 dbus_message_unref (dmessage);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1288
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1289 /* Return. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1290 return Qt;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1291 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1292
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1293 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
1294 doc: /* Send signal SIGNAL on the D-Bus BUS.
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1295
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1296 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
1297
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1298 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
1299 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
1300 offered by SERVICE. It must provide signal SIGNAL.
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1301
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1302 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
1303 converted into D-Bus types via the following rules:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1304
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1305 t and nil => DBUS_TYPE_BOOLEAN
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1306 number => DBUS_TYPE_UINT32
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1307 integer => DBUS_TYPE_INT32
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1308 float => DBUS_TYPE_DOUBLE
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1309 string => DBUS_TYPE_STRING
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1310 list => DBUS_TYPE_ARRAY
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1311
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1312 All arguments can be preceded by a type symbol. For details about
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1313 type symbols, see Info node `(dbus)Type Conversion'.
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1314
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1315 Example:
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1316
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1317 \(dbus-send-signal
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1318 :session "org.gnu.Emacs" "/org/gnu/Emacs"
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1319 "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs")
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1320
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1321 usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1322 (nargs, args)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1323 int nargs;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1324 register Lisp_Object *args;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1325 {
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1326 Lisp_Object bus, service, path, interface, signal;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1327 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1328 DBusConnection *connection;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1329 DBusMessage *dmessage;
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1330 DBusMessageIter iter;
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
1331 unsigned int dtype;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1332 int i;
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1333 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1334
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1335 /* Check parameters. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1336 bus = args[0];
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1337 service = args[1];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1338 path = args[2];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1339 interface = args[3];
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1340 signal = args[4];
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1341
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1342 CHECK_SYMBOL (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1343 CHECK_STRING (service);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1344 CHECK_STRING (path);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1345 CHECK_STRING (interface);
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1346 CHECK_STRING (signal);
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1347 GCPRO5 (bus, service, path, interface, signal);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1348
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1349 XD_DEBUG_MESSAGE ("%s %s %s %s",
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1350 SDATA (service),
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1351 SDATA (path),
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1352 SDATA (interface),
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1353 SDATA (signal));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1354
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1355 /* Open a connection to the bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1356 connection = xd_initialize (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1357
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1358 /* Create the message. */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1359 dmessage = dbus_message_new_signal (SDATA (path),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1360 SDATA (interface),
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1361 SDATA (signal));
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
1362 UNGCPRO;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1363 if (dmessage == NULL)
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1364 XD_SIGNAL1 (build_string ("Unable to create a new message"));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1365
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1366 /* Initialize parameter list of message. */
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1367 dbus_message_iter_init_append (dmessage, &iter);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1368
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1369 /* Append parameters to the message. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1370 for (i = 5; i < nargs; ++i)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1371 {
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1372 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1373 if (XD_DBUS_TYPE_P (args[i]))
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1374 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1375 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1376 XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1377 XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1378 SDATA (format2 ("%s", args[i], Qnil)),
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1379 SDATA (format2 ("%s", args[i+1], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1380 ++i;
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1381 }
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1382 else
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1383 {
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1384 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1385 XD_DEBUG_MESSAGE ("Parameter%d %s", i-4,
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1386 SDATA (format2 ("%s", args[i], Qnil)));
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1387 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1388
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1389 /* Check for valid signature. We use DBUS_TYPE_INVALID as
87361
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1390 indication that there is no parent type. */
0b387233ea86 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
Michael Albinus <michael.albinus@gmx.de>
parents: 87343
diff changeset
1391 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1392
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1393 xd_append_arg (dtype, args[i], &iter);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1394 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1395
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1396 /* 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
1397 message queue. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1398 if (!dbus_connection_send (connection, dmessage, NULL))
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1399 XD_SIGNAL1 (build_string ("Cannot send message"));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1400
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1401 /* Flush connection to ensure the message is handled. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1402 dbus_connection_flush (connection);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1403
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1404 XD_DEBUG_MESSAGE ("Signal sent");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1405
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1406 /* Cleanup. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1407 dbus_message_unref (dmessage);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1408
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1409 /* Return. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1410 return Qt;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1411 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1412
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1413 /* 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
1414 symbol, either :system or :session. */
103612
25fc47c9b012 * dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
Michael Albinus <michael.albinus@gmx.de>
parents: 101276
diff changeset
1415 static Lisp_Object
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1416 xd_read_message (bus)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1417 Lisp_Object bus;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1418 {
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1419 Lisp_Object args, key, value;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1420 struct gcpro gcpro1;
87501
38cad849184d * dbusbind.c (xd_read_message): Use non-static input_event struct.
Michael Albinus <michael.albinus@gmx.de>
parents: 87497
diff changeset
1421 struct input_event event;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1422 DBusConnection *connection;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1423 DBusMessage *dmessage;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1424 DBusMessageIter iter;
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
1425 unsigned int dtype;
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1426 int mtype, serial;
93156
3ef12fa772f2 * dbusbind.c (xd_read_message): Removed extra copying of message
Michael Albinus <michael.albinus@gmx.de>
parents: 87972
diff changeset
1427 const char *uname, *path, *interface, *member;
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1428
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1429 /* Open a connection to the bus. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1430 connection = xd_initialize (bus);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1431
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1432 /* Non blocking read of the next available message. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1433 dbus_connection_read_write (connection, 0);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1434 dmessage = dbus_connection_pop_message (connection);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1435
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1436 /* Return if there is no queued message. */
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1437 if (dmessage == NULL)
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1438 return Qnil;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1439
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1440 /* Collect the parameters. */
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1441 args = Qnil;
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1442 GCPRO1 (args);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1443
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1444 /* Loop over the resulting parameters. Construct a list. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1445 if (dbus_message_iter_init (dmessage, &iter))
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1446 {
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1447 while ((dtype = dbus_message_iter_get_arg_type (&iter))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1448 != DBUS_TYPE_INVALID)
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1449 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1450 args = Fcons (xd_retrieve_arg (dtype, &iter), args);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1451 dbus_message_iter_next (&iter);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1452 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1453 /* The arguments are stored in reverse order. Reorder them. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1454 args = Fnreverse (args);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1455 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1456
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1457 /* Read message type, message serial, unique name, object path,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1458 interface and member from the message. */
97211
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1459 mtype = dbus_message_get_type (dmessage);
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1460 serial =
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1461 ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1462 || (mtype == DBUS_MESSAGE_TYPE_ERROR))
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1463 ? dbus_message_get_reply_serial (dmessage)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1464 : dbus_message_get_serial (dmessage);
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1465 uname = dbus_message_get_sender (dmessage);
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1466 path = dbus_message_get_path (dmessage);
93156
3ef12fa772f2 * dbusbind.c (xd_read_message): Removed extra copying of message
Michael Albinus <michael.albinus@gmx.de>
parents: 87972
diff changeset
1467 interface = dbus_message_get_interface (dmessage);
97211
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1468 member = dbus_message_get_member (dmessage);
93156
3ef12fa772f2 * dbusbind.c (xd_read_message): Removed extra copying of message
Michael Albinus <michael.albinus@gmx.de>
parents: 87972
diff changeset
1469
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1470 XD_DEBUG_MESSAGE ("Event received: %s %d %s %s %s %s %s",
97211
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1471 (mtype == DBUS_MESSAGE_TYPE_INVALID)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1472 ? "DBUS_MESSAGE_TYPE_INVALID"
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1473 : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1474 ? "DBUS_MESSAGE_TYPE_METHOD_CALL"
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1475 : (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1476 ? "DBUS_MESSAGE_TYPE_METHOD_RETURN"
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1477 : (mtype == DBUS_MESSAGE_TYPE_ERROR)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1478 ? "DBUS_MESSAGE_TYPE_ERROR"
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1479 : "DBUS_MESSAGE_TYPE_SIGNAL",
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1480 serial, uname, path, interface, member,
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1481 SDATA (format2 ("%s", args, Qnil)));
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1482
97211
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1483 if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
194ecdbbd8a3 * dbusbind.c (xd_read_message): Handle D-Bus error messages.
Michael Albinus <michael.albinus@gmx.de>
parents: 97165
diff changeset
1484 || (mtype == DBUS_MESSAGE_TYPE_ERROR))
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1485 {
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1486 /* Search for a registered function of the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1487 key = list2 (bus, make_number (serial));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1488 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1489
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1490 /* There shall be exactly one entry. Construct an event. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1491 if (NILP (value))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1492 goto cleanup;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1493
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1494 /* Remove the entry. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1495 Fremhash (key, Vdbus_registered_functions_table);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1496
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1497 /* Construct an event. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1498 EVENT_INIT (event);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1499 event.kind = DBUS_EVENT;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1500 event.frame_or_window = Qnil;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1501 event.arg = Fcons (value, args);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1502 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1503
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1504 else /* (mtype != DBUS_MESSAGE_TYPE_METHOD_RETURN) */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1505 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1506 /* Vdbus_registered_functions_table requires non-nil interface
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1507 and member. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1508 if ((interface == NULL) || (member == NULL))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1509 goto cleanup;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1510
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1511 /* Search for a registered function of the message. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1512 key = list3 (bus, build_string (interface), build_string (member));
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1513 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1514
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1515 /* Loop over the registered functions. Construct an event. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1516 while (!NILP (value))
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1517 {
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1518 key = CAR_SAFE (value);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1519 /* key has the structure (UNAME SERVICE PATH HANDLER). */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1520 if (((uname == NULL)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1521 || (NILP (CAR_SAFE (key)))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1522 || (strcmp (uname, SDATA (CAR_SAFE (key))) == 0))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1523 && ((path == NULL)
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1524 || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1525 || (strcmp (path,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1526 SDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1527 == 0))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1528 && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))))))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1529 {
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1530 EVENT_INIT (event);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1531 event.kind = DBUS_EVENT;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1532 event.frame_or_window = Qnil;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1533 event.arg = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1534 args);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1535 break;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1536 }
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1537 value = CDR_SAFE (value);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1538 }
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1539
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1540 if (NILP (value))
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1541 goto cleanup;
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1542 }
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1543
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1544 /* Add type, serial, uname, path, interface and member to the event. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1545 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1546 event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1547 event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1548 event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1549 event.arg = Fcons ((path == NULL ? Qnil : build_string (path)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1550 event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1551 event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)),
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1552 event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1553 event.arg = Fcons (make_number (serial), event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1554 event.arg = Fcons (make_number (mtype), event.arg);
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1555
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1556 /* Add the bus symbol to the event. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1557 event.arg = Fcons (bus, event.arg);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1558
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1559 /* Store it into the input event queue. */
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1560 kbd_buffer_store_event (&event);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1561
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1562 XD_DEBUG_MESSAGE ("Event stored: %s",
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1563 SDATA (format2 ("%s", event.arg, Qnil)));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1564
93156
3ef12fa772f2 * dbusbind.c (xd_read_message): Removed extra copying of message
Michael Albinus <michael.albinus@gmx.de>
parents: 87972
diff changeset
1565 cleanup:
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1566 dbus_message_unref (dmessage);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1567 RETURN_UNGCPRO (Qnil);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1568 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1569
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1570 /* 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
1571 void
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1572 xd_read_queued_messages ()
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1573 {
87092
1ddad0de60e5 * dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents: 87053
diff changeset
1574
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1575 /* Vdbus_registered_functions_table will be initialized as hash
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1576 table in dbus.el. When this package isn't loaded yet, it doesn't
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1577 make sense to handle D-Bus messages. Furthermore, we ignore all
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1578 Lisp errors during the call. */
87092
1ddad0de60e5 * dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents: 87053
diff changeset
1579 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
1580 {
99098
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1581 xd_in_read_queued_messages = 1;
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1582 internal_catch (Qdbus_error, xd_read_message, QCdbus_system_bus);
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1583 internal_catch (Qdbus_error, xd_read_message, QCdbus_session_bus);
35372c2ca5c9 * dbusbind.c (xd_in_read_queued_messages): New variable.
Michael Albinus <michael.albinus@gmx.de>
parents: 98901
diff changeset
1584 xd_in_read_queued_messages = 0;
87092
1ddad0de60e5 * dbusbind.c (xd_read_message): Return value is a Lisp_Object.
Michael Albinus <michael.albinus@gmx.de>
parents: 87053
diff changeset
1585 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1586 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1587
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1588 DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal,
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1589 6, MANY, 0,
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1590 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
1591
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1592 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
1593
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1594 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
1595 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
1596 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
1597 D-Bus objects shall be accepted.
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1598
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1599 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
1600 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
1601
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1602 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
1603 HANDLER is a Lisp function to be called when the signal is received.
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1604 It must accept as arguments the values SIGNAL is sending.
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1605
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1606 All other arguments ARGS, if specified, must be strings. They stand
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1607 for the respective arguments of the signal in their order, and are
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1608 used for filtering as well. A nil argument might be used to preserve
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1609 the order.
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1610
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1611 INTERFACE, SIGNAL and HANDLER must not be nil. Example:
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1612
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1613 \(defun my-signal-handler (device)
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1614 (message "Device %s added" device))
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1615
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1616 \(dbus-register-signal
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1617 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1618 "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler)
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1619
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1620 => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded")
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1621 ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler))
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1622
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1623 `dbus-register-signal' returns an object, which can be used in
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1624 `dbus-unregister-object' for removing the registration.
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1625
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1626 usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */)
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1627 (nargs, args)
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1628 int nargs;
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1629 register Lisp_Object *args;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1630 {
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1631 Lisp_Object bus, service, path, interface, signal, handler;
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1632 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1633 Lisp_Object uname, key, key1, value;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1634 DBusConnection *connection;
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1635 int i;
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1636 char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
96847
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1637 char x[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1638 DBusError derror;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1639
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1640 /* Check parameters. */
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1641 bus = args[0];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1642 service = args[1];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1643 path = args[2];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1644 interface = args[3];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1645 signal = args[4];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1646 handler = args[5];
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1647
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1648 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
1649 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
1650 if (!NILP (path)) CHECK_STRING (path);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1651 CHECK_STRING (interface);
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1652 CHECK_STRING (signal);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1653 if (!FUNCTIONP (handler))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1654 wrong_type_argument (intern ("functionp"), handler);
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1655 GCPRO6 (bus, service, path, interface, signal, handler);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1656
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1657 /* Retrieve unique name of service. If service is a known name, we
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1658 will register for the corresponding unique name, if any. Signals
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1659 are sent always with the unique name as sender. Note: the unique
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1660 name of "org.freedesktop.DBus" is that string itself. */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1661 if ((STRINGP (service))
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1662 && (SBYTES (service) > 0)
87280
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
1663 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0)
e0d7140e5b0e * dbusbind.c (xd_retrieve_value, xd_retrieve_arg)
Michael Albinus <michael.albinus@gmx.de>
parents: 87175
diff changeset
1664 && (strncmp (SDATA (service), ":", 1) != 0))
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1665 {
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1666 uname = call2 (intern ("dbus-get-name-owner"), bus, service);
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1667 /* When there is no unique name, we mark it with an empty
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1668 string. */
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1669 if (NILP (uname))
101276
dd95cb42c0aa * dbusbind.c (Fdbus_register_signal):
Juanma Barranquero <lekktu@gmail.com>
parents: 100951
diff changeset
1670 uname = empty_unibyte_string;
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1671 }
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1672 else
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1673 uname = service;
87156
e0ab56e63db8 * dbusbind.c (Fdbus_get_unique_name, xd_read_message)
Michael Albinus <michael.albinus@gmx.de>
parents: 87092
diff changeset
1674
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1675 /* Create a matching rule if the unique name exists (when no
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1676 wildcard). */
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1677 if (NILP (uname) || (SBYTES (uname) > 0))
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1678 {
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1679 /* Open a connection to the bus. */
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1680 connection = xd_initialize (bus);
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1681
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1682 /* Create a rule to receive related signals. */
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1683 sprintf (rule,
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1684 "type='signal',interface='%s',member='%s'",
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1685 SDATA (interface),
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1686 SDATA (signal));
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1687
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1688 /* Add unique name and path to the rule if they are non-nil. */
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1689 if (!NILP (uname))
96847
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1690 {
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1691 sprintf (x, ",sender='%s'", SDATA (uname));
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1692 strcat (rule, x);
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1693 }
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1694
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1695 if (!NILP (path))
96847
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1696 {
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1697 sprintf (x, ",path='%s'", SDATA (path));
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1698 strcat (rule, x);
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1699 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1700
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1701 /* Add arguments to the rule if they are non-nil. */
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1702 for (i = 6; i < nargs; ++i)
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1703 if (!NILP (args[i]))
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1704 {
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1705 CHECK_STRING (args[i]);
96847
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1706 sprintf (x, ",arg%d='%s'", i-6, SDATA (args[i]));
5129bcf1c53e * dbusbind.c (Fdbus_register_signal): Use sprintf + strcat instead
Michael Albinus <michael.albinus@gmx.de>
parents: 96644
diff changeset
1707 strcat (rule, x);
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1708 }
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1709
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1710 /* Add the rule to the bus. */
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1711 dbus_error_init (&derror);
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1712 dbus_bus_add_match (connection, rule, &derror);
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1713 if (dbus_error_is_set (&derror))
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1714 {
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1715 UNGCPRO;
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1716 XD_ERROR (derror);
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1717 }
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1718
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1719 XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1720 }
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1721
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1722 /* Create a hash table entry. */
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1723 key = list3 (bus, interface, signal);
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1724 key1 = list4 (uname, service, path, handler);
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1725 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1726
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1727 if (NILP (Fmember (key1, value)))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1728 Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1729
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1730 /* Return object. */
96644
5d614d0d26de * dbusbind.c (Fdbus_register_signal): Allow also signal arguments
Michael Albinus <michael.albinus@gmx.de>
parents: 94963
diff changeset
1731 RETURN_UNGCPRO (list2 (key, list3 (service, path, handler)));
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1732 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1733
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1734 DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method,
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1735 6, 6, 0,
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1736 doc: /* Register for method METHOD on the D-Bus BUS.
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1737
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1738 BUS is either the symbol `:system' or the symbol `:session'.
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1739
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1740 SERVICE is the D-Bus service name of the D-Bus object METHOD is
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1741 registered for. It must be a known name.
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1742
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1743 PATH is the D-Bus object path SERVICE is registered. INTERFACE is the
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1744 interface offered by SERVICE. It must provide METHOD. HANDLER is a
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1745 Lisp function to be called when a method call is received. It must
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1746 accept the input arguments of METHOD. The return value of HANDLER is
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1747 used for composing the returning D-Bus message. */)
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1748 (bus, service, path, interface, method, handler)
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1749 Lisp_Object bus, service, path, interface, method, handler;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1750 {
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1751 Lisp_Object key, key1, value;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1752 DBusConnection *connection;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1753 int result;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1754 DBusError derror;
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1755
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1756 /* Check parameters. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1757 CHECK_SYMBOL (bus);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1758 CHECK_STRING (service);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1759 CHECK_STRING (path);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1760 CHECK_STRING (interface);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1761 CHECK_STRING (method);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1762 if (!FUNCTIONP (handler))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1763 wrong_type_argument (intern ("functionp"), handler);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1764 /* TODO: We must check for a valid service name, otherwise there is
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1765 a segmentation fault. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1766
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1767 /* Open a connection to the bus. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1768 connection = xd_initialize (bus);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1769
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1770 /* Request the known name from the bus. We can ignore the result,
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1771 it is set to -1 if there is an error - kind of redundancy. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1772 dbus_error_init (&derror);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1773 result = dbus_bus_request_name (connection, SDATA (service), 0, &derror);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1774 if (dbus_error_is_set (&derror))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1775 XD_ERROR (derror);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1776
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1777 /* Create a hash table entry. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1778 key = list3 (bus, interface, method);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1779 key1 = list4 (Qnil, service, path, handler);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1780 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1781
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1782 /* We use nil for the unique name, because the method might be
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1783 called from everybody. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1784 if (NILP (Fmember (key1, value)))
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1785 Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1786
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1787 /* Return object. */
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1788 return list2 (key, list3 (service, path, handler));
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1789 }
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1790
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1791
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1792 void
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1793 syms_of_dbusbind ()
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1794 {
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1795
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1796 Qdbus_get_unique_name = intern ("dbus-get-unique-name");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1797 staticpro (&Qdbus_get_unique_name);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1798 defsubr (&Sdbus_get_unique_name);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1799
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1800 Qdbus_call_method = intern ("dbus-call-method");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1801 staticpro (&Qdbus_call_method);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1802 defsubr (&Sdbus_call_method);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1803
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1804 Qdbus_call_method_asynchronously = intern ("dbus-call-method-asynchronously");
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1805 staticpro (&Qdbus_call_method_asynchronously);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1806 defsubr (&Sdbus_call_method_asynchronously);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1807
87887
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1808 Qdbus_method_return_internal = intern ("dbus-method-return-internal");
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1809 staticpro (&Qdbus_method_return_internal);
c7d6ce47abe2 * dbusbind.el (Fdbus_method_return_internal): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 87584
diff changeset
1810 defsubr (&Sdbus_method_return_internal);
87584
af7df042c392 * dbusbind.c (Fdbus_method_return): New function.
Michael Albinus <michael.albinus@gmx.de>
parents: 87539
diff changeset
1811
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1812 Qdbus_method_error_internal = intern ("dbus-method-error-internal");
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1813 staticpro (&Qdbus_method_error_internal);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1814 defsubr (&Sdbus_method_error_internal);
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1815
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1816 Qdbus_send_signal = intern ("dbus-send-signal");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1817 staticpro (&Qdbus_send_signal);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1818 defsubr (&Sdbus_send_signal);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1819
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1820 Qdbus_register_signal = intern ("dbus-register-signal");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1821 staticpro (&Qdbus_register_signal);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1822 defsubr (&Sdbus_register_signal);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1823
87490
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1824 Qdbus_register_method = intern ("dbus-register-method");
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1825 staticpro (&Qdbus_register_method);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1826 defsubr (&Sdbus_register_method);
5db1ff3b9244 * dbusbind.c: Fix several errors and compiler warnings. Reported
Michael Albinus <michael.albinus@gmx.de>
parents: 87364
diff changeset
1827
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1828 Qdbus_error = intern ("dbus-error");
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1829 staticpro (&Qdbus_error);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1830 Fput (Qdbus_error, Qerror_conditions,
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1831 list2 (Qdbus_error, Qerror));
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1832 Fput (Qdbus_error, Qerror_message,
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1833 build_string ("D-Bus error"));
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1834
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1835 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
1836 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
1837
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1838 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
1839 staticpro (&QCdbus_session_bus);
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1840
93420
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
1841 QCdbus_timeout = intern (":timeout");
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
1842 staticpro (&QCdbus_timeout);
629d4147200e * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
Michael Albinus <michael.albinus@gmx.de>
parents: 93156
diff changeset
1843
87343
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1844 QCdbus_type_byte = intern (":byte");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1845 staticpro (&QCdbus_type_byte);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1846
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1847 QCdbus_type_boolean = intern (":boolean");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1848 staticpro (&QCdbus_type_boolean);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1849
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1850 QCdbus_type_int16 = intern (":int16");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1851 staticpro (&QCdbus_type_int16);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1852
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1853 QCdbus_type_uint16 = intern (":uint16");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1854 staticpro (&QCdbus_type_uint16);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1855
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1856 QCdbus_type_int32 = intern (":int32");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1857 staticpro (&QCdbus_type_int32);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1858
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1859 QCdbus_type_uint32 = intern (":uint32");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1860 staticpro (&QCdbus_type_uint32);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1861
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1862 QCdbus_type_int64 = intern (":int64");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1863 staticpro (&QCdbus_type_int64);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1864
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1865 QCdbus_type_uint64 = intern (":uint64");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1866 staticpro (&QCdbus_type_uint64);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1867
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1868 QCdbus_type_double = intern (":double");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1869 staticpro (&QCdbus_type_double);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1870
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1871 QCdbus_type_string = intern (":string");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1872 staticpro (&QCdbus_type_string);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1873
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1874 QCdbus_type_object_path = intern (":object-path");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1875 staticpro (&QCdbus_type_object_path);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1876
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1877 QCdbus_type_signature = intern (":signature");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1878 staticpro (&QCdbus_type_signature);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1879
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1880 QCdbus_type_array = intern (":array");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1881 staticpro (&QCdbus_type_array);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1882
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1883 QCdbus_type_variant = intern (":variant");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1884 staticpro (&QCdbus_type_variant);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1885
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1886 QCdbus_type_struct = intern (":struct");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1887 staticpro (&QCdbus_type_struct);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1888
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1889 QCdbus_type_dict_entry = intern (":dict-entry");
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1890 staticpro (&QCdbus_type_dict_entry);
02e327d7d839 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
Michael Albinus <michael.albinus@gmx.de>
parents: 87307
diff changeset
1891
87539
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1892 DEFVAR_LISP ("dbus-registered-functions-table",
6a710fa21688 * dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
Michael Albinus <michael.albinus@gmx.de>
parents: 87535
diff changeset
1893 &Vdbus_registered_functions_table,
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1894 doc: /* Hash table of registered functions for D-Bus.
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1895 There are two different uses of the hash table: for calling registered
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1896 functions, targeted by signals or method calls, and for calling
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1897 handlers in case of non-blocking method call returns.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1898
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1899 In the first case, the key in the hash table is the list (BUS
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1900 INTERFACE MEMBER). BUS is either the symbol `:system' or the symbol
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1901 `:session'. INTERFACE is a string which denotes a D-Bus interface,
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1902 and MEMBER, also a string, is either a method or a signal INTERFACE is
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1903 offering. All arguments but BUS must not be nil.
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1904
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1905 The value in the hash table is a list of quadruple lists
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1906 \((UNAME SERVICE PATH HANDLER) (UNAME SERVICE PATH HANDLER) ...).
87175
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1907 SERVICE is the service name as registered, UNAME is the corresponding
30175fd3b679 * dbusbind.c (xd_read_message): Generate an event for every
Michael Albinus <michael.albinus@gmx.de>
parents: 87156
diff changeset
1908 unique name. PATH is the object path of the sending object. All of
87307
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1909 them can be nil, which means a wildcard then. HANDLER is the function
710ac69daf1f * dbusbind.c (top): Include <stdio.h>.
Michael Albinus <michael.albinus@gmx.de>
parents: 87280
diff changeset
1910 to be called when a D-Bus message, which matches the key criteria,
97165
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1911 arrives.
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1912
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1913 In the second case, the key in the hash table is the list (BUS SERIAL).
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1914 BUS is either the symbol `:system' or the symbol `:session'. SERIAL
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1915 is the serial number of the non-blocking method call, a reply is
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1916 expected. Both arguments must not be nil. The value in the hash
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1917 table is HANDLER, the function to be called when the D-Bus reply
b0fa771b5389 * dbusbind.c (Fdbus_call_method_asynchronously)
Michael Albinus <michael.albinus@gmx.de>
parents: 96847
diff changeset
1918 message arrives. */);
87051
1da959e791de * dbusbind.c (QCdbus_system_bus, QCdbus_session_bus): Renamed from
Michael Albinus <michael.albinus@gmx.de>
parents: 86940
diff changeset
1919 /* 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
1920 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
1921 Vdbus_registered_functions_table = Qnil;
86940
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1922
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1923 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
1924 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
1925 #ifdef DBUS_DEBUG
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1926 Vdbus_debug = Qt;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1927 #else
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1928 Vdbus_debug = Qnil;
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1929 #endif
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1930
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1931 Fprovide (intern ("dbusbind"), Qnil);
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1932
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1933 }
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1934
2dd672d9fe75 * config.in (HAVE_DBUS): Add.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1935 #endif /* HAVE_DBUS */
87053
f767f1ba8301 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87051
diff changeset
1936
f767f1ba8301 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87051
diff changeset
1937 /* arch-tag: 0e828477-b571-4fe4-b559-5c9211bc14b8
f767f1ba8301 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 87051
diff changeset
1938 (do not change this comment) */