dbus/glib/test-thread-client.c
Alexander Larsson c5020ac870 2003-04-08 Alexander Larsson <alexl@redhat.com>
Implemented recursive types, named types and new-style iters

	* bus/driver.c:
	* glib/test-thread-client.c: (thread_func):
	* glib/test-thread-server.c: (handle_test_message):
	* test/test-service.c: (handle_echo):
	Update to new api

	* dbus/Makefile.am:
	* dbus/dbus-dict.c:
	* dbus/dbus-dict.h:
	* dbus/dbus.h
	Remove DBusDict

	* dbus/dbus-internals.c: (_dbus_type_to_string):
	Update for new types.

	* dbus/dbus-marshal.[ch]:
	Implement recursive types and the new marshalling format.
	Remove hardcoded dict marshalling.
	Marshal named types.

	* dbus/dbus-message-builder.c:
	Add BYTE_ARRAY.
	Remove references to old types

	* dbus/dbus-message.[ch]:
	New non-refcounted iter API that supports recursive iters.
	Use iters for appending, including support for recursive
	iters.
	Add byte and named type support.
	Update everything to new marshalling formats.
	Add tests for new API.

	* dbus/dbus-protocol.h:
	Remove old array types.
	Add types: BYTE, ARRAY, DICT, NAMED

	* dbus/dbus-string.c:
	* dbus/dbus-sysdeps.c:
	Make parse_double locale safe.

	* dbus/dbus-test-main.c:
	Call setlocale.

	* dbus/dbus-test.c:
	Kill dict test

	* doc/dbus-specification.sgml:
	Update spec

	* test/data/incomplete-messages/missing-body.message:
	* test/data/invalid-messages/bad-boolean.message:
	* test/data/invalid-messages/bad-boolean-array.message:
	* test/data/invalid-messages/boolean-array-length-too-long.message-raw:
	* test/data/invalid-messages/boolean-has-no-value.message-raw:
	* test/data/invalid-messages/too-short-dict.message:
	* test/data/valid-messages/dict-simple.message:
	* test/data/valid-messages/dict.message:
	* test/data/valid-messages/emptiness.message:
	* test/data/valid-messages/lots-of-arguments.message:
	* test/data/valid-messages/no-padding.message:
	* test/data/valid-messages/recursive-types.message:
	Add missing NAME fields
	Fix up dicts & arrays

	* test/data/invalid-messages/dict-with-nil-value.message:
	Removed, this is not invalid anymore.

	* test/data/valid-messages/recursive-types.message:
	Add new test for deeply recursive types.
2003-04-08 15:52:51 +00:00

95 lines
1.9 KiB
C

#include <glib.h>
#include "dbus-glib.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "test-thread.h"
DBusConnection *connection;
static gpointer
thread_func (gpointer data)
{
gint32 threadnr = GPOINTER_TO_INT (data);
guint32 counter = 0;
DBusMessageIter iter;
DBusMessage *message;
char *str;
while (1)
{
message = dbus_message_new (NULL, "org.freedesktop.ThreadTest");
dbus_message_append_iter_init (message, &iter);
if (!dbus_message_iter_append_int32 (&iter, threadnr))
{
g_print ("thread %d: append threadnr failed\n", threadnr);
}
if (!dbus_message_iter_append_uint32 (&iter, counter))
{
g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
}
str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
if (!dbus_message_iter_append_string (&iter, str))
{
g_print ("thread %d: append string (%s) failed\n", threadnr, str);
}
g_free (str);
if (!dbus_connection_send (connection,
message,
NULL))
{
g_print ("thread %d: send message failed\n", threadnr);
}
dbus_message_unref (message);
counter ++;
}
return NULL;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
DBusError error;
int i;
g_thread_init (NULL);
dbus_gthread_init ();
if(argc < 2)
{
g_error("Need an address as argv[1]\n");
return 1;
}
dbus_error_init (&error);
connection = dbus_connection_open (argv[1], &error);
if (connection == NULL)
{
g_printerr ("could not open connection: %s\n", error.message);
dbus_error_free (&error);
return 1;
}
dbus_connection_setup_with_g_main (connection);
for (i = 0; i < N_TEST_THREADS; i++)
{
g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
}
loop = g_main_loop_new (NULL, FALSE);
g_main_run (loop);
return 0;
}