开发者

D-Bus GLib bindings—unable to get code off the ground

I've been playing with GLib's D-Bus bindings, trying to get something (anything) working, with very limited success. I've been trying to get Ross Burton's example code to compile and run, but keep hitting new and exciting difficulties.

Can you help debug this code, or failing that, point me at some example of D-Bus GLib code that does work?

Since Ross' code is out-of-date, I've replaced the line

dbus_g_object_class_install_info (G_OBJECT_CLASS (echo_class), &dbus_glib_echo_object_info);

with

dbus_g_object_type_install_info (G_OBJECT_TYPE (echo_class), &dbus_glib_echo_object_info);

per his comments on that article, but made no other changes other than to update the include directories to match the setup on my box.

When running the server executable, though, I get the following error:

** (process:11747): C开发者_运维问答RITICAL **: dbus_g_object_type_install_info: assertion `G_TYPE_IS_CLASSED (object_type) || G_TYPE_IS_INTERFACE (object_type)' failed

The stack trace at this point, according to gdb, is

#0  0x0000003b5f40b440 in dbus_g_object_type_install_info () from /usr/lib64/libdbus-glib-1.so.2
#1  0x0000003b5722909c in g_type_class_ref () from /lib64/libgobject-2.0.so.0
#2  0x0000003b57229798 in g_type_create_instance () from /lib64/libgobject-2.0.so.0
#3  0x0000000000400f16 in main (argc=<value optimized out>, argv=0x7fff156497d8) at EchoObject.c:111

I'm not sure what's going wrong, or what the next steps should be in debugging. I'd like to get some basic code sending and receiving D-Bus method call messages, so I can see how things should work to use in my application.

I'm using D-Bus 0.73.

Update: Given the lack of success on my part, and the lack of response here, I'm currently looking at abandoning D-Bus and finding some other IPC mechanism.

Update 2: In the end, I went with a Unix named sockets approach, which is doing exactly what I need it to do in a total of 280 lines of code (plus test code).


In the following line

dbus_g_object_type_install_info (G_OBJECT_TYPE (echo_class), &dbus_glib_echo_object_info);

you need to use the G_OBJECT_CLASS_TYPE() macro instead of G_OBJECT_TYPE().

This is because echo_class is an instance of EchoClass, which is a "class structure" in the GObject world. The G_OBJECT_TYPE() is for "object structures", which would be the Echo structure in the aforementioned example.

I know this answer is way to late for @me_and, but maybe someone else will find it useful.


dbus-glib is pretty ... nasty to use, and it's basically unmaintained at this point. You're probably better off using its upcoming replacement, GDBus, which will be included in the next stable GLib release. Check out the Lowlevel D-Bus support and Highlevel D-Bus support sections of the documentation for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