diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-03-30 16:10:52 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-04-01 11:14:27 +0100 |
commit | b5bb8f51d46aa7ea89fafcc3042d30bc4a5db018 (patch) | |
tree | 65ff542ba7ab07f12b9ea7d640f57d1331217617 | |
parent | 5421f1432ed21a198e00aa708dc00e8f032ec488 (diff) | |
download | telepathy-glib-b5bb8f51d46aa7ea89fafcc3042d30bc4a5db018.tar.gz |
dbus-tubes example: check method argument types
-rw-r--r-- | examples/client/dbus-tubes/offerer.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/examples/client/dbus-tubes/offerer.c b/examples/client/dbus-tubes/offerer.c index e5a4b2261..87ffbb9e0 100644 --- a/examples/client/dbus-tubes/offerer.c +++ b/examples/client/dbus-tubes/offerer.c @@ -37,7 +37,21 @@ handle_method_call ( GDBusMethodInvocation *invocation, gpointer user_data) { - if (!tp_strdiff (method_name, "Add")) + if (tp_strdiff (method_name, "Add")) + { + g_dbus_method_invocation_return_error (invocation, + G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, + "Unknown method '%s' on interface " EXAMPLE_INTERFACE, + method_name); + } + else if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(ii)"))) + { + g_dbus_method_invocation_return_error (invocation, + G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, + "Add takes two int32 parameters, not %s", + g_variant_get_type_string (parameters)); + } + else /* hooray! */ { guint x, y; gboolean ret; @@ -59,11 +73,6 @@ handle_method_call ( g_dbus_connection_flush_sync (connection, NULL, NULL); g_dbus_connection_close (connection, NULL, connection_closed_cb, user_data); } - else - { - /* We only have one method in our introspection XML. */ - g_return_if_reached (); - } } static void |