#include #include #include #include #include int main(int argc, char** argv) { DBusError err; dbus_error_init(&err); DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, &err); if (NULL == conn) exit(1); dbus_bus_add_match(conn, "sender='test.server'", &err); dbus_connection_flush(conn); if (dbus_error_is_set(&err)) exit(1); while (true) { dbus_connection_read_write(conn, 0); DBusMessage *msg = dbus_connection_pop_message(conn); if (NULL == msg) { sleep(1); continue; } if (dbus_message_is_signal(msg, "test.server.Event", "Broadcast")) { dbus_error_init(&err); char *action, *prefix, *name; /* !!!! we try to read three arguments while the message contains only two !!! */ if (!dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &action, DBUS_TYPE_STRING, &prefix, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) fprintf(stderr, "Message parsing error: %s\n", err.message); else printf("Got Signal with value %s %s %s\n", action, prefix, name); } dbus_message_unref(msg); } return 0; }