diff options
author | Colin Walters <walters@verbum.org> | 2005-07-11 16:12:50 +0000 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2005-07-11 16:12:50 +0000 |
commit | 622cc8af6181d7e3d839ec0bdfad376648863844 (patch) | |
tree | d1c77dc4245d50c4749fd0eff18c7dcaf6115c6c /glib/examples/example-client.c | |
parent | 8c095eea8fbe2f8c219bdb2aebcf61e4e3993f53 (diff) |
2005-07-11 Colin Walters <walters@verbum.org>
* glib/dbus-gvalue.c (struct _DBusGValue): Delete.
(dbus_g_value_types_init): Remove assertion.
(dbus_g_value_get_g_type, dbus_g_value_open)
(dbus_g_value_iterator_get_values, dbus_g_value_get_signature)
(dbus_g_value_copy, dbus_g_value_free): Delete unimplemented
functions related to DBusGValue. Now we marshal/demarshal
structures as GValueArray.
(dbus_gtype_from_signature_iter): Return G_TYPE_VALUE_ARRAY for
structures.
(signature_iter_to_g_type_array): Don't call
signature_iter_to_g_type_struct.
(signature_iter_to_g_type_struct): Delete.
(dbus_gvalue_to_signature): Delete.
(dbus_gvalue_to_signature): New function with same name as other
one; we can convert structures to signatures.
(demarshal_valuearray): New function.
(get_type_demarshaller): Use it.
(demarshal_recurse): Delete.
(marshal_proxy): New function.
(marshal_map): Warn if we can't determine signature from type.
(marshal_collection_ptrarray): Ditto.
(marshal_collection_array): Ditto.
(get_type_marshaller): Use marshal_valuearray.
(marshal_recurse): Delete.
(_dbus_gvalue_test): Add some tests.
* dbus/dbus-glib.h (struct _DBusGValueIterator):
(dbus_g_value_get_g_type, DBUS_TYPE_G_VALUE)
(dbus_g_value_open, dbus_g_value_iterator_get_value)
(dbus_g_value_iterator_get_values, dbus_g_value_iterator_recurse)
(dbus_g_value_free): Remove prototypes.
* glib/dbus-binding-tool-glib.c (dbus_g_type_get_lookup_function): Handle
G_TYPE_VALUE_ARRAY.
* glib/examples/example-service.c:
* glib/examples/example-client.c: Implement GetTuple.
* test/glib/test-dbus-glib.c:
* test/glib/test-service-glib.c:
* test/glib/test-service-glib.xml: Add structure tests.
Diffstat (limited to 'glib/examples/example-client.c')
-rw-r--r-- | glib/examples/example-client.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/glib/examples/example-client.c b/glib/examples/example-client.c index fb157a75..dac1f825 100644 --- a/glib/examples/example-client.c +++ b/glib/examples/example-client.c @@ -41,12 +41,21 @@ main (int argc, char **argv) GError *error = NULL; char **reply_list; char **reply_ptr; - DBusGValue *hello_reply_struct; + GValueArray *hello_reply_struct; GHashTable *hello_reply_dict; char *introspect_data; + guint i; g_type_init (); + { + GLogLevelFlags fatal_mask; + + fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); + fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; + g_log_set_always_fatal (fatal_mask); + } + bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (!bus) lose_gerror ("Couldn't connect to session bus", error); @@ -62,12 +71,10 @@ main (int argc, char **argv) lose_gerror ("Failed to complete HelloWorld", error); - /* FIXME - we don't support recursive values yet */ -#if 0 if (!dbus_g_proxy_call (remote_object, "GetTuple", &error, - DBUS_TYPE_G_VALUE, &hello_reply_struct, G_TYPE_INVALID)) + G_TYPE_INVALID, + G_TYPE_VALUE_ARRAY, &hello_reply_struct, G_TYPE_INVALID)) lose_gerror ("Failed to complete GetTuple", error); -#endif if (!dbus_g_proxy_call (remote_object, "GetDict", &error, G_TYPE_INVALID, @@ -80,11 +87,18 @@ main (int argc, char **argv) printf ("\n"); g_strfreev (reply_list); - /* FIXME; do something with hello_reply_struct */ -#if 0 - dbus_g_value_free (hello_reply_struct); + for (i = 0; i < hello_reply_struct->n_values; i++) + { + GValue strval = { 0, }; + + g_value_init (&strval, G_TYPE_STRING); + if (!g_value_transform (g_value_array_get_nth (hello_reply_struct, i), &strval)) + g_value_set_static_string (&strval, "(couldn't transform to string)"); + g_print ("%s: %s\n", g_type_name (G_VALUE_TYPE (g_value_array_get_nth (hello_reply_struct, i))), + g_value_get_string (&strval)); + } + g_value_array_free (hello_reply_struct); printf ("\n"); -#endif g_hash_table_foreach (hello_reply_dict, print_hash_value, NULL); g_hash_table_destroy (hello_reply_dict); |