diff options
| author | Michael Albinus | 2009-11-13 16:12:08 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-11-13 16:12:08 +0000 |
| commit | f04bb9b2d81242760c3faf2db2f9351ce0707d92 (patch) | |
| tree | 23ebc2fee7f10dfa4f6394a854e0cca909c9ce43 /src/dbusbind.c | |
| parent | b172ed20e0cd9feaf5b057860f23d9baab16c4f3 (diff) | |
| download | emacs-f04bb9b2d81242760c3faf2db2f9351ce0707d92.tar.gz emacs-f04bb9b2d81242760c3faf2db2f9351ce0707d92.zip | |
* dbusbind.c (Vdbus_registered_objects_table): Renamed from
Vdbus_registered_functions_table, because it contains also
properties. Fix docstring.
(Fdbus_call_method, Fdbus_call_method_asynchronously): Fix
docstring.
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 10ae8700cb0..d83ef4a5966 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -60,7 +60,7 @@ Lisp_Object QCdbus_type_array, QCdbus_type_variant; | |||
| 60 | Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; | 60 | Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; |
| 61 | 61 | ||
| 62 | /* Hash table which keeps function definitions. */ | 62 | /* Hash table which keeps function definitions. */ |
| 63 | Lisp_Object Vdbus_registered_functions_table; | 63 | Lisp_Object Vdbus_registered_objects_table; |
| 64 | 64 | ||
| 65 | /* Whether to debug D-Bus. */ | 65 | /* Whether to debug D-Bus. */ |
| 66 | Lisp_Object Vdbus_debug; | 66 | Lisp_Object Vdbus_debug; |
| @@ -870,7 +870,7 @@ object path SERVICE is registered at. INTERFACE is an interface | |||
| 870 | offered by SERVICE. It must provide METHOD. | 870 | offered by SERVICE. It must provide METHOD. |
| 871 | 871 | ||
| 872 | If the parameter `:timeout' is given, the following integer TIMEOUT | 872 | If the parameter `:timeout' is given, the following integer TIMEOUT |
| 873 | specifies the maximun number of milliseconds the method call must | 873 | specifies the maximum number of milliseconds the method call must |
| 874 | return. The default value is 25,000. If the method call doesn't | 874 | return. The default value is 25,000. If the method call doesn't |
| 875 | return in time, a D-Bus error is raised. | 875 | return in time, a D-Bus error is raised. |
| 876 | 876 | ||
| @@ -1078,7 +1078,7 @@ return message has arrived. If HANDLER is nil, no return message will | |||
| 1078 | be expected. | 1078 | be expected. |
| 1079 | 1079 | ||
| 1080 | If the parameter `:timeout' is given, the following integer TIMEOUT | 1080 | If the parameter `:timeout' is given, the following integer TIMEOUT |
| 1081 | specifies the maximun number of milliseconds the method call must | 1081 | specifies the maximum number of milliseconds the method call must |
| 1082 | return. The default value is 25,000. If the method call doesn't | 1082 | return. The default value is 25,000. If the method call doesn't |
| 1083 | return in time, a D-Bus error is raised. | 1083 | return in time, a D-Bus error is raised. |
| 1084 | 1084 | ||
| @@ -1096,8 +1096,8 @@ All arguments can be preceded by a type symbol. For details about | |||
| 1096 | type symbols, see Info node `(dbus)Type Conversion'. | 1096 | type symbols, see Info node `(dbus)Type Conversion'. |
| 1097 | 1097 | ||
| 1098 | Unless HANDLER is nil, the function returns a key into the hash table | 1098 | Unless HANDLER is nil, the function returns a key into the hash table |
| 1099 | `dbus-registered-functions-table'. The corresponding entry in the | 1099 | `dbus-registered-objects-table'. The corresponding entry in the hash |
| 1100 | hash table is removed, when the return message has been arrived, and | 1100 | table is removed, when the return message has been arrived, and |
| 1101 | HANDLER is called. | 1101 | HANDLER is called. |
| 1102 | 1102 | ||
| 1103 | Example: | 1103 | Example: |
| @@ -1207,11 +1207,11 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1207 | NULL, timeout)) | 1207 | NULL, timeout)) |
| 1208 | XD_SIGNAL1 (build_string ("Cannot send message")); | 1208 | XD_SIGNAL1 (build_string ("Cannot send message")); |
| 1209 | 1209 | ||
| 1210 | /* The result is the key in Vdbus_registered_functions_table. */ | 1210 | /* The result is the key in Vdbus_registered_objects_table. */ |
| 1211 | result = (list2 (bus, make_number (dbus_message_get_serial (dmessage)))); | 1211 | result = (list2 (bus, make_number (dbus_message_get_serial (dmessage)))); |
| 1212 | 1212 | ||
| 1213 | /* Create a hash table entry. */ | 1213 | /* Create a hash table entry. */ |
| 1214 | Fputhash (result, handler, Vdbus_registered_functions_table); | 1214 | Fputhash (result, handler, Vdbus_registered_objects_table); |
| 1215 | } | 1215 | } |
| 1216 | else | 1216 | else |
| 1217 | { | 1217 | { |
| @@ -1570,10 +1570,10 @@ int | |||
| 1570 | xd_pending_messages () | 1570 | xd_pending_messages () |
| 1571 | { | 1571 | { |
| 1572 | 1572 | ||
| 1573 | /* Vdbus_registered_functions_table will be initialized as hash | 1573 | /* Vdbus_registered_objects_table will be initialized as hash table |
| 1574 | table in dbus.el. When this package isn't loaded yet, it doesn't | 1574 | in dbus.el. When this package isn't loaded yet, it doesn't make |
| 1575 | make sense to handle D-Bus messages. */ | 1575 | sense to handle D-Bus messages. */ |
| 1576 | return (HASH_TABLE_P (Vdbus_registered_functions_table) | 1576 | return (HASH_TABLE_P (Vdbus_registered_objects_table) |
| 1577 | ? (xd_get_dispatch_status (QCdbus_system_bus) | 1577 | ? (xd_get_dispatch_status (QCdbus_system_bus) |
| 1578 | || ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL) | 1578 | || ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL) |
| 1579 | ? xd_get_dispatch_status (QCdbus_session_bus) | 1579 | ? xd_get_dispatch_status (QCdbus_session_bus) |
| @@ -1656,14 +1656,14 @@ xd_read_message (bus) | |||
| 1656 | { | 1656 | { |
| 1657 | /* Search for a registered function of the message. */ | 1657 | /* Search for a registered function of the message. */ |
| 1658 | key = list2 (bus, make_number (serial)); | 1658 | key = list2 (bus, make_number (serial)); |
| 1659 | value = Fgethash (key, Vdbus_registered_functions_table, Qnil); | 1659 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1660 | 1660 | ||
| 1661 | /* There shall be exactly one entry. Construct an event. */ | 1661 | /* There shall be exactly one entry. Construct an event. */ |
| 1662 | if (NILP (value)) | 1662 | if (NILP (value)) |
| 1663 | goto cleanup; | 1663 | goto cleanup; |
| 1664 | 1664 | ||
| 1665 | /* Remove the entry. */ | 1665 | /* Remove the entry. */ |
| 1666 | Fremhash (key, Vdbus_registered_functions_table); | 1666 | Fremhash (key, Vdbus_registered_objects_table); |
| 1667 | 1667 | ||
| 1668 | /* Construct an event. */ | 1668 | /* Construct an event. */ |
| 1669 | EVENT_INIT (event); | 1669 | EVENT_INIT (event); |
| @@ -1674,14 +1674,14 @@ xd_read_message (bus) | |||
| 1674 | 1674 | ||
| 1675 | else /* (mtype != DBUS_MESSAGE_TYPE_METHOD_RETURN) */ | 1675 | else /* (mtype != DBUS_MESSAGE_TYPE_METHOD_RETURN) */ |
| 1676 | { | 1676 | { |
| 1677 | /* Vdbus_registered_functions_table requires non-nil interface | 1677 | /* Vdbus_registered_objects_table requires non-nil interface and |
| 1678 | and member. */ | 1678 | member. */ |
| 1679 | if ((interface == NULL) || (member == NULL)) | 1679 | if ((interface == NULL) || (member == NULL)) |
| 1680 | goto cleanup; | 1680 | goto cleanup; |
| 1681 | 1681 | ||
| 1682 | /* Search for a registered function of the message. */ | 1682 | /* Search for a registered function of the message. */ |
| 1683 | key = list3 (bus, build_string (interface), build_string (member)); | 1683 | key = list3 (bus, build_string (interface), build_string (member)); |
| 1684 | value = Fgethash (key, Vdbus_registered_functions_table, Qnil); | 1684 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1685 | 1685 | ||
| 1686 | /* Loop over the registered functions. Construct an event. */ | 1686 | /* Loop over the registered functions. Construct an event. */ |
| 1687 | while (!NILP (value)) | 1687 | while (!NILP (value)) |
| @@ -1745,11 +1745,11 @@ void | |||
| 1745 | xd_read_queued_messages () | 1745 | xd_read_queued_messages () |
| 1746 | { | 1746 | { |
| 1747 | 1747 | ||
| 1748 | /* Vdbus_registered_functions_table will be initialized as hash | 1748 | /* Vdbus_registered_objects_table will be initialized as hash table |
| 1749 | table in dbus.el. When this package isn't loaded yet, it doesn't | 1749 | in dbus.el. When this package isn't loaded yet, it doesn't make |
| 1750 | make sense to handle D-Bus messages. Furthermore, we ignore all | 1750 | sense to handle D-Bus messages. Furthermore, we ignore all Lisp |
| 1751 | Lisp errors during the call. */ | 1751 | errors during the call. */ |
| 1752 | if (HASH_TABLE_P (Vdbus_registered_functions_table)) | 1752 | if (HASH_TABLE_P (Vdbus_registered_objects_table)) |
| 1753 | { | 1753 | { |
| 1754 | xd_in_read_queued_messages = 1; | 1754 | xd_in_read_queued_messages = 1; |
| 1755 | internal_catch (Qdbus_error, xd_read_message, QCdbus_system_bus); | 1755 | internal_catch (Qdbus_error, xd_read_message, QCdbus_system_bus); |
| @@ -1898,10 +1898,10 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG | |||
| 1898 | /* Create a hash table entry. */ | 1898 | /* Create a hash table entry. */ |
| 1899 | key = list3 (bus, interface, signal); | 1899 | key = list3 (bus, interface, signal); |
| 1900 | key1 = list4 (uname, service, path, handler); | 1900 | key1 = list4 (uname, service, path, handler); |
| 1901 | value = Fgethash (key, Vdbus_registered_functions_table, Qnil); | 1901 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1902 | 1902 | ||
| 1903 | if (NILP (Fmember (key1, value))) | 1903 | if (NILP (Fmember (key1, value))) |
| 1904 | Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table); | 1904 | Fputhash (key, Fcons (key1, value), Vdbus_registered_objects_table); |
| 1905 | 1905 | ||
| 1906 | /* Return object. */ | 1906 | /* Return object. */ |
| 1907 | RETURN_UNGCPRO (list2 (key, list3 (service, path, handler))); | 1907 | RETURN_UNGCPRO (list2 (key, list3 (service, path, handler))); |
| @@ -1950,15 +1950,14 @@ used for composing the returning D-Bus message. */) | |||
| 1950 | if (dbus_error_is_set (&derror)) | 1950 | if (dbus_error_is_set (&derror)) |
| 1951 | XD_ERROR (derror); | 1951 | XD_ERROR (derror); |
| 1952 | 1952 | ||
| 1953 | /* Create a hash table entry. */ | 1953 | /* Create a hash table entry. We use nil for the unique name, |
| 1954 | because the method might be called from anybody. */ | ||
| 1954 | key = list3 (bus, interface, method); | 1955 | key = list3 (bus, interface, method); |
| 1955 | key1 = list4 (Qnil, service, path, handler); | 1956 | key1 = list4 (Qnil, service, path, handler); |
| 1956 | value = Fgethash (key, Vdbus_registered_functions_table, Qnil); | 1957 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1957 | 1958 | ||
| 1958 | /* We use nil for the unique name, because the method might be | ||
| 1959 | called from everybody. */ | ||
| 1960 | if (NILP (Fmember (key1, value))) | 1959 | if (NILP (Fmember (key1, value))) |
| 1961 | Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table); | 1960 | Fputhash (key, Fcons (key1, value), Vdbus_registered_objects_table); |
| 1962 | 1961 | ||
| 1963 | /* Cleanup. */ | 1962 | /* Cleanup. */ |
| 1964 | dbus_error_free (&derror); | 1963 | dbus_error_free (&derror); |
| @@ -2072,26 +2071,28 @@ syms_of_dbusbind () | |||
| 2072 | QCdbus_type_dict_entry = intern_c_string (":dict-entry"); | 2071 | QCdbus_type_dict_entry = intern_c_string (":dict-entry"); |
| 2073 | staticpro (&QCdbus_type_dict_entry); | 2072 | staticpro (&QCdbus_type_dict_entry); |
| 2074 | 2073 | ||
| 2075 | DEFVAR_LISP ("dbus-registered-functions-table", | 2074 | DEFVAR_LISP ("dbus-registered-objects-table", |
| 2076 | &Vdbus_registered_functions_table, | 2075 | &Vdbus_registered_objects_table, |
| 2077 | doc: /* Hash table of registered functions for D-Bus. | 2076 | doc: /* Hash table of registered functions for D-Bus. |
| 2078 | There are two different uses of the hash table: for calling registered | 2077 | There are two different uses of the hash table: for accessing |
| 2079 | functions, targeted by signals or method calls, and for calling | 2078 | registered interfaces properties, targeted by signals or method calls, |
| 2080 | handlers in case of non-blocking method call returns. | 2079 | and for calling handlers in case of non-blocking method call returns. |
| 2081 | 2080 | ||
| 2082 | In the first case, the key in the hash table is the list (BUS | 2081 | In the first case, the key in the hash table is the list (BUS |
| 2083 | INTERFACE MEMBER). BUS is either the symbol `:system' or the symbol | 2082 | INTERFACE MEMBER). BUS is either the symbol `:system' or the symbol |
| 2084 | `:session'. INTERFACE is a string which denotes a D-Bus interface, | 2083 | `:session'. INTERFACE is a string which denotes a D-Bus interface, |
| 2085 | and MEMBER, also a string, is either a method or a signal INTERFACE is | 2084 | and MEMBER, also a string, is either a method, a signal or a property |
| 2086 | offering. All arguments but BUS must not be nil. | 2085 | INTERFACE is offering. All arguments but BUS must not be nil. |
| 2087 | 2086 | ||
| 2088 | The value in the hash table is a list of quadruple lists | 2087 | The value in the hash table is a list of quadruple lists |
| 2089 | \((UNAME SERVICE PATH HANDLER) (UNAME SERVICE PATH HANDLER) ...). | 2088 | \((UNAME SERVICE PATH OBJECT) (UNAME SERVICE PATH OBJECT) ...). |
| 2090 | SERVICE is the service name as registered, UNAME is the corresponding | 2089 | SERVICE is the service name as registered, UNAME is the corresponding |
| 2091 | unique name. PATH is the object path of the sending object. All of | 2090 | unique name. In case of registered methods and properties, UNAME is |
| 2092 | them can be nil, which means a wildcard then. HANDLER is the function | 2091 | nil. PATH is the object path of the sending object. All of them can |
| 2093 | to be called when a D-Bus message, which matches the key criteria, | 2092 | be nil, which means a wildcard then. OBJECT is either the handler to |
| 2094 | arrives. | 2093 | be called when a D-Bus message, which matches the key criteria, |
| 2094 | arrives (methods and signals), or a cons cell containing the value of | ||
| 2095 | the property. | ||
| 2095 | 2096 | ||
| 2096 | In the second case, the key in the hash table is the list (BUS SERIAL). | 2097 | In the second case, the key in the hash table is the list (BUS SERIAL). |
| 2097 | BUS is either the symbol `:system' or the symbol `:session'. SERIAL | 2098 | BUS is either the symbol `:system' or the symbol `:session'. SERIAL |
| @@ -2099,9 +2100,9 @@ is the serial number of the non-blocking method call, a reply is | |||
| 2099 | expected. Both arguments must not be nil. The value in the hash | 2100 | expected. Both arguments must not be nil. The value in the hash |
| 2100 | table is HANDLER, the function to be called when the D-Bus reply | 2101 | table is HANDLER, the function to be called when the D-Bus reply |
| 2101 | message arrives. */); | 2102 | message arrives. */); |
| 2102 | /* We initialize Vdbus_registered_functions_table in dbus.el, | 2103 | /* We initialize Vdbus_registered_objects_table in dbus.el, because |
| 2103 | because we need to define a hash table function first. */ | 2104 | we need to define a hash table function first. */ |
| 2104 | Vdbus_registered_functions_table = Qnil; | 2105 | Vdbus_registered_objects_table = Qnil; |
| 2105 | 2106 | ||
| 2106 | DEFVAR_LISP ("dbus-debug", &Vdbus_debug, | 2107 | DEFVAR_LISP ("dbus-debug", &Vdbus_debug, |
| 2107 | doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); | 2108 | doc: /* If non-nil, debug messages of D-Bus bindings are raised. */); |