diff options
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/net/dbus.el | 66 |
2 files changed, 53 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index becb813171b..01ea2265b49 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2008-01-04 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/dbus.el (dbus-list-hash-table) | ||
| 4 | (dbus-name-owner-changed-handler): Replace "signal" by "member". | ||
| 5 | (dbus-check-event): Add serial number to event. | ||
| 6 | (dbus-handle-event): Apply return message if needed. | ||
| 7 | (dbus-event-serial-number): New defun. | ||
| 8 | (dbus-event-service-name, dbus-event-path-name) | ||
| 9 | (dbus-event-interface-name, dbus-event-member-name): Adapt | ||
| 10 | implementation to serial number. | ||
| 11 | |||
| 1 | 2008-01-04 Tassilo Horn <tassilo@member.fsf.org> | 12 | 2008-01-04 Tassilo Horn <tassilo@member.fsf.org> |
| 2 | 13 | ||
| 3 | * doc-view.el (doc-view-scroll-up-or-next-page) | 14 | * doc-view.el (doc-view-scroll-up-or-next-page) |
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index f8f422c5c1f..83075762b73 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | (setq dbus-registered-functions-table (make-hash-table :test 'equal)) | 54 | (setq dbus-registered-functions-table (make-hash-table :test 'equal)) |
| 55 | 55 | ||
| 56 | (defun dbus-list-hash-table () | 56 | (defun dbus-list-hash-table () |
| 57 | "Returns all registered signal registrations to D-Bus. | 57 | "Returns all registered member registrations to D-Bus. |
| 58 | The return value is a list, with elements of kind (KEY . VALUE). | 58 | The return value is a list, with elements of kind (KEY . VALUE). |
| 59 | See `dbus-registered-functions-table' for a description of the | 59 | See `dbus-registered-functions-table' for a description of the |
| 60 | hash table." | 60 | hash table." |
| @@ -65,7 +65,7 @@ hash table." | |||
| 65 | result)) | 65 | result)) |
| 66 | 66 | ||
| 67 | (defun dbus-name-owner-changed-handler (&rest args) | 67 | (defun dbus-name-owner-changed-handler (&rest args) |
| 68 | "Reapplies all signal registrations to D-Bus. | 68 | "Reapplies all member registrations to D-Bus. |
| 69 | This handler is applied when a \"NameOwnerChanged\" signal has | 69 | This handler is applied when a \"NameOwnerChanged\" signal has |
| 70 | arrived. SERVICE is the object name for which the name owner has | 70 | arrived. SERVICE is the object name for which the name owner has |
| 71 | been changed. OLD-OWNER is the previous owner of SERVICE, or the | 71 | been changed. OLD-OWNER is the previous owner of SERVICE, or the |
| @@ -88,7 +88,7 @@ usage: (dbus-name-owner-changed-handler service old-owner new-owner)" | |||
| 88 | (maphash | 88 | (maphash |
| 89 | '(lambda (key value) | 89 | '(lambda (key value) |
| 90 | (dolist (elt value) | 90 | (dolist (elt value) |
| 91 | ;; key has the structure (BUS INTERFACE SIGNAL). | 91 | ;; key has the structure (BUS INTERFACE MEMBER). |
| 92 | ;; elt has the structure (UNAME SERVICE PATH HANDLER). | 92 | ;; elt has the structure (UNAME SERVICE PATH HANDLER). |
| 93 | (when (string-equal old-owner (car elt)) | 93 | (when (string-equal old-owner (car elt)) |
| 94 | ;; Remove old key, and add new entry with changed name. | 94 | ;; Remove old key, and add new entry with changed name. |
| @@ -98,7 +98,7 @@ usage: (dbus-name-owner-changed-handler service old-owner new-owner)" | |||
| 98 | (dbus-register-signal | 98 | (dbus-register-signal |
| 99 | ;; BUS SERVICE PATH | 99 | ;; BUS SERVICE PATH |
| 100 | (nth 0 key) (nth 1 elt) (nth 2 elt) | 100 | (nth 0 key) (nth 1 elt) (nth 2 elt) |
| 101 | ;; INTERFACE SIGNAL HANDLER | 101 | ;; INTERFACE MEMBER HANDLER |
| 102 | (nth 1 key) (nth 2 key) (nth 3 elt))))) | 102 | (nth 1 key) (nth 2 key) (nth 3 elt))))) |
| 103 | (copy-hash-table dbus-registered-functions-table)))) | 103 | (copy-hash-table dbus-registered-functions-table)))) |
| 104 | ;; The error is reported only in debug mode. | 104 | ;; The error is reported only in debug mode. |
| @@ -127,16 +127,17 @@ usage: (dbus-name-owner-changed-handler service old-owner new-owner)" | |||
| 127 | "Checks whether EVENT is a well formed D-Bus event. | 127 | "Checks whether EVENT is a well formed D-Bus event. |
| 128 | EVENT is a list which starts with symbol `dbus-event': | 128 | EVENT is a list which starts with symbol `dbus-event': |
| 129 | 129 | ||
| 130 | (dbus-event BUS SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS) | 130 | (dbus-event BUS SERIAL SERVICE PATH INTERFACE MEMBER HANDLER &rest ARGS) |
| 131 | 131 | ||
| 132 | BUS identifies the D-Bus the signal is coming from. It is either | 132 | BUS identifies the D-Bus the message is coming from. It is |
| 133 | the symbol `:system' or the symbol `:session'. SERVICE and PATH | 133 | either the symbol `:system' or the symbol `:session'. SERIAL is |
| 134 | are the unique name and the object path of the D-Bus object | 134 | the serial number of the received D-Bus message if it is a method |
| 135 | emitting the signal. INTERFACE and MEMBER denote the signal | 135 | call, or nil. SERVICE and PATH are the unique name and the |
| 136 | which has been sent. HANDLER is the function which has been | 136 | object path of the D-Bus object emitting the message. INTERFACE |
| 137 | registered for this signal. ARGS are the arguments passed to | 137 | and MEMBER denote the message which has been sent. HANDLER is |
| 138 | HANDLER, when it is called during event handling in | 138 | the function which has been registered for this message. ARGS |
| 139 | `dbus-handle-event'. | 139 | are the arguments passed to HANDLER, when it is called during |
| 140 | event handling in `dbus-handle-event'. | ||
| 140 | 141 | ||
| 141 | This function raises a `dbus-error' signal in case the event is | 142 | This function raises a `dbus-error' signal in case the event is |
| 142 | not well formed." | 143 | not well formed." |
| @@ -145,16 +146,18 @@ not well formed." | |||
| 145 | (eq (car event) 'dbus-event) | 146 | (eq (car event) 'dbus-event) |
| 146 | ;; Bus symbol. | 147 | ;; Bus symbol. |
| 147 | (symbolp (nth 1 event)) | 148 | (symbolp (nth 1 event)) |
| 149 | ;; Serial. | ||
| 150 | (or (natnump (nth 2 event)) (null (nth 2 event))) | ||
| 148 | ;; Service. | 151 | ;; Service. |
| 149 | (stringp (nth 2 event)) | ||
| 150 | ;; Object path. | ||
| 151 | (stringp (nth 3 event)) | 152 | (stringp (nth 3 event)) |
| 152 | ;; Interface. | 153 | ;; Object path. |
| 153 | (stringp (nth 4 event)) | 154 | (stringp (nth 4 event)) |
| 154 | ;; Member. | 155 | ;; Interface. |
| 155 | (stringp (nth 5 event)) | 156 | (stringp (nth 5 event)) |
| 157 | ;; Member. | ||
| 158 | (stringp (nth 6 event)) | ||
| 156 | ;; Handler. | 159 | ;; Handler. |
| 157 | (functionp (nth 6 event))) | 160 | (functionp (nth 7 event))) |
| 158 | (signal 'dbus-error (list "Not a valid D-Bus event" event)))) | 161 | (signal 'dbus-error (list "Not a valid D-Bus event" event)))) |
| 159 | 162 | ||
| 160 | ;;;###autoload | 163 | ;;;###autoload |
| @@ -166,9 +169,14 @@ part of the event, is called with arguments ARGS." | |||
| 166 | ;; We don't want to raise an error, because this function is called | 169 | ;; We don't want to raise an error, because this function is called |
| 167 | ;; in the event handling loop. | 170 | ;; in the event handling loop. |
| 168 | (condition-case err | 171 | (condition-case err |
| 169 | (progn | 172 | (let (result) |
| 170 | (dbus-check-event event) | 173 | (dbus-check-event event) |
| 171 | (apply (nth 6 event) (nthcdr 7 event))) | 174 | (setq result (apply (nth 7 event) (nthcdr 8 event))) |
| 175 | (unless (consp result) (setq result (cons result nil))) | ||
| 176 | ;; Return a message when serial is not nil. | ||
| 177 | (when (not (null (nth 2 event))) | ||
| 178 | (apply 'dbus-method-return | ||
| 179 | (nth 1 event) (nth 2 event) (nth 3 event) result))) | ||
| 172 | (dbus-error (when dbus-debug (signal (car err) (cdr err)))))) | 180 | (dbus-error (when dbus-debug (signal (car err) (cdr err)))))) |
| 173 | 181 | ||
| 174 | (defun dbus-event-bus-name (event) | 182 | (defun dbus-event-bus-name (event) |
| @@ -180,13 +188,23 @@ formed." | |||
| 180 | (dbus-check-event event) | 188 | (dbus-check-event event) |
| 181 | (nth 1 event)) | 189 | (nth 1 event)) |
| 182 | 190 | ||
| 191 | (defun dbus-event-serial-number (event) | ||
| 192 | "Return the serial number of the corresponding D-Bus message. | ||
| 193 | The result is a number in case the D-Bus message is a method | ||
| 194 | call, or nil for all other mesage types. The serial number is | ||
| 195 | needed for generating a reply message. EVENT is a D-Bus event, | ||
| 196 | see `dbus-check-event'. This function raises a `dbus-error' | ||
| 197 | signal in case the event is not well formed." | ||
| 198 | (dbus-check-event event) | ||
| 199 | (nth 2 event)) | ||
| 200 | |||
| 183 | (defun dbus-event-service-name (event) | 201 | (defun dbus-event-service-name (event) |
| 184 | "Return the name of the D-Bus object the event is coming from. | 202 | "Return the name of the D-Bus object the event is coming from. |
| 185 | The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. | 203 | The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. |
| 186 | This function raises a `dbus-error' signal in case the event is | 204 | This function raises a `dbus-error' signal in case the event is |
| 187 | not well formed." | 205 | not well formed." |
| 188 | (dbus-check-event event) | 206 | (dbus-check-event event) |
| 189 | (nth 2 event)) | 207 | (nth 3 event)) |
| 190 | 208 | ||
| 191 | (defun dbus-event-path-name (event) | 209 | (defun dbus-event-path-name (event) |
| 192 | "Return the object path of the D-Bus object the event is coming from. | 210 | "Return the object path of the D-Bus object the event is coming from. |
| @@ -194,7 +212,7 @@ The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. | |||
| 194 | This function raises a `dbus-error' signal in case the event is | 212 | This function raises a `dbus-error' signal in case the event is |
| 195 | not well formed." | 213 | not well formed." |
| 196 | (dbus-check-event event) | 214 | (dbus-check-event event) |
| 197 | (nth 3 event)) | 215 | (nth 4 event)) |
| 198 | 216 | ||
| 199 | (defun dbus-event-interface-name (event) | 217 | (defun dbus-event-interface-name (event) |
| 200 | "Return the interface name of the D-Bus object the event is coming from. | 218 | "Return the interface name of the D-Bus object the event is coming from. |
| @@ -202,7 +220,7 @@ The result is a string. EVENT is a D-Bus event, see `dbus-check-event'. | |||
| 202 | This function raises a `dbus-error' signal in case the event is | 220 | This function raises a `dbus-error' signal in case the event is |
| 203 | not well formed." | 221 | not well formed." |
| 204 | (dbus-check-event event) | 222 | (dbus-check-event event) |
| 205 | (nth 4 event)) | 223 | (nth 5 event)) |
| 206 | 224 | ||
| 207 | (defun dbus-event-member-name (event) | 225 | (defun dbus-event-member-name (event) |
| 208 | "Return the member name the event is coming from. | 226 | "Return the member name the event is coming from. |
| @@ -211,7 +229,7 @@ string. EVENT is a D-Bus event, see `dbus-check-event'. This | |||
| 211 | function raises a `dbus-error' signal in case the event is not | 229 | function raises a `dbus-error' signal in case the event is not |
| 212 | well formed." | 230 | well formed." |
| 213 | (dbus-check-event event) | 231 | (dbus-check-event event) |
| 214 | (nth 5 event)) | 232 | (nth 6 event)) |
| 215 | 233 | ||
| 216 | 234 | ||
| 217 | ;;; D-Bus registered names. | 235 | ;;; D-Bus registered names. |