comparison src/dbusbind.c @ 111472:943d9b433fca

* dbusbind.c (QCdbus_type_unix_fd): New Lisp object. (XD_BASIC_DBUS_TYPE, xd_symbol_to_dbus_type, xd_signature) (xd_append_arg, xd_retrieve_arg): Support DBUS_TYPE_UNIX_FD. (Fdbus_call_method): Add DBUS_TYPE_UNIX_FD type mapping to doc string. (syms_of_dbusbind): Initialize QCdbus_type_unix_fd).
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 10 Nov 2010 09:48:18 +0100
parents cf216ba9dc87
children 143e567b63bc
comparison
equal deleted inserted replaced
111471:5cb8f9659806 111472:943d9b433fca
55 Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; 55 Lisp_Object QCdbus_type_int16, QCdbus_type_uint16;
56 Lisp_Object QCdbus_type_int32, QCdbus_type_uint32; 56 Lisp_Object QCdbus_type_int32, QCdbus_type_uint32;
57 Lisp_Object QCdbus_type_int64, QCdbus_type_uint64; 57 Lisp_Object QCdbus_type_int64, QCdbus_type_uint64;
58 Lisp_Object QCdbus_type_double, QCdbus_type_string; 58 Lisp_Object QCdbus_type_double, QCdbus_type_string;
59 Lisp_Object QCdbus_type_object_path, QCdbus_type_signature; 59 Lisp_Object QCdbus_type_object_path, QCdbus_type_signature;
60 #ifdef DBUS_TYPE_UNIX_FD
61 Lisp_Object QCdbus_type_unix_fd;
62 #endif
60 Lisp_Object QCdbus_type_array, QCdbus_type_variant; 63 Lisp_Object QCdbus_type_array, QCdbus_type_variant;
61 Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; 64 Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry;
62 65
63 /* Registered buses. */ 66 /* Registered buses. */
64 Lisp_Object Vdbus_registered_buses; 67 Lisp_Object Vdbus_registered_buses;
145 } while (0) 148 } while (0)
146 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) 149 #define XD_DEBUG_VALID_LISP_OBJECT_P(object)
147 #endif 150 #endif
148 151
149 /* Check whether TYPE is a basic DBusType. */ 152 /* Check whether TYPE is a basic DBusType. */
153 #ifdef DBUS_TYPE_UNIX_FD
154 #define XD_BASIC_DBUS_TYPE(type) \
155 ((type == DBUS_TYPE_BYTE) \
156 || (type == DBUS_TYPE_BOOLEAN) \
157 || (type == DBUS_TYPE_INT16) \
158 || (type == DBUS_TYPE_UINT16) \
159 || (type == DBUS_TYPE_INT32) \
160 || (type == DBUS_TYPE_UINT32) \
161 || (type == DBUS_TYPE_INT64) \
162 || (type == DBUS_TYPE_UINT64) \
163 || (type == DBUS_TYPE_DOUBLE) \
164 || (type == DBUS_TYPE_STRING) \
165 || (type == DBUS_TYPE_OBJECT_PATH) \
166 || (type == DBUS_TYPE_SIGNATURE \
167 || (type == DBUS_TYPE_UNIX_FD))
168 #else
150 #define XD_BASIC_DBUS_TYPE(type) \ 169 #define XD_BASIC_DBUS_TYPE(type) \
151 ((type == DBUS_TYPE_BYTE) \ 170 ((type == DBUS_TYPE_BYTE) \
152 || (type == DBUS_TYPE_BOOLEAN) \ 171 || (type == DBUS_TYPE_BOOLEAN) \
153 || (type == DBUS_TYPE_INT16) \ 172 || (type == DBUS_TYPE_INT16) \
154 || (type == DBUS_TYPE_UINT16) \ 173 || (type == DBUS_TYPE_UINT16) \
158 || (type == DBUS_TYPE_UINT64) \ 177 || (type == DBUS_TYPE_UINT64) \
159 || (type == DBUS_TYPE_DOUBLE) \ 178 || (type == DBUS_TYPE_DOUBLE) \
160 || (type == DBUS_TYPE_STRING) \ 179 || (type == DBUS_TYPE_STRING) \
161 || (type == DBUS_TYPE_OBJECT_PATH) \ 180 || (type == DBUS_TYPE_OBJECT_PATH) \
162 || (type == DBUS_TYPE_SIGNATURE)) 181 || (type == DBUS_TYPE_SIGNATURE))
182 #endif
163 183
164 /* This was a macro. On Solaris 2.11 it was said to compile for 184 /* This was a macro. On Solaris 2.11 it was said to compile for
165 hours, when optimzation is enabled. So we have transferred it into 185 hours, when optimzation is enabled. So we have transferred it into
166 a function. */ 186 a function. */
167 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one 187 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one
180 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 200 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64
181 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE 201 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE
182 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING 202 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING
183 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH 203 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH
184 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE 204 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE
205 #ifdef DBUS_TYPE_UNIX_FD
206 : (EQ (object, QCdbus_type_unix_fd)) ? DBUS_TYPE_UNIX_FD
207 #endif
185 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY 208 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY
186 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT 209 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT
187 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT 210 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT
188 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY 211 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY
189 : DBUS_TYPE_INVALID); 212 : DBUS_TYPE_INVALID);
236 { 259 {
237 case DBUS_TYPE_BYTE: 260 case DBUS_TYPE_BYTE:
238 case DBUS_TYPE_UINT16: 261 case DBUS_TYPE_UINT16:
239 case DBUS_TYPE_UINT32: 262 case DBUS_TYPE_UINT32:
240 case DBUS_TYPE_UINT64: 263 case DBUS_TYPE_UINT64:
264 #ifdef DBUS_TYPE_UNIX_FD
265 case DBUS_TYPE_UNIX_FD:
266 #endif
241 CHECK_NATNUM (object); 267 CHECK_NATNUM (object);
242 sprintf (signature, "%c", dtype); 268 sprintf (signature, "%c", dtype);
243 break; 269 break;
244 270
245 case DBUS_TYPE_BOOLEAN: 271 case DBUS_TYPE_BOOLEAN:
449 XD_SIGNAL2 (build_string ("Unable to append argument"), object); 475 XD_SIGNAL2 (build_string ("Unable to append argument"), object);
450 return; 476 return;
451 } 477 }
452 478
453 case DBUS_TYPE_UINT32: 479 case DBUS_TYPE_UINT32:
480 #ifdef DBUS_TYPE_UNIX_FD
481 case DBUS_TYPE_UNIX_FD:
482 #endif
454 CHECK_NUMBER (object); 483 CHECK_NUMBER (object);
455 { 484 {
456 dbus_uint32_t val = XUINT (object); 485 dbus_uint32_t val = XUINT (object);
457 XD_DEBUG_MESSAGE ("%c %u", dtype, val); 486 XD_DEBUG_MESSAGE ("%c %u", dtype, val);
458 if (!dbus_message_iter_append_basic (iter, dtype, &val)) 487 if (!dbus_message_iter_append_basic (iter, dtype, &val))
646 XD_DEBUG_MESSAGE ("%c %d", dtype, val); 675 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
647 return make_fixnum_or_float (val); 676 return make_fixnum_or_float (val);
648 } 677 }
649 678
650 case DBUS_TYPE_UINT32: 679 case DBUS_TYPE_UINT32:
680 #ifdef DBUS_TYPE_UNIX_FD
681 case DBUS_TYPE_UNIX_FD:
682 #endif
651 { 683 {
652 dbus_uint32_t val; 684 dbus_uint32_t val;
653 dbus_message_iter_get_basic (iter, &val); 685 dbus_message_iter_get_basic (iter, &val);
654 XD_DEBUG_MESSAGE ("%c %d", dtype, val); 686 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
655 return make_fixnum_or_float (val); 687 return make_fixnum_or_float (val);
981 DBUS_TYPE_BOOLEAN => t or nil 1013 DBUS_TYPE_BOOLEAN => t or nil
982 DBUS_TYPE_BYTE => number 1014 DBUS_TYPE_BYTE => number
983 DBUS_TYPE_UINT16 => number 1015 DBUS_TYPE_UINT16 => number
984 DBUS_TYPE_INT16 => integer 1016 DBUS_TYPE_INT16 => integer
985 DBUS_TYPE_UINT32 => number or float 1017 DBUS_TYPE_UINT32 => number or float
1018 DBUS_TYPE_UNIX_FD => number or float
986 DBUS_TYPE_INT32 => integer or float 1019 DBUS_TYPE_INT32 => integer or float
987 DBUS_TYPE_UINT64 => number or float 1020 DBUS_TYPE_UINT64 => number or float
988 DBUS_TYPE_INT64 => integer or float 1021 DBUS_TYPE_INT64 => integer or float
989 DBUS_TYPE_DOUBLE => float 1022 DBUS_TYPE_DOUBLE => float
990 DBUS_TYPE_STRING => string 1023 DBUS_TYPE_STRING => string
2102 staticpro (&QCdbus_type_object_path); 2135 staticpro (&QCdbus_type_object_path);
2103 2136
2104 QCdbus_type_signature = intern_c_string (":signature"); 2137 QCdbus_type_signature = intern_c_string (":signature");
2105 staticpro (&QCdbus_type_signature); 2138 staticpro (&QCdbus_type_signature);
2106 2139
2140 #ifdef DBUS_TYPE_UNIX_FD
2141 QCdbus_type_unix_fd = intern_c_string (":unix-fd");
2142 staticpro (&QCdbus_type_unix_fd);
2143 #endif
2144
2107 QCdbus_type_array = intern_c_string (":array"); 2145 QCdbus_type_array = intern_c_string (":array");
2108 staticpro (&QCdbus_type_array); 2146 staticpro (&QCdbus_type_array);
2109 2147
2110 QCdbus_type_variant = intern_c_string (":variant"); 2148 QCdbus_type_variant = intern_c_string (":variant");
2111 staticpro (&QCdbus_type_variant); 2149 staticpro (&QCdbus_type_variant);