From 77a28bbf178de331eda736dad8ce56d65e3d5f6f Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 16 Dec 2007 10:51:12 +0000 Subject: (Finsert_file_contents): Fix overflow check to not depend on undefined integer overflow. --- src/ChangeLog | 5 +++++ src/fileio.c | 43 ++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index d5edca82fe9..21e1f9c9df2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-12-16 Andreas Schwab + + * fileio.c (Finsert_file_contents): Fix overflow check to not + depend on undefined integer overflow. + 2007-12-14 Jason Rumney * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT diff --git a/src/fileio.c b/src/fileio.c index 2d6f74a8840..dbdeef7076a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -21,6 +21,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include +#include #ifdef HAVE_FCNTL_H #include @@ -3693,26 +3694,26 @@ read_non_regular_quit () DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, 1, 5, 0, doc: /* Insert contents of file FILENAME after point. -Returns list of absolute file name and number of characters inserted. -If second argument VISIT is non-nil, the buffer's visited filename and -last save file modtime are set, and it is marked unmodified. If -visiting and the file does not exist, visiting is completed before the -error is signaled. - -The optional third and fourth arguments BEG and END specify what portion -of the file to insert. These arguments count bytes in the file, not -characters in the buffer. If VISIT is non-nil, BEG and END must be nil. - -If optional fifth argument REPLACE is non-nil, replace the current -buffer contents (in the accessible portion) with the file contents. -This is better than simply deleting and inserting the whole thing -because (1) it preserves some marker positions and (2) it puts less data -in the undo list. When REPLACE is non-nil, the second return value is -the number of characters that replace previous buffer contents. - -This function does code conversion according to the value of -`coding-system-for-read' or `file-coding-system-alist', and sets the -variable `last-coding-system-used' to the coding system actually used. */) + Returns list of absolute file name and number of characters inserted. + If second argument VISIT is non-nil, the buffer's visited filename and + last save file modtime are set, and it is marked unmodified. If + visiting and the file does not exist, visiting is completed before the + error is signaled. + + The optional third and fourth arguments BEG and END specify what portion + of the file to insert. These arguments count bytes in the file, not + characters in the buffer. If VISIT is non-nil, BEG and END must be nil. + + If optional fifth argument REPLACE is non-nil, replace the current + buffer contents (in the accessible portion) with the file contents. + This is better than simply deleting and inserting the whole thing + because (1) it preserves some marker positions and (2) it puts less data + in the undo list. When REPLACE is non-nil, the second return value is + the number of characters that replace previous buffer contents. + + This function does code conversion according to the value of + `coding-system-for-read' or `file-coding-system-alist', and sets the + variable `last-coding-system-used' to the coding system actually used. */) (filename, visit, beg, end, replace) Lisp_Object filename, visit, beg, end, replace; { @@ -3863,7 +3864,7 @@ variable `last-coding-system-used' to the coding system actually used. */) overflow. The calculations below double the file size twice, so check that it can be multiplied by 4 safely. */ if (XINT (end) != st.st_size - || ((int) st.st_size * 4) / 4 != st.st_size) + || st.st_size > INT_MAX / 4) error ("Maximum buffer size exceeded"); /* The file size returned from stat may be zero, but data -- cgit v1.2.3 From f5bf196677eac15a68b229caf5a8757795cf7477 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 16 Dec 2007 10:54:19 +0000 Subject: Undo spurious change. --- src/fileio.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/fileio.c b/src/fileio.c index dbdeef7076a..19558fa332a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3694,26 +3694,26 @@ read_non_regular_quit () DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, 1, 5, 0, doc: /* Insert contents of file FILENAME after point. - Returns list of absolute file name and number of characters inserted. - If second argument VISIT is non-nil, the buffer's visited filename and - last save file modtime are set, and it is marked unmodified. If - visiting and the file does not exist, visiting is completed before the - error is signaled. - - The optional third and fourth arguments BEG and END specify what portion - of the file to insert. These arguments count bytes in the file, not - characters in the buffer. If VISIT is non-nil, BEG and END must be nil. - - If optional fifth argument REPLACE is non-nil, replace the current - buffer contents (in the accessible portion) with the file contents. - This is better than simply deleting and inserting the whole thing - because (1) it preserves some marker positions and (2) it puts less data - in the undo list. When REPLACE is non-nil, the second return value is - the number of characters that replace previous buffer contents. - - This function does code conversion according to the value of - `coding-system-for-read' or `file-coding-system-alist', and sets the - variable `last-coding-system-used' to the coding system actually used. */) +Returns list of absolute file name and number of characters inserted. +If second argument VISIT is non-nil, the buffer's visited filename and +last save file modtime are set, and it is marked unmodified. If +visiting and the file does not exist, visiting is completed before the +error is signaled. + +The optional third and fourth arguments BEG and END specify what portion +of the file to insert. These arguments count bytes in the file, not +characters in the buffer. If VISIT is non-nil, BEG and END must be nil. + +If optional fifth argument REPLACE is non-nil, replace the current +buffer contents (in the accessible portion) with the file contents. +This is better than simply deleting and inserting the whole thing +because (1) it preserves some marker positions and (2) it puts less data +in the undo list. When REPLACE is non-nil, the second return value is +the number of characters that replace previous buffer contents. + +This function does code conversion according to the value of +`coding-system-for-read' or `file-coding-system-alist', and sets the +variable `last-coding-system-used' to the coding system actually used. */) (filename, visit, beg, end, replace) Lisp_Object filename, visit, beg, end, replace; { -- cgit v1.2.3 From f5306ca30f8b9b4ab8a19eb15a42174ae8a91c20 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 16 Dec 2007 22:36:47 +0000 Subject: * dbusbind.c (top): Include . (Fdbus_call_method, Fdbus_send_signal): Apply type cast in dbus_message_new_method_call and dbus_message_new_signal. (Fdbus_register_signal): Rename unique_name to uname. Check handler for FUNCTIONP instead of CHECK_SYMBOL. Handle case of non-existing unique name. Fix typos in matching rule. Return an object which is useful in Fdbus_unregister_signal. (Fdbus_unregister_signal): Reimplementation, in order to remove only the corresponding entry. (Vdbus_registered_functions_table): Change the order of entries. Apply these changes in xd_read_message and Fdbus_register_signal. --- src/ChangeLog | 14 ++++++ src/dbusbind.c | 142 ++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 103 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 21e1f9c9df2..51c19d79197 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2007-12-16 Michael Albinus + + * dbusbind.c (top): Include . + (Fdbus_call_method, Fdbus_send_signal): Apply type cast in + dbus_message_new_method_call and dbus_message_new_signal. + (Fdbus_register_signal): Rename unique_name to uname. Check + handler for FUNCTIONP instead of CHECK_SYMBOL. Handle case of + non-existing unique name. Fix typos in matching rule. Return an + object which is useful in Fdbus_unregister_signal. + (Fdbus_unregister_signal): Reimplementation, in order to remove + only the corresponding entry. + (Vdbus_registered_functions_table): Change the order of entries. + Apply these changes in xd_read_message and Fdbus_register_signal. + 2007-12-16 Andreas Schwab * fileio.c (Finsert_file_contents): Fix overflow check to not diff --git a/src/dbusbind.c b/src/dbusbind.c index 0ccccc8b22d..d4008f7314c 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -22,6 +22,7 @@ Boston, MA 02110-1301, USA. */ #ifdef HAVE_DBUS #include +#include #include #include "lisp.h" #include "frame.h" @@ -344,10 +345,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) connection = xd_initialize (bus); /* Create the message. */ - dmessage = dbus_message_new_method_call (SDATA (service), - SDATA (path), - SDATA (interface), - SDATA (method)); + dmessage = dbus_message_new_method_call ((char *) SDATA (service), + (char *) SDATA (path), + (char *) SDATA (interface), + (char *) SDATA (method)); if (dmessage == NULL) { UNGCPRO; @@ -487,9 +488,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) connection = xd_initialize (bus); /* Create the message. */ - dmessage = dbus_message_new_signal (SDATA (path), - SDATA (interface), - SDATA (signal)); + dmessage = dbus_message_new_signal ((char *) SDATA (path), + (char *) SDATA (interface), + (char *) SDATA (signal)); if (dmessage == NULL) { UNGCPRO; @@ -604,10 +605,10 @@ xd_read_message (bus) while (!NILP (value)) { key = XCAR (value); - /* key has the structure (SERVICE UNAME PATH HANDLER). */ + /* key has the structure (UNAME SERVICE PATH HANDLER). */ if (((uname == NULL) - || (NILP (XCAR (XCDR (key)))) - || (strcmp (uname, SDATA (XCAR (XCDR (key)))) == 0)) + || (NILP (XCAR (key))) + || (strcmp (uname, SDATA (XCAR (key))) == 0)) && ((path == NULL) || (NILP (XCAR (XCDR (XCDR (key))))) || (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0)) @@ -648,10 +649,10 @@ void xd_read_queued_messages () { - /* Vdbus_registered_functions_table will be made as hash table in - dbus.el. When it isn't loaded yet, it doesn't make sense to - handle D-Bus messages. Furthermore, we ignore all Lisp errors - during the call. */ + /* Vdbus_registered_functions_table will be initialized as hash + table in dbus.el. When this package isn't loaded yet, it doesn't + make sense to handle D-Bus messages. Furthermore, we ignore all + Lisp errors during the call. */ if (HASH_TABLE_P (Vdbus_registered_functions_table)) { internal_condition_case_1 (xd_read_message, QCdbus_system_bus, @@ -687,15 +688,15 @@ SIGNAL and HANDLER must not be nil. Example: :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler) - => (:system ":1.3" "/org/freedesktop/Hal/Manager" - "org.freedesktop.Hal.Manager" "DeviceAdded") + => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded") + ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler)) `dbus-register-signal' returns an object, which can be used in `dbus-unregister-signal' for removing the registration. */) (bus, service, path, interface, signal, handler) Lisp_Object bus, service, path, interface, signal, handler; { - Lisp_Object unique_name, key, value; + Lisp_Object uname, key, value; DBusConnection *connection; char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; DBusError derror; @@ -706,7 +707,7 @@ SIGNAL and HANDLER must not be nil. Example: if (!NILP (path)) CHECK_STRING (path); CHECK_STRING (interface); CHECK_STRING (signal); - CHECK_SYMBOL (handler); + FUNCTIONP (handler); /* Retrieve unique name of service. If service is a known name, we will register for the corresponding unique name, if any. Signals @@ -716,51 +717,58 @@ SIGNAL and HANDLER must not be nil. Example: && (strlen (SDATA (service)) > 0) && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) && (strncmp (SDATA (service), ":", 1) != 0)) - unique_name = call2 (intern ("dbus-get-name-owner"), bus, service); + { + uname = call2 (intern ("dbus-get-name-owner"), bus, service); + /* When there is no unique name, we mark it with an empty + string. */ + if (NILP (uname)) + uname = build_string (""); + } else - unique_name = service; + uname = service; - /* Open a connection to the bus. */ - connection = xd_initialize (bus); + /* Create a matching rule if the unique name exists (when no + wildcard). */ + if (NILP (uname) || (strlen (SDATA (uname)) > 0)) + { + /* Open a connection to the bus. */ + connection = xd_initialize (bus); - /* Create a rule to receive related signals. */ - sprintf (rule, - "type='signal',interface='%s',member=%s%", - SDATA (interface), - SDATA (signal)); + /* Create a rule to receive related signals. */ + sprintf (rule, + "type='signal',interface='%s',member='%s'", + SDATA (interface), + SDATA (signal)); - /* Add unique name and path to the rule if they are non-nil. */ - if (!NILP (unique_name)) - sprintf (rule, "%s,sender='%s'%", rule, SDATA (unique_name)); + /* Add unique name and path to the rule if they are non-nil. */ + if (!NILP (uname)) + sprintf (rule, "%s,sender='%s'", rule, SDATA (uname)); - if (!NILP (path)) - sprintf (rule, "%s,path='%s'", rule, SDATA (path)); + if (!NILP (path)) + sprintf (rule, "%s,path='%s'", rule, SDATA (path)); - /* Add the rule to the bus. */ - dbus_error_init (&derror); - dbus_bus_add_match (connection, rule, &derror); - if (dbus_error_is_set (&derror)) - XD_ERROR (derror); + /* Add the rule to the bus. */ + dbus_error_init (&derror); + dbus_bus_add_match (connection, rule, &derror); + if (dbus_error_is_set (&derror)) + XD_ERROR (derror); - XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); + XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); + } /* Create a hash table entry. */ key = list3 (bus, interface, signal); value = Fgethash (key, Vdbus_registered_functions_table, Qnil); - if (NILP (Fmember (list4 (service, unique_name, path, handler), value))) + if (NILP (Fmember (list4 (uname, service, path, handler), value))) Fputhash (key, - Fcons (list4 (service, unique_name, path, handler), value), + Fcons (list4 (uname, service, path, handler), value), Vdbus_registered_functions_table); - /* Return key. */ - return key; + /* Return object. */ + return list2 (key, list3 (service, path, handler)); } -/* The current implementation removes ALL registered functions for a - given signal. Shouldn't be a problem in general, but there might - be cases it is not desired. Maybe we can refine the - implementation. */ DEFUN ("dbus-unregister-signal", Fdbus_unregister_signal, Sdbus_unregister_signal, 1, 1, 0, doc: /* Unregister OBJECT from the D-Bus. @@ -768,9 +776,37 @@ OBJECT must be the result of a preceding `dbus-register-signal' call. */) (object) Lisp_Object object; { + Lisp_Object value; + struct gcpro gcpro1; - /* Unintern the signal symbol. */ - Fremhash (object, Vdbus_registered_functions_table); + /* Check parameter. */ + CONSP (object) && (!NILP (XCAR (object))) && CONSP (XCDR (object)); + + /* Find the corresponding entry in the hash table. */ + value = Fgethash (XCAR (object), Vdbus_registered_functions_table, Qnil); + + /* Loop over the registered functions. */ + while (!NILP (value)) + { + GCPRO1 (value); + + /* (car value) has the structure (UNAME SERVICE PATH HANDLER). + (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */ + if (!NILP (Fequal (XCDR (XCAR (value)), XCAR (XCDR (object))))) + { + /* Compute new hash value. */ + value = Fdelete (XCAR (value), + Fgethash (XCAR (object), + Vdbus_registered_functions_table, Qnil)); + if (NILP (value)) + Fremhash (XCAR (object), Vdbus_registered_functions_table); + else + Fputhash (XCAR (object), value, Vdbus_registered_functions_table); + RETURN_UNGCPRO (Qt); + } + UNGCPRO; + value = XCDR (value); + } /* Return. */ return Qnil; @@ -816,18 +852,18 @@ syms_of_dbusbind () DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, doc: /* Hash table of registered functions for D-Bus. -The key in the hash table is the list (BUS MEMBER INTERFACE). BUS is +The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is either the symbol `:system' or the symbol `:session'. INTERFACE is a string which denotes a D-Bus interface, and MEMBER, also a string, is either a method or a signal INTERFACE is offering. All arguments but BUS must not be nil. -The value in the hash table is a list of triple lists -\((SERVICE UNAME PATH HANDLER) (SERVICE UNAME PATH HANDLER) ...). +The value in the hash table is a list of quadruple lists +\((UNAME SERVICE PATH HANDLER) (UNAME SERVICE PATH HANDLER) ...). SERVICE is the service name as registered, UNAME is the corresponding unique name. PATH is the object path of the sending object. All of -them be nil, which means a wildcard then. HANDLER is the function to -be called when a D-Bus message, which matches the key criteria, +them can be nil, which means a wildcard then. HANDLER is the function +to be called when a D-Bus message, which matches the key criteria, arrives. */); /* We initialize Vdbus_registered_functions_table in dbus.el, because we need to define a hash table function first. */ -- cgit v1.2.3 From a313b2911a3a5e9ef76daec103b716ad11a607cf Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Mon, 17 Dec 2007 01:50:42 +0000 Subject: (w32_wnd_proc) : Cast char to unsigned before passing as wParam. --- src/ChangeLog | 5 +++++ src/w32fns.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 2bf4e0ed15f..a5b34e38966 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-12-17 Jason Rumney + + * w32fns.c (w32_wnd_proc) : Cast char to unsigned + before passing as wParam. + 2007-12-14 Jason Rumney * w32term.c (w32_read_socket): Use MULTIBYTE_CHAR_KEYSTROKE_EVENT diff --git a/src/w32fns.c b/src/w32fns.c index 9492989e735..44087329c78 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -3129,7 +3129,8 @@ w32_wnd_proc (hwnd, msg, wParam, lParam) { /* Forward asciified character sequence. */ post_character_message - (hwnd, WM_CHAR, key.uChar.AsciiChar, lParam, + (hwnd, WM_CHAR, + (unsigned char) key.uChar.AsciiChar, lParam, w32_get_key_modifiers (wParam, lParam)); w32_kbd_patch_key (&key); } -- cgit v1.2.3 From d57d5a78ba4f2625e86893d2a86e41e53879a581 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Wed, 19 Dec 2007 19:43:47 +0000 Subject: *** empty log message *** --- src/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 51c19d79197..57d548a315c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -856,6 +856,12 @@ * msdos.c (dos_rawgetc): Undo last change (there's no ``leaving selected frame'' on MSDOS). +2007-10-12 Martin Rudalics + + * frame.c (Qexplicit_name): New variable. + (x_report_frame_params): Report it in parameter alist. + (syms_of_frame): Intern and staticpro it. + 2007-10-10 Patrick Mahan (tiny change) * macfns.c (x_create_tip_frame): Set terminal for frame. @@ -883,6 +889,11 @@ * puresize.h (BASE_PURESIZE): Increase to 1170000. +2007-10-09 Jason Rumney + + * w32term.c (x_set_window_size): Disable code that attempts to tell + Lisp code about a size change before it actually happens. + 2007-10-09 Richard Stallman * xdisp.c (handle_invisible_prop): After setting up an ellipsis, -- cgit v1.2.3 From 54371585f73e169cd80782592b87d91d4d6bfbfd Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 19 Dec 2007 22:50:22 +0000 Subject: * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean) (QCdbus_type_int16, QCdbus_type_uint16, QCdbus_type_int32) (QCdbus_type_uint32, QCdbus_type_int64, QCdbus_type_uint64) (QCdbus_type_double, QCdbus_type_string, QCdbus_type_object_path) (QCdbus_type_signature, QCdbus_type_array, QCdbus_type_variant) (QCdbus_type_struct, QCdbus_type_dict_entry): New D-Bus type symbols. (XD_LISP_SYMBOL_TO_DBUS_TYPE): New macro. (XD_LISP_OBJECT_TO_DBUS_TYPE): Add compound types. (xd_retrieve_value): Removed. Functionality included in ... (xd_append_arg): New function. (Fdbus_call_method, Fdbus_send_signal): Apply it. --- src/ChangeLog | 15 +++ src/dbusbind.c | 302 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 272 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 57d548a315c..85fb6b357c2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2007-12-19 Michael Albinus + + * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean) + (QCdbus_type_int16, QCdbus_type_uint16, QCdbus_type_int32) + (QCdbus_type_uint32, QCdbus_type_int64, QCdbus_type_uint64) + (QCdbus_type_double, QCdbus_type_string, QCdbus_type_object_path) + (QCdbus_type_signature, QCdbus_type_array, QCdbus_type_variant) + (QCdbus_type_struct, QCdbus_type_dict_entry): New D-Bus type + symbols. + (XD_LISP_SYMBOL_TO_DBUS_TYPE): New macro. + (XD_LISP_OBJECT_TO_DBUS_TYPE): Add compound types. + (xd_retrieve_value): Removed. Functionality included in ... + (xd_append_arg): New function. + (Fdbus_call_method, Fdbus_send_signal): Apply it. + 2007-12-16 Michael Albinus * dbusbind.c (top): Include . diff --git a/src/dbusbind.c b/src/dbusbind.c index d4008f7314c..a8e5f4f0ddf 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -43,6 +43,16 @@ Lisp_Object Qdbus_error; /* Lisp symbols of the system and session buses. */ Lisp_Object QCdbus_system_bus, QCdbus_session_bus; +/* Lisp symbols of D-Bus types. */ +Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; +Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; +Lisp_Object QCdbus_type_int32, QCdbus_type_uint32; +Lisp_Object QCdbus_type_int64, QCdbus_type_uint64; +Lisp_Object QCdbus_type_double, QCdbus_type_string; +Lisp_Object QCdbus_type_object_path, QCdbus_type_signature; +Lisp_Object QCdbus_type_array, QCdbus_type_variant; +Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; + /* Hash table which keeps function definitions. */ Lisp_Object Vdbus_registered_functions_table; @@ -53,7 +63,7 @@ Lisp_Object Vdbus_debug; /* We use "xd_" and "XD_" as prefix for all internal symbols, because we don't want to poison other namespaces with "dbus_". */ -/* Raise a Lisp error from a D-Bus error. */ +/* Raise a Lisp error from a D-Bus ERROR. */ #define XD_ERROR(error) \ { \ char s[1024]; \ @@ -93,51 +103,204 @@ Lisp_Object Vdbus_debug; #define XD_DEBUG_VALID_LISP_OBJECT_P(object) #endif -/* Determine the DBusType of a given Lisp object. It is used to +/* Determine the DBusType of a given Lisp symbol. OBJECT must be one + of the predefined D-Bus type symbols. */ +#define XD_LISP_SYMBOL_TO_DBUS_TYPE(object) \ + (EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \ + : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \ + : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \ + : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \ + : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \ + : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \ + : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \ + : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \ + : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \ + : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \ + : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \ + : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \ + : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \ + : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \ + : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \ + : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \ + : DBUS_TYPE_INVALID + +/* Determine the DBusType of a given Lisp OBJECT. It is used to convert Lisp objects, being arguments of `dbus-call-method' or `dbus-send-signal', into corresponding C values appended as arguments to a D-Bus message. */ #define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \ - (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN : \ - (NATNUMP (object)) ? DBUS_TYPE_UINT32 : \ - (INTEGERP (object)) ? DBUS_TYPE_INT32 : \ - (FLOATP (object)) ? DBUS_TYPE_DOUBLE : \ - (STRINGP (object)) ? DBUS_TYPE_STRING : \ - DBUS_TYPE_INVALID - -/* Extract C value from Lisp OBJECT. DTYPE must be a valid DBusType, - as detected by XD_LISP_OBJECT_TO_DBUS_TYPE. Compound types are not - supported (yet). It is used to convert Lisp objects, being - arguments of `dbus-call-method' or `dbus-send-signal', into - corresponding C values appended as arguments to a D-Bus - message. */ -char * -xd_retrieve_value (dtype, object) + (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ + : (SYMBOLP (object)) ? XD_LISP_SYMBOL_TO_DBUS_TYPE (object) \ + : (CONSP (object)) ? ((SYMBOLP (XCAR (object)) \ + && !EQ (XCAR (object), Qt) \ + && !EQ (XCAR (object), Qnil)) \ + ? XD_LISP_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \ + : DBUS_TYPE_ARRAY) \ + : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ + : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ + : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ + : (STRINGP (object)) ? DBUS_TYPE_STRING \ + : DBUS_TYPE_INVALID + +/* Append C value, extracted from Lisp OBJECT, to iteration ITER. + DTYPE must be a valid DBusType. It is used to convert Lisp + objects, being arguments of `dbus-call-method' or + `dbus-send-signal', into corresponding C values appended as + arguments to a D-Bus message. */ +void +xd_append_arg (dtype, object, iter) unsigned int dtype; + DBusMessageIter *iter; Lisp_Object object; { + char *value; - XD_DEBUG_VALID_LISP_OBJECT_P (object); + /* Check type of object. If this has been detected implicitely, it + is OK already, but there might be cases the type symbol and the + corresponding object do'nt match. */ switch (dtype) { - case DBUS_TYPE_BOOLEAN: - XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); - return (NILP (object)) ? (char *) FALSE : (char *) TRUE; + case DBUS_TYPE_BYTE: + case DBUS_TYPE_UINT16: case DBUS_TYPE_UINT32: - XD_DEBUG_MESSAGE ("%d %d", dtype, XUINT (object)); - return (char *) XUINT (object); + case DBUS_TYPE_UINT64: + CHECK_NATNUM (object); + break; + case DBUS_TYPE_BOOLEAN: + if (!EQ (object, Qt) && !EQ (object, Qnil)) + wrong_type_argument (intern ("booleanp"), object); + break; + case DBUS_TYPE_INT16: case DBUS_TYPE_INT32: - XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); - return (char *) XINT (object); + case DBUS_TYPE_INT64: + CHECK_NUMBER (object); + break; case DBUS_TYPE_DOUBLE: - XD_DEBUG_MESSAGE ("%d %d", dtype, XFLOAT (object)); - return (char *) XFLOAT (object); + CHECK_FLOAT (object); + break; case DBUS_TYPE_STRING: - XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); - return SDATA (object); + case DBUS_TYPE_OBJECT_PATH: + case DBUS_TYPE_SIGNATURE: + CHECK_STRING (object); + break; + case DBUS_TYPE_ARRAY: + CHECK_CONS (object); + /* ToDo: Check that all list elements have the same type. */ + break; + case DBUS_TYPE_VARIANT: + CHECK_CONS (object); + /* ToDo: Check that there is exactly one element of basic type. */ + break; + case DBUS_TYPE_STRUCT: + CHECK_CONS (object); + break; + case DBUS_TYPE_DICT_ENTRY: + /* ToDo: Check that there are exactly two elements, and the + first one is of basic type. */ + CHECK_CONS (object); + break; default: - XD_DEBUG_MESSAGE ("DBus-Type %d not supported", dtype); - return NULL; + xsignal1 (Qdbus_error, build_string ("Unknown D-Bus type")); + } + + if (CONSP (object)) + + /* Compound types. */ + { + DBusMessageIter subiter; + char subtype; + + if (SYMBOLP (XCAR (object)) + && (strncmp (SDATA (XSYMBOL (XCAR (object))->xname), ":", 1) == 0)) + object = XCDR (object); + + /* Open new subiteration. */ + switch (dtype) + { + case DBUS_TYPE_ARRAY: + case DBUS_TYPE_VARIANT: + subtype = (char) XD_LISP_OBJECT_TO_DBUS_TYPE (XCAR (object)); + dbus_message_iter_open_container (iter, dtype, &subtype, &subiter); + break; + case DBUS_TYPE_STRUCT: + case DBUS_TYPE_DICT_ENTRY: + dbus_message_iter_open_container (iter, dtype, NULL, &subiter); + } + + /* Loop over list elements. */ + while (!NILP (object)) + { + dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (XCAR (object)); + if (dtype == DBUS_TYPE_INVALID) + xsignal2 (Qdbus_error, + build_string ("Not a valid argument"), XCAR (object)); + + if (SYMBOLP (XCAR (object)) + && (strncmp (SDATA (XSYMBOL (XCAR (object))->xname), ":", 1) + == 0)) + object = XCDR (object); + + xd_append_arg (dtype, XCAR (object), &subiter); + + object = XCDR (object); + } + + dbus_message_iter_close_container (iter, &subiter); + } + + else + + /* Basic type. */ + { + switch (dtype) + { + case DBUS_TYPE_BYTE: + XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + value = (unsigned char *) XUINT (object); + break; + case DBUS_TYPE_BOOLEAN: + XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); + value = (NILP (object)) + ? (unsigned char *) FALSE : (unsigned char *) TRUE; + break; + case DBUS_TYPE_INT16: + XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + value = (char *) (dbus_int16_t *) XINT (object); + break; + case DBUS_TYPE_UINT16: + XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + value = (char *) (dbus_uint16_t *) XUINT (object); + break; + case DBUS_TYPE_INT32: + XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + value = (char *) (dbus_int32_t *) XINT (object); + break; + case DBUS_TYPE_UINT32: + XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + value = (char *) (dbus_uint32_t *) XUINT (object); + break; + case DBUS_TYPE_INT64: + XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + value = (char *) (dbus_int64_t *) XINT (object); + break; + case DBUS_TYPE_UINT64: + XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + value = (char *) (dbus_int64_t *) XUINT (object); + break; + case DBUS_TYPE_DOUBLE: + XD_DEBUG_MESSAGE ("%d %f", dtype, XFLOAT (object)); + value = (char *) (float *) XFLOAT (object); + break; + case DBUS_TYPE_STRING: + case DBUS_TYPE_OBJECT_PATH: + case DBUS_TYPE_SIGNATURE: + XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); + value = SDATA (object); + break; + } + if (!dbus_message_iter_append_basic (iter, dtype, &value)) + xsignal2 (Qdbus_error, + build_string ("Unable to append argument"), object); } } @@ -357,6 +520,9 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) UNGCPRO; + /* Initialize parameter list of message. */ + dbus_message_iter_init_append (dmessage, &iter); + /* Append parameters to the message. */ for (i = 5; i < nargs; ++i) { @@ -370,14 +536,11 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) if (dtype == DBUS_TYPE_INVALID) xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); - value = (char *) xd_retrieve_value (dtype, args[i]); + if (SYMBOLP (args[i]) + && (strncmp (SDATA (XSYMBOL (args[i])->xname), ":", 1) == 0)) + ++i; - if (!dbus_message_append_args (dmessage, - dtype, - &value, - DBUS_TYPE_INVALID)) - xsignal2 (Qdbus_error, - build_string ("Unable to append argument"), args[i]); + xd_append_arg (dtype, args[i], &iter); } /* Send the message. */ @@ -460,6 +623,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; DBusConnection *connection; DBusMessage *dmessage; + DBusMessageIter iter; unsigned int dtype; int i; char *value; @@ -499,6 +663,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) UNGCPRO; + /* Initialize parameter list of message. */ + dbus_message_iter_init_append (dmessage, &iter); + /* Append parameters to the message. */ for (i = 5; i < nargs; ++i) { @@ -511,14 +678,11 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) if (dtype == DBUS_TYPE_INVALID) xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); - value = (char *) xd_retrieve_value (dtype, args[i]); + if (SYMBOLP (args[i]) + && (strncmp (SDATA (XSYMBOL (args[i])->xname), ":", 1) == 0)) + ++i; - if (!dbus_message_append_args (dmessage, - dtype, - &value, - DBUS_TYPE_INVALID)) - xsignal2 (Qdbus_error, - build_string ("Unable to append argument"), args[i]); + xd_append_arg (dtype, args[i], &iter); } /* Send the message. The message is just added to the outgoing @@ -850,6 +1014,54 @@ syms_of_dbusbind () QCdbus_session_bus = intern (":session"); staticpro (&QCdbus_session_bus); + QCdbus_type_byte = intern (":byte"); + staticpro (&QCdbus_type_byte); + + QCdbus_type_boolean = intern (":boolean"); + staticpro (&QCdbus_type_boolean); + + QCdbus_type_int16 = intern (":int16"); + staticpro (&QCdbus_type_int16); + + QCdbus_type_uint16 = intern (":uint16"); + staticpro (&QCdbus_type_uint16); + + QCdbus_type_int32 = intern (":int32"); + staticpro (&QCdbus_type_int32); + + QCdbus_type_uint32 = intern (":uint32"); + staticpro (&QCdbus_type_uint32); + + QCdbus_type_int64 = intern (":int64"); + staticpro (&QCdbus_type_int64); + + QCdbus_type_uint64 = intern (":uint64"); + staticpro (&QCdbus_type_uint64); + + QCdbus_type_double = intern (":double"); + staticpro (&QCdbus_type_double); + + QCdbus_type_string = intern (":string"); + staticpro (&QCdbus_type_string); + + QCdbus_type_object_path = intern (":object-path"); + staticpro (&QCdbus_type_object_path); + + QCdbus_type_signature = intern (":signature"); + staticpro (&QCdbus_type_signature); + + QCdbus_type_array = intern (":array"); + staticpro (&QCdbus_type_array); + + QCdbus_type_variant = intern (":variant"); + staticpro (&QCdbus_type_variant); + + QCdbus_type_struct = intern (":struct"); + staticpro (&QCdbus_type_struct); + + QCdbus_type_dict_entry = intern (":dict-entry"); + staticpro (&QCdbus_type_dict_entry); + DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, doc: /* Hash table of registered functions for D-Bus. The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is -- cgit v1.2.3 From 87cf1a39ef9ba9e445e3130614b8eecf4dc57a35 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 21 Dec 2007 22:01:43 +0000 Subject: * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE): New macros. (XD_SYMBOL_TO_DBUS_TYPE): Renamed from XD_LISP_SYMBOL_TO_DBUS_TYPE. (XD_OBJECT_TO_DBUS_TYPE): Renamed from XD_LISP_OBJECT_TO_DBUS_TYPE. Simplify. (xd_signature): New function. (xd_append_arg): Compute also signatures. Major rewrite. (xd_retrieve_arg): Make debug messages friendly. (Fdbus_call_method, Fdbus_send_signal): Extend docstring. Check for signatures of arguments. --- src/ChangeLog | 14 ++ src/dbusbind.c | 433 ++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 316 insertions(+), 131 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 85fb6b357c2..7c2bbffd1e4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2007-12-21 Michael Albinus + + * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE): + New macros. + (XD_SYMBOL_TO_DBUS_TYPE): Renamed from + XD_LISP_SYMBOL_TO_DBUS_TYPE. + (XD_OBJECT_TO_DBUS_TYPE): Renamed from + XD_LISP_OBJECT_TO_DBUS_TYPE. Simplify. + (xd_signature): New function. + (xd_append_arg): Compute also signatures. Major rewrite. + (xd_retrieve_arg): Make debug messages friendly. + (Fdbus_call_method, Fdbus_send_signal): Extend docstring. Check + for signatures of arguments. + 2007-12-19 Michael Albinus * dbusbind.c (QCdbus_type_byte, QCdbus_type_boolean) diff --git a/src/dbusbind.c b/src/dbusbind.c index a8e5f4f0ddf..01168f51a95 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -103,61 +103,85 @@ Lisp_Object Vdbus_debug; #define XD_DEBUG_VALID_LISP_OBJECT_P(object) #endif +/* Check whether TYPE is a basic DBusType. */ +#define XD_BASIC_DBUS_TYPE(type) \ + ((type == DBUS_TYPE_BYTE) \ + || (type == DBUS_TYPE_BOOLEAN) \ + || (type == DBUS_TYPE_INT16) \ + || (type == DBUS_TYPE_UINT16) \ + || (type == DBUS_TYPE_INT32) \ + || (type == DBUS_TYPE_UINT32) \ + || (type == DBUS_TYPE_INT64) \ + || (type == DBUS_TYPE_UINT64) \ + || (type == DBUS_TYPE_DOUBLE) \ + || (type == DBUS_TYPE_STRING) \ + || (type == DBUS_TYPE_OBJECT_PATH) \ + || (type == DBUS_TYPE_SIGNATURE)) + /* Determine the DBusType of a given Lisp symbol. OBJECT must be one of the predefined D-Bus type symbols. */ -#define XD_LISP_SYMBOL_TO_DBUS_TYPE(object) \ - (EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \ - : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \ - : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \ - : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \ - : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \ - : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \ - : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \ - : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \ - : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \ - : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \ - : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \ - : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \ - : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \ - : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \ - : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \ - : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \ - : DBUS_TYPE_INVALID +#define XD_SYMBOL_TO_DBUS_TYPE(object) \ + ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \ + : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \ + : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \ + : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \ + : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \ + : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \ + : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \ + : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \ + : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \ + : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \ + : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \ + : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \ + : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \ + : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \ + : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \ + : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \ + : DBUS_TYPE_INVALID) + +/* Check whether a Lisp symbol is a predefined D-Bus type symbol. */ +#define XD_DBUS_TYPE_P(object) \ + (SYMBOLP (object) && ((XD_SYMBOL_TO_DBUS_TYPE (object) != DBUS_TYPE_INVALID))) /* Determine the DBusType of a given Lisp OBJECT. It is used to convert Lisp objects, being arguments of `dbus-call-method' or `dbus-send-signal', into corresponding C values appended as arguments to a D-Bus message. */ -#define XD_LISP_OBJECT_TO_DBUS_TYPE(object) \ - (EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ - : (SYMBOLP (object)) ? XD_LISP_SYMBOL_TO_DBUS_TYPE (object) \ - : (CONSP (object)) ? ((SYMBOLP (XCAR (object)) \ - && !EQ (XCAR (object), Qt) \ - && !EQ (XCAR (object), Qnil)) \ - ? XD_LISP_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \ - : DBUS_TYPE_ARRAY) \ - : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ - : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ - : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ - : (STRINGP (object)) ? DBUS_TYPE_STRING \ - : DBUS_TYPE_INVALID - -/* Append C value, extracted from Lisp OBJECT, to iteration ITER. - DTYPE must be a valid DBusType. It is used to convert Lisp - objects, being arguments of `dbus-call-method' or - `dbus-send-signal', into corresponding C values appended as - arguments to a D-Bus message. */ +#define XD_OBJECT_TO_DBUS_TYPE(object) \ + ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ + : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ + : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ + : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ + : (STRINGP (object)) ? DBUS_TYPE_STRING \ + : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \ + : (CONSP (object)) ? ((XD_DBUS_TYPE_P (XCAR (object))) \ + ? XD_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \ + : DBUS_TYPE_ARRAY) \ + : DBUS_TYPE_INVALID) + +/* Return a list pointer which does not have a Lisp symbol as car. */ +#define XD_NEXT_VALUE(object) \ + ((XD_DBUS_TYPE_P (XCAR (object))) ? XCDR (object) : object) + +/* Compute SIGNATURE of OBJECT. It must have a form that it can be + used in dbus_message_iter_open_container. DTYPE is the DBusType + the object is related to. It is passed as argument, because it + cannot be detected in basic type objects, when they are preceded by + a type symbol. PARENT_TYPE is the DBusType of a container this + signature is embedded, or DBUS_TYPE_INVALID. It is needed for the + check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ void -xd_append_arg (dtype, object, iter) - unsigned int dtype; - DBusMessageIter *iter; +xd_signature(signature, dtype, parent_type, object) + char *signature; + unsigned int dtype, parent_type; Lisp_Object object; { - char *value; + unsigned int subtype; + Lisp_Object elt; + char x[DBUS_MAXIMUM_SIGNATURE_LENGTH]; + + elt = object; - /* Check type of object. If this has been detected implicitely, it - is OK already, but there might be cases the type symbol and the - corresponding object do'nt match. */ switch (dtype) { case DBUS_TYPE_BYTE: @@ -165,143 +189,269 @@ xd_append_arg (dtype, object, iter) case DBUS_TYPE_UINT32: case DBUS_TYPE_UINT64: CHECK_NATNUM (object); + sprintf (signature, "%c", dtype); break; + case DBUS_TYPE_BOOLEAN: if (!EQ (object, Qt) && !EQ (object, Qnil)) wrong_type_argument (intern ("booleanp"), object); + sprintf (signature, "%c", dtype); break; + case DBUS_TYPE_INT16: case DBUS_TYPE_INT32: case DBUS_TYPE_INT64: CHECK_NUMBER (object); + sprintf (signature, "%c", dtype); break; + case DBUS_TYPE_DOUBLE: CHECK_FLOAT (object); + sprintf (signature, "%c", dtype); break; + case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: case DBUS_TYPE_SIGNATURE: CHECK_STRING (object); + sprintf (signature, "%c", dtype); break; + case DBUS_TYPE_ARRAY: + /* Check that all elements have the same D-Bus type. For + complex element types, we just check the container type, not + the whole element's signature. */ CHECK_CONS (object); - /* ToDo: Check that all list elements have the same type. */ + + if (EQ (QCdbus_type_array, XCAR (elt))) /* Type symbol is optional. */ + elt = XD_NEXT_VALUE (elt); + subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); + xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); + + while (!NILP (elt)) + { + if (subtype != XD_OBJECT_TO_DBUS_TYPE (XCAR (elt))) + wrong_type_argument (intern ("D-Bus"), XCAR (elt)); + elt = XCDR (XD_NEXT_VALUE (elt)); + } + + sprintf (signature, "%c%s", dtype, x); break; + case DBUS_TYPE_VARIANT: + /* Check that there is exactly one element. */ CHECK_CONS (object); - /* ToDo: Check that there is exactly one element of basic type. */ + + elt = XD_NEXT_VALUE (elt); + subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); + xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); + + if (!NILP (XCDR (XD_NEXT_VALUE (elt)))) + wrong_type_argument (intern ("D-Bus"), + XCAR (XCDR (XD_NEXT_VALUE (elt)))); + + sprintf (signature, "%c%s", dtype, x); break; + case DBUS_TYPE_STRUCT: - CHECK_CONS (object); - break; - case DBUS_TYPE_DICT_ENTRY: - /* ToDo: Check that there are exactly two elements, and the - first one is of basic type. */ - CHECK_CONS (object); + /* A struct might contain any number of objects with different + types. No further check needed. */ + CHECK_CONS (object); + + elt = XD_NEXT_VALUE (elt); + + /* Compose the signature from the elements. It is enclosed by + parentheses. */ + sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR ); + while (!NILP (elt)) + { + subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); + xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); + strcat (signature, x); + elt = XCDR (XD_NEXT_VALUE (elt)); + } + sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR); break; - default: - xsignal1 (Qdbus_error, build_string ("Unknown D-Bus type")); - } - if (CONSP (object)) + case DBUS_TYPE_DICT_ENTRY: + /* Check that there are exactly two elements, and the first one + is of basic type. It must also be an element of an + array. */ + CHECK_CONS (object); - /* Compound types. */ - { - DBusMessageIter subiter; - char subtype; + if (parent_type != DBUS_TYPE_ARRAY) + wrong_type_argument (intern ("D-Bus"), object); - if (SYMBOLP (XCAR (object)) - && (strncmp (SDATA (XSYMBOL (XCAR (object))->xname), ":", 1) == 0)) - object = XCDR (object); + /* Compose the signature from the elements. It is enclosed by + curly braces. */ + sprintf (signature, "%c", DBUS_DICT_ENTRY_BEGIN_CHAR); - /* Open new subiteration. */ - switch (dtype) - { - case DBUS_TYPE_ARRAY: - case DBUS_TYPE_VARIANT: - subtype = (char) XD_LISP_OBJECT_TO_DBUS_TYPE (XCAR (object)); - dbus_message_iter_open_container (iter, dtype, &subtype, &subiter); - break; - case DBUS_TYPE_STRUCT: - case DBUS_TYPE_DICT_ENTRY: - dbus_message_iter_open_container (iter, dtype, NULL, &subiter); - } + /* First element. */ + elt = XD_NEXT_VALUE (elt); + subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); + xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); + strcat (signature, x); - /* Loop over list elements. */ - while (!NILP (object)) - { - dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (XCAR (object)); - if (dtype == DBUS_TYPE_INVALID) - xsignal2 (Qdbus_error, - build_string ("Not a valid argument"), XCAR (object)); + if (!XD_BASIC_DBUS_TYPE (subtype)) + wrong_type_argument (intern ("D-Bus"), XCAR (XD_NEXT_VALUE (elt))); - if (SYMBOLP (XCAR (object)) - && (strncmp (SDATA (XSYMBOL (XCAR (object))->xname), ":", 1) - == 0)) - object = XCDR (object); + /* Second element. */ + elt = XCDR (XD_NEXT_VALUE (elt)); + subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); + xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); + strcat (signature, x); - xd_append_arg (dtype, XCAR (object), &subiter); + if (!NILP (XCDR (XD_NEXT_VALUE (elt)))) + wrong_type_argument (intern ("D-Bus"), + XCAR (XCDR (XD_NEXT_VALUE (elt)))); - object = XCDR (object); - } + /* Closing signature. */ + sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR); + break; - dbus_message_iter_close_container (iter, &subiter); + default: + wrong_type_argument (intern ("D-Bus"), object); } - else + XD_DEBUG_MESSAGE ("%s", signature); +} - /* Basic type. */ +/* Append C value, extracted from Lisp OBJECT, to iteration ITER. + DTYPE must be a valid DBusType. It is used to convert Lisp + objects, being arguments of `dbus-call-method' or + `dbus-send-signal', into corresponding C values appended as + arguments to a D-Bus message. */ +void +xd_append_arg (dtype, object, iter) + unsigned int dtype; + Lisp_Object object; + DBusMessageIter *iter; +{ + Lisp_Object elt; + char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; + DBusMessageIter subiter; + char *value; + + XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", object, Qnil))); + + if (XD_BASIC_DBUS_TYPE (dtype)) { switch (dtype) { case DBUS_TYPE_BYTE: - XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object)); value = (unsigned char *) XUINT (object); break; + case DBUS_TYPE_BOOLEAN: - XD_DEBUG_MESSAGE ("%d %s", dtype, (NILP (object)) ? "false" : "true"); + XD_DEBUG_MESSAGE ("%c %s", dtype, (NILP (object)) ? "false" : "true"); value = (NILP (object)) ? (unsigned char *) FALSE : (unsigned char *) TRUE; break; + case DBUS_TYPE_INT16: - XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object)); value = (char *) (dbus_int16_t *) XINT (object); break; + case DBUS_TYPE_UINT16: - XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object)); value = (char *) (dbus_uint16_t *) XUINT (object); break; + case DBUS_TYPE_INT32: - XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object)); value = (char *) (dbus_int32_t *) XINT (object); break; + case DBUS_TYPE_UINT32: - XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object)); value = (char *) (dbus_uint32_t *) XUINT (object); break; + case DBUS_TYPE_INT64: - XD_DEBUG_MESSAGE ("%d %d", dtype, XINT (object)); + XD_DEBUG_MESSAGE ("%c %d", dtype, XINT (object)); value = (char *) (dbus_int64_t *) XINT (object); break; + case DBUS_TYPE_UINT64: - XD_DEBUG_MESSAGE ("%d %u", dtype, XUINT (object)); + XD_DEBUG_MESSAGE ("%c %u", dtype, XUINT (object)); value = (char *) (dbus_int64_t *) XUINT (object); break; + case DBUS_TYPE_DOUBLE: - XD_DEBUG_MESSAGE ("%d %f", dtype, XFLOAT (object)); + XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object)); value = (char *) (float *) XFLOAT (object); break; + case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: case DBUS_TYPE_SIGNATURE: - XD_DEBUG_MESSAGE ("%d %s", dtype, SDATA (object)); + XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (object)); value = SDATA (object); break; } + if (!dbus_message_iter_append_basic (iter, dtype, &value)) xsignal2 (Qdbus_error, build_string ("Unable to append argument"), object); } + + else /* Compound types. */ + { + + /* All compound types except array have a type symbol. For + array, it is optional. Skip it. */ + if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (XCAR (object)))) + object = XD_NEXT_VALUE (object); + + /* Open new subiteration. */ + switch (dtype) + { + case DBUS_TYPE_ARRAY: + case DBUS_TYPE_VARIANT: + /* A variant has just one element. An array has elements of + the same type. Both have been checked already, it is + sufficient to retrieve just the signature of the first + element. */ + xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)), + dtype, XCAR (XD_NEXT_VALUE (object))); + XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, + SDATA (format2 ("%s", object, Qnil))); + if (!dbus_message_iter_open_container (iter, dtype, + signature, &subiter)) + xsignal3 (Qdbus_error, + build_string ("Cannot open container"), + make_number (dtype), build_string (signature)); + break; + + case DBUS_TYPE_STRUCT: + case DBUS_TYPE_DICT_ENTRY: + XD_DEBUG_MESSAGE ("%c %s", dtype, + SDATA (format2 ("%s", object, Qnil))); + if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter)) + xsignal2 (Qdbus_error, + build_string ("Cannot open container"), + make_number (dtype)); + break; + } + + /* Loop over list elements. */ + while (!NILP (object)) + { + dtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (object)); + object = XD_NEXT_VALUE (object); + + xd_append_arg (dtype, XCAR (object), &subiter); + + object = XCDR (object); + } + + if (!dbus_message_iter_close_container (iter, &subiter)) + xsignal2 (Qdbus_error, + build_string ("Cannot close container"), + make_number (dtype)); + } } /* Retrieve C value from a DBusMessageIter structure ITER, and return @@ -320,25 +470,28 @@ xd_retrieve_arg (dtype, iter) { dbus_bool_t val; dbus_message_iter_get_basic (iter, &val); - XD_DEBUG_MESSAGE ("%d %s", dtype, (val == FALSE) ? "false" : "true"); + XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true"); return (val == FALSE) ? Qnil : Qt; } + case DBUS_TYPE_INT32: case DBUS_TYPE_UINT32: { dbus_uint32_t val; dbus_message_iter_get_basic (iter, &val); - XD_DEBUG_MESSAGE ("%d %d", dtype, val); + XD_DEBUG_MESSAGE ("%c %d", dtype, val); return make_number (val); } + case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: { char *val; dbus_message_iter_get_basic (iter, &val); - XD_DEBUG_MESSAGE ("%d %s", dtype, val); + XD_DEBUG_MESSAGE ("%c %s", dtype, val); return build_string (val); } + case DBUS_TYPE_ARRAY: case DBUS_TYPE_VARIANT: case DBUS_TYPE_STRUCT: @@ -359,8 +512,9 @@ xd_retrieve_arg (dtype, iter) } RETURN_UNGCPRO (Fnreverse (result)); } + default: - XD_DEBUG_MESSAGE ("DBusType %d not supported", dtype); + XD_DEBUG_MESSAGE ("DBusType '%c' not supported", dtype); return Qnil; } } @@ -439,16 +593,33 @@ converted into D-Bus types via the following rules: integer => DBUS_TYPE_INT32 float => DBUS_TYPE_DOUBLE string => DBUS_TYPE_STRING + list => DBUS_TYPE_ARRAY -Other Lisp objects are not supported as input arguments of METHOD. +All arguments can be preceded by a type symbol. For details about +type symbols, see Info node `(dbus)Type Conversion'. `dbus-call-method' returns the resulting values of METHOD as a list of Lisp objects. The type conversion happens the other direction as for -input arguments. Additionally to the types supported for input -arguments, the D-Bus compound types DBUS_TYPE_ARRAY, DBUS_TYPE_VARIANT, -DBUS_TYPE_STRUCT and DBUS_TYPE_DICT_ENTRY are accepted. All of them -are converted into a list of Lisp objects which correspond to the -elements of the D-Bus container. Example: +input arguments. It follows the mapping rules: + + DBUS_TYPE_BOOLEAN => t or nil + DBUS_TYPE_BYTE => number + DBUS_TYPE_UINT16 => number + DBUS_TYPE_INT16 => integer + DBUS_TYPE_UINT32 => number + DBUS_TYPE_INT32 => integer + DBUS_TYPE_UINT64 => number + DBUS_TYPE_INT64 => integer + DBUS_TYPE_DOUBLE => float + DBUS_TYPE_STRING => string + DBUS_TYPE_OBJECT_PATH => string + DBUS_TYPE_SIGNATURE => string + DBUS_TYPE_ARRAY => list + DBUS_TYPE_VARIANT => list + DBUS_TYPE_STRUCT => list + DBUS_TYPE_DICT_ENTRY => list + +Example: \(dbus-call-method :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp" @@ -482,7 +653,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) DBusError derror; unsigned int dtype; int i; - char *value; + char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ bus = args[0]; @@ -529,17 +700,16 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_MESSAGE ("Parameter%d %s", - i-4, - SDATA (format2 ("%s", args[i], Qnil))); + i-4, SDATA (format2 ("%s", args[i], Qnil))); - dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); - if (dtype == DBUS_TYPE_INVALID) - xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); - - if (SYMBOLP (args[i]) - && (strncmp (SDATA (XSYMBOL (args[i])->xname), ":", 1) == 0)) + dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); + if (XD_DBUS_TYPE_P (args[i])) ++i; + /* Check for valid signature. We use DBUS_TYPE_INVALID is + indication that there is no parent type. */ + xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); + xd_append_arg (dtype, args[i], &iter); } @@ -605,8 +775,10 @@ converted into D-Bus types via the following rules: integer => DBUS_TYPE_INT32 float => DBUS_TYPE_DOUBLE string => DBUS_TYPE_STRING + list => DBUS_TYPE_ARRAY -Other Lisp objects are not supported as arguments of SIGNAL. +All arguments can be preceded by a type symbol. For details about +type symbols, see Info node `(dbus)Type Conversion'. Example: @@ -626,7 +798,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) DBusMessageIter iter; unsigned int dtype; int i; - char *value; + char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ bus = args[0]; @@ -671,17 +843,16 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_MESSAGE ("Parameter%d %s", - i-4, - SDATA (format2 ("%s", args[i], Qnil))); - - dtype = XD_LISP_OBJECT_TO_DBUS_TYPE (args[i]); - if (dtype == DBUS_TYPE_INVALID) - xsignal2 (Qdbus_error, build_string ("Not a valid argument"), args[i]); + i-4, SDATA (format2 ("%s", args[i], Qnil))); - if (SYMBOLP (args[i]) - && (strncmp (SDATA (XSYMBOL (args[i])->xname), ":", 1) == 0)) + dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); + if (XD_DBUS_TYPE_P (args[i])) ++i; + /* Check for valid signature. We use DBUS_TYPE_INVALID is + indication that there is no parent type. */ + xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); + xd_append_arg (dtype, args[i], &iter); } -- cgit v1.2.3 From 9af5078b398dbeee60dc39bb91924de7baae5336 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 22 Dec 2007 14:54:23 +0000 Subject: * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE, DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64, DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE. Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit as number. (Fdbus_call_method): Fix docstring. --- src/ChangeLog | 9 +++++++ src/dbusbind.c | 75 +++++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 7c2bbffd1e4..952f9d7e6e8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2007-12-22 Michael Albinus + + * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE, + DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64, + DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE. + Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit + as number. + (Fdbus_call_method): Fix docstring. + 2007-12-21 Michael Albinus * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE): diff --git a/src/dbusbind.c b/src/dbusbind.c index 01168f51a95..79f98d0bc55 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -218,7 +218,7 @@ xd_signature(signature, dtype, parent_type, object) break; case DBUS_TYPE_ARRAY: - /* Check that all elements have the same D-Bus type. For + /* Check that all list elements have the same D-Bus type. For complex element types, we just check the container type, not the whole element's signature. */ CHECK_CONS (object); @@ -239,7 +239,7 @@ xd_signature(signature, dtype, parent_type, object) break; case DBUS_TYPE_VARIANT: - /* Check that there is exactly one element. */ + /* Check that there is exactly one list element. */ CHECK_CONS (object); elt = XD_NEXT_VALUE (elt); @@ -254,8 +254,8 @@ xd_signature(signature, dtype, parent_type, object) break; case DBUS_TYPE_STRUCT: - /* A struct might contain any number of objects with different - types. No further check needed. */ + /* A struct list might contain any number of elements with + different types. No further check needed. */ CHECK_CONS (object); elt = XD_NEXT_VALUE (elt); @@ -274,11 +274,12 @@ xd_signature(signature, dtype, parent_type, object) break; case DBUS_TYPE_DICT_ENTRY: - /* Check that there are exactly two elements, and the first one - is of basic type. It must also be an element of an - array. */ + /* Check that there are exactly two list elements, and the first + one is of basic type. The dictionary entry itself must be an + element of an array. */ CHECK_CONS (object); + /* Check the parent object type. */ if (parent_type != DBUS_TYPE_ARRAY) wrong_type_argument (intern ("D-Bus"), object); @@ -381,7 +382,7 @@ xd_append_arg (dtype, object, iter) case DBUS_TYPE_DOUBLE: XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object)); - value = (char *) (float *) XFLOAT (object); + value = (char *) (double *) XFLOAT (object); break; case DBUS_TYPE_STRING: @@ -411,9 +412,9 @@ xd_append_arg (dtype, object, iter) case DBUS_TYPE_ARRAY: case DBUS_TYPE_VARIANT: /* A variant has just one element. An array has elements of - the same type. Both have been checked already, it is - sufficient to retrieve just the signature of the first - element. */ + the same type. Both have been checked already for + correct types, it is sufficient to retrieve just the + signature of the first element. */ xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)), dtype, XCAR (XD_NEXT_VALUE (object))); XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, @@ -427,6 +428,7 @@ xd_append_arg (dtype, object, iter) case DBUS_TYPE_STRUCT: case DBUS_TYPE_DICT_ENTRY: + /* These containers do not require a signature. */ XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", object, Qnil))); if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter)) @@ -447,6 +449,7 @@ xd_append_arg (dtype, object, iter) object = XCDR (object); } + /* Close the subiteration. */ if (!dbus_message_iter_close_container (iter, &subiter)) xsignal2 (Qdbus_error, build_string ("Cannot close container"), @@ -456,8 +459,8 @@ xd_append_arg (dtype, object, iter) /* Retrieve C value from a DBusMessageIter structure ITER, and return a converted Lisp object. The type DTYPE of the argument of the - D-Bus message must be a valid DBusType. Compound D-Bus types are - partly supported; they result always in a Lisp list. */ + D-Bus message must be a valid DBusType. Compound D-Bus types + result always in a Lisp list. */ Lisp_Object xd_retrieve_arg (dtype, iter) unsigned int dtype; @@ -466,6 +469,16 @@ xd_retrieve_arg (dtype, iter) switch (dtype) { + case DBUS_TYPE_BYTE: + case DBUS_TYPE_INT16: + case DBUS_TYPE_UINT16: + { + dbus_uint16_t val; + dbus_message_iter_get_basic (iter, &val); + XD_DEBUG_MESSAGE ("%c %d", dtype, val); + return make_number (val); + } + case DBUS_TYPE_BOOLEAN: { dbus_bool_t val; @@ -479,12 +492,36 @@ xd_retrieve_arg (dtype, iter) { dbus_uint32_t val; dbus_message_iter_get_basic (iter, &val); - XD_DEBUG_MESSAGE ("%c %d", dtype, val); - return make_number (val); + if (FIXNUM_OVERFLOW_P (val)) + XD_DEBUG_MESSAGE ("%c %f", dtype, val) + else + XD_DEBUG_MESSAGE ("%c %d", dtype, val); + return make_fixnum_or_float (val); + } + + case DBUS_TYPE_INT64: + case DBUS_TYPE_UINT64: + { + dbus_uint64_t val; + dbus_message_iter_get_basic (iter, &val); + if (FIXNUM_OVERFLOW_P (val)) + XD_DEBUG_MESSAGE ("%c %f", dtype, val) + else + XD_DEBUG_MESSAGE ("%c %d", dtype, val); + return make_fixnum_or_float (val); + } + + case DBUS_TYPE_DOUBLE: + { + double val; + dbus_message_iter_get_basic (iter, &val); + XD_DEBUG_MESSAGE ("%c %f", dtype, val); + return make_float (val); } case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: + case DBUS_TYPE_SIGNATURE: { char *val; dbus_message_iter_get_basic (iter, &val); @@ -606,10 +643,10 @@ input arguments. It follows the mapping rules: DBUS_TYPE_BYTE => number DBUS_TYPE_UINT16 => number DBUS_TYPE_INT16 => integer - DBUS_TYPE_UINT32 => number - DBUS_TYPE_INT32 => integer - DBUS_TYPE_UINT64 => number - DBUS_TYPE_INT64 => integer + DBUS_TYPE_UINT32 => number or float + DBUS_TYPE_INT32 => integer or float + DBUS_TYPE_UINT64 => number or float + DBUS_TYPE_INT64 => integer or float DBUS_TYPE_DOUBLE => float DBUS_TYPE_STRING => string DBUS_TYPE_OBJECT_PATH => string -- cgit v1.2.3 From b17f4b438f0c0cd5035f3cfcfd84525ee32f977b Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 22 Dec 2007 14:55:43 +0000 Subject: *** empty log message *** --- src/dbusbind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dbusbind.c b/src/dbusbind.c index 79f98d0bc55..88f2ccdb3eb 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -382,7 +382,7 @@ xd_append_arg (dtype, object, iter) case DBUS_TYPE_DOUBLE: XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object)); - value = (char *) (double *) XFLOAT (object); + value = (char *) (float *) XFLOAT (object); break; case DBUS_TYPE_STRING: -- cgit v1.2.3 From b014713ca63fcc6604b80159aaad46f6219ca62c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 22 Dec 2007 17:20:55 +0000 Subject: (syms_of_callint) : Add reference to history-length in the doc string. --- src/ChangeLog | 5 +++++ src/callint.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index a5b34e38966..284bca33828 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-12-22 Eli Zaretskii + + * callint.c (syms_of_callint) : Add reference to + history-length in the doc string. + 2007-12-17 Jason Rumney * w32fns.c (w32_wnd_proc) : Cast char to unsigned diff --git a/src/callint.c b/src/callint.c index 9dcc077fd65..65ef8aacadb 100644 --- a/src/callint.c +++ b/src/callint.c @@ -960,7 +960,10 @@ This is what `(interactive \"P\")' returns. */); DEFVAR_LISP ("command-history", &Vcommand_history, doc: /* List of recent commands that read arguments from terminal. -Each command is represented as a form to evaluate. */); +Each command is represented as a form to evaluate. + +Maximum length of the history list is determined by the value +of `history-length', which see. */); Vcommand_history = Qnil; DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status, -- cgit v1.2.3 From 585a8772d5baf90ae9c85d046153e800a3f60235 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Sun, 23 Dec 2007 06:01:51 +0000 Subject: (fill_menubar) [MAC_OSX]: Add workaround for Mac OS X 10.5 about not changing Help menu title. --- src/ChangeLog | 5 +++++ src/macmenu.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 284bca33828..fa3d8e78b05 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-12-23 YAMAMOTO Mitsuharu + + * macmenu.c (fill_menubar) [MAC_OSX]: Add workaround for Mac OS X 10.5 + about not changing Help menu title. + 2007-12-22 Eli Zaretskii * callint.c (syms_of_callint) : Add reference to diff --git a/src/macmenu.c b/src/macmenu.c index b8cfd6a4d2f..c7b63917a4c 100644 --- a/src/macmenu.c +++ b/src/macmenu.c @@ -3174,7 +3174,22 @@ fill_menubar (wv, deep_p) GetMenuTitle (menu, old_title); if (!EqualString (title, old_title, false, false)) - SetMenuTitle (menu, title); + { +#ifdef MAC_OSX + if (id + 1 == min_menu_id[MAC_MENU_MENU_BAR + 1] + || GetMenuRef (id + 1) == NULL) + { + /* This is a workaround for Mac OS X 10.5 where just + calling SetMenuTitle fails to change the title of + the last (Help) menu in the menu bar. */ + DeleteMenu (id); + DisposeMenu (menu); + menu = NULL; + } + else +#endif /* MAC_OSX */ + SetMenuTitle (menu, title); + } #else /* !TARGET_API_MAC_CARBON */ if (!EqualString (title, (*menu)->menuData, false, false)) { @@ -3186,7 +3201,8 @@ fill_menubar (wv, deep_p) } #endif /* !TARGET_API_MAC_CARBON */ } - else + + if (!menu) { menu = NewMenu (id, title); InsertMenu (menu, 0); -- cgit v1.2.3 From 5742be860f445f80c06c12846bd9ee0d44aadd30 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Mon, 24 Dec 2007 03:01:28 +0000 Subject: (phys_cursor_in_rect_p): Check if cursor is in fringe area. --- src/ChangeLog | 4 ++++ src/xdisp.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index fa3d8e78b05..2a8fc8e3f17 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2007-12-24 YAMAMOTO Mitsuharu + + * xdisp.c (phys_cursor_in_rect_p): Check if cursor is in fringe area. + 2007-12-23 YAMAMOTO Mitsuharu * macmenu.c (fill_menubar) [MAC_OSX]: Add workaround for Mac OS X 10.5 diff --git a/src/xdisp.c b/src/xdisp.c index 13660f413e7..fa53a98556f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -23481,6 +23481,24 @@ phys_cursor_in_rect_p (w, r) { XRectangle cr, result; struct glyph *cursor_glyph; + struct glyph_row *row; + + if (w->phys_cursor.vpos >= 0 + && w->phys_cursor.vpos < w->current_matrix->nrows + && (row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos), + row->enabled_p) + && row->cursor_in_fringe_p) + { + /* Cursor is in the fringe. */ + cr.x = window_box_right_offset (w, + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) + ? RIGHT_MARGIN_AREA + : TEXT_AREA)); + cr.y = row->y; + cr.width = WINDOW_RIGHT_FRINGE_WIDTH (w); + cr.height = row->height; + return x_intersect_rectangles (&cr, r, &result); + } cursor_glyph = get_phys_cursor_glyph (w); if (cursor_glyph) -- cgit v1.2.3 From 9d826ef2087381a1241029671ca942718c3a19d9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Mon, 24 Dec 2007 05:26:06 +0000 Subject: (make_process): Initialize pty_flag to Qnil instead of 0 as it is not a bit field on Emacs 22 yet. --- src/ChangeLog | 3 +++ src/process.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 2a8fc8e3f17..c0b86a16593 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2007-12-24 YAMAMOTO Mitsuharu + * process.c (make_process): Initialize pty_flag to Qnil instead of 0 + as it is not a bit field on Emacs 22 yet. + * xdisp.c (phys_cursor_in_rect_p): Check if cursor is in fringe area. 2007-12-23 YAMAMOTO Mitsuharu diff --git a/src/process.c b/src/process.c index adf8af9670d..eb0dae04e96 100644 --- a/src/process.c +++ b/src/process.c @@ -626,7 +626,7 @@ make_process (name) XSETFASTINT (p->tick, 0); XSETFASTINT (p->update_tick, 0); p->pid = 0; - p->pty_flag = 0; + p->pty_flag = Qnil; p->raw_status_new = 0; p->status = Qrun; p->mark = Fmake_marker (); -- cgit v1.2.3