gdbus: Use symbolic constants for interfaces from dbus-specification

Most D-Bus interfaces are domain-specific, but these interfaces from the
D-Bus Specification are intended to be commonly used in any context for
which they are found to be appropriate.

Most of these use `gdbusprivate.h`. One exception is that
`gio/tests/gdbus-example-*` redefine the constants locally: due to these
files' dual role as part of the unit tests and as sample code, it seems
desirable to ensure that they can still be compiled outside GLib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2024-05-13 13:00:34 +01:00 committed by Philip Withnall
parent b4f8d4a5d5
commit 7c609f8142
18 changed files with 95 additions and 75 deletions

View File

@ -164,7 +164,7 @@ send_property_change (GApplicationImpl *impl)
g_dbus_connection_emit_signal (impl->session_bus,
NULL,
impl->object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
"org.gtk.Application",

View File

@ -192,7 +192,7 @@ print_methods_and_signals (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
name,
path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect",
NULL,
G_VARIANT_TYPE ("(s)"),
@ -264,7 +264,7 @@ print_paths (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
name,
path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect",
NULL,
G_VARIANT_TYPE ("(s)"),
@ -502,7 +502,7 @@ call_helper_get_method_in_signature (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
dest,
path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect",
NULL,
G_VARIANT_TYPE ("(s)"),
@ -1501,7 +1501,7 @@ dump_interface (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
name,
object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"GetAll",
g_variant_new ("(s)", o->name),
NULL,
@ -1539,7 +1539,7 @@ dump_interface (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
name,
object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"Get",
g_variant_new ("(ss)", o->name, o->properties[n]->name),
G_VARIANT_TYPE ("(v)"),
@ -1721,7 +1721,7 @@ introspect_do (GDBusConnection *c,
result = g_dbus_connection_call_sync (c,
opt_introspect_dest,
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect",
NULL,
G_VARIANT_TYPE ("(s)"),

View File

@ -482,7 +482,7 @@ struct _GDBusConnection
GMutex init_lock;
/* Set (by loading the contents of /var/lib/dbus/machine-id) the first time
* someone calls org.freedesktop.DBus.Peer.GetMachineId(). Protected by @lock.
* someone calls DBUS_INTERFACE_PEER.GetMachineId(). Protected by @lock.
*/
gchar *machine_id;
@ -5256,7 +5256,7 @@ static const gchar introspect_tail[] =
"</node>\n";
static const gchar introspect_properties_interface[] =
" <interface name=\"org.freedesktop.DBus.Properties\">\n"
" <interface name=\"" DBUS_INTERFACE_PROPERTIES "\">\n"
" <method name=\"Get\">\n"
" <arg type=\"s\" name=\"interface_name\" direction=\"in\"/>\n"
" <arg type=\"s\" name=\"property_name\" direction=\"in\"/>\n"
@ -5279,12 +5279,12 @@ static const gchar introspect_properties_interface[] =
" </interface>\n";
static const gchar introspect_introspectable_interface[] =
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">\n"
" <method name=\"Introspect\">\n"
" <arg type=\"s\" name=\"xml_data\" direction=\"out\"/>\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.freedesktop.DBus.Peer\">\n"
" <interface name=\"" DBUS_INTERFACE_PEER "\">\n"
" <method name=\"Ping\"/>\n"
" <method name=\"GetMachineId\">\n"
" <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n"
@ -5389,11 +5389,11 @@ handle_introspect (GDBusConnection *connection,
sizeof (introspect_tail));
introspect_append_header (s);
if (!g_hash_table_lookup (eo->map_if_name_to_ei,
"org.freedesktop.DBus.Properties"))
DBUS_INTERFACE_PROPERTIES))
g_string_append (s, introspect_properties_interface);
if (!g_hash_table_lookup (eo->map_if_name_to_ei,
"org.freedesktop.DBus.Introspectable"))
DBUS_INTERFACE_INTROSPECTABLE))
g_string_append (s, introspect_introspectable_interface);
/* then include the registered interfaces */
@ -5645,28 +5645,28 @@ obj_message_func (GDBusConnection *connection,
}
}
if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Introspectable") == 0 &&
if (g_strcmp0 (interface_name, DBUS_INTERFACE_INTROSPECTABLE) == 0 &&
g_strcmp0 (member, "Introspect") == 0 &&
g_strcmp0 (signature, "") == 0)
{
handled = handle_introspect (connection, eo, message);
goto out;
}
else if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Properties") == 0 &&
else if (g_strcmp0 (interface_name, DBUS_INTERFACE_PROPERTIES) == 0 &&
g_strcmp0 (member, "Get") == 0 &&
g_strcmp0 (signature, "ss") == 0)
{
handled = handle_getset_property (connection, eo, message, TRUE);
goto out;
}
else if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Properties") == 0 &&
else if (g_strcmp0 (interface_name, DBUS_INTERFACE_PROPERTIES) == 0 &&
g_strcmp0 (member, "Set") == 0 &&
g_strcmp0 (signature, "ssv") == 0)
{
handled = handle_getset_property (connection, eo, message, FALSE);
goto out;
}
else if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Properties") == 0 &&
else if (g_strcmp0 (interface_name, DBUS_INTERFACE_PROPERTIES) == 0 &&
g_strcmp0 (member, "GetAll") == 0 &&
g_strcmp0 (signature, "s") == 0)
{
@ -7011,9 +7011,9 @@ handle_subtree_introspect (GDBusConnection *connection,
for (n = 0; interfaces[n] != NULL; n++)
{
if (strcmp (interfaces[n]->name, "org.freedesktop.DBus.Properties") == 0)
if (strcmp (interfaces[n]->name, DBUS_INTERFACE_PROPERTIES) == 0)
has_properties_interface = TRUE;
else if (strcmp (interfaces[n]->name, "org.freedesktop.DBus.Introspectable") == 0)
else if (strcmp (interfaces[n]->name, DBUS_INTERFACE_INTROSPECTABLE) == 0)
has_introspectable_interface = TRUE;
}
if (!has_properties_interface)
@ -7095,7 +7095,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
is_property_get = FALSE;
is_property_set = FALSE;
is_property_get_all = FALSE;
if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Properties") == 0)
if (g_strcmp0 (interface_name, DBUS_INTERFACE_PROPERTIES) == 0)
{
if (g_strcmp0 (member, "Get") == 0 && g_strcmp0 (signature, "ss") == 0)
is_property_get = TRUE;
@ -7177,7 +7177,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
interface_user_data);
CONNECTION_UNLOCK (connection);
}
/* handle org.freedesktop.DBus.Properties interface if not explicitly handled */
/* handle DBUS_INTERFACE_PROPERTIES if not explicitly handled */
else if (is_property_get || is_property_set || is_property_get_all)
{
if (is_property_get)
@ -7292,7 +7292,7 @@ process_subtree_vtable_message_in_idle_cb (gpointer _data)
handled = FALSE;
if (g_strcmp0 (g_dbus_message_get_interface (data->message), "org.freedesktop.DBus.Introspectable") == 0 &&
if (g_strcmp0 (g_dbus_message_get_interface (data->message), DBUS_INTERFACE_INTROSPECTABLE) == 0 &&
g_strcmp0 (g_dbus_message_get_member (data->message), "Introspect") == 0 &&
g_strcmp0 (g_dbus_message_get_signature (data->message), "") == 0)
handled = handle_subtree_introspect (data->es->connection,
@ -7609,21 +7609,21 @@ handle_generic_unlocked (GDBusConnection *connection,
signature = g_dbus_message_get_signature (message);
path = g_dbus_message_get_path (message);
if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Introspectable") == 0 &&
if (g_strcmp0 (interface_name, DBUS_INTERFACE_INTROSPECTABLE) == 0 &&
g_strcmp0 (member, "Introspect") == 0 &&
g_strcmp0 (signature, "") == 0)
{
handle_generic_introspect_unlocked (connection, path, message);
handled = TRUE;
}
else if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Peer") == 0 &&
else if (g_strcmp0 (interface_name, DBUS_INTERFACE_PEER) == 0 &&
g_strcmp0 (member, "Ping") == 0 &&
g_strcmp0 (signature, "") == 0)
{
handle_generic_ping_unlocked (connection, path, message);
handled = TRUE;
}
else if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Peer") == 0 &&
else if (g_strcmp0 (interface_name, DBUS_INTERFACE_PEER) == 0 &&
g_strcmp0 (member, "GetMachineId") == 0 &&
g_strcmp0 (signature, "") == 0)
{

View File

@ -464,7 +464,7 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
else
g_assert_not_reached ();
}
else if (g_str_equal (invocation->interface_name, "org.freedesktop.DBus.Properties") &&
else if (g_str_equal (invocation->interface_name, DBUS_INTERFACE_PROPERTIES) &&
g_str_equal (invocation->method_name, "GetAll"))
{
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})")))

View File

@ -1026,7 +1026,7 @@ signal_cb (GDBusConnection *connection,
//g_debug ("yay, signal_cb %s %s: %s\n", signal_name, object_path, g_variant_print (parameters, TRUE));
g_object_ref (manager);
if (g_strcmp0 (interface_name, "org.freedesktop.DBus.Properties") == 0)
if (g_strcmp0 (interface_name, DBUS_INTERFACE_PROPERTIES) == 0)
{
if (g_strcmp0 (signal_name, "PropertiesChanged") == 0)
{
@ -1419,7 +1419,7 @@ initable_init (GInitable *initable,
NULL, /* GDBusInterfaceInfo* */
manager->priv->name,
manager->priv->object_path,
"org.freedesktop.DBus.ObjectManager",
DBUS_INTERFACE_OBJECT_MANAGER,
cancellable,
error);
if (manager->priv->control_proxy == NULL)

View File

@ -34,6 +34,8 @@
#include "gioerror.h"
#include "gdbusprivate.h"
#include "glibintl.h"
/**
@ -841,7 +843,7 @@ static const GDBusMethodInfo * const manager_method_info_pointers[] =
static const GDBusInterfaceInfo manager_interface_info =
{
-1,
"org.freedesktop.DBus.ObjectManager",
DBUS_INTERFACE_OBJECT_MANAGER,
(GDBusMethodInfo **) manager_method_info_pointers,
(GDBusSignalInfo **) manager_signal_info_pointers,
(GDBusPropertyInfo **) NULL,

View File

@ -36,6 +36,12 @@ G_BEGIN_DECLS
#define DBUS_INTERFACE_LOCAL "org.freedesktop.DBus.Local"
#define DBUS_PATH_LOCAL "/org/freedesktop/DBus/Local"
/* Other well-known D-Bus interfaces from the specification */
#define DBUS_INTERFACE_INTROSPECTABLE "org.freedesktop.DBus.Introspectable"
#define DBUS_INTERFACE_OBJECT_MANAGER "org.freedesktop.DBus.ObjectManager"
#define DBUS_INTERFACE_PEER "org.freedesktop.DBus.Peer"
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
/* 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 */

View File

@ -1058,7 +1058,7 @@ on_properties_changed (GDBusConnection *connection,
g_dbus_connection_call (proxy->priv->connection,
proxy->priv->name_owner,
proxy->priv->object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"Get",
g_variant_new ("(ss)", proxy->priv->interface_name, data->prop_name),
G_VARIANT_TYPE ("(v)"),
@ -1330,7 +1330,7 @@ on_name_owner_changed (GDBusConnection *connection,
g_dbus_connection_call (proxy->priv->connection,
data->name_owner,
proxy->priv->object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"GetAll",
g_variant_new ("(s)", proxy->priv->interface_name),
G_VARIANT_TYPE ("(a{sv})"),
@ -1424,7 +1424,7 @@ async_init_data_set_name_owner (GTask *task,
g_dbus_connection_call (proxy->priv->connection,
name_owner,
proxy->priv->object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"GetAll",
g_variant_new ("(s)", proxy->priv->interface_name),
G_VARIANT_TYPE ("(a{sv})"),
@ -1688,7 +1688,7 @@ async_initable_init_first (GAsyncInitable *initable)
proxy->priv->properties_changed_subscription_id =
g_dbus_connection_signal_subscribe (proxy->priv->connection,
proxy->priv->name,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
proxy->priv->object_path,
proxy->priv->interface_name,

View File

@ -241,7 +241,7 @@ set_debug_enabled (GDebugControllerDBus *self,
g_dbus_connection_emit_signal (priv->connection,
NULL,
"/org/gtk/Debugging",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
"org.gtk.Debugging",

View File

@ -24,6 +24,7 @@
#include <gio/gio.h>
#include <locale.h>
#include "gdbusprivate.h"
static void
test_dbus_basic (void)
@ -218,7 +219,7 @@ test_dbus_properties (void)
properties_changed_id = g_dbus_connection_signal_subscribe (remote_connection,
g_dbus_connection_get_unique_name (controller_connection),
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
"/org/gtk/Debugging",
NULL,
@ -231,7 +232,7 @@ test_dbus_properties (void)
g_dbus_connection_call (remote_connection,
g_dbus_connection_get_unique_name (controller_connection),
"/org/gtk/Debugging",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"Get",
g_variant_new ("(ss)", "org.gtk.Debugging", "DebugEnabled"),
G_VARIANT_TYPE ("(v)"),

View File

@ -1,6 +1,8 @@
#include <gio/gio.h>
#include <stdlib.h>
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
/* ---------------------------------------------------------------------------------------------------- */
/* The object we want to export */
@ -253,7 +255,7 @@ send_property_change (GObject *obj,
g_dbus_connection_emit_signal (connection,
NULL,
"/org/myorg/MyObject",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
"org.myorg.MyObject",

View File

@ -7,6 +7,8 @@
#include <unistd.h>
#endif
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
/* ---------------------------------------------------------------------------------------------------- */
static GDBusNodeInfo *introspection_data = NULL;
@ -243,7 +245,7 @@ handle_set_property (GDBusConnection *connection,
g_dbus_connection_emit_signal (connection,
NULL,
object_path,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
interface_name,
@ -306,7 +308,7 @@ on_timeout_cb (gpointer user_data)
g_dbus_connection_emit_signal (connection,
NULL,
"/org/gtk/GDBus/TestObject",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new ("(sa{sv}as)",
"org.gtk.GDBus.TestInterface",

View File

@ -25,6 +25,7 @@
#include <string.h>
#include "gdbus-tests.h"
#include "gdbusprivate.h"
/* all tests rely on a shared mainloop */
static GMainLoop *loop = NULL;
@ -377,7 +378,7 @@ get_nodes_at (GDBusConnection *c,
NULL,
g_dbus_connection_get_unique_name (c),
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
NULL,
&error);
g_assert_no_error (error);
@ -436,7 +437,7 @@ has_interface (GDBusConnection *c,
NULL,
g_dbus_connection_get_unique_name (c),
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
NULL,
&error);
g_assert_no_error (error);
@ -485,7 +486,7 @@ count_interfaces (GDBusConnection *c,
NULL,
g_dbus_connection_get_unique_name (c),
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
NULL,
&error);
g_assert_no_error (error);
@ -778,7 +779,7 @@ test_dispatch_thread_func (gpointer user_data)
/* generic interfaces */
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Peer.Ping",
DBUS_INTERFACE_PEER ".Ping",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
@ -858,7 +859,7 @@ test_dispatch_thread_func (gpointer user_data)
/* user properties */
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.Get",
DBUS_INTERFACE_PROPERTIES ".Get",
g_variant_new ("(ss)",
"org.example.Foo",
"PropertyUno"),
@ -877,7 +878,7 @@ test_dispatch_thread_func (gpointer user_data)
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.Get",
DBUS_INTERFACE_PROPERTIES ".Get",
g_variant_new ("(ss)",
"org.example.Foo",
"ThisDoesntExist"),
@ -892,7 +893,7 @@ test_dispatch_thread_func (gpointer user_data)
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.Get",
DBUS_INTERFACE_PROPERTIES ".Get",
g_variant_new ("(ss)",
"org.example.Foo",
"NotReadable"),
@ -907,7 +908,7 @@ test_dispatch_thread_func (gpointer user_data)
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.Set",
DBUS_INTERFACE_PROPERTIES ".Set",
g_variant_new ("(ssv)",
"org.example.Foo",
"NotReadable",
@ -928,7 +929,7 @@ test_dispatch_thread_func (gpointer user_data)
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.Set",
DBUS_INTERFACE_PROPERTIES ".Set",
g_variant_new ("(ssv)",
"org.example.Foo",
"NotWritable",
@ -944,7 +945,7 @@ test_dispatch_thread_func (gpointer user_data)
error = NULL;
value = g_dbus_proxy_call_sync (foo_proxy,
"org.freedesktop.DBus.Properties.GetAll",
DBUS_INTERFACE_PROPERTIES ".GetAll",
g_variant_new ("(s)",
"org.example.Foo"),
G_DBUS_CALL_FLAGS_NONE,
@ -1466,7 +1467,7 @@ static const GDBusInterfaceInfo test_interface_info1 =
static const GDBusInterfaceInfo test_interface_info2 =
{
-1,
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
(GDBusMethodInfo **) NULL,
(GDBusSignalInfo **) NULL,
(GDBusPropertyInfo **) NULL,
@ -1491,7 +1492,7 @@ check_interfaces (GDBusConnection *c,
NULL,
g_dbus_connection_get_unique_name (c),
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
NULL,
&error);
g_assert_no_error (error);
@ -1555,8 +1556,8 @@ test_registered_interfaces (void)
guint id1, id2;
const gchar *interfaces[] = {
"org.example.Foo",
"org.freedesktop.DBus.Properties",
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_PROPERTIES,
DBUS_INTERFACE_INTROSPECTABLE,
NULL,
};
@ -1607,10 +1608,10 @@ test_async_method_call (GDBusConnection *connection,
const GDBusPropertyInfo *property;
/* Strictly speaking, this function should also expect to receive
* method calls not on the org.freedesktop.DBus.Properties interface,
* method calls not on the DBUS_INTERFACE_PROPERTIES interface,
* but we don't do any during this testcase, so assert that.
*/
g_assert_cmpstr (interface_name, ==, "org.freedesktop.DBus.Properties");
g_assert_cmpstr (interface_name, ==, DBUS_INTERFACE_PROPERTIES);
g_assert_null (g_dbus_method_invocation_get_method_info (invocation));
property = g_dbus_method_invocation_get_property_info (invocation);
@ -1714,7 +1715,7 @@ test_async_case (GDBusConnection *connection,
va_start (ap, format_string);
g_dbus_connection_call (connection, g_dbus_connection_get_unique_name (connection), "/foo",
"org.freedesktop.DBus.Properties", method, g_variant_new_va (format_string, NULL, &ap),
DBUS_INTERFACE_PROPERTIES, method, g_variant_new_va (format_string, NULL, &ap),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, ensure_result_cb, (gpointer) expected_reply);
va_end (ap);

View File

@ -24,6 +24,7 @@
#include <unistd.h>
#include <string.h>
#include "gdbusprivate.h"
#include "gdbus-tests.h"
/* all tests rely on a shared mainloop */
@ -50,7 +51,7 @@ test_introspection (GDBusProxy *proxy)
* Invoke Introspect(), then parse the output.
*/
result = g_dbus_proxy_call_sync (proxy,
"org.freedesktop.DBus.Introspectable.Introspect",
DBUS_INTERFACE_INTROSPECTABLE ".Introspect",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
@ -69,7 +70,7 @@ test_introspection (GDBusProxy *proxy)
interface_info = g_dbus_node_info_lookup_interface (node_info, "com.example.NonExistantInterface");
g_assert (interface_info == NULL);
interface_info = g_dbus_node_info_lookup_interface (node_info, "org.freedesktop.DBus.Introspectable");
interface_info = g_dbus_node_info_lookup_interface (node_info, DBUS_INTERFACE_INTROSPECTABLE);
g_assert (interface_info != NULL);
method_info = g_dbus_interface_info_lookup_method (interface_info, "NonExistantMethod");
g_assert (method_info == NULL);

View File

@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include "gdbusprivate.h"
#include "gdbus-tests.h"
static const GDBusArgInfo foo_get_fds_in_args =
@ -141,7 +142,7 @@ test_method_invocation_return_method_call (GDBusConnection *connection,
{
gboolean no_reply = g_dbus_message_get_flags (g_dbus_method_invocation_get_message (invocation)) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED;
if (g_str_equal (interface_name, "org.freedesktop.DBus.Properties") &&
if (g_str_equal (interface_name, DBUS_INTERFACE_PROPERTIES) &&
g_str_equal (method_name, "Get"))
{
const gchar *iface_name, *prop_name;
@ -178,7 +179,7 @@ test_method_invocation_return_method_call (GDBusConnection *connection,
g_test_assert_expected_messages ();
}
else if (g_str_equal (interface_name, "org.freedesktop.DBus.Properties") &&
else if (g_str_equal (interface_name, DBUS_INTERFACE_PROPERTIES) &&
g_str_equal (method_name, "Set"))
{
const gchar *iface_name, *prop_name;
@ -202,7 +203,7 @@ test_method_invocation_return_method_call (GDBusConnection *connection,
g_test_assert_expected_messages ();
g_variant_unref (value);
}
else if (g_str_equal (interface_name, "org.freedesktop.DBus.Properties") &&
else if (g_str_equal (interface_name, DBUS_INTERFACE_PROPERTIES) &&
g_str_equal (method_name, "GetAll"))
{
const gchar *iface_name;
@ -325,11 +326,11 @@ test_method_invocation_return (void)
}
calls[] =
{
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidType')", TRUE },
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidTypeNull')", TRUE },
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidValueType')", TRUE },
{ "org.freedesktop.DBus.Properties", "Set", "('org.example.Foo', 'InvalidType', <'irrelevant'>)", TRUE },
{ "org.freedesktop.DBus.Properties", "GetAll", "('org.example.Foo',)", TRUE },
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidType')", TRUE },
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidTypeNull')", TRUE },
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidValueType')", TRUE },
{ DBUS_INTERFACE_PROPERTIES, "Set", "('org.example.Foo', 'InvalidType', <'irrelevant'>)", TRUE },
{ DBUS_INTERFACE_PROPERTIES, "GetAll", "('org.example.Foo',)", TRUE },
{ "org.example.Foo", "WrongReturnType", "()", TRUE },
{ "org.example.Foo", "GetFDs", "('Valid',)", FALSE },
{ "org.example.Foo", "GetFDs", "('WrongNumber',)", TRUE },

View File

@ -48,6 +48,7 @@
#include <gio/giowin32-afunix.h>
#endif
#include "gdbusprivate.h"
#include "gdbus-tests.h"
#include "gdbus-object-manager-example/objectmanager-gen.h"
@ -2156,7 +2157,7 @@ codegen_test_peer (void)
/* Poke server and make sure animal is updated */
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal1),
"org.freedesktop.DBus.Peer.Ping",
DBUS_INTERFACE_PEER ".Ping",
NULL, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
g_assert_no_error (error);
@ -2177,7 +2178,7 @@ codegen_test_peer (void)
/* Some random unrelated call, just to get some test coverage */
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal2),
"org.freedesktop.DBus.Peer.GetMachineId",
DBUS_INTERFACE_PEER ".GetMachineId",
NULL, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
g_assert_no_error (error);
@ -2191,7 +2192,7 @@ codegen_test_peer (void)
/* Poke server and make sure animal is updated */
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal2),
"org.freedesktop.DBus.Peer.Ping",
DBUS_INTERFACE_PEER ".Ping",
NULL, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
g_assert_no_error (error);

View File

@ -25,6 +25,7 @@
#include <string.h>
#include <stdio.h>
#include "gdbusprivate.h"
#include "gdbus-tests.h"
#include "gstdio.h"
@ -1511,7 +1512,7 @@ introspect (GDBusConnection *connection,
g_dbus_connection_call (connection,
name,
object_path,
"org.freedesktop.DBus.Introspectable",
DBUS_INTERFACE_INTROSPECTABLE,
"Introspect",
NULL, /* params */
G_VARIANT_TYPE ("(s)"),
@ -1603,7 +1604,7 @@ om_check_get_all (GDBusConnection *c,
g_dbus_connection_call (c,
g_dbus_connection_get_unique_name (c),
"/managed",
"org.freedesktop.DBus.ObjectManager",
DBUS_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects",
NULL, /* params */
G_VARIANT_TYPE ("(a{oa{sa{sv}}})"),
@ -2016,7 +2017,7 @@ check_object_manager (void)
om_signal_id = g_dbus_connection_signal_subscribe (c,
NULL, /* sender */
"org.freedesktop.DBus.ObjectManager",
DBUS_INTERFACE_OBJECT_MANAGER,
NULL, /* member */
NULL, /* object_path */
NULL, /* arg0 */
@ -2060,7 +2061,7 @@ check_object_manager (void)
/* Check that the manager object is visible */
info = introspect (c, g_dbus_connection_get_unique_name (c), "/managed", loop);
g_assert_cmpint (count_interfaces (info), ==, 4); /* ObjectManager + Properties,Introspectable,Peer */
g_assert (has_interface (info, "org.freedesktop.DBus.ObjectManager"));
g_assert (has_interface (info, DBUS_INTERFACE_OBJECT_MANAGER));
g_assert_cmpint (count_nodes (info), ==, 0);
g_dbus_node_info_unref (info);

View File

@ -1,6 +1,8 @@
#include <gio/gio.h>
#include <stdlib.h>
#include "gdbusprivate.h"
static GDBusNodeInfo *introspection_data = NULL;
static GMainLoop *loop = NULL;
static GHashTable *properties = NULL;
@ -688,7 +690,7 @@ handle_method_call (GDBusConnection *connection,
g_dbus_connection_emit_signal (connection,
NULL,
"/com/example/TestObject",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new_parsed ("('com.example.Frob', [{%s, %v}], @as [])", name, value),
NULL);
@ -703,7 +705,7 @@ handle_method_call (GDBusConnection *connection,
g_dbus_connection_emit_signal (connection,
NULL,
"/com/example/TestObject",
"org.freedesktop.DBus.Properties",
DBUS_INTERFACE_PROPERTIES,
"PropertiesChanged",
g_variant_new_parsed ("('com.example.Frob', @a{sv} [], ['PropertyThatWillBeInvalidated'])"),
NULL);