unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* DBus binding & direct connections (p2p)?
@ 2017-07-27 12:07 Nicolas Petton
  2017-07-28  7:35 ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-27 12:07 UTC (permalink / raw)
  To: Emacs Devel

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

Hi,

I was wondering if the Emacs binding for DBus handles peer to peer
connections between two applications without a bus daemon?

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-27 12:07 DBus binding & direct connections (p2p)? Nicolas Petton
@ 2017-07-28  7:35 ` Michael Albinus
  2017-07-28  8:28   ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-28  7:35 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

> Hi,

Hi Nicolas,

> I was wondering if the Emacs binding for DBus handles peer to peer
> connections between two applications without a bus daemon?

There does not exist such an interface in the D-Bus specification. The
standard interface org.freedesktop.DBus.Peer offers the methods Ping and
GetMachineId, which are something different. See
<https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-peer>.

The Java D-Bus bindings offer the interface
org.freedesktop.dbus.DirectConnection, which "Handles a peer to peer
connection between two applications withou a bus daemon.". See
<https://dbus.freedesktop.org/doc/dbus-java/api/org/freedesktop/dbus/DirectConnection.html>. Likely
this is what you've asked for; it isn't implemented in the Emacs bindings.

> Cheers,
> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28  7:35 ` Michael Albinus
@ 2017-07-28  8:28   ` Nicolas Petton
  2017-07-28  9:15     ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-28  8:28 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Michael,

> The Java D-Bus bindings offer the interface
> org.freedesktop.dbus.DirectConnection, which "Handles a peer to peer
> connection between two applications withou a bus daemon.". See
> <https://dbus.freedesktop.org/doc/dbus-java/api/org/freedesktop/dbus/DirectConnection.html>. Likely
> this is what you've asked for; it isn't implemented in the Emacs
> bindings.

That's exactly what I meant.  Some applications communicate through
dbus, using peer-to-peer communications, without using a bus.

The Python binding allows for direct connections to be open like the
following (TCP in this example):

    import dbus;
    conn = dbus.connection.Connection("tcp:host=localhost,port=1234")

I think that calling `dbus_connection_open' with a dbus address would be
enough to support direct connections in the Emacs binding (but I might
be wrong).

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28  8:28   ` Nicolas Petton
@ 2017-07-28  9:15     ` Michael Albinus
  2017-07-28 10:03       ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-28  9:15 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

> Hi Michael,

Hi Nicolas,

> That's exactly what I meant.  Some applications communicate through
> dbus, using peer-to-peer communications, without using a bus.
>
> The Python binding allows for direct connections to be open like the
> following (TCP in this example):
>
>     import dbus;
>     conn = dbus.connection.Connection("tcp:host=localhost,port=1234")
>
> I think that calling `dbus_connection_open' with a dbus address would be
> enough to support direct connections in the Emacs binding (but I might
> be wrong).

I've never tried it peer-to-peer, but there is `dbus-init-bus'. If you
don't use `:system' or `:session' as BUS argument but a string address
as shown by you, it calls `dbus_connection_open' with that address. If
you provide a non-nil PRIVATE argument, it calls
`dbus_connection_open_private' instead. Play with this :-)

> Cheers,
> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28  9:15     ` Michael Albinus
@ 2017-07-28 10:03       ` Nicolas Petton
  2017-07-28 10:10         ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-28 10:03 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Michael,

> I've never tried it peer-to-peer, but there is `dbus-init-bus'. If you
> don't use `:system' or `:session' as BUS argument but a string address
> as shown by you, it calls `dbus_connection_open' with that address. If
> you provide a non-nil PRIVATE argument, it calls
> `dbus_connection_open_private' instead. Play with this :-)

I tried this already, but I get:

  D-Bus error: "No such interface 'org.freedesktop.DBus' on object at path
  /org/freedesktop/DBus"

Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 10:03       ` Nicolas Petton
@ 2017-07-28 10:10         ` Nicolas Petton
  2017-07-28 11:21           ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-28 10:10 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Nicolas Petton <nicolas@petton.fr> writes:

> I tried this already, but I get:
>
>   D-Bus error: "No such interface 'org.freedesktop.DBus' on object at path
>   /org/freedesktop/DBus"

My guess is that dbusbind.c tries to register to a bus, but there is no bus:

  if (STRINGP (bus))
    dbus_bus_register (connection, &derror);

Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 10:10         ` Nicolas Petton
@ 2017-07-28 11:21           ` Michael Albinus
  2017-07-28 11:26             ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-28 11:21 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

> Nicolas Petton <nicolas@petton.fr> writes:
>
>> I tried this already, but I get:
>>
>>   D-Bus error: "No such interface 'org.freedesktop.DBus' on object at path
>>   /org/freedesktop/DBus"
>
> My guess is that dbusbind.c tries to register to a bus, but there is no bus:
>
>   if (STRINGP (bus))
>     dbus_bus_register (connection, &derror);

Yes, `dbus-init-bus' is intended for that purpose ...

Implementing something like Java's org.freedesktop.dbus.DirectConnection
seems to be expensive, so I fear we haven't anything in Emacs which
could be used w/o a bus.

> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 11:21           ` Michael Albinus
@ 2017-07-28 11:26             ` Nicolas Petton
  2017-07-28 11:33               ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-28 11:26 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

