aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2007-12-29 02:39:17 +0000
committerMiles Bader2007-12-29 02:39:17 +0000
commita0c92ed92d3d62d4926dafb1d595d87843df4688 (patch)
tree78f12dd6f97a0f96b846fbf08e3f8ce39a701f8e /src
parent9aeb99f00a02c695b14f2ee349141eb9641ca6da (diff)
parent870356897e927f380841268667a92b40fb9e6782 (diff)
downloademacs-a0c92ed92d3d62d4926dafb1d595d87843df4688.tar.gz
emacs-a0c92ed92d3d62d4926dafb1d595d87843df4688.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-306
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog85
-rw-r--r--src/callint.c5
-rw-r--r--src/dbusbind.c708
-rw-r--r--src/fileio.c3
-rw-r--r--src/macmenu.c3
-rw-r--r--src/process.c2
-rw-r--r--src/w32fns.c3
-rw-r--r--src/xdisp.c18
8 files changed, 696 insertions, 131 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d5edca82fe9..be2c5824f51 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,77 @@
12007-12-24 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * process.c (make_process): Initialize pty_flag to Qnil instead of 0
4 as it is not a bit field on Emacs 22 yet.
5
6 * xdisp.c (phys_cursor_in_rect_p): Check if cursor is in fringe area.
7
82007-12-22 Eli Zaretskii <eliz@gnu.org>
9
10 * callint.c (syms_of_callint) <command-history>: Add reference to
11 history-length in the doc string.
12
132007-12-17 Jason Rumney <jasonr@gnu.org>
14
15 * w32fns.c (w32_wnd_proc) <WM_KEYDOWN>: Cast char to unsigned
16 before passing as wParam.
17
182007-12-22 Michael Albinus <michael.albinus@gmx.de>
19
20 * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
21 DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64,
22 DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE.
23 Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit
24 as number.
25 (Fdbus_call_method): Fix docstring.
26
272007-12-21 Michael Albinus <michael.albinus@gmx.de>
28
29 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
30 New macros.
31 (XD_SYMBOL_TO_DBUS_TYPE): Renamed from
32 XD_LISP_SYMBOL_TO_DBUS_TYPE.
33 (XD_OBJECT_TO_DBUS_TYPE): Renamed from
34 XD_LISP_OBJECT_TO_DBUS_TYPE. Simplify.
35 (xd_signature): New function.
36 (xd_append_arg): Compute also signatures. Major rewrite.
37 (xd_retrieve_arg): Make debug messages friendly.
38 (Fdbus_call_method, Fdbus_send_signal): Extend docstring. Check
39 for signatures of arguments.
40
412007-12-19 Michael Albinus <michael.albinus@gmx.de>
42
43 * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean)
44 (QCdbus_type_int16, QCdbus_type_uint16, QCdbus_type_int32)
45 (QCdbus_type_uint32, QCdbus_type_int64, QCdbus_type_uint64)
46 (QCdbus_type_double, QCdbus_type_string, QCdbus_type_object_path)
47 (QCdbus_type_signature, QCdbus_type_array, QCdbus_type_variant)
48 (QCdbus_type_struct, QCdbus_type_dict_entry): New D-Bus type
49 symbols.
50 (XD_LISP_SYMBOL_TO_DBUS_TYPE): New macro.
51 (XD_LISP_OBJECT_TO_DBUS_TYPE): Add compound types.
52 (xd_retrieve_value): Removed. Functionality included in ...
53 (xd_append_arg): New function.
54 (Fdbus_call_method, Fdbus_send_signal): Apply it.
55
562007-12-16 Michael Albinus <michael.albinus@gmx.de>
57
58 * dbusbind.c (top): Include <stdio.h>.
59 (Fdbus_call_method, Fdbus_send_signal): Apply type cast in
60 dbus_message_new_method_call and dbus_message_new_signal.
61 (Fdbus_register_signal): Rename unique_name to uname. Check
62 handler for FUNCTIONP instead of CHECK_SYMBOL. Handle case of
63 non-existing unique name. Fix typos in matching rule. Return an
64 object which is useful in Fdbus_unregister_signal.
65 (Fdbus_unregister_signal): Reimplementation, in order to remove
66 only the corresponding entry.
67 (Vdbus_registered_functions_table): Change the order of entries.
68 Apply these changes in xd_read_message and Fdbus_register_signal.
69
702007-12-16 Andreas Schwab <schwab@suse.de>
71
72 * fileio.c (Finsert_file_contents): Fix overflow check to not
73 depend on undefined integer overflow.
74
12007-12-14 Jason Rumney <jasonr@gnu.org> 752007-12-14 Jason Rumney <jasonr@gnu.org>
2 76
3 * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT 77 * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT
@@ -837,6 +911,12 @@
837 * msdos.c (dos_rawgetc): Undo last change (there's no ``leaving 911 * msdos.c (dos_rawgetc): Undo last change (there's no ``leaving
838 selected frame'' on MSDOS). 912 selected frame'' on MSDOS).
839 913
9142007-10-12 Martin Rudalics <rudalics@gmx.at>
915
916 * frame.c (Qexplicit_name): New variable.
917 (x_report_frame_params): Report it in parameter alist.
918 (syms_of_frame): Intern and staticpro it.
919
8402007-10-10 Patrick Mahan <mahan@mahan.org> (tiny change) 9202007-10-10 Patrick Mahan <mahan@mahan.org> (tiny change)
841 921
842 * macfns.c (x_create_tip_frame): Set terminal for frame. 922 * macfns.c (x_create_tip_frame): Set terminal for frame.
@@ -864,6 +944,11 @@
864 944
865 * puresize.h (BASE_PURESIZE): Increase to 1170000. 945 * puresize.h (BASE_PURESIZE): Increase to 1170000.
866 946
9472007-10-09 Jason Rumney <jasonr@gnu.org>
948
949 * w32term.c (x_set_window_size): Disable code that attempts to tell
950 Lisp code about a size change before it actually happens.
951
8672007-10-09 Richard Stallman <rms@gnu.org> 9522007-10-09 Richard Stallman <rms@gnu.org>
868 953
869 * xdisp.c (handle_invisible_prop): After setting up an ellipsis, 954 * xdisp.c (handle_invisible_prop): After setting up an ellipsis,
diff --git a/src/callint.c b/src/callint.c
index a19c424c899..2ac53105afb 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -941,7 +941,10 @@ This is what `(interactive \"P\")' returns. */);
941 941
942 DEFVAR_LISP ("command-history", &Vcommand_history, 942 DEFVAR_LISP ("command-history", &Vcommand_history,
943 doc: /* List of recent commands that read arguments from terminal. 943 doc: /* List of recent commands that read arguments from terminal.
944Each command is represented as a form to evaluate. */); 944Each command is represented as a form to evaluate.
945
946Maximum length of the history list is determined by the value
947of `history-length', which see. */);
945 Vcommand_history = Qnil; 948 Vcommand_history = Qnil;
946 949
947 DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status, 950 DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status,
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 0ccccc8b22d..88f2ccdb3eb 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -22,6 +22,7 @@ Boston, MA 02110-1301, USA. */
22 22
23#ifdef HAVE_DBUS 23#ifdef HAVE_DBUS
24#include <stdlib.h> 24#include <stdlib.h>
25#include <stdio.h>
25#include <dbus/dbus.h> 26#include <dbus/dbus.h>
26#include "lisp.h" 27#include "lisp.h"
27#include "frame.h" 28#include "frame.h"
@@ -42,6 +43,16 @@ Lisp_Object Qdbus_error;
42/* Lisp symbols of the system and session buses. */ 43/* Lisp symbols of the system and session buses. */
43Lisp_Object QCdbus_system_bus, QCdbus_session_bus; 44Lisp_Object QCdbus_system_bus, QCdbus_session_bus;
44 45
46/* Lisp symbols of D-Bus types. */
47Lisp_Object QCdbus_type_byte, QCdbus_type_boolean;
48Lisp_Object QCdbus_type_int16, QCdbus_type_uint16;
49Lisp_Object QCdbus_type_int32, QCdbus_type_uint32;
50Lisp_Object QCdbus_type_int64, QCdbus_type_uint64;
51Lisp_Object QCdbus_type_double, QCdbus_type_string;
52Lisp_Object QCdbus_type_object_path, QCdbus_type_signature;
53Lisp_Object QCdbus_type_array, QCdbus_type_variant;
54Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry;
55
45/* Hash table which keeps function definitions. */ 56/* Hash table which keeps function definitions. */
46Lisp_Object Vdbus_registered_functions_table; 57Lisp_Object Vdbus_registered_functions_table;
47 58
@@ -52,7 +63,7 @@ Lisp_Object Vdbus_debug;
52/* We use "xd_" and "XD_" as prefix for all internal symbols, because 63/* We use "xd_" and "XD_" as prefix for all internal symbols, because
53 we don't want to poison other namespaces with "dbus_". */ 64 we don't want to poison other namespaces with "dbus_". */
54 65
55/* Raise a Lisp error from a D-Bus error. */ 66/* Raise a Lisp error from a D-Bus ERROR. */
56#define XD_ERROR(error) \ 67#define XD_ERROR(error) \
57 { \ 68 { \
58 char s[1024]; \ 69 char s[1024]; \
@@ -92,58 +103,364 @@ Lisp_Object Vdbus_debug;
92#define XD_DEBUG_VALID_LISP_OBJECT_P(object) 103#define XD_DEBUG_VALID_LISP_OBJECT_P(object)
93#endif 104#endif
94 105
95/* Determine the DBusType of a given Lisp object. It is used to 106/* Check whether TYPE is a basic DBusType. */
107#define XD_BASIC_DBUS_TYPE(type) \
108 ((type == DBUS_TYPE_BYTE) \
109 || (type == DBUS_TYPE_BOOLEAN) \
110 || (type == DBUS_TYPE_INT16) \
111 || (type == DBUS_TYPE_UINT16) \
112 || (type == DBUS_TYPE_INT32) \
113 || (type == DBUS_TYPE_UINT32) \
114 || (type == DBUS_TYPE_INT64) \
115 || (type == DBUS_TYPE_UINT64) \
116 || (type == DBUS_TYPE_DOUBLE) \
117 || (type == DBUS_TYPE_STRING) \
118 || (type == DBUS_TYPE_OBJECT_PATH) \
119 || (type == DBUS_TYPE_SIGNATURE))
120
121/* Determine the DBusType of a given Lisp symbol. OBJECT must be one
122 of the predefined D-Bus type symbols. */
123#define XD_SYMBOL_TO_DBUS_TYPE(object) \
124 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \
125 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \
126 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \
127 : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \
128 : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \
129 : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \
130 : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \
131 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \
132 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \
133 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \
134 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \
135 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \
136 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \
137 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \
138 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \
139 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \
140 : DBUS_TYPE_INVALID)
141
142/* Check whether a Lisp symbol is a predefined D-Bus type symbol. */
143#define XD_DBUS_TYPE_P(object) \
144 (SYMBOLP (object) && ((XD_SYMBOL_TO_DBUS_TYPE (object) != DBUS_TYPE_INVALID)))
145
146/* Determine the DBusType of a given Lisp OBJECT. It is used to
96 convert Lisp objects, being arguments of `dbus-call-method' or 147 convert Lisp objects, being arguments of `dbus-call-method' or
97 `dbus-send-signal', into corresponding C values appended as 148 `dbus-send-signal', into corresponding C values appended as
98 arguments to a D-Bus message. */ 149 arguments to a D-Bus message. */
99#define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \ 150#define XD_OBJECT_TO_DBUS_TYPE(object) \
100 (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \ 151 ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \
101 (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \ 152 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \
102 (INTEGERP (object)) ? DBUS_TYPE_INT32 : \ 153 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \
103 (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \ 154 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \
104 (STRINGP (object)) ? DBUS_TYPE_STRING : \ 155 : (STRINGP (object)) ? DBUS_TYPE_STRING \
105 DBUS_TYPE_INVALID 156 : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \
106 157 : (CONSP (object)) ? ((XD_DBUS_TYPE_P (XCAR (object))) \
107/* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType, 158 ? XD_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \
108 as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not 159 : DBUS_TYPE_ARRAY) \
109 supported (yet). It is used to convert Lisp objects, being 160 : DBUS_TYPE_INVALID)
110 arguments of `dbus-call-method' or `dbus-send-signal', into 161
111 corresponding C values appended as arguments to a D-Bus 162/* Return a list pointer which does not have a Lisp symbol as car. */
112 message. */ 163#define XD_NEXT_VALUE(object) \
113char * 164 ((XD_DBUS_TYPE_P (XCAR (object))) ? XCDR (object) : object)
114xd_retrieve_value (dtype, object) 165
115 unsigned int dtype; 166/* Compute SIGNATURE of OBJECT. It must have a form that it can be
167 used in dbus_message_iter_open_container. DTYPE is the DBusType
168 the object is related to. It is passed as argument, because it
169 cannot be detected in basic type objects, when they are preceded by
170 a type symbol. PARENT_TYPE is the DBusType of a container this
171 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the
172 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */
173void
174xd_signature(signature, dtype, parent_type, object)
175 char *signature;
176 unsigned int dtype, parent_type;
116 Lisp_Object object; 177 Lisp_Object object;
117{ 178{
179 unsigned int subtype;
180 Lisp_Object elt;
181 char x[DBUS_MAXIMUM_SIGNATURE_LENGTH];
182
183 elt = object;
118 184
119 XD_DEBUG_VALID_LISP_OBJECT_P (object);
120 switch (dtype) 185 switch (dtype)
121 { 186 {
122 case DBUS_TYPE_BOOLEAN: 187 case DBUS_TYPE_BYTE:
123 XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); 188 case DBUS_TYPE_UINT16:
124 return (NILP (object)) ? (char *) FALSE : (char *) TRUE;
125 case DBUS_TYPE_UINT32: 189 case DBUS_TYPE_UINT32:
126 XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object)); 190 case DBUS_TYPE_UINT64:
127 return (char *) XUINT (object); 191 CHECK_NATNUM (object);
192 sprintf (signature, "%c", dtype);
193 break;
194
195 case DBUS_TYPE_BOOLEAN:
196 if (!EQ (object, Qt) && !EQ (object, Qnil))
197 wrong_type_argument (intern ("booleanp"), object);
198 sprintf (signature, "%c", dtype);
199 break;
200
201 case DBUS_TYPE_INT16:
128 case DBUS_TYPE_INT32: 202 case DBUS_TYPE_INT32:
129 XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); 203 case DBUS_TYPE_INT64:
130 return (char *) XINT (object); 204 CHECK_NUMBER (object);
205 sprintf (signature, "%c", dtype);
206 break;
207
131 case DBUS_TYPE_DOUBLE: 208 case DBUS_TYPE_DOUBLE:
132 XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object)); 209 CHECK_FLOAT (object);
133 return (char *) XFLOAT (object); 210 sprintf (signature, "%c", dtype);
211 break;
212
134 case DBUS_TYPE_STRING: 213 case DBUS_TYPE_STRING:
135 XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); 214 case DBUS_TYPE_OBJECT_PATH:
136 return SDATA (object); 215 case DBUS_TYPE_SIGNATURE:
216 CHECK_STRING (object);
217 sprintf (signature, "%c", dtype);
218 break;
219
220 case DBUS_TYPE_ARRAY:
221 /* Check that all list elements have the same D-Bus type. For
222 complex element types, we just check the container type, not
223 the whole element's signature. */
224 CHECK_CONS (object);
225
226 if (EQ (QCdbus_type_array, XCAR (elt))) /* Type symbol is optional. */
227 elt = XD_NEXT_VALUE (elt);
228 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
229 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
230
231 while (!NILP (elt))
232 {
233 if (subtype != XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)))
234 wrong_type_argument (intern ("D-Bus"), XCAR (elt));
235 elt = XCDR (XD_NEXT_VALUE (elt));
236 }
237
238 sprintf (signature, "%c%s", dtype, x);
239 break;
240
241 case DBUS_TYPE_VARIANT:
242 /* Check that there is exactly one list element. */
243 CHECK_CONS (object);
244
245 elt = XD_NEXT_VALUE (elt);
246 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
247 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
248
249 if (!NILP (XCDR (XD_NEXT_VALUE (elt))))
250 wrong_type_argument (intern ("D-Bus"),
251 XCAR (XCDR (XD_NEXT_VALUE (elt))));
252
253 sprintf (signature, "%c%s", dtype, x);
254 break;
255
256 case DBUS_TYPE_STRUCT:
257 /* A struct list might contain any number of elements with
258 different types. No further check needed. */
259 CHECK_CONS (object);
260
261 elt = XD_NEXT_VALUE (elt);
262
263 /* Compose the signature from the elements. It is enclosed by
264 parentheses. */
265 sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR );
266 while (!NILP (elt))
267 {
268 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
269 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
270 strcat (signature, x);
271 elt = XCDR (XD_NEXT_VALUE (elt));
272 }
273 sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR);
274 break;
275
276 case DBUS_TYPE_DICT_ENTRY:
277 /* Check that there are exactly two list elements, and the first
278 one is of basic type. The dictionary entry itself must be an
279 element of an array. */
280 CHECK_CONS (object);
281
282 /* Check the parent object type. */
283 if (parent_type != DBUS_TYPE_ARRAY)
284 wrong_type_argument (intern ("D-Bus"), object);
285
286 /* Compose the signature from the elements. It is enclosed by
287 curly braces. */
288 sprintf (signature, "%c", DBUS_DICT_ENTRY_BEGIN_CHAR);
289
290 /* First element. */
291 elt = XD_NEXT_VALUE (elt);
292 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
293 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
294 strcat (signature, x);
295
296 if (!XD_BASIC_DBUS_TYPE (subtype))
297 wrong_type_argument (intern ("D-Bus"), XCAR (XD_NEXT_VALUE (elt)));
298
299 /* Second element. */
300 elt = XCDR (XD_NEXT_VALUE (elt));
301 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt));
302 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt)));
303 strcat (signature, x);
304
305 if (!NILP (XCDR (XD_NEXT_VALUE (elt))))
306 wrong_type_argument (intern ("D-Bus"),
307 XCAR (XCDR (XD_NEXT_VALUE (elt))));
308
309 /* Closing signature. */
310 sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR);
311 break;
312
137 default: 313 default:
138 XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype); 314 wrong_type_argument (intern ("D-Bus"), object);
139 return NULL; 315 }
316
317 XD_DEBUG_MESSAGE ("%s", signature);
318}
319
320/* Append C value, extracted from Lisp OBJECT, to iteration ITER.
321 DTYPE must be a valid DBusType. It is used to convert Lisp
322 objects, being arguments of `dbus-call-method' or
323 `dbus-send-signal', into corresponding C values appended as
324 arguments to a D-Bus message. */
325void
326xd_append_arg (dtype, object, iter)
327 unsigned int dtype;
328 Lisp_Object object;
329 DBusMessageIter *iter;
330{
331 Lisp_Object elt;
332 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
333 DBusMessageIter subiter;
334 char *value;
335
336 XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", object, Qnil)));
337
338 if (XD_BASIC_DBUS_TYPE (dtype))
339 {
340 switch (dtype)
341 {
342 case DBUS_TYPE_BYTE:
343 XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
344 value = (unsigned char *) XUINT (object);
345 break;
346
347 case DBUS_TYPE_BOOLEAN:
348 XD_DEBUG_MESSAGE ("%c %s", dtype, (NILP (object)) ? "false" : "true");
349 value = (NILP (object))
350 ? (unsigned char *) FALSE : (unsigned char *) TRUE;
351 break;
352
353 case DBUS_TYPE_INT16:
354 XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
355 value = (char *) (dbus_int16_t *) XINT (object);
356 break;
357
358 case DBUS_TYPE_UINT16:
359 XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
360 value = (char *) (dbus_uint16_t *) XUINT (object);
361 break;
362
363 case DBUS_TYPE_INT32:
364 XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
365 value = (char *) (dbus_int32_t *) XINT (object);
366 break;
367
368 case DBUS_TYPE_UINT32:
369 XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
370 value = (char *) (dbus_uint32_t *) XUINT (object);
371 break;
372
373 case DBUS_TYPE_INT64:
374 XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object));
375 value = (char *) (dbus_int64_t *) XINT (object);
376 break;
377
378 case DBUS_TYPE_UINT64:
379 XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object));
380 value = (char *) (dbus_int64_t *) XUINT (object);
381 break;
382
383 case DBUS_TYPE_DOUBLE:
384 XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object));
385 value = (char *) (float *) XFLOAT (object);
386 break;
387
388 case DBUS_TYPE_STRING:
389 case DBUS_TYPE_OBJECT_PATH:
390 case DBUS_TYPE_SIGNATURE:
391 XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (object));
392 value = SDATA (object);
393 break;
394 }
395
396 if (!dbus_message_iter_append_basic (iter, dtype, &value))
397 xsignal2 (Qdbus_error,
398 build_string ("Unable to append argument"), object);
399 }
400
401 else /* Compound types. */
402 {
403
404 /* All compound types except array have a type symbol. For
405 array, it is optional. Skip it. */
406 if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (XCAR (object))))
407 object = XD_NEXT_VALUE (object);
408
409 /* Open new subiteration. */
410 switch (dtype)
411 {
412 case DBUS_TYPE_ARRAY:
413 case DBUS_TYPE_VARIANT:
414 /* A variant has just one element. An array has elements of
415 the same type. Both have been checked already for
416 correct types, it is sufficient to retrieve just the
417 signature of the first element. */
418 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)),
419 dtype, XCAR (XD_NEXT_VALUE (object)));
420 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
421 SDATA (format2 ("%s", object, Qnil)));
422 if (!dbus_message_iter_open_container (iter, dtype,
423 signature, &subiter))
424 xsignal3 (Qdbus_error,
425 build_string ("Cannot open container"),
426 make_number (dtype), build_string (signature));
427 break;
428
429 case DBUS_TYPE_STRUCT:
430 case DBUS_TYPE_DICT_ENTRY:
431 /* These containers do not require a signature. */
432 XD_DEBUG_MESSAGE ("%c %s", dtype,
433 SDATA (format2 ("%s", object, Qnil)));
434 if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter))
435 xsignal2 (Qdbus_error,
436 build_string ("Cannot open container"),
437 make_number (dtype));
438 break;
439 }
440
441 /* Loop over list elements. */
442 while (!NILP (object))
443 {
444 dtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (object));
445 object = XD_NEXT_VALUE (object);
446
447 xd_append_arg (dtype, XCAR (object), &subiter);
448
449 object = XCDR (object);
450 }
451
452 /* Close the subiteration. */
453 if (!dbus_message_iter_close_container (iter, &subiter))
454 xsignal2 (Qdbus_error,
455 build_string ("Cannot close container"),
456 make_number (dtype));
140 } 457 }
141} 458}
142 459
143/* Retrieve C value from a DBusMessageIter structure ITER, and return 460/* Retrieve C value from a DBusMessageIter structure ITER, and return
144 a converted Lisp object. The type DTYPE of the argument of the 461 a converted Lisp object. The type DTYPE of the argument of the
145 D-Bus message must be a valid DBusType. Compound D-Bus types are 462 D-Bus message must be a valid DBusType. Compound D-Bus types
146 partly supported; they result always in a Lisp list. */ 463 result always in a Lisp list. */
147Lisp_Object 464Lisp_Object
148xd_retrieve_arg (dtype, iter) 465xd_retrieve_arg (dtype, iter)
149 unsigned int dtype; 466 unsigned int dtype;
@@ -152,29 +469,66 @@ xd_retrieve_arg (dtype, iter)
152 469
153 switch (dtype) 470 switch (dtype)
154 { 471 {
472 case DBUS_TYPE_BYTE:
473 case DBUS_TYPE_INT16:
474 case DBUS_TYPE_UINT16:
475 {
476 dbus_uint16_t val;
477 dbus_message_iter_get_basic (iter, &val);
478 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
479 return make_number (val);
480 }
481
155 case DBUS_TYPE_BOOLEAN: 482 case DBUS_TYPE_BOOLEAN:
156 { 483 {
157 dbus_bool_t val; 484 dbus_bool_t val;
158 dbus_message_iter_get_basic (iter, &val); 485 dbus_message_iter_get_basic (iter, &val);
159 XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true"); 486 XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
160 return (val == FALSE) ? Qnil : Qt; 487 return (val == FALSE) ? Qnil : Qt;
161 } 488 }
489
162 case DBUS_TYPE_INT32: 490 case DBUS_TYPE_INT32:
163 case DBUS_TYPE_UINT32: 491 case DBUS_TYPE_UINT32:
164 { 492 {
165 dbus_uint32_t val; 493 dbus_uint32_t val;
166 dbus_message_iter_get_basic (iter, &val); 494 dbus_message_iter_get_basic (iter, &val);
167 XD_DEBUG_MESSAGE ("%d %d", dtype, val); 495 if (FIXNUM_OVERFLOW_P (val))
168 return make_number (val); 496 XD_DEBUG_MESSAGE ("%c %f", dtype, val)
497 else
498 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
499 return make_fixnum_or_float (val);
500 }
501
502 case DBUS_TYPE_INT64:
503 case DBUS_TYPE_UINT64:
504 {
505 dbus_uint64_t val;
506 dbus_message_iter_get_basic (iter, &val);
507 if (FIXNUM_OVERFLOW_P (val))
508 XD_DEBUG_MESSAGE ("%c %f", dtype, val)
509 else
510 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
511 return make_fixnum_or_float (val);
512 }
513
514 case DBUS_TYPE_DOUBLE:
515 {
516 double val;
517 dbus_message_iter_get_basic (iter, &val);
518 XD_DEBUG_MESSAGE ("%c %f", dtype, val);
519 return make_float (val);
169 } 520 }
521
170 case DBUS_TYPE_STRING: 522 case DBUS_TYPE_STRING:
171 case DBUS_TYPE_OBJECT_PATH: 523 case DBUS_TYPE_OBJECT_PATH:
524 case DBUS_TYPE_SIGNATURE:
172 { 525 {
173 char *val; 526 char *val;
174 dbus_message_iter_get_basic (iter, &val); 527 dbus_message_iter_get_basic (iter, &val);
175 XD_DEBUG_MESSAGE ("%d %s", dtype, val); 528 XD_DEBUG_MESSAGE ("%c %s", dtype, val);
176 return build_string (val); 529 return build_string (val);
177 } 530 }
531
178 case DBUS_TYPE_ARRAY: 532 case DBUS_TYPE_ARRAY:
179 case DBUS_TYPE_VARIANT: 533 case DBUS_TYPE_VARIANT:
180 case DBUS_TYPE_STRUCT: 534 case DBUS_TYPE_STRUCT:
@@ -195,8 +549,9 @@ xd_retrieve_arg (dtype, iter)
195 } 549 }
196 RETURN_UNGCPRO (Fnreverse (result)); 550 RETURN_UNGCPRO (Fnreverse (result));
197 } 551 }
552
198 default: 553 default:
199 XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype); 554 XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype);
200 return Qnil; 555 return Qnil;
201 } 556 }
202} 557}
@@ -275,16 +630,33 @@ converted into D-Bus types via the following rules:
275 integer => DBUS_TYPE_INT32 630 integer => DBUS_TYPE_INT32
276 float => DBUS_TYPE_DOUBLE 631 float => DBUS_TYPE_DOUBLE
277 string => DBUS_TYPE_STRING 632 string => DBUS_TYPE_STRING
633 list => DBUS_TYPE_ARRAY
278 634
279Other Lisp objects are not supported as input arguments of METHOD. 635All arguments can be preceded by a type symbol. For details about
636type symbols, see Info node `(dbus)Type Conversion'.
280 637
281`dbus-call-method' returns the resulting values of METHOD as a list of 638`dbus-call-method' returns the resulting values of METHOD as a list of
282Lisp objects. The type conversion happens the other direction as for 639Lisp objects. The type conversion happens the other direction as for
283input arguments. Additionally to the types supported for input 640input arguments. It follows the mapping rules:
284arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT, 641
285DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them 642 DBUS_TYPE_BOOLEAN => t or nil
286are converted into a list of Lisp objects which correspond to the 643 DBUS_TYPE_BYTE => number
287elements of the D-Bus container. Example: 644 DBUS_TYPE_UINT16 => number
645 DBUS_TYPE_INT16 => integer
646 DBUS_TYPE_UINT32 => number or float
647 DBUS_TYPE_INT32 => integer or float
648 DBUS_TYPE_UINT64 => number or float
649 DBUS_TYPE_INT64 => integer or float
650 DBUS_TYPE_DOUBLE => float
651 DBUS_TYPE_STRING => string
652 DBUS_TYPE_OBJECT_PATH => string
653 DBUS_TYPE_SIGNATURE => string
654 DBUS_TYPE_ARRAY => list
655 DBUS_TYPE_VARIANT => list
656 DBUS_TYPE_STRUCT => list
657 DBUS_TYPE_DICT_ENTRY => list
658
659Example:
288 660
289\(dbus-call-method 661\(dbus-call-method
290 :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp" 662 :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
@@ -318,7 +690,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
318 DBusError derror; 690 DBusError derror;
319 unsigned int dtype; 691 unsigned int dtype;
320 int i; 692 int i;
321 char *value; 693 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
322 694
323 /* Check parameters. */ 695 /* Check parameters. */
324 bus = args[0]; 696 bus = args[0];
@@ -344,10 +716,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
344 connection = xd_initialize (bus); 716 connection = xd_initialize (bus);
345 717
346 /* Create the message. */ 718 /* Create the message. */
347 dmessage = dbus_message_new_method_call (SDATA (service), 719 dmessage = dbus_message_new_method_call ((char *) SDATA (service),
348 SDATA (path), 720 (char *) SDATA (path),
349 SDATA (interface), 721 (char *) SDATA (interface),
350 SDATA (method)); 722 (char *) SDATA (method));
351 if (dmessage == NULL) 723 if (dmessage == NULL)
352 { 724 {
353 UNGCPRO; 725 UNGCPRO;
@@ -356,27 +728,26 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
356 728
357 UNGCPRO; 729 UNGCPRO;
358 730
731 /* Initialize parameter list of message. */
732 dbus_message_iter_init_append (dmessage, &iter);
733
359 /* Append parameters to the message. */ 734 /* Append parameters to the message. */
360 for (i = 5; i < nargs; ++i) 735 for (i = 5; i < nargs; ++i)
361 { 736 {
362 737
363 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); 738 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
364 XD_DEBUG_MESSAGE ("Parameter%d %s", 739 XD_DEBUG_MESSAGE ("Parameter%d %s",
365 i-4, 740 i-4, SDATA (format2 ("%s", args[i], Qnil)));
366 SDATA (format2 ("%s", args[i], Qnil)));
367 741
368 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); 742 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
369 if (dtype == DBUS_TYPE_INVALID) 743 if (XD_DBUS_TYPE_P (args[i]))
370 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); 744 ++i;
371 745
372 value = (char *) xd_retrieve_value (dtype, args[i]); 746 /* Check for valid signature. We use DBUS_TYPE_INVALID is
747 indication that there is no parent type. */
748 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
373 749
374 if (!dbus_message_append_args (dmessage, 750 xd_append_arg (dtype, args[i], &iter);
375 dtype,
376 &value,
377 DBUS_TYPE_INVALID))
378 xsignal2 (Qdbus_error,
379 build_string ("Unable to append argument"), args[i]);
380 } 751 }
381 752
382 /* Send the message. */ 753 /* Send the message. */
@@ -441,8 +812,10 @@ converted into D-Bus types via the following rules:
441 integer => DBUS_TYPE_INT32 812 integer => DBUS_TYPE_INT32
442 float => DBUS_TYPE_DOUBLE 813 float => DBUS_TYPE_DOUBLE
443 string => DBUS_TYPE_STRING 814 string => DBUS_TYPE_STRING
815 list => DBUS_TYPE_ARRAY
444 816
445Other Lisp objects are not supported as arguments of SIGNAL. 817All arguments can be preceded by a type symbol. For details about
818type symbols, see Info node `(dbus)Type Conversion'.
446 819
447Example: 820Example:
448 821
@@ -459,9 +832,10 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
459 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 832 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
460 DBusConnection *connection; 833 DBusConnection *connection;
461 DBusMessage *dmessage; 834 DBusMessage *dmessage;
835 DBusMessageIter iter;
462 unsigned int dtype; 836 unsigned int dtype;
463 int i; 837 int i;
464 char *value; 838 char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
465 839
466 /* Check parameters. */ 840 /* Check parameters. */
467 bus = args[0]; 841 bus = args[0];
@@ -487,9 +861,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
487 connection = xd_initialize (bus); 861 connection = xd_initialize (bus);
488 862
489 /* Create the message. */ 863 /* Create the message. */
490 dmessage = dbus_message_new_signal (SDATA (path), 864 dmessage = dbus_message_new_signal ((char *) SDATA (path),
491 SDATA (interface), 865 (char *) SDATA (interface),
492 SDATA (signal)); 866 (char *) SDATA (signal));
493 if (dmessage == NULL) 867 if (dmessage == NULL)
494 { 868 {
495 UNGCPRO; 869 UNGCPRO;
@@ -498,26 +872,25 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
498 872
499 UNGCPRO; 873 UNGCPRO;
500 874
875 /* Initialize parameter list of message. */
876 dbus_message_iter_init_append (dmessage, &iter);
877
501 /* Append parameters to the message. */ 878 /* Append parameters to the message. */
502 for (i = 5; i < nargs; ++i) 879 for (i = 5; i < nargs; ++i)
503 { 880 {
504 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); 881 XD_DEBUG_VALID_LISP_OBJECT_P (args[i]);
505 XD_DEBUG_MESSAGE ("Parameter%d %s", 882 XD_DEBUG_MESSAGE ("Parameter%d %s",
506 i-4, 883 i-4, SDATA (format2 ("%s", args[i], Qnil)));
507 SDATA (format2 ("%s", args[i], Qnil)));
508 884
509 dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); 885 dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
510 if (dtype == DBUS_TYPE_INVALID) 886 if (XD_DBUS_TYPE_P (args[i]))
511 xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); 887 ++i;
512 888
513 value = (char *) xd_retrieve_value (dtype, args[i]); 889 /* Check for valid signature. We use DBUS_TYPE_INVALID is
890 indication that there is no parent type. */
891 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]);
514 892
515 if (!dbus_message_append_args (dmessage, 893 xd_append_arg (dtype, args[i], &iter);
516 dtype,
517 &value,
518 DBUS_TYPE_INVALID))
519 xsignal2 (Qdbus_error,
520 build_string ("Unable to append argument"), args[i]);
521 } 894 }
522 895
523 /* Send the message. The message is just added to the outgoing 896 /* Send the message. The message is just added to the outgoing
@@ -604,10 +977,10 @@ xd_read_message (bus)
604 while (!NILP (value)) 977 while (!NILP (value))
605 { 978 {
606 key = XCAR (value); 979 key = XCAR (value);
607 /* key has the structure (SERVICE UNAME PATH HANDLER). */ 980 /* key has the structure (UNAME SERVICE PATH HANDLER). */
608 if (((uname == NULL) 981 if (((uname == NULL)
609 || (NILP (XCAR (XCDR (key)))) 982 || (NILP (XCAR (key)))
610 || (strcmp (uname, SDATA (XCAR (XCDR (key)))) == 0)) 983 || (strcmp (uname, SDATA (XCAR (key))) == 0))
611 && ((path == NULL) 984 && ((path == NULL)
612 || (NILP (XCAR (XCDR (XCDR (key))))) 985 || (NILP (XCAR (XCDR (XCDR (key)))))
613 || (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0)) 986 || (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0))
@@ -648,10 +1021,10 @@ void
648xd_read_queued_messages () 1021xd_read_queued_messages ()
649{ 1022{
650 1023
651 /* Vdbus_registered_functions_table will be made as hash table in 1024 /* Vdbus_registered_functions_table will be initialized as hash
652 dbus.el. When it isn't loaded yet, it doesn't make sense to 1025 table in dbus.el. When this package isn't loaded yet, it doesn't
653 handle D-Bus messages. Furthermore, we ignore all Lisp errors 1026 make sense to handle D-Bus messages. Furthermore, we ignore all
654 during the call. */ 1027 Lisp errors during the call. */
655 if (HASH_TABLE_P (Vdbus_registered_functions_table)) 1028 if (HASH_TABLE_P (Vdbus_registered_functions_table))
656 { 1029 {
657 internal_condition_case_1 (xd_read_message, QCdbus_system_bus, 1030 internal_condition_case_1 (xd_read_message, QCdbus_system_bus,
@@ -687,15 +1060,15 @@ SIGNAL and HANDLER must not be nil. Example:
687 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" 1060 :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
688 "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler) 1061 "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler)
689 1062
690 => (:system ":1.3" "/org/freedesktop/Hal/Manager" 1063 => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded")
691 "org.freedesktop.Hal.Manager" "DeviceAdded") 1064 ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler))
692 1065
693`dbus-register-signal' returns an object, which can be used in 1066`dbus-register-signal' returns an object, which can be used in
694`dbus-unregister-signal' for removing the registration. */) 1067`dbus-unregister-signal' for removing the registration. */)
695 (bus, service, path, interface, signal, handler) 1068 (bus, service, path, interface, signal, handler)
696 Lisp_Object bus, service, path, interface, signal, handler; 1069 Lisp_Object bus, service, path, interface, signal, handler;
697{ 1070{
698 Lisp_Object unique_name, key, value; 1071 Lisp_Object uname, key, value;
699 DBusConnection *connection; 1072 DBusConnection *connection;
700 char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; 1073 char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
701 DBusError derror; 1074 DBusError derror;
@@ -706,7 +1079,7 @@ SIGNAL and HANDLER must not be nil. Example:
706 if (!NILP (path)) CHECK_STRING (path); 1079 if (!NILP (path)) CHECK_STRING (path);
707 CHECK_STRING (interface); 1080 CHECK_STRING (interface);
708 CHECK_STRING (signal); 1081 CHECK_STRING (signal);
709 CHECK_SYMBOL (handler); 1082 FUNCTIONP (handler);
710 1083
711 /* Retrieve unique name of service. If service is a known name, we 1084 /* Retrieve unique name of service. If service is a known name, we
712 will register for the corresponding unique name, if any. Signals 1085 will register for the corresponding unique name, if any. Signals
@@ -716,51 +1089,58 @@ SIGNAL and HANDLER must not be nil. Example:
716 && (strlen (SDATA (service)) > 0) 1089 && (strlen (SDATA (service)) > 0)
717 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) 1090 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0)
718 && (strncmp (SDATA (service), ":", 1) != 0)) 1091 && (strncmp (SDATA (service), ":", 1) != 0))
719 unique_name = call2 (intern ("dbus-get-name-owner"), bus, service); 1092 {
1093 uname = call2 (intern ("dbus-get-name-owner"), bus, service);
1094 /* When there is no unique name, we mark it with an empty
1095 string. */
1096 if (NILP (uname))
1097 uname = build_string ("");
1098 }
720 else 1099 else
721 unique_name = service; 1100 uname = service;
722 1101
723 /* Open a connection to the bus. */ 1102 /* Create a matching rule if the unique name exists (when no
724 connection = xd_initialize (bus); 1103 wildcard). */
1104 if (NILP (uname) || (strlen (SDATA (uname)) > 0))
1105 {
1106 /* Open a connection to the bus. */
1107 connection = xd_initialize (bus);
725 1108
726 /* Create a rule to receive related signals. */ 1109 /* Create a rule to receive related signals. */
727 sprintf (rule, 1110 sprintf (rule,
728 "type='signal',interface='%s',member=%s%", 1111 "type='signal',interface='%s',member='%s'",
729 SDATA (interface), 1112 SDATA (interface),
730 SDATA (signal)); 1113 SDATA (signal));
731 1114
732 /* Add unique name and path to the rule if they are non-nil. */ 1115 /* Add unique name and path to the rule if they are non-nil. */
733 if (!NILP (unique_name)) 1116 if (!NILP (uname))
734 sprintf (rule, "%s,sender='%s'%", rule, SDATA (unique_name)); 1117 sprintf (rule, "%s,sender='%s'", rule, SDATA (uname));
735 1118
736 if (!NILP (path)) 1119 if (!NILP (path))
737 sprintf (rule, "%s,path='%s'", rule, SDATA (path)); 1120 sprintf (rule, "%s,path='%s'", rule, SDATA (path));
738 1121
739 /* Add the rule to the bus. */ 1122 /* Add the rule to the bus. */
740 dbus_error_init (&derror); 1123 dbus_error_init (&derror);
741 dbus_bus_add_match (connection, rule, &derror); 1124 dbus_bus_add_match (connection, rule, &derror);
742 if (dbus_error_is_set (&derror)) 1125 if (dbus_error_is_set (&derror))
743 XD_ERROR (derror); 1126 XD_ERROR (derror);
744 1127
745 XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); 1128 XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
1129 }
746 1130
747 /* Create a hash table entry. */ 1131 /* Create a hash table entry. */
748 key = list3 (bus, interface, signal); 1132 key = list3 (bus, interface, signal);
749 value = Fgethash (key, Vdbus_registered_functions_table, Qnil); 1133 value = Fgethash (key, Vdbus_registered_functions_table, Qnil);
750 1134
751 if (NILP (Fmember (list4 (service, unique_name, path, handler), value))) 1135 if (NILP (Fmember (list4 (uname, service, path, handler), value)))
752 Fputhash (key, 1136 Fputhash (key,
753 Fcons (list4 (service, unique_name, path, handler), value), 1137 Fcons (list4 (uname, service, path, handler), value),
754 Vdbus_registered_functions_table); 1138 Vdbus_registered_functions_table);
755 1139
756 /* Return key. */ 1140 /* Return object. */
757 return key; 1141 return list2 (key, list3 (service, path, handler));
758} 1142}
759 1143
760/* The current implementation removes ALL registered functions for a
761 given signal. Shouldn't be a problem in general, but there might
762 be cases it is not desired. Maybe we can refine the
763 implementation. */
764DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal, 1144DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal,
765 1, 1, 0, 1145 1, 1, 0,
766 doc: /* Unregister OBJECT from the D-Bus. 1146 doc: /* Unregister OBJECT from the D-Bus.
@@ -768,9 +1148,37 @@ OBJECT must be the result of a preceding `dbus-register-signal' call. */)
768 (object) 1148 (object)
769 Lisp_Object object; 1149 Lisp_Object object;
770{ 1150{
1151 Lisp_Object value;
1152 struct gcpro gcpro1;
1153
1154 /* Check parameter. */
1155 CONSP (object) && (!NILP (XCAR (object))) && CONSP (XCDR (object));
771 1156
772 /* Unintern the signal symbol. */ 1157 /* Find the corresponding entry in the hash table. */
773 Fremhash (object, Vdbus_registered_functions_table); 1158 value = Fgethash (XCAR (object), Vdbus_registered_functions_table, Qnil);
1159
1160 /* Loop over the registered functions. */
1161 while (!NILP (value))
1162 {
1163 GCPRO1 (value);
1164
1165 /* (car value) has the structure (UNAME SERVICE PATH HANDLER).
1166 (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */
1167 if (!NILP (Fequal (XCDR (XCAR (value)), XCAR (XCDR (object)))))
1168 {
1169 /* Compute new hash value. */
1170 value = Fdelete (XCAR (value),
1171 Fgethash (XCAR (object),
1172 Vdbus_registered_functions_table, Qnil));
1173 if (NILP (value))
1174 Fremhash (XCAR (object), Vdbus_registered_functions_table);
1175 else
1176 Fputhash (XCAR (object), value, Vdbus_registered_functions_table);
1177 RETURN_UNGCPRO (Qt);
1178 }
1179 UNGCPRO;
1180 value = XCDR (value);
1181 }
774 1182
775 /* Return. */ 1183 /* Return. */
776 return Qnil; 1184 return Qnil;
@@ -814,20 +1222,68 @@ syms_of_dbusbind ()
814 QCdbus_session_bus = intern (":session"); 1222 QCdbus_session_bus = intern (":session");
815 staticpro (&QCdbus_session_bus); 1223 staticpro (&QCdbus_session_bus);
816 1224
1225 QCdbus_type_byte = intern (":byte");
1226 staticpro (&QCdbus_type_byte);
1227
1228 QCdbus_type_boolean = intern (":boolean");
1229 staticpro (&QCdbus_type_boolean);
1230
1231 QCdbus_type_int16 = intern (":int16");
1232 staticpro (&QCdbus_type_int16);
1233
1234 QCdbus_type_uint16 = intern (":uint16");
1235 staticpro (&QCdbus_type_uint16);
1236
1237 QCdbus_type_int32 = intern (":int32");
1238 staticpro (&QCdbus_type_int32);
1239
1240 QCdbus_type_uint32 = intern (":uint32");
1241 staticpro (&QCdbus_type_uint32);
1242
1243 QCdbus_type_int64 = intern (":int64");
1244 staticpro (&QCdbus_type_int64);
1245
1246 QCdbus_type_uint64 = intern (":uint64");
1247 staticpro (&QCdbus_type_uint64);
1248
1249 QCdbus_type_double = intern (":double");
1250 staticpro (&QCdbus_type_double);
1251
1252 QCdbus_type_string = intern (":string");
1253 staticpro (&QCdbus_type_string);
1254
1255 QCdbus_type_object_path = intern (":object-path");
1256 staticpro (&QCdbus_type_object_path);
1257
1258 QCdbus_type_signature = intern (":signature");
1259 staticpro (&QCdbus_type_signature);
1260
1261 QCdbus_type_array = intern (":array");
1262 staticpro (&QCdbus_type_array);
1263
1264 QCdbus_type_variant = intern (":variant");
1265 staticpro (&QCdbus_type_variant);
1266
1267 QCdbus_type_struct = intern (":struct");
1268 staticpro (&QCdbus_type_struct);
1269
1270 QCdbus_type_dict_entry = intern (":dict-entry");
1271 staticpro (&QCdbus_type_dict_entry);
1272
817 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, 1273 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table,
818 doc: /* Hash table of registered functions for D-Bus. 1274 doc: /* Hash table of registered functions for D-Bus.
819The key in the hash table is the list (BUS MEMBER INTERFACE). BUS is 1275The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is
820either the symbol `:system' or the symbol `:session'. INTERFACE is a 1276either the symbol `:system' or the symbol `:session'. INTERFACE is a
821string which denotes a D-Bus interface, and MEMBER, also a string, is 1277string which denotes a D-Bus interface, and MEMBER, also a string, is
822either a method or a signal INTERFACE is offering. All arguments but 1278either a method or a signal INTERFACE is offering. All arguments but
823BUS must not be nil. 1279BUS must not be nil.
824 1280
825The value in the hash table is a list of triple lists 1281The value in the hash table is a list of quadruple lists
826\((SERVICE UNAME PATH HANDLER) (SERVICE UNAME PATH HANDLER) ...). 1282\((UNAME SERVICE PATH HANDLER) (UNAME SERVICE PATH HANDLER) ...).
827SERVICE is the service name as registered, UNAME is the corresponding 1283SERVICE is the service name as registered, UNAME is the corresponding
828unique name. PATH is the object path of the sending object. All of 1284unique name. PATH is the object path of the sending object. All of
829them be nil, which means a wildcard then. HANDLER is the function to 1285them can be nil, which means a wildcard then. HANDLER is the function
830be called when a D-Bus message, which matches the key criteria, 1286to be called when a D-Bus message, which matches the key criteria,
831arrives. */); 1287arrives. */);
832 /* We initialize Vdbus_registered_functions_table in dbus.el, 1288 /* We initialize Vdbus_registered_functions_table in dbus.el,
833 because we need to define a hash table function first. */ 1289 because we need to define a hash table function first. */
diff --git a/src/fileio.c b/src/fileio.c
index 51a40e66db9..4dfb0d24796 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -21,6 +21,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21Boston, MA 02110-1301, USA. */ 21Boston, MA 02110-1301, USA. */
22 22
23#include <config.h> 23#include <config.h>
24#include <limits.h>
24 25
25#ifdef HAVE_FCNTL_H 26#ifdef HAVE_FCNTL_H
26#include <fcntl.h> 27#include <fcntl.h>
@@ -3882,7 +3883,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
3882 overflow. The calculations below double the file size 3883 overflow. The calculations below double the file size
3883 twice, so check that it can be multiplied by 4 safely. */ 3884 twice, so check that it can be multiplied by 4 safely. */
3884 if (XINT (end) != st.st_size 3885 if (XINT (end) != st.st_size
3885 || ((int) st.st_size * 4) / 4 != st.st_size) 3886 || st.st_size > INT_MAX / 4)
3886 error ("Maximum buffer size exceeded"); 3887 error ("Maximum buffer size exceeded");
3887 3888
3888 /* The file size returned from stat may be zero, but data 3889 /* The file size returned from stat may be zero, but data
diff --git a/src/macmenu.c b/src/macmenu.c
index aa0be0bdc2e..616d136465a 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -3272,7 +3272,8 @@ fill_menubar (wv, deep_p)
3272 } 3272 }
3273#endif /* !TARGET_API_MAC_CARBON */ 3273#endif /* !TARGET_API_MAC_CARBON */
3274 } 3274 }
3275 else 3275
3276 if (!menu)
3276 { 3277 {
3277#if TARGET_API_MAC_CARBON 3278#if TARGET_API_MAC_CARBON
3278 err = CreateNewMenu (id, 0, &menu); 3279 err = CreateNewMenu (id, 0, &menu);
diff --git a/src/process.c b/src/process.c
index c2f0c82a6a8..542bf4fdda5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -631,7 +631,7 @@ make_process (name)
631 p->tick = 0; 631 p->tick = 0;
632 p->update_tick = 0; 632 p->update_tick = 0;
633 p->pid = 0; 633 p->pid = 0;
634 p->pty_flag = 0; 634 p->pty_flag = Qnil;
635 p->raw_status_new = 0; 635 p->raw_status_new = 0;
636 p->status = Qrun; 636 p->status = Qrun;
637 p->mark = Fmake_marker (); 637 p->mark = Fmake_marker ();
diff --git a/src/w32fns.c b/src/w32fns.c
index 8ddf8d0f74d..8b2b865c6d3 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3144,7 +3144,8 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
3144 { 3144 {
3145 /* Forward asciified character sequence. */ 3145 /* Forward asciified character sequence. */
3146 post_character_message 3146 post_character_message
3147 (hwnd, WM_CHAR, key.uChar.AsciiChar, lParam, 3147 (hwnd, WM_CHAR,
3148 (unsigned char) key.uChar.AsciiChar, lParam,
3148 w32_get_key_modifiers (wParam, lParam)); 3149 w32_get_key_modifiers (wParam, lParam));
3149 w32_kbd_patch_key (&key); 3150 w32_kbd_patch_key (&key);
3150 } 3151 }
diff --git a/src/xdisp.c b/src/xdisp.c
index 5f0ff5e08f9..8e24fbacb4e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23837,6 +23837,24 @@ phys_cursor_in_rect_p (w, r)
23837{ 23837{
23838 XRectangle cr, result; 23838 XRectangle cr, result;
23839 struct glyph *cursor_glyph; 23839 struct glyph *cursor_glyph;
23840 struct glyph_row *row;
23841
23842 if (w->phys_cursor.vpos >= 0
23843 && w->phys_cursor.vpos < w->current_matrix->nrows
23844 && (row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos),
23845 row->enabled_p)
23846 && row->cursor_in_fringe_p)
23847 {
23848 /* Cursor is in the fringe. */
23849 cr.x = window_box_right_offset (w,
23850 (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
23851 ? RIGHT_MARGIN_AREA
23852 : TEXT_AREA));
23853 cr.y = row->y;
23854 cr.width = WINDOW_RIGHT_FRINGE_WIDTH (w);
23855 cr.height = row->height;
23856 return x_intersect_rectangles (&cr, r, &result);
23857 }
23840 23858
23841 cursor_glyph = get_phys_cursor_glyph (w); 23859 cursor_glyph = get_phys_cursor_glyph (w);
23842 if (cursor_glyph) 23860 if (cursor_glyph)