unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jan Moringen <jan.moringen@uni-bielefeld.de>
Cc: emacs-devel@gnu.org
Subject: Re: DBus methods without name grabbing
Date: Sun, 09 Jan 2011 10:42:17 +0100	[thread overview]
Message-ID: <8739p2pg5i.fsf@gmx.de> (raw)
In-Reply-To: <3138_1294465704_ZZh0g6t4U5Dm1.00_1294465702.2322.47.camel@gunhead> (Jan Moringen's message of "Sat, 08 Jan 2011 06:48:21 +0100")

Jan Moringen <jan.moringen@uni-bielefeld.de> writes:

> Hi,

Hi Jan,

>> 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.
>
> Done.
>
>> 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.
>
> I don't see which parts of the these discussions could be shortened.

FTTB, let the changes as you have proposed. This we could tune later.

> I'm not sure about the integer constant and how they would be declared.
> I used keywords instead.

That's OK.

> --- doc/misc/ChangeLog	2011-01-04 12:38:33 +0000
> +++ doc/misc/ChangeLog	2011-01-08 05:37:49 +0000
> +2011-01-08  Jan Moringen  <jmoringe@techfak.uni-bielefeld.de>
> +
> +	* dbus.texi (Receiving Method Calls): rearranged node to mention
> +	dbus-register-service and dbus-unregister-service first
> +
>  2011-01-04  Jan Moringen  <jan.moringen@uni-bielefeld.de>

There are some conventions for ChangeLog entries: Start with capital
letter, speak in active words ("Rearrange" instead of "Rearranged"),
end with a period, etc.

Do you intend to use different email addresses?

> --- doc/misc/dbus.texi	2011-01-04 12:38:33 +0000
> +++ doc/misc/dbus.texi	2011-01-08 05:37:49 +0000
> +@defun dbus-register-service bus service &rest flags
> +Register the known name @var{service} on D-Bus @var{bus}.
> +
> +@var{bus} is either the symbol @code{:system} or the symbol
> +@code{:session}.
> +
> +@var{service} is the service name to be registered on the D-Bus.  It
> +must be a known name.
> +@end defun

A description of FLAGS is missing, also return values.

> +@defun dbus-unregister-service bus service
> +Unregister all objects from D-Bus @var{bus}, registered by Emacs for
> +@var{service}.
> +
> +@var{bus} is either the symbol @code{:system} or the symbol
> +@code{:session}.
> +
> +@var{service} is the D-Bus service name of the D-Bus.  It must be a
> +known name.  Emacs releases its association to @var{service} from
> +D-Bus.
> +@end defun

Ditto for the return values.

> --- lisp/ChangeLog	2011-01-04 19:50:21 +0000
> +++ lisp/ChangeLog	2011-01-08 05:44:07 +0000
> +2011-01-08  Jan Moringen  <jmoringe@techfak.uni-bielefeld.de>
> +
> +	* net/dbus.el (dbus-unregister-service): translate returned
> +	integer into a symbol
> +
> +	* net/dbus.el (dbus-register-property): use
> +	`dbus-register-service' to do the name registration
> +

It will be just one commit, so you can merge the entries.

> --- lisp/net/dbus.el	2011-01-04 10:57:24 +0000
> +++ lisp/net/dbus.el	2011-01-08 05:44:07 +0000
> @@ -193,9 +193,14 @@
>  	       (puthash key (delete elt value) dbus-registered-objects-table)
>  	     (remhash key dbus-registered-objects-table))))))
>     dbus-registered-objects-table)
> -  (dbus-call-method
> -   bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
> -   "ReleaseName" service))
> +  (let ((reply (dbus-call-method
> +		bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
> +		"ReleaseName" service)))
> +    (case reply
> +      (1 :released)
> +      (2 :non-existent)
> +      (3 :not-owner)
> +      (t reply))))

In case reply is not 1, 2 or 3, there is a problem. We shall raise a
dbus-error then.

> @@ -917,14 +922,18 @@
>    ;; 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 nil)
> +  (dbus-register-method
> +   bus service path dbus-interface-properties "GetAll" 
> +   'dbus-property-handler nil)
> +  (dbus-register-method
> +   bus service path dbus-interface-properties "Set" 
> +   'dbus-property-handler nil)
> +
> +  ;; Register the name SERVICE with BUS.
> +  (unless dont-register-service
> +    (dbus-register-service bus service))
 
I guess you mean t (or better 'dont-register) as last argument of the
dbus-register-method calls.

Btw, the comment can be shortened.  "We use `dbus-service-emacs' ..." is
not true anymore.

> --- src/dbusbind.c	2011-01-04 11:11:43 +0000
> +++ src/dbusbind.c	2011-01-08 05:38:56 +0000
@@ -1835,6 +1847,114 @@
> +The function returns a keyword, indicating the result of the
> +operation.  The following keyword can be returned:

"One of the following keywords is returned:"

> +    if (value == -1)
> +      xsignal0 (Qdbus_error); 
> +		//	"Unrecognized name request flag");

XD_SIGNAL2 (build_string ("Unrecognized name request flag"), args[i]);

> +  /* 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), flags, 
> +				  &derror);
> +  if (dbus_error_is_set (&derror))
> +    XD_ERROR (derror);

The second sentence of the comment is not true anymore.

> @@ -2028,18 +2149,9 @@
>    /* Open a connection to the bus.  */
>    connection = xd_initialize (bus, TRUE);
>  
> +  /* Request the name.  */
> +  if (!(NILP(dont_register_service)))
> +    Fdbus_register_service (2, args);

It must be

if (NILP (dont_register_service))

> Kind regards,
> Jan

Best regards, Michael.



  reply	other threads:[~2011-01-09  9:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-02 21:06 DBus methods without name grabbing Jan Moringen
2011-01-03 12:55 ` Michael Albinus
2011-01-04  2:42   ` Jan Moringen
2011-01-04 10:10     ` Michael Albinus
2011-01-04 10:29       ` Jan Moringen
2011-01-04 13:09         ` Michael Albinus
2011-01-05  4:17       ` Jan Moringen
2011-01-05 11:45         ` Michael Albinus
2011-01-08  5:48           ` Jan Moringen
2011-01-09  9:42             ` Michael Albinus [this message]
2011-01-09 16:08               ` Jan Moringen
2011-01-10 11:40                 ` Michael Albinus
     [not found]       ` <1294201048.2508.1.camel@gunhead>
2011-01-05 10:46         ` Jan Moringen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739p2pg5i.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=jan.moringen@uni-bielefeld.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).