> Yes, `dbus-init-bus' is intended for that purpose ...
>
> Implementing something like Java's org.freedesktop.dbus.DirectConnection
> seems to be expensive, so I fear we haven't anything in Emacs which
> could be used w/o a bus.

I don't understand, why it would be expensive?

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 11:26             ` Nicolas Petton
@ 2017-07-28 11:33               ` Michael Albinus
  2017-07-28 11:36                 ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-28 11:33 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

>> Implementing something like Java's org.freedesktop.dbus.DirectConnection
>> seems to be expensive, so I fear we haven't anything in Emacs which
>> could be used w/o a bus.
>
> I don't understand, why it would be expensive?

It must be in C, I suppose. And while listening, it must implement
something a bus (daemon) is supposed to handle.

Just from roughly reading that Java implementation. But I might be
wrong. You could try to implement yourself, of course.

> Cheers,
> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 11:33               ` Michael Albinus
@ 2017-07-28 11:36                 ` Nicolas Petton
  2017-07-28 11:47                   ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-28 11:36 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

> Just from roughly reading that Java implementation. But I might be
> wrong. You could try to implement yourself, of course.

Yes, I'll give it a shot.  I'll start by looking at the existing usages
in C of direct DBus communications.

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 11:36                 ` Nicolas Petton
@ 2017-07-28 11:47                   ` Michael Albinus
  2017-07-31  8:52                     ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-28 11:47 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

> Yes, I'll give it a shot.  I'll start by looking at the existing usages
> in C of direct DBus communications.

Could you send me a pointer?

> Cheers,
> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-28 11:47                   ` Michael Albinus
@ 2017-07-31  8:52                     ` Nicolas Petton
  2017-07-31 14:29                       ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Nicolas Petton @ 2017-07-31  8:52 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

>> Yes, I'll give it a shot.  I'll start by looking at the existing usages
>> in C of direct DBus communications.
>
> Could you send me a pointer?

Sure.  One thing I'm interested in is connecting Indium with
WebKitGTK+.  The remote inspector server starts a p2p dbus connection,
and the client connects to it, see:

https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/glib/RemoteInspectorClient.cpp#L160

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-31  8:52                     ` Nicolas Petton
@ 2017-07-31 14:29                       ` Michael Albinus
  2017-07-31 19:12                         ` Nicolas Petton
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2017-07-31 14:29 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: Emacs Devel

Nicolas Petton <nicolas@petton.fr> writes:

> Michael Albinus <michael.albinus@gmx.de> writes:
>
>>> Yes, I'll give it a shot.  I'll start by looking at the existing usages
>>> in C of direct DBus communications.
>>
>> Could you send me a pointer?
>
> Sure.  One thing I'm interested in is connecting Indium with
> WebKitGTK+.  The remote inspector server starts a p2p dbus connection,
> and the client connects to it, see:
>
> https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/glib/RemoteInspectorClient.cpp#L160

Well, this is g_dbus_connection_new_for_address, see
<https://developer.gnome.org/gio/stable/GDBusConnection.html#g-dbus-connection-new-for-address>.

The gio implementation of D-Bus offers functions, which are not
available in libdbus-1.so, the reference implementation we use in Emacs.

> Cheers,
> Nico

Best regards, Michael.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DBus binding & direct connections (p2p)?
  2017-07-31 14:29                       ` Michael Albinus
@ 2017-07-31 19:12                         ` Nicolas Petton
  0 siblings, 0 replies; 14+ messages in thread
From: Nicolas Petton @ 2017-07-31 19:12 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs Devel

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

Michael Albinus <michael.albinus@gmx.de> writes:

>> https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/glib/RemoteInspectorClient.cpp#L160
>
> Well, this is g_dbus_connection_new_for_address, see
> <https://developer.gnome.org/gio/stable/GDBusConnection.html#g-dbus-connection-new-for-address>.

Yes, I saw that.

> The gio implementation of D-Bus offers functions, which are not
> available in libdbus-1.so, the reference implementation we use in
> Emacs.

Ok, thanks.  I wasn't aware that the gio implementation was something
different entirely, I thought it was just wrapping libdbus.

Then I'll have to check what the Python binding is using, because the
following works just fine in Python 3:

  import dbus

  connection = dbus.connection.Connection("tcp:host=localhost,port=1234")
  res = c.call_blocking(None, "/org/webkit/Inspector", "org.webkit.Inspector", "SetupInspectorClient", "ay", [dbus.ByteArray()])
  str = "".join(chr(byte) for byte in res)

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-07-31 19:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-27 12:07 DBus binding & direct connections (p2p)? Nicolas Petton
2017-07-28  7:35 ` Michael Albinus
2017-07-28  8:28   ` Nicolas Petton
2017-07-28  9:15     ` Michael Albinus
2017-07-28 10:03       ` Nicolas Petton
2017-07-28 10:10         ` Nicolas Petton
2017-07-28 11:21           ` Michael Albinus
2017-07-28 11:26             ` Nicolas Petton
2017-07-28 11:33               ` Michael Albinus
2017-07-28 11:36                 ` Nicolas Petton
2017-07-28 11:47                   ` Michael Albinus
2017-07-31  8:52                     ` Nicolas Petton
2017-07-31 14:29                       ` Michael Albinus
2017-07-31 19:12                         ` Nicolas Petton

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).