From 8e1a42043352c5a3a0d8d3681cdfd328b036761f Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 6 May 2010 10:16:36 -0400 Subject: Nuke redundant signatures from introspection data + fixup error returns Make g_dbus_message_new_method_error() be a varadic function and also provide _valist() and _literal() variants. Use the varadic function to provide more detail when generating errors. --- docs/reference/gdbus/gdbus-standalone-sections.txt | 10 ++-- gdbus/gdbusconnection.c | 65 ++++++++++++++-------- gdbus/gdbusintrospection.c | 23 -------- gdbus/gdbusintrospection.h | 6 -- gdbus/gdbusmessage.c | 65 +++++++++++++++++++++- gdbus/gdbusmessage.h | 10 +++- gdbus/gdbusmethodinvocation.c | 40 +++++-------- gdbus/gdbusprivate.c | 24 ++++++++ gdbus/gdbusprivate.h | 3 + gdbus/gdbusproxy.c | 29 ++++++---- gdbus/tests/export.c | 34 +++++------ gdbus/tests/introspection.c | 11 +++- 12 files changed, 203 insertions(+), 117 deletions(-) diff --git a/docs/reference/gdbus/gdbus-standalone-sections.txt b/docs/reference/gdbus/gdbus-standalone-sections.txt index 09fd542..1443065 100644 --- a/docs/reference/gdbus/gdbus-standalone-sections.txt +++ b/docs/reference/gdbus/gdbus-standalone-sections.txt @@ -32,19 +32,15 @@ g_credentials_to_string g_credentials_has_unix_user g_credentials_get_unix_user g_credentials_set_unix_user -g_credentials_unset_unix_user g_credentials_has_unix_group g_credentials_get_unix_group g_credentials_set_unix_group -g_credentials_unset_unix_group g_credentials_has_unix_process g_credentials_get_unix_process g_credentials_set_unix_process -g_credentials_unset_unix_process g_credentials_has_windows_user g_credentials_get_windows_user g_credentials_set_windows_user -g_credentials_unset_windows_user G_CREDENTIALS G_IS_CREDENTIALS @@ -125,10 +121,12 @@ GDBusMessageHeaderField GDBusMessage GDBusMessageClass g_dbus_message_new +g_dbus_message_new_signal g_dbus_message_new_method_call -g_dbus_message_new_method_error g_dbus_message_new_method_reply -g_dbus_message_new_signal +g_dbus_message_new_method_error +g_dbus_message_new_method_error_valist +g_dbus_message_new_method_error_literal g_dbus_message_print g_dbus_message_get_type g_dbus_message_set_type diff --git a/gdbus/gdbusconnection.c b/gdbus/gdbusconnection.c index 9f625db..dfb2745 100644 --- a/gdbus/gdbusconnection.c +++ b/gdbus/gdbusconnection.c @@ -2966,9 +2966,9 @@ invoke_get_property_in_idle_cb (gpointer _data) g_assert (error != NULL); dbus_error_name = g_dbus_error_encode_gerror (error); - reply = g_dbus_message_new_method_error (data->message, - dbus_error_name, - error->message); + reply = g_dbus_message_new_method_error_literal (data->message, + dbus_error_name, + error->message); g_dbus_connection_send_message (data->connection, reply, NULL, NULL); g_free (dbus_error_name); g_error_free (error); @@ -3003,7 +3003,10 @@ invoke_set_property_in_idle_cb (gpointer _data) { reply = g_dbus_message_new_method_error (data->message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Type of property to set is incorrect")); + _("Error setting property `%s': Expected type `%s' but got `%s'"), + data->property_info->name, + data->property_info->signature, + g_variant_get_type_string (value)); goto out; } @@ -3019,9 +3022,9 @@ invoke_set_property_in_idle_cb (gpointer _data) gchar *dbus_error_name; g_assert (error != NULL); dbus_error_name = g_dbus_error_encode_gerror (error); - reply = g_dbus_message_new_method_error (data->message, - dbus_error_name, - error->message); + reply = g_dbus_message_new_method_error_literal (data->message, + dbus_error_name, + error->message); g_free (dbus_error_name); g_error_free (error); } @@ -3092,7 +3095,8 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such property")); + _("No such property `%s'"), + property_name); g_dbus_connection_send_message_unlocked (connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3103,7 +3107,8 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Property is not readable")); + _("Property `%s' is not readable"), + property_name); g_dbus_connection_send_message_unlocked (connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3113,7 +3118,8 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Property is not writable")); + _("Property `%s' is not writable"), + property_name); g_dbus_connection_send_message_unlocked (connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3180,7 +3186,8 @@ handle_getset_property (GDBusConnection *connection, GDBusMessage *reply; reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such interface")); + _("No such interface `%s'"), + interface_name); g_dbus_connection_send_message_unlocked (eo->connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3349,7 +3356,8 @@ handle_get_all_properties (GDBusConnection *connection, GDBusMessage *reply; reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such interface")); + _("No such interface"), + interface_name); g_dbus_connection_send_message_unlocked (eo->connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3581,6 +3589,7 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection, GVariant *parameters; GSource *idle_source; gboolean handled; + gchar *in_signature; handled = FALSE; @@ -3594,7 +3603,8 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection, { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.UnknownMethod", - _("No such method")); + _("No such method `%s'"), + g_dbus_message_get_member (message)); g_dbus_connection_send_message_unlocked (connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -3603,17 +3613,24 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection, /* Check that the incoming args are of the right type - if they are not, return * the org.freedesktop.DBus.Error.InvalidArgs error to the caller + * + * TODO: might also be worth caching the combined signature. */ - if (g_strcmp0 (g_dbus_message_get_signature (message), method_info->in_signature) != 0) + in_signature = _g_dbus_compute_complete_signature (method_info->in_args, FALSE); + if (g_strcmp0 (g_dbus_message_get_signature (message), in_signature) != 0) { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Signature of message does not match what is expected")); + _("Signature of message, `%s', does not match expected signature `%s'"), + g_dbus_message_get_signature (message), + in_signature); g_dbus_connection_send_message_unlocked (connection, reply, NULL, NULL); g_object_unref (reply); + g_free (in_signature); handled = TRUE; goto out; } + g_free (in_signature); parameters = g_dbus_message_get_body (message); if (parameters == NULL) @@ -4476,7 +4493,8 @@ handle_subtree_method_invocation (GDBusConnection *connection, GDBusMessage *reply; reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such interface")); + _("No such interface `%s'"), + interface_name); g_dbus_connection_send_message (es->connection, reply, NULL, NULL); g_object_unref (reply); handled = TRUE; @@ -4577,8 +4595,11 @@ process_subtree_vtable_message_in_idle_cb (gpointer _data) { GDBusMessage *reply; reply = g_dbus_message_new_method_error (data->message, - "org.freedesktop.DBus.Error.UnknownMethod", - _("Method doesn't exist")); + "org.freedesktop.DBus.Error.UnknownMethod", + _("Method `%s' on interface `%s' with signature `%s' does not exist"), + g_dbus_message_get_member (data->message), + g_dbus_message_get_interface (data->message), + g_dbus_message_get_signature (data->message)); g_dbus_connection_send_message (data->es->connection, reply, NULL, NULL); g_object_unref (reply); } @@ -4794,13 +4815,11 @@ handle_generic_get_machine_id_unlocked (GDBusConnection *connection, NULL, &error)) { - gchar *s; - s = g_strdup_printf (_("Unable to load /var/lib/dbus/machine-id: %s"), error->message); - g_error_free (error); reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.Failed", - s); - g_free (s); + _("Unable to load /var/lib/dbus/machine-id: %s"), + error->message); + g_error_free (error); } else { diff --git a/gdbus/gdbusintrospection.c b/gdbus/gdbusintrospection.c index 3f39c8a..63b945e 100644 --- a/gdbus/gdbusintrospection.c +++ b/gdbus/gdbusintrospection.c @@ -298,9 +298,7 @@ g_dbus_method_info_unref (GDBusMethodInfo *info) if (g_atomic_int_dec_and_test (&info->ref_count)) { g_free (info->name); - g_free (info->in_signature); free_null_terminated_array (info->in_args, (GDestroyNotify) g_dbus_arg_info_unref); - g_free (info->out_signature); free_null_terminated_array (info->out_args, (GDestroyNotify) g_dbus_arg_info_unref); free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref); g_free (info); @@ -323,7 +321,6 @@ g_dbus_signal_info_unref (GDBusSignalInfo *info) if (g_atomic_int_dec_and_test (&info->ref_count)) { g_free (info->name); - g_free (info->signature); free_null_terminated_array (info->args, (GDestroyNotify) g_dbus_arg_info_unref); free_null_terminated_array (info->annotations, (GDestroyNotify) g_dbus_annotation_info_unref); g_free (info); @@ -440,20 +437,6 @@ g_dbus_arg_info_set (ParseData *data, info->annotations = annotations; } -static gchar * -compute_signature (GDBusArgInfo **args, - guint num_args) -{ - GString *s; - guint n; - - s = g_string_new (""); - for (n = 0; n < num_args; n++) - g_string_append (s, args[n]->signature); - - return g_string_free (s, FALSE); -} - static void g_dbus_method_info_set (ParseData *data, GDBusMethodInfo *info, @@ -474,16 +457,12 @@ g_dbus_method_info_set (ParseData *data, //info->in_num_args = in_num_args; info->in_args = in_args; } - g_free (info->in_signature); - info->in_signature = compute_signature (in_args, in_num_args); if (out_num_args != 0) { //info->out_num_args = out_num_args; info->out_args = out_args; } - g_free (info->out_signature); - info->out_signature = compute_signature (out_args, out_num_args); if (annotations != NULL) info->annotations = annotations; @@ -507,8 +486,6 @@ g_dbus_signal_info_set (ParseData *data, //info->num_args = num_args; info->args = args; } - g_free (info->signature); - info->signature = compute_signature (args, num_args); if (annotations != NULL) { diff --git a/gdbus/gdbusintrospection.h b/gdbus/gdbusintrospection.h index 4c35b8a..afbb455 100644 --- a/gdbus/gdbusintrospection.h +++ b/gdbus/gdbusintrospection.h @@ -69,9 +69,7 @@ struct _GDBusArgInfo * GDBusMethodInfo: * @ref_count: The reference count or -1 if statically allocated. * @name: The name of the D-Bus method, e.g. @RequestName. - * @in_signature: The combined D-Bus signature of all arguments passed to the method. * @in_args: A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no in arguments. - * @out_signature: The combined D-Bus signature of all arguments the method returns. * @out_args: A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no out arguments. * @annotations: A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. * @@ -81,9 +79,7 @@ struct _GDBusMethodInfo { volatile gint ref_count; gchar *name; - gchar *in_signature; GDBusArgInfo **in_args; - gchar *out_signature; GDBusArgInfo **out_args; GDBusAnnotationInfo **annotations; }; @@ -92,7 +88,6 @@ struct _GDBusMethodInfo * GDBusSignalInfo: * @ref_count: The reference count or -1 if statically allocated. * @name: The name of the D-Bus signal, e.g. "NameOwnerChanged". - * @signature: The combined D-Bus signature of all arguments of the signal. * @args: A pointer to a %NULL-terminated array of pointers to #GDBusArgInfo structures or %NULL if there are no arguments. * @annotations: A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations. * @@ -102,7 +97,6 @@ struct _GDBusSignalInfo { volatile gint ref_count; gchar *name; - gchar *signature; GDBusArgInfo **args; GDBusAnnotationInfo **annotations; }; diff --git a/gdbus/gdbusmessage.c b/gdbus/gdbusmessage.c index e1f19bb..b4332f5 100644 --- a/gdbus/gdbusmessage.c +++ b/gdbus/gdbusmessage.c @@ -225,6 +225,37 @@ g_dbus_message_new_method_reply (GDBusMessage *method_call_message) * @method_call_message: A message of type %G_DBUS_MESSAGE_TYPE_METHOD_CALL to * create a reply message to. * @error_name: A valid D-Bus error name. + * @error_message_format: The D-Bus error message in a printf() format. + * @...: Arguments for @error_message_format. + * + * Creates a new #GDBusMessage that is an error reply to @method_call_message. + * + * Returns: A #GDBusMessage. Free with g_object_unref(). + */ +GDBusMessage * +g_dbus_message_new_method_error (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message_format, + ...) +{ + GDBusMessage *ret; + va_list var_args; + + va_start (var_args, error_message_format); + ret = g_dbus_message_new_method_error_valist (method_call_message, + error_name, + error_message_format, + var_args); + va_end (var_args); + + return ret; +} + +/** + * g_dbus_message_new_method_error_literal: + * @method_call_message: A message of type %G_DBUS_MESSAGE_TYPE_METHOD_CALL to + * create a reply message to. + * @error_name: A valid D-Bus error name. * @error_message: The D-Bus error message. * * Creates a new #GDBusMessage that is an error reply to @method_call_message. @@ -232,9 +263,9 @@ g_dbus_message_new_method_reply (GDBusMessage *method_call_message) * Returns: A #GDBusMessage. Free with g_object_unref(). */ GDBusMessage * -g_dbus_message_new_method_error (GDBusMessage *method_call_message, - const gchar *error_name, - const gchar *error_message) +g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message) { GDBusMessage *message; const gchar *sender; @@ -260,6 +291,34 @@ g_dbus_message_new_method_error (GDBusMessage *method_call_message, return message; } +/** + * g_dbus_message_new_method_error_valist: + * @method_call_message: A message of type %G_DBUS_MESSAGE_TYPE_METHOD_CALL to + * create a reply message to. + * @error_name: A valid D-Bus error name. + * @error_message_format: The D-Bus error message in a printf() format. + * @var_args: Arguments for @error_message_format. + * + * Like g_dbus_message_new_method_error() but intended for language bindings. + * + * Returns: A #GDBusMessage. Free with g_object_unref(). + */ +GDBusMessage * +g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message_format, + va_list var_args) +{ + GDBusMessage *ret; + gchar *error_message; + error_message = g_strdup_vprintf (error_message_format, var_args); + ret = g_dbus_message_new_method_error_literal (method_call_message, + error_name, + error_message); + g_free (error_message); + return ret; +} + /* ---------------------------------------------------------------------------------------------------- */ /* TODO: need GI annotations to specify that any guchar value goes for the type */ diff --git a/gdbus/gdbusmessage.h b/gdbus/gdbusmessage.h index 224f66f..06d72e6 100644 --- a/gdbus/gdbusmessage.h +++ b/gdbus/gdbusmessage.h @@ -81,7 +81,15 @@ GDBusMessage *g_dbus_message_new_method_call (const gchar GDBusMessage *g_dbus_message_new_method_reply (GDBusMessage *method_call_message); GDBusMessage *g_dbus_message_new_method_error (GDBusMessage *method_call_message, const gchar *error_name, - const gchar *error_message); + const gchar *error_message_format, + ...); +GDBusMessage *g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message_format, + va_list var_args); +GDBusMessage *g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message, + const gchar *error_name, + const gchar *error_message); gchar *g_dbus_message_print (GDBusMessage *message, guint indent); diff --git a/gdbus/gdbusmethodinvocation.c b/gdbus/gdbusmethodinvocation.c index 0bd096d..dc6950b 100644 --- a/gdbus/gdbusmethodinvocation.c +++ b/gdbus/gdbusmethodinvocation.c @@ -595,33 +595,23 @@ g_dbus_method_invocation_return_value (GDBusMethodInvocation *invocation, /* if we have introspection data, check that the signature of @parameters is correct */ if (invocation->priv->method_info != NULL) { - gboolean pass; + gchar *signature; + const gchar *type_string; - pass = FALSE; - if (parameters == NULL) - { - if (g_strcmp0 (invocation->priv->method_info->out_signature, "") == 0) - pass = TRUE; - } - else - { - const gchar *type_string; - gchar *sig_with_paren; - - /* this can probably be done a lot more efficiently */ - sig_with_paren = g_strdup_printf ("(%s)", invocation->priv->method_info->out_signature); - type_string = g_variant_get_type_string (parameters); - if (g_strcmp0 (sig_with_paren, type_string) == 0) - pass = TRUE; - g_free (sig_with_paren); - } + type_string = "()"; + if (parameters != NULL) + type_string = g_variant_get_type_string (parameters); + signature = _g_dbus_compute_complete_signature (invocation->priv->method_info->out_args, TRUE); - if (!pass) + if (g_strcmp0 (type_string, signature) != 0) { - g_warning (_("Type of return value is incorrect, expected type `(%s)'"), - invocation->priv->method_info->out_signature); + g_warning (_("Type of return value is incorrect, got `%s', expected `%s'"), + type_string, + signature); + g_free (signature); goto out; } + g_free (signature); } reply = g_dbus_message_new_method_reply (invocation->priv->message); @@ -795,9 +785,9 @@ g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation, g_return_if_fail (error_name != NULL && g_dbus_is_name (error_name)); g_return_if_fail (error_message != NULL); - reply = g_dbus_message_new_method_error (invocation->priv->message, - error_name, - error_message); + reply = g_dbus_message_new_method_error_literal (invocation->priv->message, + error_name, + error_message); g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, NULL, NULL); g_object_unref (reply); diff --git a/gdbus/gdbusprivate.c b/gdbus/gdbusprivate.c index 3ef661b..08295d4 100644 --- a/gdbus/gdbusprivate.c +++ b/gdbus/gdbusprivate.c @@ -38,6 +38,7 @@ #include "gdbusprivate.h" #include "gdbusmessage.h" #include "gdbuserror.h" +#include "gdbusintrospection.h" /* ---------------------------------------------------------------------------------------------------- */ @@ -1014,3 +1015,26 @@ _g_dbus_initialize (void) g_once_init_leave (&initialized, 1); } } + +/* ---------------------------------------------------------------------------------------------------- */ + +gchar * +_g_dbus_compute_complete_signature (GDBusArgInfo **args, + gboolean include_parentheses) +{ + GString *s; + guint n; + + if (include_parentheses) + s = g_string_new ("("); + else + s = g_string_new (""); + if (args != NULL) + for (n = 0; args[n] != NULL; n++) + g_string_append (s, args[n]->signature); + + if (include_parentheses) + g_string_append_c (s, ')'); + + return g_string_free (s, FALSE); +} diff --git a/gdbus/gdbusprivate.h b/gdbus/gdbusprivate.h index 8d59c1a..c01059d 100644 --- a/gdbus/gdbusprivate.h +++ b/gdbus/gdbusprivate.h @@ -73,6 +73,9 @@ gboolean _g_dbus_address_parse_entry (const gchar *address_entry, GHashTable **out_key_value_pairs, GError **error); +gchar * _g_dbus_compute_complete_signature (GDBusArgInfo **args, + gboolean include_parentheses); + /* ---------------------------------------------------------------------------------------------------- */ G_END_DECLS diff --git a/gdbus/gdbusproxy.c b/gdbus/gdbusproxy.c index 58e77bf..651fa83 100644 --- a/gdbus/gdbusproxy.c +++ b/gdbus/gdbusproxy.c @@ -1277,28 +1277,37 @@ validate_method_return (const char *method_name, const GDBusMethodInfo *expected_method_info, GError **error) { - const char *type_string; - if (value == NULL || !expected_method_info) - return TRUE; + const gchar *type_string; + gchar *signature; + gboolean ret; + + ret = TRUE; + signature = NULL; + + if (value == NULL || expected_method_info == NULL) + goto out; /* Shouldn't happen... */ if (g_variant_classify (value) != G_VARIANT_CLASS_TUPLE) - return TRUE; + goto out; type_string = g_variant_get_type_string (value); - /* introspection data doesn't have the () characters... */ - if (strncmp (type_string + 1, expected_method_info->out_signature, strlen (type_string + 1) - 1) != 0) + signature = _g_dbus_compute_complete_signature (expected_method_info->out_args, TRUE); + if (g_strcmp0 (type_string, signature) != 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, - _("Method %s returned signature %s, but expected (%s)"), + _("Method `%s' returned signature `%s', but expected `%s'"), method_name, type_string, - expected_method_info->out_signature); - return FALSE; + signature); + ret = FALSE; } - return TRUE; + + out: + g_free (signature); + return ret; } /** diff --git a/gdbus/tests/export.c b/gdbus/tests/export.c index d98a57e..2b5abb2 100644 --- a/gdbus/tests/export.c +++ b/gdbus/tests/export.c @@ -57,16 +57,16 @@ static const GDBusMethodInfo foo_method_info_method1 = { -1, "Method1", - "s", (GDBusArgInfo **) &foo_method1_in_arg_pointers, - "s", (GDBusArgInfo **) &foo_method1_out_arg_pointers, + (GDBusArgInfo **) &foo_method1_in_arg_pointers, + (GDBusArgInfo **) &foo_method1_out_arg_pointers, NULL }; static const GDBusMethodInfo foo_method_info_method2 = { -1, "Method2", - "", NULL, - "", NULL, + NULL, + NULL, NULL }; static const GDBusMethodInfo *foo_method_info_pointers[] = {&foo_method_info_method1, &foo_method_info_method2, NULL}; @@ -75,7 +75,7 @@ static const GDBusSignalInfo foo_signal_info = { -1, "SignalAlpha", - "", NULL, + NULL, NULL }; static const GDBusSignalInfo *foo_signal_info_pointers[] = {&foo_signal_info, NULL}; @@ -201,15 +201,15 @@ static const GDBusMethodInfo bar_method_info[] = { -1, "MethodA", - "", NULL, - "", NULL, + NULL, + NULL, NULL }, { -1, "MethodB", - "", NULL, - "", NULL, + NULL, + NULL, NULL } }; @@ -220,7 +220,7 @@ static const GDBusSignalInfo bar_signal_info[] = { -1, "SignalMars", - "", NULL, + NULL, NULL } }; @@ -255,8 +255,8 @@ static const GDBusMethodInfo dyna_method_info[] = { -1, "DynaCyber", - "", NULL, - "", NULL, + NULL, + NULL, NULL } }; @@ -809,7 +809,7 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); - g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Signature of message does not match what is expected"); + g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Signature of message, `s', does not match expected signature `'"); g_error_free (error); g_assert (value == NULL); @@ -822,7 +822,7 @@ test_dispatch_thread_func (gpointer user_data) NULL, &error); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); - g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method"); + g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method `NonExistantMethod'"); g_error_free (error); g_assert (value == NULL); @@ -857,7 +857,7 @@ test_dispatch_thread_func (gpointer user_data) &error); g_assert (value == NULL); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); - g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: No such property"); + g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: No such property `ThisDoesntExist'"); g_error_free (error); error = NULL; @@ -872,7 +872,7 @@ test_dispatch_thread_func (gpointer user_data) &error); g_assert (value == NULL); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); - g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property is not readable"); + g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property `NotReadable' is not readable"); g_error_free (error); error = NULL; @@ -904,7 +904,7 @@ test_dispatch_thread_func (gpointer user_data) &error); g_assert (value == NULL); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS); - g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property is not writable"); + g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Property `NotWritable' is not writable"); g_error_free (error); error = NULL; diff --git a/gdbus/tests/introspection.c b/gdbus/tests/introspection.c index 77bd566..5fe84ed 100644 --- a/gdbus/tests/introspection.c +++ b/gdbus/tests/introspection.c @@ -79,9 +79,7 @@ introspection_on_proxy_appeared (GDBusConnection *connection, g_assert (method_info == NULL); method_info = g_dbus_interface_info_lookup_method (interface_info, "Introspect"); g_assert (method_info != NULL); - g_assert_cmpstr (method_info->in_signature, ==, ""); g_assert (method_info->in_args == NULL); - g_assert_cmpstr (method_info->out_signature, ==, "s"); g_assert (method_info->out_args != NULL); g_assert (method_info->out_args[0] != NULL); g_assert (method_info->out_args[1] == NULL); @@ -91,7 +89,14 @@ introspection_on_proxy_appeared (GDBusConnection *connection, g_assert (interface_info != NULL); signal_info = g_dbus_interface_info_lookup_signal (interface_info, "TestSignal"); g_assert (signal_info != NULL); - g_assert_cmpstr (signal_info->signature, ==, "sov"); + g_assert (signal_info->args != NULL); + g_assert (signal_info->args[0] != NULL); + g_assert_cmpstr (signal_info->args[0]->signature, ==, "s"); + g_assert (signal_info->args[1] != NULL); + g_assert_cmpstr (signal_info->args[1]->signature, ==, "o"); + g_assert (signal_info->args[2] != NULL); + g_assert_cmpstr (signal_info->args[2]->signature, ==, "v"); + g_assert (signal_info->args[3] == NULL); g_dbus_node_info_unref (node_info); g_variant_unref (result); -- cgit v1.2.3