dbus/test/glib test-service-glib.xml, 1.4, 1.5 test-service-glib.c,
1.12, 1.13 test-dbus-glib.c, 1.17, 1.18 my-object-marshal.list,
NONE, 1.1 Makefile.am, 1.13, 1.14 .cvsignore, 1.5, 1.6
Colin Walters
walters at freedesktop.org
Fri Jun 17 07:29:50 PDT 2005
Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv20123/test/glib
Modified Files:
test-service-glib.xml test-service-glib.c test-dbus-glib.c
Makefile.am .cvsignore
Added Files:
my-object-marshal.list
Log Message:
2005-06-17 Colin Walters <walters at verbum.org>
* glib/dbus-gproxy.c (dbus_g_proxy_emit_remote_signal): Don't
spew warnings if we get malformed remote signals.
* glib/dbus-gobject.c (propsig_iterate): New function.
(lookup_object_info): New function, extracted from
lookup_object_and_method.
(introspect_properties, introspect_signals): Delete; these
are merged into write_interface.
(write_interface): Write out signals and properties here;
dump the org.gtk.object stuff and use the interface given
in the introspection data blob. Also fix up property XML.
(lookup_values): New function.
(introspect_interfaces): Gather a mapping from interface to a
list of its methods, signals, and properties, then write out
each interface.
(lookup_object_and_method): Use lookup_object_info.
(struct DBusGSignalClosure): Add interface.
(dbus_g_signal_closure_new): Add interface. Don't dup signame;
we can just use the constant data.
(dbus_g_signal_closure_finalize): Don't free signal name.
(signal_emitter_marshaller): Use interface from signal closure.
(export_signals): Only export signals mentioned in introspection
blob.
(dbus_g_connection_register_g_object): Warn if we have no
introspection data for an object.
(funcsig_equal): Remove unused variable.
(dbus_g_object_register_marshaller): Take varargs instead of
list.
(dbus_g_object_register_marshaller_array): New function,
extracted from old dbus_g_object_register_marshaller.
* glib/dbus-binding-tool-glib.c (struct DBusBindingToolCData): Add
signals and property data.
(write_quoted_string): New function, extracted from generate_glue.
(generate_glue): Write signals and properties to introspection
blob.
* dbus/dbus-glib.h (struct DBusGObjectInfo): Include
exported_signals and exported_properties.
(dbus_g_object_register_marshaller): Update prototype.
(dbus_g_object_register_marshaller_array): Prototype.
* test/glib/test-dbus-glib.c: Extend testing to cover new signals.
* test/glib/test-service-glib.c: Add new test signals and method
to emit them.
* test/glib/test-service-glib.xml: Add some test signals.
* test/glib/Makefile.am (BUILT_SOURCES): Add my-object-marshal.c
and my-object-marshal.h
(test_service_glib_SOURCES, test_dbus_glib_SOURCES): Add
my-object-marshal.c.
(my-object-marshal.c, my-object-marshal.h): Implement.
* test/glib/.cvsignore: Update.
* doc/TODO: Remove two GLib TODO items fixed by this
patch.
Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- test-service-glib.xml 13 Jun 2005 03:01:19 -0000 1.4
+++ test-service-glib.xml 17 Jun 2005 14:29:48 -0000 1.5
@@ -84,13 +84,24 @@
<method name="EmitFrobnicate">
</method>
+ <!-- Export signals -->
+ <signal name="Frobnicate"/>
</interface>
+ <!-- Test multiple interfaces on the same object -->
+
<interface name="org.freedesktop.DBus.Tests.FooObject">
<method name="GetValue">
<arg type="u" direction="out" />
</method>
+ <method name="EmitSignals">
+ </method>
+
+ <signal name="Sig0"/>
+
+ <signal name="Sig1"/>
+
</interface>
</node>
Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- test-service-glib.c 13 Jun 2005 03:01:19 -0000 1.12
+++ test-service-glib.c 17 Jun 2005 14:29:48 -0000 1.13
@@ -10,6 +10,7 @@
#include <glib/gi18n.h>
#include <glib-object.h>
#include <glib/gquark.h>
+#include "my-object-marshal.h"
typedef struct MyObject MyObject;
typedef struct MyObjectClass MyObjectClass;
@@ -77,6 +78,8 @@
gboolean my_object_get_value (MyObject *obj, guint *ret, GError **error);
+gboolean my_object_emit_signals (MyObject *obj, GError **error);
+
gboolean my_object_emit_frobnicate (MyObject *obj, GError **error);
#include "test-service-glib-glue.h"
@@ -93,10 +96,11 @@
enum
{
FROBNICATE,
+ SIG0,
+ SIG1,
LAST_SIGNAL
};
-static void *parent_class;
static guint signals[LAST_SIGNAL] = { 0 };
static void
@@ -185,6 +189,23 @@
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
+ signals[SIG0] =
+ g_signal_new ("sig0",
+ G_OBJECT_CLASS_TYPE (mobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ my_object_marshal_VOID__STRING_INT_STRING,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
+
+ signals[SIG1] =
+ g_signal_new ("sig1",
+ G_OBJECT_CLASS_TYPE (mobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ my_object_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE);
}
GQuark
@@ -403,6 +424,21 @@
return TRUE;
}
+gboolean
+my_object_emit_signals (MyObject *obj, GError **error)
+{
+ GValue val = {0, };
+
+ g_signal_emit (obj, signals[SIG0], 0, "foo", 22, "moo");
+
+ g_value_init (&val, G_TYPE_STRING);
+ g_value_set_string (&val, "bar");
+ g_signal_emit (obj, signals[SIG1], 0, "baz", &val);
+ g_value_unset (&val);
+
+ return TRUE;
+}
+
static GMainLoop *loop;
#define TEST_SERVICE_NAME "org.freedesktop.DBus.TestSuiteGLibService"
Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- test-dbus-glib.c 13 Jun 2005 03:01:19 -0000 1.17
+++ test-dbus-glib.c 17 Jun 2005 14:29:48 -0000 1.18
@@ -7,10 +7,14 @@
#include <glib/dbus-gidl.h>
#include <glib/dbus-gparser.h>
#include <glib-object.h>
+#include "my-object-marshal.h"
static GMainLoop *loop = NULL;
static int n_times_foo_received = 0;
static int n_times_frobnicate_received = 0;
+static int n_times_sig0_received = 0;
+static int n_times_sig1_received = 0;
+static guint exit_timeout = 0;
static gboolean
timed_exit (gpointer loop)
@@ -27,6 +31,7 @@
n_times_foo_received += 1;
g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
}
static void
@@ -39,6 +44,44 @@
g_assert (val == 42);
g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
+}
+
+static void
+sig0_signal_handler (DBusGProxy *proxy,
+ const char *str0,
+ int val,
+ const char *str1,
+ void *user_data)
+{
+ n_times_sig0_received += 1;
+
+ g_assert (!strcmp (str0, "foo"));
+
+ g_assert (val == 22);
+
+ g_assert (!strcmp (str1, "moo"));
+
+ g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
+}
+
+static void
+sig1_signal_handler (DBusGProxy *proxy,
+ const char *str0,
+ GValue *value,
+ void *user_data)
+{
+ n_times_sig1_received += 1;
+
+ g_assert (!strcmp (str0, "baz"));
+
+ g_assert (G_VALUE_HOLDS_STRING (value));
+
+ g_assert (!strcmp (g_value_get_string (value), "bar"));
+
+ g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
}
static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
@@ -216,9 +259,7 @@
G_TYPE_INVALID);
dbus_g_connection_flush (connection);
-
- g_timeout_add (5000, timed_exit, loop);
-
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
g_main_loop_run (loop);
if (n_times_foo_received != 1)
@@ -643,21 +684,86 @@
dbus_g_connection_flush (connection);
-
-#if 0
- g_timeout_add (5000, timed_exit, loop);
-
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
g_main_loop_run (loop);
if (n_times_frobnicate_received != 1)
lose ("Frobnicate signal received %d times, should have been 1", n_times_frobnicate_received);
-#endif
+
+ if (!dbus_g_proxy_invoke (proxy, "EmitFrobnicate", &error,
+ G_TYPE_INVALID, G_TYPE_INVALID))
+ lose_gerror ("Failed to complete EmitFrobnicate call", error);
+
+ dbus_g_connection_flush (connection);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+
+ if (n_times_frobnicate_received != 2)
+ lose ("Frobnicate signal received %d times, should have been 2", n_times_frobnicate_received);
g_object_unref (G_OBJECT (proxy));
proxy = dbus_g_proxy_new_for_name_owner (connection,
"org.freedesktop.DBus.TestSuiteGLibService",
"/org/freedesktop/DBus/Tests/MyTestObject",
+ "org.freedesktop.DBus.Tests.FooObject",
+ &error);
+
+ if (proxy == NULL)
+ lose_gerror ("Failed to create proxy for name owner", error);
+
+ dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_INT_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID);
+
+ dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+
+ dbus_g_proxy_add_signal (proxy, "Sig0", G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE);
+
+ dbus_g_proxy_connect_signal (proxy, "Sig0",
+ G_CALLBACK (sig0_signal_handler),
+ NULL, NULL);
+ dbus_g_proxy_connect_signal (proxy, "Sig1",
+ G_CALLBACK (sig1_signal_handler),
+ NULL, NULL);
+
+ dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
+
+ dbus_g_connection_flush (connection);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+
+ if (n_times_sig0_received != 1)
+ lose ("Sig0 signal received %d times, should have been 1", n_times_sig0_received);
+ if (n_times_sig1_received != 1)
+ lose ("Sig1 signal received %d times, should have been 1", n_times_sig1_received);
+
+ dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
+ dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
+
+ dbus_g_connection_flush (connection);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+
+ if (n_times_sig0_received != 3)
+ lose ("Sig0 signal received %d times, should have been 3", n_times_sig0_received);
+ if (n_times_sig1_received != 3)
+ lose ("Sig1 signal received %d times, should have been 3", n_times_sig1_received);
+
+ g_object_unref (G_OBJECT (proxy));
+
+ proxy = dbus_g_proxy_new_for_name_owner (connection,
+ "org.freedesktop.DBus.TestSuiteGLibService",
+ "/org/freedesktop/DBus/Tests/MyTestObject",
"org.freedesktop.DBus.Introspectable",
&error);
@@ -680,7 +786,6 @@
gboolean found_properties;
gboolean found_myobject;
gboolean found_fooobject;
- gboolean found_gtk_myobject;
node = description_load_from_string (v_STRING_2, strlen (v_STRING_2), &error);
if (!node)
@@ -688,7 +793,6 @@
found_introspectable = FALSE;
found_properties = FALSE;
- found_gtk_myobject = FALSE;
found_myobject = FALSE;
found_fooobject = FALSE;
for (elt = node_info_get_interfaces (node); elt ; elt = elt->next)
@@ -699,8 +803,6 @@
found_introspectable = TRUE;
else if (!found_properties && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Properties") == 0)
found_properties = TRUE;
- else if (strcmp (interface_info_get_name (iface), "org.gtk.objects.MyObject") == 0)
- found_gtk_myobject = TRUE;
else if (!found_myobject && strcmp (interface_info_get_name (iface), "org.freedesktop.DBus.Tests.MyObject") == 0)
{
GSList *elt;
@@ -729,7 +831,7 @@
lose ("Unexpected or duplicate interface %s", interface_info_get_name (iface));
}
- if (!(found_introspectable && found_gtk_myobject && found_myobject && found_properties))
+ if (!(found_introspectable && found_myobject && found_properties))
lose ("Missing interface");
}
g_free (v_STRING_2);
--- NEW FILE: my-object-marshal.list ---
NONE:STRING,INT,STRING
NONE:STRING,BOXED
Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/Makefile.am,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Makefile.am 16 Jun 2005 04:32:50 -0000 1.13
+++ Makefile.am 17 Jun 2005 14:29:48 -0000 1.14
@@ -35,14 +35,16 @@
noinst_PROGRAMS= test-dbus-glib test-service-glib $(THREAD_APPS)
test_dbus_glib_SOURCES= \
+ my-object-marshal.c \
test-dbus-glib.c
test_dbus_glib_LDADD= $(DBUS_GLIB_TOOL_LIBS) $(top_builddir)/glib/libdbus-glib-1.la $(top_builddir)/glib/libdbus-gtool.la
-test_service_glib_SOURCES= \
- test-service-glib.c
+BUILT_SOURCES = test-service-glib-glue.h test-service-glib-bindings.h my-object-marshal.c my-object-marshal.h
-BUILT_SOURCES = test-service-glib-glue.h test-service-glib-bindings.h
+test_service_glib_SOURCES= \
+ my-object-marshal.c \
+ test-service-glib.c
test-service-glib-glue.h: test-service-glib.xml $(top_builddir)/glib/dbus-binding-tool
$(top_builddir)/glib/dbus-binding-tool --prefix=my_object --mode=glib-server --output=test-service-glib-glue.h $(srcdir)/test-service-glib.xml
@@ -50,7 +52,14 @@
test-service-glib-bindings.h: test-service-glib.xml $(top_builddir)/glib/dbus-binding-tool
$(top_builddir)/glib/dbus-binding-tool --prefix=my_object --mode=glib-client --output=test-service-glib-bindings.h $(srcdir)/test-service-glib.xml
-CLEANFILES = test-service-glib-glue.h test-service-glib-bindings.h
+my-object-marshal.c: Makefile my-object-marshal.list
+ @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header --body > my-object-marshal.c
+
+my-object-marshal.h: Makefile my-object-marshal.list
+ @GLIB_GENMARSHAL@ --prefix=my_object_marshal $(srcdir)/my-object-marshal.list --header > my-object-marshal.h
+
+
+CLEANFILES = $(BUILT_SOURCES)
test_service_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
Index: .cvsignore
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/.cvsignore,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- .cvsignore 12 Mar 2005 16:33:00 -0000 1.5
+++ .cvsignore 17 Jun 2005 14:29:48 -0000 1.6
@@ -11,3 +11,5 @@
test-service-glib-bindings.h
test-service-glib-glue.h
run-with-tmp-session-bus.conf
+my-object-marshal.h
+my-object-marshal.c
More information about the dbus-commit
mailing list