[gjs] Bug 585386: Add a flush() method to DBus bus object.
- From: C. Scott Ananian <cananian src gnome org>
- To: svn-commits-list gnome org
- Subject: [gjs] Bug 585386: Add a flush() method to DBus bus object.
- Date: Thu, 11 Jun 2009 14:48:04 -0400 (EDT)
commit f8e978b52eaa5004ca31022e2ab28cd872a73ff8
Author: C. Scott Ananian <cscott litl com>
Date: Wed Jun 10 17:30:50 2009 -0400
Bug 585386: Add a flush() method to DBus bus object.
This can be used to ensure that DBus signals have been sent before continuing.
modules/dbus.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/modules/dbus.c b/modules/dbus.c
index 63ffa31..a63e20a 100644
--- a/modules/dbus.c
+++ b/modules/dbus.c
@@ -870,6 +870,38 @@ gjs_js_dbus_emit_signal(JSContext *context,
return JS_TRUE;
}
+/* Blocks until dbus outgoing message queue is empty. This is the only way
+ * to ensure that a signal has been sent before proceeding. */
+static JSBool
+gjs_js_dbus_flush(JSContext *context,
+ JSObject *obj,
+ uintN argc,
+ jsval *argv,
+ jsval *retval)
+{
+ DBusConnection *bus_connection;
+ DBusBusType bus_type;
+
+ if (argc != 0) {
+ gjs_throw(context, "Does not take any arguments.");
+ return JS_FALSE;
+ }
+
+ if (!get_bus_type_from_object(context, obj, &bus_type))
+ return JS_FALSE;
+
+ if (!bus_check(context, bus_type))
+ return JS_FALSE;
+
+ gjs_debug(GJS_DEBUG_DBUS, "Flushing bus");
+
+ bus_connection = DBUS_CONNECTION_FROM_TYPE(bus_type);
+
+ dbus_connection_flush(bus_connection);
+
+ return JS_TRUE;
+}
+
/* Args are bus_name, object_path, iface, method, out signature, in signature, args */
static JSBool
gjs_js_dbus_call(JSContext *context,
@@ -1541,6 +1573,12 @@ define_bus_proto(JSContext *context,
goto out;
if (!JS_DefineFunction(context, bus_proto_obj,
+ "flush",
+ gjs_js_dbus_flush,
+ 0, GJS_MODULE_PROP_FLAGS))
+ goto out;
+
+ if (!JS_DefineFunction(context, bus_proto_obj,
"start_service",
gjs_js_dbus_start_service,
1, GJS_MODULE_PROP_FLAGS))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]