#include #include #include #include #include static DBusConnection *conn; 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); int ret = dbus_bus_request_name(conn, "test.server", DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (dbus_error_is_set(&err)) exit(1); for (;;) { DBusMessage *msg = dbus_message_new_signal("/test/server", "test.server.Event", "Broadcast"); if (NULL == msg) exit(1); const char *action = "some-random-id"; const char *prefix = "button"; const char *name = "lid"; /* !!!! we append only two arguments !!! */ if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &action, DBUS_TYPE_STRING, &prefix, /*DBUS_TYPE_STRING, &name,*/ DBUS_TYPE_INVALID)) exit(1); if (!dbus_connection_send(conn, msg, NULL)) exit(1); dbus_connection_flush(conn); dbus_message_unref(msg); sleep(1); } return 0; }