[seed] Implement seed_js_dbus_watch_signal



commit c00ff342a790c39e4e9ac9d303f5b8d85224cf8f
Author: Robert Carr <racarr svn gnome org>
Date:   Sat May 9 19:21:04 2009 -0400

    Implement seed_js_dbus_watch_signal
---
 modules/dbus/module.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/modules/dbus/module.c b/modules/dbus/module.c
index f65c61b..add88a6 100644
--- a/modules/dbus/module.c
+++ b/modules/dbus/module.c
@@ -593,6 +593,62 @@ signal_handler_callback(DBusConnection *connection,
     signal_handler_unref(handler); /* for safety */
 }
 
+static SeedValue
+seed_js_dbus_watch_signal (SeedContext ctx,
+			   SeedObject function,
+			   SeedObject this_object,
+			   size_t argument_count,
+			   const SeedValue arguments[],
+			   SeedException *exception)
+{
+    const char *bus_name;
+    const char *object_path;
+    const char *iface;
+    const char *signal;
+    SignalHandler *handler;
+    int id;
+    DBusBusType bus_type;
+
+    if (argument_count < 5) 
+      {
+	seed_make_exception(ctx, exception, "ArgumentError", "Not enough args, need bus name, object path, interface, signal and callback");
+	return seed_make_null (ctx);
+      }
+
+    if (!seed_value_is_object (ctx, arguments[4]) || !seed_value_is_function (ctx, arguments[4]))
+      {
+	seed_make_exception(ctx, exception, "ArgumentError", "arg 5 must be a callback to invoke when call completes");
+	return seed_make_null (ctx);
+      }
+
+    fill_with_null_or_string(ctx, &bus_name, arguments[0], exception);
+    fill_with_null_or_string(ctx, &object_path, arguments[1], exception);
+    fill_with_null_or_string(ctx, &iface, arguments[2], exception);
+    fill_with_null_or_string(ctx, &signal, arguments[3], exception);
+
+    bus_type = get_bus_type_from_object (ctx, this_object, exception);
+
+    handler = signal_handler_new(ctx, arguments[4], exception);
+    if (handler == NULL)
+      return seed_make_null (ctx);
+
+    id = big_dbus_watch_signal(bus_type,
+                               bus_name,
+                               object_path,
+                               iface,
+                               signal,
+                               signal_handler_callback,
+                               handler,
+                               signal_on_watch_removed);
+    handler->bus_type = bus_type;
+    handler->connection_id = id;
+
+    /* signal_on_watch_removed() takes ownership of our
+     * ref to the SignalHandler
+     */
+
+    return seed_value_from_int (ctx, id, exception);
+}
 
 static SeedValue
 seed_js_dbus_signature_length (SeedContext ctx,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]