taoso / btk

虚拟蓝牙键盘(BlueTooth Keyboard)
MIT License
273 stars 42 forks source link

Move from dbus-python (libdbus w/ known problems) to pydbus (GDBus built into GLib since 2010) #10

Closed hh closed 8 years ago

hh commented 8 years ago

I've been having trouble on newer systems getting dbus-python up and running due to it's dependencies not being available on newer systems. It looks like it may not be the best option, and is slowly losing support.

pydbus provides us some better integration with systemd prevalent on newer systems (most of the off-the-shelf embedded world / raspi, beaglebone etc).

From http://cgit.freedesktop.org/dbus/dbus-python/tree/README#n36 :

Problems and alternatives
=========================

dbus-python might not be the best D-Bus binding for you to use. dbus-python
does not follow the principle of "In the face of ambiguity, refuse the
temptation to guess", and can't be changed to not do so without seriously
breaking compatibility.

In addition, it uses libdbus (which has known problems with multi-threaded
use) and attempts to be main-loop-agnostic (which means you have to select
a suitable main loop for your application).

Alternative underlying lib http://www.freedesktop.org/wiki/Software/DBusBindings/ :

Since version 2.26, GLib includes a D-Bus binding.
This replaces the DBus-GLib bindings and
many applications have started migrating their code. 

https://developer.gnome.org/gio/2.26/gdbus-convenience.html https://developer.gnome.org/gio/2.26/gdbus-lowlevel.html

Decent looking Python binding: https://github.com/LEW21/pydbus

taoso commented 8 years ago

:+1:

ai0 commented 8 years ago

taoso commented 8 years ago

The example given by pydbus is too simple to reference.

taoso commented 8 years ago

@hh After struggling to look up Gio doc at https://developer.gnome.org/gio/stable/gdbus-lowlevel.html and https://developer.gnome.org/gio/stable/gdbus-convenience.html, I build a simple DBus server at https://github.com/lvht/hello-dbus/blob/master/foo.py, without python-dbus

And the foo.py should be a good start to replace the python-dbus lib.

taoso commented 8 years ago

@hh I have made a try to replace python-dbus with gi.repository at c4feb2ab959b367944c80a7fb44a954443133f4b, but still not worked. FYI.

taoso commented 8 years ago

@hh maybe the pydbus is not a must :smiling_imp:

hh commented 8 years ago

Nice!

hh commented 8 years ago

:+1: