changeset 112113:f68ebb34e243

* dbusbind.c (Fdbus_register_method): Added optional parameter dont_register_service. Updated docstring accordingly.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 04 Jan 2011 12:11:43 +0100
parents 318b7249ccd0
children 2e84d340bbaf
files src/ChangeLog src/dbusbind.c
diffstat 2 files changed, 35 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Jan 04 11:57:24 2011 +0100
+++ b/src/ChangeLog	Tue Jan 04 12:11:43 2011 +0100
@@ -1,3 +1,8 @@
+2011-01-04  Jan Moringen  <jan.moringen@uni-bielefeld.de>
+
+	* dbusbind.c (Fdbus_register_method): Added optional parameter
+	dont_register_service.  Updated docstring accordingly.
+
 2011-01-04  Glenn Morris  <rgm@gnu.org>
 
 	* emacs.c (emacs_copyright): Update short copyright year to 2011.
--- a/src/dbusbind.c	Tue Jan 04 11:57:24 2011 +0100
+++ b/src/dbusbind.c	Tue Jan 04 12:11:43 2011 +0100
@@ -1,5 +1,5 @@
 /* Elisp bindings for D-Bus.
-   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1983,21 +1983,32 @@
 }
 
 DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method,
-       6, 6, 0,
+       6, 7, 0,
        doc: /* Register for method METHOD on the D-Bus BUS.
 
 BUS is either a Lisp symbol, `:system' or `:session', or a string
 denoting the bus address.
 
 SERVICE is the D-Bus service name of the D-Bus object METHOD is
-registered for.  It must be a known name.
+registered for.  It must be a known name (See discussion of
+DONT-REGISTER-SERVICE below).
+
+PATH is the D-Bus object path SERVICE is registered (See discussion of
+DONT-REGISTER-SERVICE below).  INTERFACE is the interface offered by
+SERVICE.  It must provide METHOD.  HANDLER is a Lisp function to be
+called when a method call is received.  It must accept the input
+arguments of METHOD.  The return value of HANDLER is used for
+composing the returning D-Bus message.
 
-PATH is the D-Bus object path SERVICE is registered.  INTERFACE is the
-interface offered by SERVICE.  It must provide METHOD.  HANDLER is a
-Lisp function to be called when a method call is received.  It must
-accept the input arguments of METHOD.  The return value of HANDLER is
-used for composing the returning D-Bus message.  */)
-  (Lisp_Object bus, Lisp_Object service, Lisp_Object path, Lisp_Object interface, Lisp_Object method, Lisp_Object handler)
+When DONT-REGISTER-SERVICE is non-nil, the known name SERVICE is not
+registered.  This means that other D-Bus clients have no way of
+noticing the newly registered method.  When interfaces are constructed
+incrementally by adding single methods or properties at a time,
+DONT-REGISTER-SERVICE can be use to prevent other clients from
+discovering the still incomplete interface.*/)
+  (Lisp_Object bus, Lisp_Object service, Lisp_Object path,
+   Lisp_Object interface, Lisp_Object method, Lisp_Object handler,
+   Lisp_Object dont_register_service)
 {
   Lisp_Object key, key1, value;
   DBusConnection *connection;
@@ -2019,10 +2030,16 @@
 
   /* Request the known name from the bus.  We can ignore the result,
      it is set to -1 if there is an error - kind of redundancy.  */
-  dbus_error_init (&derror);
-  result = dbus_bus_request_name (connection, SDATA (service), 0, &derror);
-  if (dbus_error_is_set (&derror))
-    XD_ERROR (derror);
+  if (NILP (dont_register_service))
+    {
+      dbus_error_init (&derror);
+      result = dbus_bus_request_name (connection, SDATA (service), 0, &derror);
+      if (dbus_error_is_set (&derror))
+	XD_ERROR (derror);
+
+      /* Cleanup.  */
+      dbus_error_free (&derror);
+    }
 
   /* Create a hash table entry.  We use nil for the unique name,
      because the method might be called from anybody.  */
@@ -2033,9 +2050,6 @@
   if (NILP (Fmember (key1, value)))
     Fputhash (key, Fcons (key1, value), Vdbus_registered_objects_table);
 
-  /* Cleanup.  */
-  dbus_error_free (&derror);
-
   /* Return object.  */
   return list2 (key, list3 (service, path, handler));
 }