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 (NULL,
23 "/org/freedesktop/ThreadTest",
24 "org.freedesktop.ThreadTest",
27 dbus_message_append_iter_init (message, &iter);
29 if (!dbus_message_iter_append_int32 (&iter, threadnr))
31 g_print ("thread %d: append threadnr failed\n", threadnr);
34 if (!dbus_message_iter_append_uint32 (&iter, counter))
36 g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
39 str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
40 if (!dbus_message_iter_append_string (&iter, str))
42 g_print ("thread %d: append string (%s) failed\n", threadnr, str);
46 if (!dbus_connection_send (connection,
50 g_print ("thread %d: send message failed\n", threadnr);
53 dbus_message_unref (message);
62 main (int argc, char *argv[])
73 g_error("Need an address as argv[1]\n");
77 dbus_error_init (&error);
78 connection = dbus_connection_open (argv[1], &error);
79 if (connection == NULL)
81 g_printerr ("could not open connection: %s\n", error.message);
82 dbus_error_free (&error);
86 dbus_connection_setup_with_g_main (connection, NULL);
88 for (i = 0; i < N_TEST_THREADS; i++)
90 g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
93 loop = g_main_loop_new (NULL, FALSE);