=== modified file 'lisp/net/dbus.el' --- lisp/net/dbus.el 2010-08-30 13:03:05 +0000 +++ lisp/net/dbus.el 2010-10-03 02:25:51 +0000 @@ -868,7 +868,8 @@ (add-to-list 'result (cons (car dict) (caadr dict)) 'append))))) (defun dbus-register-property - (bus service path interface property access value &optional emits-signal) + (bus service path interface property access value + &optional emits-signal dont-request-name) "Register property PROPERTY on the D-Bus BUS. BUS is either a Lisp symbol, `:system' or `:session', or a string @@ -899,7 +900,8 @@ (signal 'dbus-error (list "Access type invalid" access))) ;; Register SERVICE. - (unless (member service (dbus-list-names bus)) + (unless (or dont-request-name + (member service (dbus-list-names bus))) (dbus-call-method bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus "RequestName" service 0)) @@ -907,11 +909,14 @@ ;; Add the handler. We use `dbus-service-emacs' as service name, in ;; order to let unregister SERVICE despite of this default handler. (dbus-register-method - bus service path dbus-interface-properties "Get" 'dbus-property-handler) + bus service path dbus-interface-properties "Get" 'dbus-property-handler + dont-request-name) (dbus-register-method - bus service path dbus-interface-properties "GetAll" 'dbus-property-handler) + bus service path dbus-interface-properties "GetAll" 'dbus-property-handler + dont-request-name) (dbus-register-method - bus service path dbus-interface-properties "Set" 'dbus-property-handler) + bus service path dbus-interface-properties "Set" 'dbus-property-handler + dont-request-name) ;; Send the PropertiesChanged signal. (when emits-signal === modified file 'src/dbusbind.c' --- src/dbusbind.c 2010-10-01 13:56:33 +0000 +++ src/dbusbind.c 2010-10-03 02:17:34 +0000 @@ -1947,7 +1947,7 @@ } 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 @@ -1961,7 +1961,7 @@ 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) + (Lisp_Object bus, Lisp_Object service, Lisp_Object path, Lisp_Object interface, Lisp_Object method, Lisp_Object handler, Lisp_Object dont_request_name) { Lisp_Object key, key1, value; DBusConnection *connection; @@ -1983,10 +1983,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 (!dont_request_name || NILP (dont_request_name)) + { + 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. */ @@ -1997,9 +2003,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)); }