diff options
| author | Michael Albinus | 2007-12-08 12:56:59 +0000 |
|---|---|---|
| committer | Michael Albinus | 2007-12-08 12:56:59 +0000 |
| commit | 79945ac143dcf3e16076d9a4a669f987c58f6db1 (patch) | |
| tree | 7fef0cabc3b9c69a5c03f16a8c8d50641cb5faec | |
| parent | a31d47c7ddfa55bd49b6cfd4b066cd776da459a9 (diff) | |
| download | emacs-79945ac143dcf3e16076d9a4a669f987c58f6db1.tar.gz emacs-79945ac143dcf3e16076d9a4a669f987c58f6db1.zip | |
* net/dbus.el (dbus-hash-table=): Remove function. We cannot
apply wildcards in a hash table key; there is no usable hash code
then.
(dbus-registered-functions-table): Use `equal' as test function.
(dbus-name-owner-changed-handler): Rewrite due to new hash table
structure.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/net/dbus.el | 70 |
2 files changed, 33 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7608273c9bf..c3b59a1db8f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2007-12-08 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/dbus.el (dbus-hash-table=): Remove function. We cannot | ||
| 4 | apply wildcards in a hash table key; there is no usable hash code | ||
| 5 | then. | ||
| 6 | (dbus-registered-functions-table): Use `equal' as test function. | ||
| 7 | (dbus-name-owner-changed-handler): Rewrite due to new hash table | ||
| 8 | structure. | ||
| 9 | |||
| 1 | 2007-12-08 Martin Rudalics <rudalics@gmx.at> | 10 | 2007-12-08 Martin Rudalics <rudalics@gmx.at> |
| 2 | 11 | ||
| 3 | * progmodes/cc-cmds.el (c-mask-paragraph): Avoid invalid search | 12 | * progmodes/cc-cmds.el (c-mask-paragraph): Avoid invalid search |
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index b0f01c24d41..83d0f7fa3ec 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el | |||
| @@ -49,36 +49,9 @@ | |||
| 49 | 49 | ||
| 50 | ;;; Hash table of registered functions. | 50 | ;;; Hash table of registered functions. |
| 51 | 51 | ||
| 52 | (defun dbus-hash-table= (x y) | 52 | ;; We create it here. So we have a simple test in dbusbind.c, whether |
| 53 | "Compares keys X and Y in the hash table of registered functions for D-Bus. | 53 | ;; the Lisp code has been loaded. |
| 54 | See `dbus-registered-functions-table' for a description of the hash table." | 54 | (setq dbus-registered-functions-table (make-hash-table :test 'equal)) |
| 55 | (and | ||
| 56 | ;; Bus symbol, either :system or :session. | ||
| 57 | (equal (car x) (car y)) | ||
| 58 | ;; Service. | ||
| 59 | (or | ||
| 60 | (null (nth 1 x)) (null (nth 1 y)) ; wildcard | ||
| 61 | (string-equal (nth 1 x) (nth 1 y))) | ||
| 62 | ;; Path. | ||
| 63 | (or | ||
| 64 | (null (nth 2 x)) (null (nth 2 y)) ; wildcard | ||
| 65 | (string-equal (nth 2 x) (nth 2 y))) | ||
| 66 | ;; Member. | ||
| 67 | (or | ||
| 68 | (null (nth 3 x)) (null (nth 3 y)) ; wildcard | ||
| 69 | (string-equal (nth 3 x) (nth 3 y))) | ||
| 70 | ;; Interface. | ||
| 71 | (or | ||
| 72 | (null (nth 4 x)) (null (nth 4 y)) ; wildcard | ||
| 73 | (string-equal (nth 4 x) (nth 4 y))))) | ||
| 74 | |||
| 75 | (define-hash-table-test 'dbus-hash-table-test 'dbus-hash-table= 'sxhash) | ||
| 76 | |||
| 77 | ;; When we assume that service, path, interface and and member are | ||
| 78 | ;; always strings in the key, we could use `equal' as test function. | ||
| 79 | ;; But we want to have also `nil' there, being a wildcard. | ||
| 80 | (setq dbus-registered-functions-table | ||
| 81 | (make-hash-table :test 'dbus-hash-table-test)) | ||
| 82 | 55 | ||
| 83 | (defun dbus-list-hash-table () | 56 | (defun dbus-list-hash-table () |
| 84 | "Returns all registered signal registrations to D-Bus. | 57 | "Returns all registered signal registrations to D-Bus. |
| @@ -99,24 +72,29 @@ been changed. OLD-OWNER is the previous owner of SERVICE, or the | |||
| 99 | empty string if SERVICE was not owned yet. NEW-OWNER is the new | 72 | empty string if SERVICE was not owned yet. NEW-OWNER is the new |
| 100 | owner of SERVICE, or the empty string if SERVICE looses any name owner." | 73 | owner of SERVICE, or the empty string if SERVICE looses any name owner." |
| 101 | (save-match-data | 74 | (save-match-data |
| 102 | ;; Check whether SERVICE is a known name, and OLD-OWNER and | 75 | ;; Check whether SERVICE is a known name. |
| 103 | ;; NEW-OWNER are defined. | ||
| 104 | (when (and (stringp service) (not (string-match "^:" service)) | 76 | (when (and (stringp service) (not (string-match "^:" service)) |
| 105 | (not (zerop (length old-owner))) | 77 | (stringp old-owner) (stringp new-owner)) |
| 106 | (not (zerop (length new-owner)))) | 78 | (maphash |
| 107 | (let ((bus (dbus-event-bus-name last-input-event))) | 79 | '(lambda (key value) |
| 108 | (maphash | 80 | (dolist (elt value) |
| 109 | '(lambda (key value) | 81 | ;; key has the structure (BUS INTERFACE SIGNAL). |
| 110 | ;; Check for matching bus and service name. | 82 | ;; elt has the structure (SERVICE UNAME PATH HANDLER). |
| 111 | (when (and (equal bus (car key)) | 83 | (when (string-equal old-owner (cadr elt)) |
| 112 | (string-equal old-owner (nth 1 key))) | ||
| 113 | ;; Remove old key, and add new entry with changed name. | 84 | ;; Remove old key, and add new entry with changed name. |
| 114 | (when dbus-debug (message "Remove rule for %s" key)) | 85 | (when dbus-debug (message "Remove rule for %s %s" key elt)) |
| 115 | (dbus-unregister-signal key) | 86 | ;(dbus-unregister-signal key) |
| 116 | (setcar (nthcdr 1 key) new-owner) | 87 | (setcar (cdr elt) new-owner) |
| 117 | (when dbus-debug (message "Add rule for %s" key)) | 88 | (when dbus-debug (message "Add rule for %s %s" key elt)) |
| 118 | (apply 'dbus-register-signal (append key (list value))))) | 89 | ;; Maybe we could arrange the lists a little bit better |
| 119 | (copy-hash-table dbus-registered-functions-table)))))) | 90 | ;; that we don't need to extract every single element? |
| 91 | (when (not (zerop (length new-owner))) | ||
| 92 | (dbus-register-signal | ||
| 93 | ;; BUS SERVICE PATH | ||
| 94 | (nth 0 key) (nth 0 elt) (nth 2 elt) | ||
| 95 | ;; INTERFACE SIGNAL HANDLER | ||
| 96 | (nth 1 key) (nth 2 key) (nth 3 elt)))))) | ||
| 97 | (copy-hash-table dbus-registered-functions-table))))) | ||
| 120 | 98 | ||
| 121 | ;; Register the handler. | 99 | ;; Register the handler. |
| 122 | (condition-case nil | 100 | (condition-case nil |