mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
gdbus: Use symbolic constants for the reserved Local path and interface
These are reserved by the D-Bus Specification. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
7401577074
commit
b4f8d4a5d5
@ -1416,7 +1416,7 @@ validate_headers (GDBusMessage *message,
|
||||
case G_DBUS_MESSAGE_HEADER_FIELD_PATH:
|
||||
if (!validate_header (message, field_type, header_value, G_VARIANT_TYPE_OBJECT_PATH, error))
|
||||
goto out;
|
||||
if (g_strcmp0 (g_variant_get_string (header_value, NULL), "/org/freedesktop/DBus/Local") == 0)
|
||||
if (g_strcmp0 (g_variant_get_string (header_value, NULL), DBUS_PATH_LOCAL) == 0)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
@ -1438,7 +1438,7 @@ validate_headers (GDBusMessage *message,
|
||||
message_type_to_string (message->type));
|
||||
goto out;
|
||||
}
|
||||
if (g_strcmp0 (g_variant_get_string (header_value, NULL), "org.freedesktop.DBus.Local") == 0)
|
||||
if (g_strcmp0 (g_variant_get_string (header_value, NULL), DBUS_INTERFACE_LOCAL) == 0)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
|
@ -32,6 +32,10 @@ G_BEGIN_DECLS
|
||||
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
||||
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
||||
|
||||
/* Reserved by the specification for locally-generated messages */
|
||||
#define DBUS_INTERFACE_LOCAL "org.freedesktop.DBus.Local"
|
||||
#define DBUS_PATH_LOCAL "/org/freedesktop/DBus/Local"
|
||||
|
||||
/* Owner flags */
|
||||
#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT 0x1 /**< Allow another service to become the primary owner if requested */
|
||||
#define DBUS_NAME_FLAG_REPLACE_EXISTING 0x2 /**< Request to replace the current primary owner */
|
||||
|
@ -1027,10 +1027,10 @@ test_message_serialize_header_checks (void)
|
||||
g_clear_error (&error);
|
||||
g_assert_null (blob);
|
||||
/* interface reserved value => error */
|
||||
g_dbus_message_set_interface (message, "org.freedesktop.DBus.Local");
|
||||
g_dbus_message_set_interface (message, DBUS_INTERFACE_LOCAL);
|
||||
blob = g_dbus_message_to_blob (message, &blob_size, G_DBUS_CAPABILITY_FLAGS_NONE, &error);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
||||
g_assert_cmpstr (error->message, ==, "Cannot serialize message: SIGNAL message: INTERFACE header field is using the reserved value org.freedesktop.DBus.Local");
|
||||
g_assert_cmpstr (error->message, ==, "Cannot serialize message: SIGNAL message: INTERFACE header field is using the reserved value " DBUS_INTERFACE_LOCAL);
|
||||
g_clear_error (&error);
|
||||
g_assert_null (blob);
|
||||
/* reset interface */
|
||||
@ -1044,10 +1044,10 @@ test_message_serialize_header_checks (void)
|
||||
g_clear_error (&error);
|
||||
g_assert_null (blob);
|
||||
/* path reserved value => error */
|
||||
g_dbus_message_set_path (message, "/org/freedesktop/DBus/Local");
|
||||
g_dbus_message_set_path (message, DBUS_PATH_LOCAL);
|
||||
blob = g_dbus_message_to_blob (message, &blob_size, G_DBUS_CAPABILITY_FLAGS_NONE, &error);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
|
||||
g_assert_cmpstr (error->message, ==, "Cannot serialize message: SIGNAL message: PATH header field is using the reserved value /org/freedesktop/DBus/Local");
|
||||
g_assert_cmpstr (error->message, ==, "Cannot serialize message: SIGNAL message: PATH header field is using the reserved value " DBUS_PATH_LOCAL);
|
||||
g_clear_error (&error);
|
||||
g_assert_null (blob);
|
||||
/* reset path */
|
||||
|
Loading…
Reference in New Issue
Block a user