commit a4c3eba64eaa1c40d222249524bca8d5ba235d56 Author: Mario Lang Date: Wed Aug 5 22:31:14 2009 +0200 Simplify (and fix) updateApplications signal emission dbind_emit_signal_va() is pretty broken. Instead of fixing it, this patch simplifies the emit() function in registry.c, eliminating the need for dbind_emit_signal_va altogether. Tested and verified that all arguments are delivered now. diff --git a/registryd/registry.c b/registryd/registry.c index 8a3d8f0..bc2efd7 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -54,13 +54,24 @@ spi_registry_init (SpiRegistry *registry) /*---------------------------------------------------------------------------*/ -static void emit(SpiRegistry *reg, const char *itf, const char *name, int ftype, ...) +static void emit(SpiRegistry *reg, const char *name, guint sigtype, const char *app) { - va_list arg; + DBusMessage *msg = NULL; + DBusError error; - va_start(arg, ftype); - dbind_emit_signal_va (reg->bus, SPI_DBUS_PATH_REGISTRY, itf, name, NULL, ftype, arg); - va_end(arg); + dbus_error_init (&error); + + if ((msg = dbus_message_new_signal (SPI_DBUS_PATH_REGISTRY, + SPI_DBUS_INTERFACE_REGISTRY, name))) { + dbus_message_append_args(msg, DBUS_TYPE_INT32, &sigtype, + DBUS_TYPE_STRING, &app, DBUS_TYPE_INVALID); + + dbus_connection_send (reg->bus, msg, NULL); + + dbus_message_unref (msg); + } + + dbus_error_free (&error); } /*---------------------------------------------------------------------------*/ @@ -124,37 +135,19 @@ seq_remove_string (GSequence *seq, gchar *str) static void add_application (DBusConnection *bus, SpiRegistry *reg, gchar *app) { - guint add = REGISTRY_APPLICATION_ADD; - if (seq_add_string (reg->apps, app)) { - emit (reg, - SPI_DBUS_INTERFACE_REGISTRY, - "updateApplications", - DBUS_TYPE_INT32, - &add, - DBUS_TYPE_STRING, - &app, - DBUS_TYPE_INVALID); + emit (reg, "updateApplications", REGISTRY_APPLICATION_ADD, app); } } static void remove_application (DBusConnection *bus, SpiRegistry *reg, gchar *app) { - guint remove = REGISTRY_APPLICATION_REMOVE; - if (seq_remove_string (reg->apps, app)) { /*TODO spi_remove_device_listeners (registry->de_controller, old);*/ - emit (reg, - SPI_DBUS_INTERFACE_REGISTRY, - "updateApplications", - DBUS_TYPE_INT32, - &remove, - DBUS_TYPE_STRING, - &app, - DBUS_TYPE_INVALID); + emit (reg, "updateApplications", REGISTRY_APPLICATION_REMOVE, app); } }