all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jan Moringen <jan.moringen@uni-bielefeld.de>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: DBus methods without name grabbing
Date: Wed, 05 Jan 2011 05:17:28 +0100	[thread overview]
Message-ID: <26843_1294201050_ZZh0g3doKzQB1.00_1294201048.2508.1.camel@gunhead> (raw)
In-Reply-To: <87zkrhf081.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

Hi Michael.

> >> - We might introduce a new function `dbus-register-service' (in dbusbind.c).
> >>   It could offer optional argument flags, a list of the supported flags
> >>   of "org.freedesktop.DBus.RequestName"
> >>   (DBUS_NAME_FLAG_ALLOW_REPLACEMENT, DBUS_NAME_FLAG_REPLACE_EXISTING,
> >>   DBUS_NAME_FLAG_DO_NOT_QUEUE). This function shall be called in
> >>   `dbus-register-method' and `dbus-register-property' when
> >>   `dont-register-service' is nil. Btw, the function
> >>   `dbus-unregister-service' exists already ...
> >
> > I would rather tackle this change in a separate patch later.
> 
> OK, I'll do it next days (except you want to do it yourself :-)

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

Kind regards,
Jan

[-- Attachment #2: dbus-register-service.patch --]
[-- Type: text/x-patch, Size: 8026 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: jan.moringen@uni-bielefeld.de-20110105040922-\
#   vc2ma9x9190gle92
# target_branch: bzr://bzr.savannah.gnu.org/emacs/trunk/
# testament_sha1: 951371c07f78adb5726378a78265e35c8e00f263
# timestamp: 2011-01-05 05:09:46 +0100
# base_revision_id: ken.manheimer@gmail.com-20110104195021-\
#   1x68s956czngphh2
# 
# Begin patch
=== modified file 'doc/misc/dbus.texi'
--- 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
 
+@defun dbus-register-service bus service
+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
+
 @defun dbus-unregister-service bus service
 Unregister all objects from D-Bus @var{bus}, registered by Emacs for
 @var{service}.

=== modified file 'etc/NEWS'
--- etc/NEWS	2011-01-04 16:57:45 +0000
+++ etc/NEWS	2011-01-05 04:09:22 +0000
@@ -558,7 +558,9 @@
 system or session bus.
 
 *** 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
 ** Tramp
 
 *** There exists a new inline access method "ksu" (kerberized su).

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2011-01-04 11:11:43 +0000
+++ src/ChangeLog	2011-01-05 04:09:22 +0000
@@ -1,3 +1,14 @@
+2011-01-05  Jan Moringen  <jmoringe@techfak.uni-bielefeld.de>
+
+	Added function dbus-register-service in dbusbind.c
+	* dbusbind.c (Qdbus_register_service): new variable; holds
+	function dbus-register-service
+	(Fdbus_register_service): new function; register a service known
+	name on a D-Bus
+	(Fdbus_register_method): use Fdbus_register_service to register
+	the service name
+	(syms_of_dbusbind): added symbol `dbus-register-service'
+
 2011-01-04  Jan Moringen  <jan.moringen@uni-bielefeld.de>
 
 	* dbusbind.c (Fdbus_register_method): Added optional parameter

=== modified file 'src/dbusbind.c'
--- src/dbusbind.c	2011-01-04 11:11:43 +0000
+++ src/dbusbind.c	2011-01-05 04:09:22 +0000
@@ -38,6 +38,7 @@
 Lisp_Object Qdbus_method_return_internal;
 Lisp_Object Qdbus_method_error_internal;
 Lisp_Object Qdbus_send_signal;
+Lisp_Object Qdbus_register_service;
 Lisp_Object Qdbus_register_signal;
 Lisp_Object Qdbus_register_method;
 
@@ -1835,6 +1836,43 @@
   xd_in_read_queued_messages = 0;
 }
 
+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)
+{
+  DBusConnection *connection;
+  int result;
+  DBusError derror;
+
+  /* Check parameters.  */
+  CHECK_STRING (service);
+
+  /* Open a connection to the bus.  */
+  connection = xd_initialize (bus, TRUE);
+
+  /* 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);
+
+  /* Cleanup.  */
+  dbus_error_free (&derror);
+
+  /* Return object.  */
+  return Qnil;
+}
+
 DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal,
        6, MANY, 0,
        doc: /* Register for signal SIGNAL on the D-Bus BUS.
@@ -2028,18 +2066,8 @@
   /* Open a connection to the bus.  */
   connection = xd_initialize (bus, TRUE);
 
-  /* 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.  */
-  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);
-    }
+  /* Request the name.  */
+  Fdbus_register_service (bus, service);
 
   /* Create a hash table entry.  We use nil for the unique name,
      because the method might be called from anybody.  */
@@ -2091,6 +2119,10 @@
   staticpro (&Qdbus_send_signal);
   defsubr (&Sdbus_send_signal);
 
+  Qdbus_register_service = intern_c_string ("dbus-register-service");
+  staticpro (&Qdbus_register_service);
+  defsubr (&Sdbus_register_service);
+
   Qdbus_register_signal = intern_c_string ("dbus-register-signal");
   staticpro (&Qdbus_register_signal);
   defsubr (&Sdbus_register_signal);

# Begin b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T
i3xkUWCLMrBsCu7G6mkTZvMzVFyKWEoJLFtWSOZRJQPRBQuGS9hgFYKVpzLOxuPoGyOqhyOsYqN/
wiPEbwMozTmc0E7lRKaBFsSuzSlKP8HAFgZGefm9cGPzgEg0LfbqiMkyAokL5zoBT98WDTXQT3Bq
UJjuZXgKIoERUwDlRB1lI4iCCJTzObCgGvmNUsXBJrqCKRWxM+2NmpEg9TPNOMGCvKPYBQSHHKq8
c0yVtsYxSimpvpdwa0hU91hfPzam2XQfk5zzoYX8GEJIZyw3eOFEyx40mlfDVgTTDUaEr4BG1d8B
KkQKAsXD3pCVDnvqiMFdlkVSGsEVONN1OgIgEkyq08tDk06o54IJZUg/ZZDCSY8NL3UdywzuQYkx
IkTFMiKaihOk6FB6s7GJkJ8YmhGBFfWWKN8FnWaqKgwFccRoMMON6jUjPd2JaBE4IZkzCjXAU/Ll
nDaXiL+HmPIUjs7OZedQZqZgwKkwMMC19UQhIJJmZBglu5c/FMIyTE8tQluM4MF2NxkLQZJkRC6o
1dJKtEKtZCkC6whsY8zhtDQb49Lk000hpTphJzZfyMcAN6Q57akiHGIX9jorhOumweSQaE+UbpwN
yRH9GkTOViSgpwnoaqTGmGgYF+3AXGmgzsFberJKLYxdQyYyFCIhRqknEB7ShEoKNQCBVUk0ArFh
XIO0tCAwZtxJIVaUKtc1G2QYMWF/0e3Hs7lVnXcasVIitYGeYV3wFmrt42RE0sJTl1rADMyR6GVg
0h7N7v05yOAj1GYLkrkw06OKqtZo8BEu84Vb/6V+6Kk6UtQLS1ldNS9q6xhgTMEU46SMrbSA/dGs
NQjgCqVoktKWQwSreiQEHF4hyEkVPaCTrqBNUXLnXWWoTFHmzITgFhM096RaEoYzyx/4u5IpwoSE
LPS36A==

  parent reply	other threads:[~2011-01-05  4:17 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 [this message]
2011-01-05 11:45         ` Michael Albinus
2011-01-08  5:48           ` Jan Moringen
2011-01-09  9:42             ` Michael Albinus
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

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

  git send-email \
    --in-reply-to=26843_1294201050_ZZh0g3doKzQB1.00_1294201048.2508.1.camel@gunhead \
    --to=jan.moringen@uni-bielefeld.de \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.