[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v |
Date: |
Tue, 04 Dec 2007 21:21:10 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Michael Albinus <albinus> 07/12/04 21:21:09
Index: net/dbus.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/dbus.el,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- net/dbus.el 2 Dec 2007 16:26:17 -0000 1.1
+++ net/dbus.el 4 Dec 2007 21:21:09 -0000 1.2
@@ -46,36 +46,76 @@
(defconst dbus-interface-introspectable "org.freedesktop.DBus.Introspectable"
"The interface supported by introspectable objects.")
+
+;;; Hash table of registered functions.
+
+(defun dbus-hash-table= (x y)
+ "Compares keys X and Y in the hash table of registered functions for D-Bus.
+See `dbus-registered-functions-table' for a description of the hash table."
+ (and
+ (listp x) (listp y)
+ ;; Bus symbol, either :system or :session.
+ (symbolp (car x)) (symbolp (car y)) (equal (car x) (car y))
+ ;; Interface.
+ (stringp (cadr x)) (stringp (cadr y)) (string-equal (cadr x) (cadr y))
+ ;; Member.
+ (stringp (caddr x)) (stringp (caddr y)) (string-equal (caddr x) (caddr
y))))
+
+(define-hash-table-test 'dbus-hash-table-test
+ 'dbus-hash-table= 'sxhash)
+
+(setq dbus-registered-functions-table
+ (make-hash-table :test 'dbus-hash-table-test))
+
+
+;;; D-Bus events.
+
(defun dbus-check-event (event)
"Checks whether EVENT is a well formed D-Bus event.
EVENT is a list which starts with symbol `dbus-event':
- (dbus-event SYMBOL SERVICE PATH &rest ARGS)
+ (dbus-event HANDLER BUS SERVICE PATH INTERFACE MEMBER &rest ARGS)
-SYMBOL is the interned Lisp symbol which has been generated
-during signal registration. SERVICE and PATH are the unique name
-and the object path of the D-Bus object emitting the signal.
-ARGS are the arguments passed to the corresponding handler.
+HANDLER is the function which has been registered for this
+signal. BUS identifies the D-Bus the signal is coming from. It
+is either the symbol `:system' or the symbol `:session'. SERVICE
+and PATH are the name and the object path of the D-Bus object
+emitting the signal. INTERFACE and MEMBER denote the signal
+which has been sent. ARGS are the arguments passed to HANDLER,
+when it is called during event handling in `dbus-handle-event'.
This function raises a `dbus-error' signal in case the event is
not well formed."
(when dbus-debug (message "DBus-Event %s" event))
(unless (and (listp event)
(eq (car event) 'dbus-event)
- (symbolp (cadr event))
- (stringp (car (cddr event)))
- (stringp (cadr (cddr event))))
+ ;; Handler.
+ (functionp (nth 1 event))
+ ;; Bus symbol.
+ (symbolp (nth 2 event))
+ ;; Service.
+ (stringp (nth 3 event))
+ ;; Object path.
+ (stringp (nth 4 event))
+ ;; Interface.
+ (stringp (nth 5 event))
+ ;; Member.
+ (stringp (nth 6 event)))
(signal 'dbus-error (list "Not a valid D-Bus event" event))))
;;;###autoload
(defun dbus-handle-event (event)
"Handle events from the D-Bus.
-EVENT is a D-Bus event, see `dbus-check-event'. This function
-raises a `dbus-error' signal in case the event is not well
-formed."
+EVENT is a D-Bus event, see `dbus-check-event'. HANDLER, being
+part of the event, is called with arguments ARGS."
(interactive "e")
+ ;; We don't want to raise an error, because this function is called
+ ;; in the event handling loop.
+ (condition-case nil
+ (progn
(dbus-check-event event)
- (when (functionp (cadr event)) (apply (cadr event) (cddr (cddr event)))))
+ (apply (cadr event) (nthcdr 7 event)))
+ (dbus-error)))
(defun dbus-event-bus-name (event)
"Return the bus name the event is coming from.
@@ -84,16 +124,15 @@
raises a `dbus-error' signal in case the event is not well
formed."
(dbus-check-event event)
- (save-match-data
- (intern (car (split-string (symbol-name (cadr event)) "\\.")))))
+ (nth 2 event))
(defun dbus-event-service-name (event)
- "Return the unique name of the D-Bus object the event is coming from.
+ "Return the name of the D-Bus object the event is coming from.
The result is a string. EVENT is a D-Bus event, see `dbus-check-event'.
This function raises a `dbus-error' signal in case the event is
not well formed."
(dbus-check-event event)
- (car (cddr event)))
+ (nth 3 event))
(defun dbus-event-path-name (event)
"Return the object path of the D-Bus object the event is coming from.
@@ -101,7 +140,7 @@
This function raises a `dbus-error' signal in case the event is
not well formed."
(dbus-check-event event)
- (cadr (cddr event)))
+ (nth 4 event))
(defun dbus-event-interface-name (event)
"Return the interface name of the D-Bus object the event is coming from.
@@ -109,9 +148,7 @@
This function raises a `dbus-error' signal in case the event is
not well formed."
(dbus-check-event event)
- (save-match-data
- (string-match "^[^.]+\\.\\(.+\\)\\.[^.]+$" (symbol-name (cadr event)))
- (match-string 1 (symbol-name (cadr event)))))
+ (nth 5 event))
(defun dbus-event-member-name (event)
"Return the member name the event is coming from.
@@ -120,8 +157,10 @@
function raises a `dbus-error' signal in case the event is not
well formed."
(dbus-check-event event)
- (save-match-data
- (car (nreverse (split-string (symbol-name (cadr event)) "\\.")))))
+ (nth 6 event))
+
+
+;;; D-Bus registered names.
(defun dbus-list-activatable-names ()
"Return the D-Bus service names which can be activated as list.
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v,
Michael Albinus <=
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Miles Bader, 2007/12/04
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Michael Albinus, 2007/12/05
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Michael Albinus, 2007/12/06
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Michael Albinus, 2007/12/08
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Michael Albinus, 2007/12/16
- [Emacs-diffs] Changes to emacs/lisp/net/dbus.el,v, Michael Albinus, 2007/12/30