changeset 104602:d74b934b16e5

* net/dbus.el (dbus-ping): Add optional parameter TIMEOUT.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 25 Aug 2009 10:13:54 +0000
parents 3f203311bcc1
children d52f81521f32
files lisp/net/dbus.el
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net/dbus.el	Tue Aug 25 10:11:08 2009 +0000
+++ b/lisp/net/dbus.el	Tue Aug 25 10:13:54 2009 +0000
@@ -493,13 +493,26 @@
      bus dbus-service-dbus dbus-path-dbus
      dbus-interface-dbus "GetNameOwner" service)))
 
-(defun dbus-ping (bus service)
-  "Check whether SERVICE is registered for D-Bus BUS."
+(defun dbus-ping (bus service &optional timeout)
+  "Check whether SERVICE is registered for D-Bus BUS.
+TIMEOUT, a nonnegative integer, specifies the maximum number of
+milliseconds `dbus-ping' must return.  The default value is 25,000.
+
+Note, that this autoloads SERVICE if it is not running yet.  If
+it shall be checked whether SERVICE is already running, one shall
+apply
+
+  \(member service \(dbus-list-known-names bus))"
   ;; "Ping" raises a D-Bus error if SERVICE does not exist.
   ;; Otherwise, it returns silently with `nil'.
   (condition-case nil
       (not
-       (dbus-call-method bus service dbus-path-dbus dbus-interface-peer "Ping"))
+       (if (natnump timeout)
+	   (dbus-call-method
+	    bus service dbus-path-dbus dbus-interface-peer
+	    "Ping" :timeout timeout)
+	 (dbus-call-method
+	  bus service dbus-path-dbus dbus-interface-peer "Ping")))
     (dbus-error nil)))