[seed] A little more DBus module
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] A little more DBus module
- Date: Sat, 9 May 2009 01:19:07 -0400 (EDT)
commit a322be29b8dedb5cef0204f2f650a98643f3c64c
Author: Robert Carr <racarr svn gnome org>
Date: Thu May 7 23:53:29 2009 -0400
A little more DBus module
---
modules/dbus/Makefile.am | 15 ++++++++-----
modules/dbus/module.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/modules/dbus/Makefile.am b/modules/dbus/Makefile.am
index c6f47e9..6402a5f 100644
--- a/modules/dbus/Makefile.am
+++ b/modules/dbus/Makefile.am
@@ -3,16 +3,16 @@ if BUILD_DBUS_MODULE
seedlibdir = ${exec_prefix}/lib/seed
seedlib_LTLIBRARIES = \
- libdbus.la
+ libdbusnative.la
-libdbus_la_SOURCES = \
+libdbusnative_la_SOURCES = \
module.c \
util/dbus.c \
util/dbus-proxy.c \
util/dbus-signals.c
-libdbus_la_CFLAGS = \
+libdbusnative_la_CFLAGS = \
-I top_srcdir@/libseed/ \
$(GOBJECT_INTROSPECTION_CFLAGS) \
$(DBUS_CFLAGS) \
@@ -20,10 +20,13 @@ libdbus_la_CFLAGS = \
$(SEED_PROFILE_CFLAGS)
-libdbus_la_LDFLAGS = \
+libdbusnative_la_LDFLAGS = \
$(GOBJECT_INTROSPECTION_LDFLAGS) \
- $(SEED_PROFILE_LIBS) \
- $(DBUS_LDFLAGS)
+ -L/lib \
+ -ldbus-1 \
+ $(DBUS_LDFLAGS) \
+ $(SEED_PROFILE_LIBS)
+
endif
diff --git a/modules/dbus/module.c b/modules/dbus/module.c
index a01a496..ca67a51 100644
--- a/modules/dbus/module.c
+++ b/modules/dbus/module.c
@@ -6,12 +6,31 @@ SeedContext ctx;
SeedContextGroup group;
SeedObject namespace_ref;
+SeedClass dbus_namespace_class;
static gboolean session_bus_weakref_added = FALSE;
static DBusConnection *session_bus = NULL;
static gboolean system_bus_weakref_added = FALSE;
static DBusConnection *system_bus = NULL;
+SeedObject bus_proto;
+
+static SeedValue
+seed_js_dbus_get_machine_id (SeedContext ctx,
+ SeedObject object,
+ SeedString property_name,
+ SeedException *exception)
+{
+ SeedValue ret;
+ gchar *id;
+
+ id = dbus_get_local_machine_id ();
+ ret = seed_value_from_string (ctx, id, exception);
+ dbus_free (id);
+
+ return ret;
+}
+
static SeedValue
seed_js_dbus_signature_length (SeedContext ctx,
SeedObject function,
@@ -50,12 +69,39 @@ seed_js_dbus_signature_length (SeedContext ctx,
return seed_value_from_int (ctx, length, exception);
}
+seed_static_function dbus_funcs[] = {
+ {"signatureLength", seed_js_dbus_signature_length, 0},
+ {0, 0, 0}
+};
+
+seed_static_value dbus_values[] = {
+ {"localMachineID", seed_js_dbus_get_machine_id, 0, 0},
+ {0, 0, 0, 0}
+};
+
+static void
+seed_define_bus_proto (SeedContext ctx)
+{
+ bus_proto = seed_make_object (ctx, NULL, NULL);
+
+ seed_value_protect (ctx, bus_proto);
+}
+
SeedObject
seed_module_init(SeedEngine * eng)
{
+ seed_class_definition dbus_namespace_class_def = seed_empty_class;
+
ctx = eng->context;
group = eng->group;
- namespace_ref = seed_make_object (eng->context, NULL, NULL);
+
+ dbus_namespace_class_def.class_name = "dbusnative";
+ dbus_namespace_class_def.static_functions = dbus_funcs;
+ dbus_namespace_class_def.static_values = dbus_values;
+
+ dbus_namespace_class = seed_create_class (&dbus_namespace_class_def);
+
+ namespace_ref = seed_make_object (eng->context, dbus_namespace_class, NULL);
seed_object_set_property (ctx, namespace_ref, "BUS_SESSION", seed_value_from_int (ctx, DBUS_BUS_SESSION, NULL));
seed_object_set_property (ctx, namespace_ref, "BUS_SYSTEM", seed_value_from_int (ctx, DBUS_BUS_SYSTEM, NULL));
@@ -65,5 +111,7 @@ seed_module_init(SeedEngine * eng)
(SeedFunctionCallback)seed_js_dbus_signature_length,
namespace_ref);
+ seed_define_bus_proto (ctx);
+
return namespace_ref;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]