[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DBus methods without name grabbing

From: Michael Albinus
Subject: Re: DBus methods without name grabbing
Date: Wed, 05 Jan 2011 12:45:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Jan Moringen <address@hidden> writes:

> Hi Michael.

Hi Jan,

> I gave it a shot. See attached patch. Like the last patch, this probably
> needs revision.


> --- doc/misc/dbus.texi        2011-01-04 12:38:33 +0000
> +++ doc/misc/dbus.texi        2011-01-05 04:09:22 +0000
> @@ -1491,6 +1491,16 @@
>  to the service from D-Bus.
>  @end defun
> address@hidden dbus-register-service bus service
> +Register the known name @var{service} on D-Bus @var{bus}.
> +
> address@hidden is either the symbol @code{:system} or the symbol
> address@hidden:session}.
> +
> address@hidden is the service name to be registered on the D-Bus.  It
> +must be a known name.
> address@hidden defun
> +
>  @defun dbus-unregister-service bus service
>  Unregister all objects from D-Bus @var{bus}, registered by Emacs for
>  @var{service}.

Maybe we shall rearrange the whole node a little bit. In the
introductionary paragraph, service names could be described more
detailed, especially their registration policies. Afterwards,
dbus-register-service shall follow.

The explanation of dont-register-service in dbus-register-method and
dbus-register-property could be shortened, referring to the explanation
in dbus-register-service.

> --- etc/NEWS  2011-01-04 16:57:45 +0000
> +++ etc/NEWS  2011-01-05 04:09:22 +0000
> @@ -558,7 +558,9 @@
>  *** dbus-register-{method,property} do not necessarily register names 
> anymore.
> -
> +*** New function dbus-register-service
> +    Register a service known name on a D-Bus without simultaneously
> +    registering a property or a method

I guess we could join both entries.

> --- src/dbusbind.c    2011-01-04 11:11:43 +0000
> +++ src/dbusbind.c    2011-01-05 04:09:22 +0000
> +DEFUN ("dbus-register-service", Fdbus_register_service, 
> Sdbus_register_service,
> +       2, 2, 0,
> +       doc: /* Register known name SERVICE 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 that should be registered.  It must
> +be a known name.
> +
> +Return nil.*/)
> +  (Lisp_Object bus, Lisp_Object service)

Your implementation looks OK to me. However, I have a more general
function in mind. Something like this:

--8<---------------cut here---------------start------------->8---
DEFUN ("dbus-register-service", Fdbus_register_service, Sdbus_register_service,
       2, MANY, 0, doc: /* Register known name SERVICE 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 that should be registered.

FLAGS are integers, which control how the service name is registered.
The following integer constants could be used:

`dbus-service-allow-replacement': Allow another service to become the
primary owner if requested.

`dbus-service-replace-existing': Request to replace the current
primary owner.

`dbus-service-do-not-queue': If we can not become the primary owner do
not place us in the queue.

The function returns an integer, indicating the result of the
operation.  There are predefined constants to check:

`dbus-service-primary-owner': Service has become the primary owner of
the requested name.

`dbus-service-in-queue': Service could not become the primary owner
and has been placed in the queue.

`dbus-service-exists': Service is already in the queue.

`dbus-service-already-owner': Service is already the primary owner.


\(dbus-register-service :session dbus-service-emacs)

  => 1 ;; This is `dbus-service-primary-owner'.

  :session "org.freedesktop.TextEditor"
  dbus-service-allow-replacement dbus-service-replace-existing)

  => 4 ;; This is `dbus-service-already-owner'.

usage: (dbus-register-service BUS SERVICE &rest FLAGS)  */)
  (int nargs, register Lisp_Object *args)
--8<---------------cut here---------------end--------------->8---

The constants shall be declared as well, for initialization you could
use DBUS_NAME_FLAG* and DBUS_REQUEST_NAME_REPLY* from dbus-shared.h.

And while we are at this, maybe dbus-unregister-service could also
return a similar result, based on DBUS_RELEASE_NAME_REPLY*.

> @@ -2028,18 +2066,8 @@
> +  /* Request the name.  */
> +  Fdbus_register_service (bus, service);

As you have said the other message, the check for dont-register-service
is missing.

Furthermore, I would also propose to use dbus-register-service in
dbus-register-property (in dbus.el).

> Kind regards,
> Jan

Best regards, Michael.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]