summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornitinosiris <nitinwartkar58@gmail.com>2021-05-27 14:18:34 +0530
committernitinosiris <nitinwartkar58@gmail.com>2021-06-08 21:07:21 +0530
commit5e2986ea2c3c491130867c93ccdc62b508f12332 (patch)
treec36412cd2ce16b2eb45214ef322ab658037eba6b
parent4575c70a6b02d486ae882b41b9caba314e3a4ace (diff)
downloadglib-5e2986ea2c3c491130867c93ccdc62b508f12332.tar.gz
gdbusconnection: removed a confusing message
The message `No such interface %s on object at path %s` displayed when requested object does not exist, which was kind of confusing. Closes #793
-rw-r--r--gio/gdbusconnection.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 7c20462eb..46f61bdd4 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -5052,7 +5052,8 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection,
static gboolean
obj_message_func (GDBusConnection *connection,
ExportedObject *eo,
- GDBusMessage *message)
+ GDBusMessage *message,
+ gboolean *object_found)
{
const gchar *interface_name;
const gchar *member;
@@ -5088,6 +5089,10 @@ obj_message_func (GDBusConnection *connection,
ei->user_data);
goto out;
}
+ else
+ {
+ *object_found = TRUE;
+ }
}
if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Introspectable") == 0 &&
@@ -7113,6 +7118,7 @@ distribute_method_call (GDBusConnection *connection,
const gchar *path;
gchar *subtree_path;
gchar *needle;
+ gboolean object_found = FALSE;
g_assert (g_dbus_message_get_message_type (message) == G_DBUS_MESSAGE_TYPE_METHOD_CALL);
@@ -7154,7 +7160,7 @@ distribute_method_call (GDBusConnection *connection,
eo = g_hash_table_lookup (connection->map_object_path_to_eo, object_path);
if (eo != NULL)
{
- if (obj_message_func (connection, eo, message))
+ if (obj_message_func (connection, eo, message, &object_found))
goto out;
}
@@ -7179,11 +7185,22 @@ distribute_method_call (GDBusConnection *connection,
goto out;
/* if we end up here, the message has not been not handled - so return an error saying this */
- reply = g_dbus_message_new_method_error (message,
+ if (object_found == TRUE)
+ {
+ reply = g_dbus_message_new_method_error (message,
+ "org.freedesktop.DBus.Error.UnknownMethod",
+ _("No such interface “%s” on object at path %s"),
+ interface_name,
+ object_path);
+ }
+ else
+ {
+ reply = g_dbus_message_new_method_error (message,
"org.freedesktop.DBus.Error.UnknownMethod",
- _("No such interface “%s” on object at path %s"),
- interface_name,
+ _("Object does not exist at path “%s”"),
object_path);
+ }
+
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (reply);