2 * Based on examples from "Connect desktop apps using D-BUS -- Helping
3 * applications talk to one another", developerWorks 27 Jul 2004,
6 #define DBUS_API_SUBJECT_TO_CHANGE
7 #include <proto/dbus.h>
9 #include <proto/exec.h>
13 #include "dbus-amiga.h"
15 struct Library
* DBUSBase
;
18 static void send_ping(DBusConnection
*bus
);
23 DBUSBase
= OpenLibrary("dbus.library", 1);
25 if (DBUSBase
!= NULL
) {
27 CloseLibrary(DBUSBase
);
31 fprintf (stderr
, "Unable to open dbus.library version 1\n");
42 /* Get a connection to the session bus */
43 dbus_error_init (&error
);
44 bus
= dbus_bus_get (DBUS_BUS_SESSION
, &error
);
47 fprintf(stderr
, "Failed to connect to the D-BUS daemon: %s", error
.message
);
48 dbus_error_free(&error
);
52 /* Set up this connection to work in an Amiga thread */
53 if (dbus_a_setup_connection(bus
)) {
54 while ((SetSignal(0, 0) & SIGBREAKF_CTRL_C
) == 0) {
58 dbus_a_cleanup_connection(bus
);
61 dbus_error_free(&error
);
65 static void send_ping(DBusConnection
*bus
)
69 /* Create a new signal "Ping" on the "com.burtonini.dbus.Signal" interface,
70 * from the object "/com/burtonini/dbus/ping". */
71 message
= dbus_message_new_signal ("/com/burtonini/dbus/ping",
72 "com.burtonini.dbus.Signal", "Ping");
73 /* Append the string "Ping!" to the signal */
74 dbus_message_append_args (message
,
75 DBUS_TYPE_STRING
, "Ping!",
78 dbus_connection_send (bus
, message
, NULL
);
79 /* Free the signal now we have finished with it */
80 dbus_message_unref (message
);
81 /* Tell the user we send a signal */