dbus/test/glib test-service-glib.xml, 1.5, 1.6 test-service-glib.c,
1.14, 1.15 test-dbus-glib.c, 1.20, 1.21
Colin Walters
walters at freedesktop.org
Mon Jun 27 11:20:23 PDT 2005
Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv3685/test/glib
Modified Files:
test-service-glib.xml test-service-glib.c test-dbus-glib.c
Log Message:
2005-06-27 Colin Walters <walters at verbum.org>
* test/glib/test-dbus-glib.c:
* test/glib/test-service-glib.c:
* test/glib/test-service-glib.xml:
Test hash table signal emitting.
* glib/dbus-gobject.c (_dbus_gobject_lookup_marshaller): Convert
types to their fundamental basis types, since this is what
marshallers operate on. Also add an entry for VOID__BOXED.
(dbus_g_object_register_marshaller_array): Convert to fundamental.
Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test-service-glib.xml 17 Jun 2005 14:29:48 -0000 1.5
+++ test-service-glib.xml 27 Jun 2005 18:20:20 -0000 1.6
@@ -102,6 +102,11 @@
<signal name="Sig1"/>
+ <method name="EmitSignal2">
+ </method>
+
+ <signal name="Sig2"/>
+
</interface>
</node>
Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- test-service-glib.c 26 Jun 2005 17:02:09 -0000 1.14
+++ test-service-glib.c 27 Jun 2005 18:20:20 -0000 1.15
@@ -79,6 +79,7 @@
gboolean my_object_get_value (MyObject *obj, guint *ret, GError **error);
gboolean my_object_emit_signals (MyObject *obj, GError **error);
+gboolean my_object_emit_signal2 (MyObject *obj, GError **error);
gboolean my_object_emit_frobnicate (MyObject *obj, GError **error);
@@ -98,6 +99,7 @@
FROBNICATE,
SIG0,
SIG1,
+ SIG2,
LAST_SIGNAL
};
@@ -206,6 +208,15 @@
NULL, NULL,
my_object_marshal_VOID__STRING_BOXED,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE);
+
+ signals[SIG2] =
+ g_signal_new ("sig2",
+ G_OBJECT_CLASS_TYPE (mobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1, DBUS_TYPE_G_STRING_STRING_HASHTABLE);
}
GQuark
@@ -438,6 +449,19 @@
return TRUE;
}
+gboolean
+my_object_emit_signal2 (MyObject *obj, GError **error)
+{
+ GHashTable *table;
+
+ table = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (table, "baz", "cow");
+ g_hash_table_insert (table, "bar", "foo");
+ g_signal_emit (obj, signals[SIG2], 0, table);
+ g_hash_table_destroy (table);
+ 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.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- test-dbus-glib.c 26 Jun 2005 17:02:09 -0000 1.20
+++ test-dbus-glib.c 27 Jun 2005 18:20:20 -0000 1.21
@@ -14,6 +14,7 @@
static int n_times_frobnicate_received = 0;
static int n_times_sig0_received = 0;
static int n_times_sig1_received = 0;
+static int n_times_sig2_received = 0;
static guint exit_timeout = 0;
static gboolean
@@ -84,6 +85,24 @@
g_source_remove (exit_timeout);
}
+static void
+sig2_signal_handler (DBusGProxy *proxy,
+ GHashTable *table,
+ void *user_data)
+{
+ n_times_sig2_received += 1;
+
+ g_assert (g_hash_table_size (table) == 2);
+
+ g_assert (g_hash_table_lookup (table, "baz") != NULL);
+ g_assert (!strcmp (g_hash_table_lookup (table, "baz"), "cow"));
+ g_assert (g_hash_table_lookup (table, "bar") != NULL);
+ g_assert (!strcmp (g_hash_table_lookup (table, "bar"), "foo"));
+
+ g_main_loop_quit (loop);
+ g_source_remove (exit_timeout);
+}
+
static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
@@ -721,7 +740,8 @@
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_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (proxy, "Sig2", DBUS_TYPE_G_STRING_STRING_HASHTABLE, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Sig0",
G_CALLBACK (sig0_signal_handler),
@@ -729,6 +749,9 @@
dbus_g_proxy_connect_signal (proxy, "Sig1",
G_CALLBACK (sig1_signal_handler),
NULL, NULL);
+ dbus_g_proxy_connect_signal (proxy, "Sig2",
+ G_CALLBACK (sig2_signal_handler),
+ NULL, NULL);
dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
@@ -743,6 +766,15 @@
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, "EmitSignal2", G_TYPE_INVALID);
+ dbus_g_connection_flush (connection);
+
+ exit_timeout = g_timeout_add (5000, timed_exit, loop);
+ g_main_loop_run (loop);
+
+ if (n_times_sig2_received != 1)
+ lose ("Sig2 signal received %d times, should have been 1", n_times_sig2_received);
+
dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
dbus_g_proxy_call_no_reply (proxy, "EmitSignals", G_TYPE_INVALID);
More information about the dbus-commit
mailing list