7 #include "test-thread.h"
9 DBusConnection *connection;
12 thread_func (gpointer data)
14 gint32 threadnr = GPOINTER_TO_INT (data);
22 message = dbus_message_new_method_call ("org.freedesktop.ThreadTest",
25 dbus_message_append_iter_init (message, &iter);
27 if (!dbus_message_iter_append_int32 (&iter, threadnr))
29 g_print ("thread %d: append threadnr failed\n", threadnr);
32 if (!dbus_message_iter_append_uint32 (&iter, counter))
34 g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
37 str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
38 if (!dbus_message_iter_append_string (&iter, str))
40 g_print ("thread %d: append string (%s) failed\n", threadnr, str);
44 if (!dbus_connection_send (connection,
48 g_print ("thread %d: send message failed\n", threadnr);
51 dbus_message_unref (message);
60 main (int argc, char *argv[])
71 g_error("Need an address as argv[1]\n");
75 dbus_error_init (&error);
76 connection = dbus_connection_open (argv[1], &error);
77 if (connection == NULL)
79 g_printerr ("could not open connection: %s\n", error.message);
80 dbus_error_free (&error);
84 dbus_connection_setup_with_g_main (connection, NULL);
86 for (i = 0; i < N_TEST_THREADS; i++)
88 g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
91 loop = g_main_loop_new (NULL, FALSE);