diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2021-06-16 10:58:04 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2021-06-16 10:58:04 +0000 |
commit | 4d6dbe09049ee1a02fdb0aa3ae01c499dc033c27 (patch) | |
tree | 3c0f67bdeb754b9119ad947297a6da2c1f97e5e3 | |
parent | 00feb4d5a9e350b907d436a0b9b472fb2f1068bb (diff) | |
parent | a70df97c636d23a4673d715d10e22b5fbaa833f4 (diff) | |
download | glib-4d6dbe09049ee1a02fdb0aa3ae01c499dc033c27.tar.gz |
Merge branch 'g_dbus' into 'main'
gdbus: Add g_dbus_is_error_name() symbol for g_dbus_is_interface_name()
Closes #402
See merge request GNOME/glib!2156
-rw-r--r-- | docs/reference/gio/gio-sections-common.txt | 1 | ||||
-rw-r--r-- | gio/gdbusmessage.c | 2 | ||||
-rw-r--r-- | gio/gdbusutils.c | 22 | ||||
-rw-r--r-- | gio/gdbusutils.h | 2 | ||||
-rw-r--r-- | gio/tests/gdbus-names.c | 10 |
5 files changed, 34 insertions, 3 deletions
diff --git a/docs/reference/gio/gio-sections-common.txt b/docs/reference/gio/gio-sections-common.txt index 5151a9d75..250491a42 100644 --- a/docs/reference/gio/gio-sections-common.txt +++ b/docs/reference/gio/gio-sections-common.txt @@ -2806,6 +2806,7 @@ g_dbus_is_name g_dbus_is_unique_name g_dbus_is_member_name g_dbus_is_interface_name +g_dbus_is_error_name g_dbus_gvalue_to_gvariant g_dbus_gvariant_to_gvalue g_dbus_escape_object_path_bytestring diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index e36d1fe88..cdc0b83e8 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c @@ -3204,7 +3204,7 @@ g_dbus_message_set_error_name (GDBusMessage *message, const gchar *value) { g_return_if_fail (G_IS_DBUS_MESSAGE (message)); - g_return_if_fail (value == NULL || g_dbus_is_interface_name (value)); + g_return_if_fail (value == NULL || g_dbus_is_error_name (value)); set_string_header (message, G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME, value); } diff --git a/gio/gdbusutils.c b/gio/gdbusutils.c index cd52208d2..f12e86204 100644 --- a/gio/gdbusutils.c +++ b/gio/gdbusutils.c @@ -268,6 +268,28 @@ g_dbus_is_interface_name (const gchar *string) return ret; } +/** + * g_dbus_is_error_name: + * @string: The string to check. + * + * Check whether @string is a valid D-Bus error name. + * + * This function returns the same result as g_dbus_is_interface_name(), + * because D-Bus error names are defined to have exactly the + * same syntax as interface names. + * + * Returns: %TRUE if valid, %FALSE otherwise. + * + * Since: 2.70 + */ +gboolean +g_dbus_is_error_name (const gchar *string) +{ + /* Error names are the same syntax as interface names. + * See https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-error */ + return g_dbus_is_interface_name (string); +} + /* ---------------------------------------------------------------------------------------------------- */ /* TODO: maybe move to glib? if so, it should conform to http://en.wikipedia.org/wiki/Guid and/or diff --git a/gio/gdbusutils.h b/gio/gdbusutils.h index fd7358fcf..da8e42280 100644 --- a/gio/gdbusutils.h +++ b/gio/gdbusutils.h @@ -42,6 +42,8 @@ GLIB_AVAILABLE_IN_ALL gboolean g_dbus_is_member_name (const gchar *string); GLIB_AVAILABLE_IN_ALL gboolean g_dbus_is_interface_name (const gchar *string); +GLIB_AVAILABLE_IN_2_70 +gboolean g_dbus_is_error_name (const gchar *string); GLIB_AVAILABLE_IN_ALL void g_dbus_gvariant_to_gvalue (GVariant *value, diff --git a/gio/tests/gdbus-names.c b/gio/tests/gdbus-names.c index 89bccb83d..8504220a9 100644 --- a/gio/tests/gdbus-names.c +++ b/gio/tests/gdbus-names.c @@ -1162,9 +1162,15 @@ test_validate_names (void) g_assert (!g_dbus_is_unique_name (names[n].string)); if (names[n].interface) - g_assert (g_dbus_is_interface_name (names[n].string)); + { + g_assert (g_dbus_is_interface_name (names[n].string)); + g_assert (g_dbus_is_error_name (names[n].string)); + } else - g_assert (!g_dbus_is_interface_name (names[n].string)); + { + g_assert (!g_dbus_is_interface_name (names[n].string)); + g_assert (!g_dbus_is_error_name (names[n].string)); + } } } |