mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 22:59:16 +02:00
Merge branch 'wip/smcv/more-gdbus-constants' into 'main'
gdbus: Make more use of symbolic constants for various aspects of the D-Bus protocol See merge request GNOME/glib!4069
This commit is contained in:
commit
5b1817c07b
@ -32,6 +32,7 @@
|
|||||||
#include "gdbusconnection.h"
|
#include "gdbusconnection.h"
|
||||||
#include "gdbusintrospection.h"
|
#include "gdbusintrospection.h"
|
||||||
#include "gdbuserror.h"
|
#include "gdbuserror.h"
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "glib/gstdio.h"
|
#include "glib/gstdio.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -163,7 +164,7 @@ send_property_change (GApplicationImpl *impl)
|
|||||||
g_dbus_connection_emit_signal (impl->session_bus,
|
g_dbus_connection_emit_signal (impl->session_bus,
|
||||||
NULL,
|
NULL,
|
||||||
impl->object_path,
|
impl->object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new ("(sa{sv}as)",
|
g_variant_new ("(sa{sv}as)",
|
||||||
"org.gtk.Application",
|
"org.gtk.Application",
|
||||||
@ -510,10 +511,10 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
|||||||
if (app_flags & G_APPLICATION_ALLOW_REPLACEMENT)
|
if (app_flags & G_APPLICATION_ALLOW_REPLACEMENT)
|
||||||
{
|
{
|
||||||
impl->name_lost_signal = g_dbus_connection_signal_subscribe (impl->session_bus,
|
impl->name_lost_signal = g_dbus_connection_signal_subscribe (impl->session_bus,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameLost",
|
"NameLost",
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
impl->bus_name,
|
impl->bus_name,
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
name_lost,
|
name_lost,
|
||||||
@ -526,9 +527,9 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
|||||||
name_owner_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
|
name_owner_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
|
||||||
|
|
||||||
reply = g_dbus_connection_call_sync (impl->session_bus,
|
reply = g_dbus_connection_call_sync (impl->session_bus,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"RequestName",
|
"RequestName",
|
||||||
g_variant_new ("(su)", impl->bus_name, name_owner_flags),
|
g_variant_new ("(su)", impl->bus_name, name_owner_flags),
|
||||||
G_VARIANT_TYPE ("(u)"),
|
G_VARIANT_TYPE ("(u)"),
|
||||||
@ -540,8 +541,7 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
|||||||
g_variant_get (reply, "(u)", &rval);
|
g_variant_get (reply, "(u)", &rval);
|
||||||
g_variant_unref (reply);
|
g_variant_unref (reply);
|
||||||
|
|
||||||
/* DBUS_REQUEST_NAME_REPLY_EXISTS: 3 */
|
impl->primary = (rval != DBUS_REQUEST_NAME_REPLY_EXISTS);
|
||||||
impl->primary = (rval != 3);
|
|
||||||
|
|
||||||
if (!impl->primary && impl->name_lost_signal)
|
if (!impl->primary && impl->name_lost_signal)
|
||||||
{
|
{
|
||||||
@ -599,8 +599,8 @@ g_application_impl_stop_primary (GApplicationImpl *impl)
|
|||||||
|
|
||||||
if (impl->primary && impl->bus_name)
|
if (impl->primary && impl->bus_name)
|
||||||
{
|
{
|
||||||
g_dbus_connection_call (impl->session_bus, "org.freedesktop.DBus",
|
g_dbus_connection_call (impl->session_bus, DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", "org.freedesktop.DBus",
|
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
|
||||||
"ReleaseName", g_variant_new ("(s)", impl->bus_name),
|
"ReleaseName", g_variant_new ("(s)", impl->bus_name),
|
||||||
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
|
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
|
||||||
impl->primary = FALSE;
|
impl->primary = FALSE;
|
||||||
|
@ -37,9 +37,10 @@
|
|||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#include "glib/glib-private.h"
|
#include "glib/glib-private.h"
|
||||||
#include "gdbusprivate.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Escape values for console colors */
|
/* Escape values for console colors */
|
||||||
@ -191,7 +192,7 @@ print_methods_and_signals (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
"Introspect",
|
"Introspect",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -263,7 +264,7 @@ print_paths (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
"Introspect",
|
"Introspect",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -332,9 +333,9 @@ print_names (GDBusConnection *c,
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"ListNames",
|
"ListNames",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(as)"),
|
G_VARIANT_TYPE ("(as)"),
|
||||||
@ -356,9 +357,9 @@ print_names (GDBusConnection *c,
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"ListActivatableNames",
|
"ListActivatableNames",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(as)"),
|
G_VARIANT_TYPE ("(as)"),
|
||||||
@ -501,7 +502,7 @@ call_helper_get_method_in_signature (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
dest,
|
dest,
|
||||||
path,
|
path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
"Introspect",
|
"Introspect",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -1500,7 +1501,7 @@ dump_interface (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
name,
|
name,
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"GetAll",
|
"GetAll",
|
||||||
g_variant_new ("(s)", o->name),
|
g_variant_new ("(s)", o->name),
|
||||||
NULL,
|
NULL,
|
||||||
@ -1538,7 +1539,7 @@ dump_interface (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
name,
|
name,
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"Get",
|
"Get",
|
||||||
g_variant_new ("(ss)", o->name, o->properties[n]->name),
|
g_variant_new ("(ss)", o->name, o->properties[n]->name),
|
||||||
G_VARIANT_TYPE ("(v)"),
|
G_VARIANT_TYPE ("(v)"),
|
||||||
@ -1720,7 +1721,7 @@ introspect_do (GDBusConnection *c,
|
|||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
opt_introspect_dest,
|
opt_introspect_dest,
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
"Introspect",
|
"Introspect",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
|
@ -482,7 +482,7 @@ struct _GDBusConnection
|
|||||||
GMutex init_lock;
|
GMutex init_lock;
|
||||||
|
|
||||||
/* Set (by loading the contents of /var/lib/dbus/machine-id) the first time
|
/* 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;
|
gchar *machine_id;
|
||||||
|
|
||||||
@ -2418,7 +2418,7 @@ name_watcher_deliver_get_name_owner_reply_unlocked (SignalData *name_watcher,
|
|||||||
if (type == G_DBUS_MESSAGE_TYPE_ERROR)
|
if (type == G_DBUS_MESSAGE_TYPE_ERROR)
|
||||||
{
|
{
|
||||||
if (g_strcmp0 (g_dbus_message_get_error_name (message),
|
if (g_strcmp0 (g_dbus_message_get_error_name (message),
|
||||||
"org.freedesktop.DBus.Error.NameHasNoOwner"))
|
DBUS_ERROR_NAME_HAS_NO_OWNER))
|
||||||
name_watcher_set_name_owner_unlocked (name_watcher, NULL);
|
name_watcher_set_name_owner_unlocked (name_watcher, NULL);
|
||||||
/* else it's something like NoReply or AccessDenied, which tells
|
/* else it's something like NoReply or AccessDenied, which tells
|
||||||
* us nothing - leave the owner set to whatever we most recently
|
* us nothing - leave the owner set to whatever we most recently
|
||||||
@ -2972,9 +2972,9 @@ initable_init (GInitable *initable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hello_result = g_dbus_connection_call_sync (connection,
|
hello_result = g_dbus_connection_call_sync (connection,
|
||||||
"org.freedesktop.DBus", /* name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"Hello",
|
"Hello",
|
||||||
NULL, /* parameters */
|
NULL, /* parameters */
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -3655,9 +3655,9 @@ add_match_rule (GDBusConnection *connection,
|
|||||||
if (match_rule[0] == '-')
|
if (match_rule[0] == '-')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
message = g_dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"AddMatch");
|
"AddMatch");
|
||||||
g_dbus_message_set_body (message, g_variant_new ("(s)", match_rule));
|
g_dbus_message_set_body (message, g_variant_new ("(s)", match_rule));
|
||||||
error = NULL;
|
error = NULL;
|
||||||
@ -3686,9 +3686,9 @@ remove_match_rule (GDBusConnection *connection,
|
|||||||
if (match_rule[0] == '-')
|
if (match_rule[0] == '-')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
message = g_dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"RemoveMatch");
|
"RemoveMatch");
|
||||||
g_dbus_message_set_body (message, g_variant_new ("(s)", match_rule));
|
g_dbus_message_set_body (message, g_variant_new ("(s)", match_rule));
|
||||||
|
|
||||||
@ -3714,9 +3714,9 @@ remove_match_rule (GDBusConnection *connection,
|
|||||||
static gboolean
|
static gboolean
|
||||||
is_signal_data_for_name_lost_or_acquired (SignalData *signal_data)
|
is_signal_data_for_name_lost_or_acquired (SignalData *signal_data)
|
||||||
{
|
{
|
||||||
return g_strcmp0 (signal_data->sender, "org.freedesktop.DBus") == 0 &&
|
return g_strcmp0 (signal_data->sender, DBUS_SERVICE_DBUS) == 0 &&
|
||||||
g_strcmp0 (signal_data->interface_name, "org.freedesktop.DBus") == 0 &&
|
g_strcmp0 (signal_data->interface_name, DBUS_INTERFACE_DBUS) == 0 &&
|
||||||
g_strcmp0 (signal_data->object_path, "/org/freedesktop/DBus") == 0 &&
|
g_strcmp0 (signal_data->object_path, DBUS_PATH_DBUS) == 0 &&
|
||||||
(g_strcmp0 (signal_data->member, "NameLost") == 0 ||
|
(g_strcmp0 (signal_data->member, "NameLost") == 0 ||
|
||||||
g_strcmp0 (signal_data->member, "NameAcquired") == 0);
|
g_strcmp0 (signal_data->member, "NameAcquired") == 0);
|
||||||
}
|
}
|
||||||
@ -3885,7 +3885,7 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection,
|
|||||||
*/
|
*/
|
||||||
rule = args_to_rule (sender, interface_name, member, object_path, arg0, flags);
|
rule = args_to_rule (sender, interface_name, member, object_path, arg0, flags);
|
||||||
|
|
||||||
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, "org.freedesktop.DBus") == 0))
|
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, DBUS_SERVICE_DBUS) == 0))
|
||||||
sender_is_its_own_owner = TRUE;
|
sender_is_its_own_owner = TRUE;
|
||||||
else
|
else
|
||||||
sender_is_its_own_owner = FALSE;
|
sender_is_its_own_owner = FALSE;
|
||||||
@ -4715,7 +4715,7 @@ invoke_get_property_in_idle_cb (gpointer _data)
|
|||||||
&es))
|
&es))
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (data->message,
|
reply = g_dbus_message_new_method_error (data->message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"),
|
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"),
|
||||||
g_dbus_message_get_path (data->message));
|
g_dbus_message_get_path (data->message));
|
||||||
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -4851,7 +4851,7 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
|
|||||||
if (vtable == NULL)
|
if (vtable == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Check that the property exists - if not fail with org.freedesktop.DBus.Error.InvalidArgs
|
/* Check that the property exists - if not fail with DBUS_ERROR_INVALID_ARGS
|
||||||
*/
|
*/
|
||||||
property_info = NULL;
|
property_info = NULL;
|
||||||
|
|
||||||
@ -4860,7 +4860,7 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
|
|||||||
if (property_info == NULL)
|
if (property_info == NULL)
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("No such property “%s”"),
|
_("No such property “%s”"),
|
||||||
property_name);
|
property_name);
|
||||||
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -4872,7 +4872,7 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
|
|||||||
if (is_get && !(property_info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE))
|
if (is_get && !(property_info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE))
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("Property “%s” is not readable"),
|
_("Property “%s” is not readable"),
|
||||||
property_name);
|
property_name);
|
||||||
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -4883,7 +4883,7 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
|
|||||||
else if (!is_get && !(property_info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE))
|
else if (!is_get && !(property_info->flags & G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE))
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("Property “%s” is not writable"),
|
_("Property “%s” is not writable"),
|
||||||
property_name);
|
property_name);
|
||||||
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -4896,14 +4896,14 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
|
|||||||
{
|
{
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
|
|
||||||
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if the type
|
/* Fail with DBUS_ERROR_INVALID_ARGS if the type
|
||||||
* of the given value is wrong
|
* of the given value is wrong
|
||||||
*/
|
*/
|
||||||
g_variant_get_child (g_dbus_message_get_body (message), 2, "v", &value);
|
g_variant_get_child (g_dbus_message_get_body (message), 2, "v", &value);
|
||||||
if (g_strcmp0 (g_variant_get_type_string (value), property_info->signature) != 0)
|
if (g_strcmp0 (g_variant_get_type_string (value), property_info->signature) != 0)
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("Error setting property “%s”: Expected type “%s” but got “%s”"),
|
_("Error setting property “%s”: Expected type “%s” but got “%s”"),
|
||||||
property_name, property_info->signature,
|
property_name, property_info->signature,
|
||||||
g_variant_get_type_string (value));
|
g_variant_get_type_string (value));
|
||||||
@ -5000,7 +5000,7 @@ handle_getset_property (GDBusConnection *connection,
|
|||||||
&property_name,
|
&property_name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is
|
/* Fail with DBUS_ERROR_INVALID_ARGS if there is
|
||||||
* no such interface registered
|
* no such interface registered
|
||||||
*/
|
*/
|
||||||
ei = g_hash_table_lookup (eo->map_if_name_to_ei, interface_name);
|
ei = g_hash_table_lookup (eo->map_if_name_to_ei, interface_name);
|
||||||
@ -5008,7 +5008,7 @@ handle_getset_property (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("No such interface “%s”"),
|
_("No such interface “%s”"),
|
||||||
interface_name);
|
interface_name);
|
||||||
g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -5069,7 +5069,7 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
|
|||||||
&es))
|
&es))
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (data->message,
|
reply = g_dbus_message_new_method_error (data->message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"),
|
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"),
|
||||||
g_dbus_message_get_path (data->message));
|
g_dbus_message_get_path (data->message));
|
||||||
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -5215,7 +5215,7 @@ handle_get_all_properties (GDBusConnection *connection,
|
|||||||
"(&s)",
|
"(&s)",
|
||||||
&interface_name);
|
&interface_name);
|
||||||
|
|
||||||
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is
|
/* Fail with DBUS_ERROR_INVALID_ARGS if there is
|
||||||
* no such interface registered
|
* no such interface registered
|
||||||
*/
|
*/
|
||||||
ei = g_hash_table_lookup (eo->map_if_name_to_ei, interface_name);
|
ei = g_hash_table_lookup (eo->map_if_name_to_ei, interface_name);
|
||||||
@ -5223,7 +5223,7 @@ handle_get_all_properties (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("No such interface “%s”"),
|
_("No such interface “%s”"),
|
||||||
interface_name);
|
interface_name);
|
||||||
g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -5256,7 +5256,7 @@ static const gchar introspect_tail[] =
|
|||||||
"</node>\n";
|
"</node>\n";
|
||||||
|
|
||||||
static const gchar introspect_properties_interface[] =
|
static const gchar introspect_properties_interface[] =
|
||||||
" <interface name=\"org.freedesktop.DBus.Properties\">\n"
|
" <interface name=\"" DBUS_INTERFACE_PROPERTIES "\">\n"
|
||||||
" <method name=\"Get\">\n"
|
" <method name=\"Get\">\n"
|
||||||
" <arg type=\"s\" name=\"interface_name\" direction=\"in\"/>\n"
|
" <arg type=\"s\" name=\"interface_name\" direction=\"in\"/>\n"
|
||||||
" <arg type=\"s\" name=\"property_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";
|
" </interface>\n";
|
||||||
|
|
||||||
static const gchar introspect_introspectable_interface[] =
|
static const gchar introspect_introspectable_interface[] =
|
||||||
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
|
" <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">\n"
|
||||||
" <method name=\"Introspect\">\n"
|
" <method name=\"Introspect\">\n"
|
||||||
" <arg type=\"s\" name=\"xml_data\" direction=\"out\"/>\n"
|
" <arg type=\"s\" name=\"xml_data\" direction=\"out\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
" <interface name=\"org.freedesktop.DBus.Peer\">\n"
|
" <interface name=\"" DBUS_INTERFACE_PEER "\">\n"
|
||||||
" <method name=\"Ping\"/>\n"
|
" <method name=\"Ping\"/>\n"
|
||||||
" <method name=\"GetMachineId\">\n"
|
" <method name=\"GetMachineId\">\n"
|
||||||
" <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n"
|
" <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n"
|
||||||
@ -5389,11 +5389,11 @@ handle_introspect (GDBusConnection *connection,
|
|||||||
sizeof (introspect_tail));
|
sizeof (introspect_tail));
|
||||||
introspect_append_header (s);
|
introspect_append_header (s);
|
||||||
if (!g_hash_table_lookup (eo->map_if_name_to_ei,
|
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);
|
g_string_append (s, introspect_properties_interface);
|
||||||
|
|
||||||
if (!g_hash_table_lookup (eo->map_if_name_to_ei,
|
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);
|
g_string_append (s, introspect_introspectable_interface);
|
||||||
|
|
||||||
/* then include the registered interfaces */
|
/* then include the registered interfaces */
|
||||||
@ -5439,7 +5439,7 @@ call_in_idle_cb (gpointer user_data)
|
|||||||
{
|
{
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
reply = g_dbus_message_new_method_error (g_dbus_method_invocation_get_message (invocation),
|
reply = g_dbus_message_new_method_error (g_dbus_method_invocation_get_message (invocation),
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("No such interface “%s” on object at path %s"),
|
_("No such interface “%s” on object at path %s"),
|
||||||
g_dbus_method_invocation_get_interface_name (invocation),
|
g_dbus_method_invocation_get_interface_name (invocation),
|
||||||
g_dbus_method_invocation_get_object_path (invocation));
|
g_dbus_method_invocation_get_object_path (invocation));
|
||||||
@ -5534,13 +5534,13 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection,
|
|||||||
/* TODO: the cost of this is O(n) - it might be worth caching the result */
|
/* TODO: the cost of this is O(n) - it might be worth caching the result */
|
||||||
method_info = g_dbus_interface_info_lookup_method (interface_info, g_dbus_message_get_member (message));
|
method_info = g_dbus_interface_info_lookup_method (interface_info, g_dbus_message_get_member (message));
|
||||||
|
|
||||||
/* if the method doesn't exist, return the org.freedesktop.DBus.Error.UnknownMethod
|
/* if the method doesn't exist, return the DBUS_ERROR_UNKNOWN_METHOD
|
||||||
* error to the caller
|
* error to the caller
|
||||||
*/
|
*/
|
||||||
if (method_info == NULL)
|
if (method_info == NULL)
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("No such method “%s”"),
|
_("No such method “%s”"),
|
||||||
g_dbus_message_get_member (message));
|
g_dbus_message_get_member (message));
|
||||||
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -5561,7 +5561,7 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the incoming args are of the right type - if they are not, return
|
/* 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
|
* the DBUS_ERROR_INVALID_ARGS error to the caller
|
||||||
*/
|
*/
|
||||||
in_type = _g_dbus_compute_complete_signature (method_info->in_args);
|
in_type = _g_dbus_compute_complete_signature (method_info->in_args);
|
||||||
if (!g_variant_is_of_type (parameters, in_type))
|
if (!g_variant_is_of_type (parameters, in_type))
|
||||||
@ -5571,7 +5571,7 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection,
|
|||||||
type_string = g_variant_type_dup_string (in_type);
|
type_string = g_variant_type_dup_string (in_type);
|
||||||
|
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("Type of message, “%s”, does not match expected type “%s”"),
|
_("Type of message, “%s”, does not match expected type “%s”"),
|
||||||
g_variant_get_type_string (parameters),
|
g_variant_get_type_string (parameters),
|
||||||
type_string);
|
type_string);
|
||||||
@ -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 (member, "Introspect") == 0 &&
|
||||||
g_strcmp0 (signature, "") == 0)
|
g_strcmp0 (signature, "") == 0)
|
||||||
{
|
{
|
||||||
handled = handle_introspect (connection, eo, message);
|
handled = handle_introspect (connection, eo, message);
|
||||||
goto out;
|
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 (member, "Get") == 0 &&
|
||||||
g_strcmp0 (signature, "ss") == 0)
|
g_strcmp0 (signature, "ss") == 0)
|
||||||
{
|
{
|
||||||
handled = handle_getset_property (connection, eo, message, TRUE);
|
handled = handle_getset_property (connection, eo, message, TRUE);
|
||||||
goto out;
|
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 (member, "Set") == 0 &&
|
||||||
g_strcmp0 (signature, "ssv") == 0)
|
g_strcmp0 (signature, "ssv") == 0)
|
||||||
{
|
{
|
||||||
handled = handle_getset_property (connection, eo, message, FALSE);
|
handled = handle_getset_property (connection, eo, message, FALSE);
|
||||||
goto out;
|
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 (member, "GetAll") == 0 &&
|
||||||
g_strcmp0 (signature, "s") == 0)
|
g_strcmp0 (signature, "s") == 0)
|
||||||
{
|
{
|
||||||
@ -7011,9 +7011,9 @@ handle_subtree_introspect (GDBusConnection *connection,
|
|||||||
|
|
||||||
for (n = 0; interfaces[n] != NULL; n++)
|
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;
|
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;
|
has_introspectable_interface = TRUE;
|
||||||
}
|
}
|
||||||
if (!has_properties_interface)
|
if (!has_properties_interface)
|
||||||
@ -7095,7 +7095,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
|
|||||||
is_property_get = FALSE;
|
is_property_get = FALSE;
|
||||||
is_property_set = FALSE;
|
is_property_set = FALSE;
|
||||||
is_property_get_all = 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)
|
if (g_strcmp0 (member, "Get") == 0 && g_strcmp0 (signature, "ss") == 0)
|
||||||
is_property_get = TRUE;
|
is_property_get = TRUE;
|
||||||
@ -7177,7 +7177,7 @@ handle_subtree_method_invocation (GDBusConnection *connection,
|
|||||||
interface_user_data);
|
interface_user_data);
|
||||||
CONNECTION_UNLOCK (connection);
|
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)
|
else if (is_property_get || is_property_set || is_property_get_all)
|
||||||
{
|
{
|
||||||
if (is_property_get)
|
if (is_property_get)
|
||||||
@ -7196,14 +7196,14 @@ handle_subtree_method_invocation (GDBusConnection *connection,
|
|||||||
interface_info = interfaces[n];
|
interface_info = interfaces[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if the user-code
|
/* Fail with DBUS_ERROR_INVALID_ARGS if the user-code
|
||||||
* claims it won't support the interface
|
* claims it won't support the interface
|
||||||
*/
|
*/
|
||||||
if (interface_info == NULL)
|
if (interface_info == NULL)
|
||||||
{
|
{
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.InvalidArgs",
|
DBUS_ERROR_INVALID_ARGS,
|
||||||
_("No such interface “%s”"),
|
_("No such interface “%s”"),
|
||||||
interface_name);
|
interface_name);
|
||||||
g_dbus_connection_send_message (es->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
g_dbus_connection_send_message (es->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
|
||||||
@ -7292,7 +7292,7 @@ process_subtree_vtable_message_in_idle_cb (gpointer _data)
|
|||||||
|
|
||||||
handled = FALSE;
|
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_member (data->message), "Introspect") == 0 &&
|
||||||
g_strcmp0 (g_dbus_message_get_signature (data->message), "") == 0)
|
g_strcmp0 (g_dbus_message_get_signature (data->message), "") == 0)
|
||||||
handled = handle_subtree_introspect (data->es->connection,
|
handled = handle_subtree_introspect (data->es->connection,
|
||||||
@ -7315,7 +7315,7 @@ process_subtree_vtable_message_in_idle_cb (gpointer _data)
|
|||||||
{
|
{
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
reply = g_dbus_message_new_method_error (data->message,
|
reply = g_dbus_message_new_method_error (data->message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("Method “%s” on interface “%s” with signature “%s” does not exist"),
|
_("Method “%s” on interface “%s” with signature “%s” does not exist"),
|
||||||
g_dbus_message_get_member (data->message),
|
g_dbus_message_get_member (data->message),
|
||||||
g_dbus_message_get_interface (data->message),
|
g_dbus_message_get_interface (data->message),
|
||||||
@ -7546,7 +7546,7 @@ handle_generic_get_machine_id_unlocked (GDBusConnection *connection,
|
|||||||
if (connection->machine_id == NULL)
|
if (connection->machine_id == NULL)
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error_literal (message,
|
reply = g_dbus_message_new_method_error_literal (message,
|
||||||
"org.freedesktop.DBus.Error.Failed",
|
DBUS_ERROR_FAILED,
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
@ -7609,21 +7609,21 @@ handle_generic_unlocked (GDBusConnection *connection,
|
|||||||
signature = g_dbus_message_get_signature (message);
|
signature = g_dbus_message_get_signature (message);
|
||||||
path = g_dbus_message_get_path (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 (member, "Introspect") == 0 &&
|
||||||
g_strcmp0 (signature, "") == 0)
|
g_strcmp0 (signature, "") == 0)
|
||||||
{
|
{
|
||||||
handle_generic_introspect_unlocked (connection, path, message);
|
handle_generic_introspect_unlocked (connection, path, message);
|
||||||
handled = TRUE;
|
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 (member, "Ping") == 0 &&
|
||||||
g_strcmp0 (signature, "") == 0)
|
g_strcmp0 (signature, "") == 0)
|
||||||
{
|
{
|
||||||
handle_generic_ping_unlocked (connection, path, message);
|
handle_generic_ping_unlocked (connection, path, message);
|
||||||
handled = TRUE;
|
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 (member, "GetMachineId") == 0 &&
|
||||||
g_strcmp0 (signature, "") == 0)
|
g_strcmp0 (signature, "") == 0)
|
||||||
{
|
{
|
||||||
@ -7723,7 +7723,7 @@ distribute_method_call (GDBusConnection *connection,
|
|||||||
if (object_found == TRUE)
|
if (object_found == TRUE)
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("No such interface “%s” on object at path %s"),
|
_("No such interface “%s” on object at path %s"),
|
||||||
interface_name,
|
interface_name,
|
||||||
path);
|
path);
|
||||||
@ -7731,7 +7731,7 @@ distribute_method_call (GDBusConnection *connection,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
reply = g_dbus_message_new_method_error (message,
|
reply = g_dbus_message_new_method_error (message,
|
||||||
"org.freedesktop.DBus.Error.UnknownMethod",
|
DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
_("Object does not exist at path “%s”"),
|
_("Object does not exist at path “%s”"),
|
||||||
path);
|
path);
|
||||||
}
|
}
|
||||||
|
@ -28,32 +28,11 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gio/gunixsocketaddress.h>
|
#include <gio/gunixsocketaddress.h>
|
||||||
#include "gdbusdaemon.h"
|
#include "gdbusdaemon.h"
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
#include "gdbus-daemon-generated.h"
|
#include "gdbus-daemon-generated.h"
|
||||||
|
|
||||||
#define DBUS_SERVICE_NAME "org.freedesktop.DBus"
|
|
||||||
|
|
||||||
/* 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 */
|
|
||||||
#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0x4 /**< If we can not become the primary owner do not place us in the queue */
|
|
||||||
|
|
||||||
/* Replies to request for a name */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 /**< Service has become the primary owner of the requested name */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2 /**< Service could not become the primary owner and has been placed in the queue */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_EXISTS 3 /**< Service is already in the queue */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 /**< Service is already the primary owner */
|
|
||||||
|
|
||||||
/* Replies to releasing a name */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 /**< Service was released from the given name */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */
|
|
||||||
#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */
|
|
||||||
|
|
||||||
/* Replies to service starts */
|
|
||||||
#define DBUS_START_REPLY_SUCCESS 1 /**< Service was auto started */
|
|
||||||
#define DBUS_START_REPLY_ALREADY_RUNNING 2 /**< Service was already running */
|
|
||||||
|
|
||||||
#define IDLE_TIMEOUT_MSEC 3000
|
#define IDLE_TIMEOUT_MSEC 3000
|
||||||
|
|
||||||
struct _GDBusDaemon
|
struct _GDBusDaemon
|
||||||
@ -576,7 +555,7 @@ match_matches (GDBusDaemon *daemon,
|
|||||||
check_type = CHECK_TYPE_NAME;
|
check_type = CHECK_TYPE_NAME;
|
||||||
value = g_dbus_message_get_sender (message);
|
value = g_dbus_message_get_sender (message);
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
value = DBUS_SERVICE_NAME;
|
value = DBUS_SERVICE_DBUS;
|
||||||
break;
|
break;
|
||||||
case MATCH_ELEMENT_DESTINATION:
|
case MATCH_ELEMENT_DESTINATION:
|
||||||
check_type = CHECK_TYPE_NAME;
|
check_type = CHECK_TYPE_NAME;
|
||||||
@ -718,8 +697,8 @@ send_name_owner_changed (GDBusDaemon *daemon,
|
|||||||
{
|
{
|
||||||
GDBusMessage *signal_message;
|
GDBusMessage *signal_message;
|
||||||
|
|
||||||
signal_message = g_dbus_message_new_signal ("/org/freedesktop/DBus",
|
signal_message = g_dbus_message_new_signal (DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged");
|
"NameOwnerChanged");
|
||||||
g_dbus_message_set_body (signal_message,
|
g_dbus_message_set_body (signal_message,
|
||||||
g_variant_new ("(sss)",
|
g_variant_new ("(sss)",
|
||||||
@ -774,8 +753,8 @@ name_replace_owner (Name *name, NameOwner *owner)
|
|||||||
g_assert (old_owner->client != new_client);
|
g_assert (old_owner->client != new_client);
|
||||||
|
|
||||||
g_dbus_connection_emit_signal (old_client->connection,
|
g_dbus_connection_emit_signal (old_client->connection,
|
||||||
NULL, "/org/freedesktop/DBus",
|
NULL, DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", "NameLost",
|
DBUS_INTERFACE_DBUS, "NameLost",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
name->name), NULL);
|
name->name), NULL);
|
||||||
|
|
||||||
@ -797,8 +776,8 @@ name_replace_owner (Name *name, NameOwner *owner)
|
|||||||
new_name = new_client->id;
|
new_name = new_client->id;
|
||||||
|
|
||||||
g_dbus_connection_emit_signal (new_client->connection,
|
g_dbus_connection_emit_signal (new_client->connection,
|
||||||
NULL, "/org/freedesktop/DBus",
|
NULL, DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", "NameAcquired",
|
DBUS_INTERFACE_DBUS, "NameAcquired",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
name->name), NULL);
|
name->name), NULL);
|
||||||
}
|
}
|
||||||
@ -875,7 +854,7 @@ client_new (GDBusDaemon *daemon, GDBusConnection *connection)
|
|||||||
g_hash_table_insert (daemon->clients, client->id, client);
|
g_hash_table_insert (daemon->clients, client->id, client);
|
||||||
|
|
||||||
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (daemon), connection,
|
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (daemon), connection,
|
||||||
"/org/freedesktop/DBus", &error);
|
DBUS_PATH_DBUS, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
|
||||||
g_signal_connect (connection, "closed", G_CALLBACK (connection_closed), client);
|
g_signal_connect (connection, "closed", G_CALLBACK (connection_closed), client);
|
||||||
@ -1035,9 +1014,9 @@ handle_get_name_owner (_GFreedesktopDBus *object,
|
|||||||
GDBusDaemon *daemon = G_DBUS_DAEMON (object);
|
GDBusDaemon *daemon = G_DBUS_DAEMON (object);
|
||||||
Name *name;
|
Name *name;
|
||||||
|
|
||||||
if (strcmp (arg_name, DBUS_SERVICE_NAME) == 0)
|
if (strcmp (arg_name, DBUS_SERVICE_DBUS) == 0)
|
||||||
{
|
{
|
||||||
_g_freedesktop_dbus_complete_get_name_owner (object, invocation, DBUS_SERVICE_NAME);
|
_g_freedesktop_dbus_complete_get_name_owner (object, invocation, DBUS_SERVICE_DBUS);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,8 +1052,8 @@ handle_hello (_GFreedesktopDBus *object,
|
|||||||
_g_freedesktop_dbus_complete_hello (object, invocation, client->id);
|
_g_freedesktop_dbus_complete_hello (object, invocation, client->id);
|
||||||
|
|
||||||
g_dbus_connection_emit_signal (client->connection,
|
g_dbus_connection_emit_signal (client->connection,
|
||||||
NULL, "/org/freedesktop/DBus",
|
NULL, DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", "NameAcquired",
|
DBUS_INTERFACE_DBUS, "NameAcquired",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
client->id), NULL);
|
client->id), NULL);
|
||||||
|
|
||||||
@ -1191,11 +1170,11 @@ handle_release_name (_GFreedesktopDBus *object,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (arg_name, DBUS_SERVICE_NAME) == 0)
|
if (strcmp (arg_name, DBUS_SERVICE_DBUS) == 0)
|
||||||
{
|
{
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||||
"Cannot release a service named " DBUS_SERVICE_NAME ", because that is owned by the bus");
|
"Cannot release a service named " DBUS_SERVICE_DBUS ", because that is owned by the bus");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1305,11 +1284,11 @@ handle_request_name (_GFreedesktopDBus *object,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (arg_name, DBUS_SERVICE_NAME) == 0)
|
if (strcmp (arg_name, DBUS_SERVICE_DBUS) == 0)
|
||||||
{
|
{
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||||
"Cannot acquire a service named " DBUS_SERVICE_NAME ", because that is reserved");
|
"Cannot acquire a service named " DBUS_SERVICE_DBUS ", because that is reserved");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1425,7 +1404,7 @@ route_message (Client *source_client, GDBusMessage *message)
|
|||||||
|
|
||||||
dest_client = NULL;
|
dest_client = NULL;
|
||||||
dest = g_dbus_message_get_destination (message);
|
dest = g_dbus_message_get_destination (message);
|
||||||
if (dest != NULL && strcmp (dest, DBUS_SERVICE_NAME) != 0)
|
if (dest != NULL && strcmp (dest, DBUS_SERVICE_DBUS) != 0)
|
||||||
{
|
{
|
||||||
dest_client = g_hash_table_lookup (daemon->clients, dest);
|
dest_client = g_hash_table_lookup (daemon->clients, dest);
|
||||||
|
|
||||||
@ -1459,7 +1438,7 @@ route_message (Client *source_client, GDBusMessage *message)
|
|||||||
broadcast_message (daemon, message, dest_client != NULL, TRUE, dest_client);
|
broadcast_message (daemon, message, dest_client != NULL, TRUE, dest_client);
|
||||||
|
|
||||||
/* Swallow messages not for the bus */
|
/* Swallow messages not for the bus */
|
||||||
if (dest == NULL || strcmp (dest, DBUS_SERVICE_NAME) != 0)
|
if (dest == NULL || strcmp (dest, DBUS_SERVICE_DBUS) != 0)
|
||||||
{
|
{
|
||||||
g_object_unref (message);
|
g_object_unref (message);
|
||||||
message = NULL;
|
message = NULL;
|
||||||
@ -1531,7 +1510,7 @@ filter_function (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_dbus_message_get_sender (message) == NULL)
|
if (g_dbus_message_get_sender (message) == NULL)
|
||||||
g_dbus_message_set_sender (message, DBUS_SERVICE_NAME);
|
g_dbus_message_set_sender (message, DBUS_SERVICE_DBUS);
|
||||||
if (g_dbus_message_get_destination (message) == NULL)
|
if (g_dbus_message_get_destination (message) == NULL)
|
||||||
g_dbus_message_set_destination (message, client->id);
|
g_dbus_message_set_destination (message, client->id);
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
|
|
||||||
static const GDBusErrorEntry g_dbus_error_entries[] =
|
static const GDBusErrorEntry g_dbus_error_entries[] =
|
||||||
{
|
{
|
||||||
{G_DBUS_ERROR_FAILED, "org.freedesktop.DBus.Error.Failed"},
|
{G_DBUS_ERROR_FAILED, DBUS_ERROR_FAILED},
|
||||||
{G_DBUS_ERROR_NO_MEMORY, "org.freedesktop.DBus.Error.NoMemory"},
|
{G_DBUS_ERROR_NO_MEMORY, "org.freedesktop.DBus.Error.NoMemory"},
|
||||||
{G_DBUS_ERROR_SERVICE_UNKNOWN, "org.freedesktop.DBus.Error.ServiceUnknown"},
|
{G_DBUS_ERROR_SERVICE_UNKNOWN, "org.freedesktop.DBus.Error.ServiceUnknown"},
|
||||||
{G_DBUS_ERROR_NAME_HAS_NO_OWNER, "org.freedesktop.DBus.Error.NameHasNoOwner"},
|
{G_DBUS_ERROR_NAME_HAS_NO_OWNER, DBUS_ERROR_NAME_HAS_NO_OWNER},
|
||||||
{G_DBUS_ERROR_NO_REPLY, "org.freedesktop.DBus.Error.NoReply"},
|
{G_DBUS_ERROR_NO_REPLY, "org.freedesktop.DBus.Error.NoReply"},
|
||||||
{G_DBUS_ERROR_IO_ERROR, "org.freedesktop.DBus.Error.IOError"},
|
{G_DBUS_ERROR_IO_ERROR, "org.freedesktop.DBus.Error.IOError"},
|
||||||
{G_DBUS_ERROR_BAD_ADDRESS, "org.freedesktop.DBus.Error.BadAddress"},
|
{G_DBUS_ERROR_BAD_ADDRESS, "org.freedesktop.DBus.Error.BadAddress"},
|
||||||
@ -51,10 +51,10 @@ static const GDBusErrorEntry g_dbus_error_entries[] =
|
|||||||
{G_DBUS_ERROR_NO_NETWORK, "org.freedesktop.DBus.Error.NoNetwork"},
|
{G_DBUS_ERROR_NO_NETWORK, "org.freedesktop.DBus.Error.NoNetwork"},
|
||||||
{G_DBUS_ERROR_ADDRESS_IN_USE, "org.freedesktop.DBus.Error.AddressInUse"},
|
{G_DBUS_ERROR_ADDRESS_IN_USE, "org.freedesktop.DBus.Error.AddressInUse"},
|
||||||
{G_DBUS_ERROR_DISCONNECTED, "org.freedesktop.DBus.Error.Disconnected"},
|
{G_DBUS_ERROR_DISCONNECTED, "org.freedesktop.DBus.Error.Disconnected"},
|
||||||
{G_DBUS_ERROR_INVALID_ARGS, "org.freedesktop.DBus.Error.InvalidArgs"},
|
{G_DBUS_ERROR_INVALID_ARGS, DBUS_ERROR_INVALID_ARGS},
|
||||||
{G_DBUS_ERROR_FILE_NOT_FOUND, "org.freedesktop.DBus.Error.FileNotFound"},
|
{G_DBUS_ERROR_FILE_NOT_FOUND, "org.freedesktop.DBus.Error.FileNotFound"},
|
||||||
{G_DBUS_ERROR_FILE_EXISTS, "org.freedesktop.DBus.Error.FileExists"},
|
{G_DBUS_ERROR_FILE_EXISTS, "org.freedesktop.DBus.Error.FileExists"},
|
||||||
{G_DBUS_ERROR_UNKNOWN_METHOD, "org.freedesktop.DBus.Error.UnknownMethod"},
|
{G_DBUS_ERROR_UNKNOWN_METHOD, DBUS_ERROR_UNKNOWN_METHOD},
|
||||||
{G_DBUS_ERROR_TIMED_OUT, "org.freedesktop.DBus.Error.TimedOut"},
|
{G_DBUS_ERROR_TIMED_OUT, "org.freedesktop.DBus.Error.TimedOut"},
|
||||||
{G_DBUS_ERROR_MATCH_RULE_NOT_FOUND, "org.freedesktop.DBus.Error.MatchRuleNotFound"},
|
{G_DBUS_ERROR_MATCH_RULE_NOT_FOUND, "org.freedesktop.DBus.Error.MatchRuleNotFound"},
|
||||||
{G_DBUS_ERROR_MATCH_RULE_INVALID, "org.freedesktop.DBus.Error.MatchRuleInvalid"},
|
{G_DBUS_ERROR_MATCH_RULE_INVALID, "org.freedesktop.DBus.Error.MatchRuleInvalid"},
|
||||||
|
@ -1416,7 +1416,7 @@ validate_headers (GDBusMessage *message,
|
|||||||
case G_DBUS_MESSAGE_HEADER_FIELD_PATH:
|
case G_DBUS_MESSAGE_HEADER_FIELD_PATH:
|
||||||
if (!validate_header (message, field_type, header_value, G_VARIANT_TYPE_OBJECT_PATH, error))
|
if (!validate_header (message, field_type, header_value, G_VARIANT_TYPE_OBJECT_PATH, error))
|
||||||
goto out;
|
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_set_error (error,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
@ -1438,7 +1438,7 @@ validate_headers (GDBusMessage *message,
|
|||||||
message_type_to_string (message->type));
|
message_type_to_string (message->type));
|
||||||
goto out;
|
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_set_error (error,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
|
@ -464,7 +464,7 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
|
|||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
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"))
|
g_str_equal (invocation->method_name, "GetAll"))
|
||||||
{
|
{
|
||||||
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})")))
|
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})")))
|
||||||
|
@ -258,9 +258,9 @@ on_name_lost_or_acquired (GDBusConnection *connection,
|
|||||||
Client *client = user_data;
|
Client *client = user_data;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
|
||||||
if (g_strcmp0 (object_path, "/org/freedesktop/DBus") != 0 ||
|
if (g_strcmp0 (object_path, DBUS_PATH_DBUS) != 0 ||
|
||||||
g_strcmp0 (interface_name, "org.freedesktop.DBus") != 0 ||
|
g_strcmp0 (interface_name, DBUS_INTERFACE_DBUS) != 0 ||
|
||||||
g_strcmp0 (sender_name, "org.freedesktop.DBus") != 0)
|
g_strcmp0 (sender_name, DBUS_SERVICE_DBUS) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
|
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
|
||||||
@ -319,20 +319,20 @@ request_name_cb (GObject *source_object,
|
|||||||
|
|
||||||
switch (request_name_reply)
|
switch (request_name_reply)
|
||||||
{
|
{
|
||||||
case 1: /* DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER */
|
case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
|
||||||
/* We got the name - now listen for NameLost and NameAcquired */
|
/* We got the name - now listen for NameLost and NameAcquired */
|
||||||
call_acquired_handler (client);
|
call_acquired_handler (client);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* DBUS_REQUEST_NAME_REPLY_IN_QUEUE */
|
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
|
||||||
/* Waiting in line - listen for NameLost and NameAcquired */
|
/* Waiting in line - listen for NameLost and NameAcquired */
|
||||||
call_lost_handler (client);
|
call_lost_handler (client);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* assume we couldn't get the name - explicit fallthrough */
|
/* assume we couldn't get the name - explicit fallthrough */
|
||||||
case 3: /* DBUS_REQUEST_NAME_REPLY_EXISTS */
|
case DBUS_REQUEST_NAME_REPLY_EXISTS:
|
||||||
case 4: /* DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER */
|
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
|
||||||
/* Some other part of the process is already owning the name */
|
/* Some other part of the process is already owning the name */
|
||||||
call_lost_handler (client);
|
call_lost_handler (client);
|
||||||
unsubscribe = TRUE;
|
unsubscribe = TRUE;
|
||||||
@ -419,10 +419,10 @@ has_connection (Client *client)
|
|||||||
* ensure that the user callbacks get called an appropriate number of times. */
|
* ensure that the user callbacks get called an appropriate number of times. */
|
||||||
client->name_lost_subscription_id =
|
client->name_lost_subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (client->connection,
|
g_dbus_connection_signal_subscribe (client->connection,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameLost",
|
"NameLost",
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
client->name,
|
client->name,
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
on_name_lost_or_acquired,
|
on_name_lost_or_acquired,
|
||||||
@ -430,10 +430,10 @@ has_connection (Client *client)
|
|||||||
(GDestroyNotify) client_unref);
|
(GDestroyNotify) client_unref);
|
||||||
client->name_acquired_subscription_id =
|
client->name_acquired_subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (client->connection,
|
g_dbus_connection_signal_subscribe (client->connection,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameAcquired",
|
"NameAcquired",
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
client->name,
|
client->name,
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
on_name_lost_or_acquired,
|
on_name_lost_or_acquired,
|
||||||
@ -443,9 +443,9 @@ has_connection (Client *client)
|
|||||||
/* attempt to acquire the name */
|
/* attempt to acquire the name */
|
||||||
client->needs_release = TRUE;
|
client->needs_release = TRUE;
|
||||||
g_dbus_connection_call (client->connection,
|
g_dbus_connection_call (client->connection,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"RequestName", /* method name */
|
"RequestName", /* method name */
|
||||||
g_variant_new ("(su)",
|
g_variant_new ("(su)",
|
||||||
client->name,
|
client->name,
|
||||||
@ -936,9 +936,9 @@ g_bus_unown_name (guint owner_id)
|
|||||||
*/
|
*/
|
||||||
error = NULL;
|
error = NULL;
|
||||||
result = g_dbus_connection_call_sync (client->connection,
|
result = g_dbus_connection_call_sync (client->connection,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"ReleaseName", /* method name */
|
"ReleaseName", /* method name */
|
||||||
g_variant_new ("(s)", client->name),
|
g_variant_new ("(s)", client->name),
|
||||||
G_VARIANT_TYPE ("(u)"),
|
G_VARIANT_TYPE ("(u)"),
|
||||||
@ -954,7 +954,7 @@ g_bus_unown_name (guint owner_id)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_variant_get (result, "(u)", &release_name_reply);
|
g_variant_get (result, "(u)", &release_name_reply);
|
||||||
if (release_name_reply != 1 /* DBUS_RELEASE_NAME_REPLY_RELEASED */)
|
if (release_name_reply != DBUS_RELEASE_NAME_REPLY_RELEASED)
|
||||||
{
|
{
|
||||||
g_warning ("Unexpected reply %d when releasing name %s", release_name_reply, client->name);
|
g_warning ("Unexpected reply %d when releasing name %s", release_name_reply, client->name);
|
||||||
}
|
}
|
||||||
|
@ -344,9 +344,9 @@ on_name_owner_changed (GDBusConnection *connection,
|
|||||||
if (!client->initialized)
|
if (!client->initialized)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (g_strcmp0 (object_path, "/org/freedesktop/DBus") != 0 ||
|
if (g_strcmp0 (object_path, DBUS_PATH_DBUS) != 0 ||
|
||||||
g_strcmp0 (interface_name, "org.freedesktop.DBus") != 0 ||
|
g_strcmp0 (interface_name, DBUS_INTERFACE_DBUS) != 0 ||
|
||||||
g_strcmp0 (sender_name, "org.freedesktop.DBus") != 0)
|
g_strcmp0 (sender_name, DBUS_SERVICE_DBUS) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_variant_get (parameters,
|
g_variant_get (parameters,
|
||||||
@ -424,9 +424,9 @@ static void
|
|||||||
invoke_get_name_owner (Client *client)
|
invoke_get_name_owner (Client *client)
|
||||||
{
|
{
|
||||||
g_dbus_connection_call (client->connection,
|
g_dbus_connection_call (client->connection,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetNameOwner", /* method name */
|
"GetNameOwner", /* method name */
|
||||||
g_variant_new ("(s)", client->name),
|
g_variant_new ("(s)", client->name),
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -457,11 +457,11 @@ start_service_by_name_cb (GObject *source_object,
|
|||||||
guint32 start_service_result;
|
guint32 start_service_result;
|
||||||
g_variant_get (result, "(u)", &start_service_result);
|
g_variant_get (result, "(u)", &start_service_result);
|
||||||
|
|
||||||
if (start_service_result == 1) /* DBUS_START_REPLY_SUCCESS */
|
if (start_service_result == DBUS_START_REPLY_SUCCESS)
|
||||||
{
|
{
|
||||||
invoke_get_name_owner (client);
|
invoke_get_name_owner (client);
|
||||||
}
|
}
|
||||||
else if (start_service_result == 2) /* DBUS_START_REPLY_ALREADY_RUNNING */
|
else if (start_service_result == DBUS_START_REPLY_ALREADY_RUNNING)
|
||||||
{
|
{
|
||||||
invoke_get_name_owner (client);
|
invoke_get_name_owner (client);
|
||||||
}
|
}
|
||||||
@ -504,10 +504,10 @@ has_connection (Client *client)
|
|||||||
|
|
||||||
/* start listening to NameOwnerChanged messages immediately */
|
/* start listening to NameOwnerChanged messages immediately */
|
||||||
client->name_owner_changed_subscription_id = g_dbus_connection_signal_subscribe (client->connection,
|
client->name_owner_changed_subscription_id = g_dbus_connection_signal_subscribe (client->connection,
|
||||||
"org.freedesktop.DBus", /* name */
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus", /* if */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged", /* signal */
|
"NameOwnerChanged", /* signal */
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
client->name,
|
client->name,
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
on_name_owner_changed,
|
on_name_owner_changed,
|
||||||
@ -517,9 +517,9 @@ has_connection (Client *client)
|
|||||||
if (client->flags & G_BUS_NAME_WATCHER_FLAGS_AUTO_START)
|
if (client->flags & G_BUS_NAME_WATCHER_FLAGS_AUTO_START)
|
||||||
{
|
{
|
||||||
g_dbus_connection_call (client->connection,
|
g_dbus_connection_call (client->connection,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"StartServiceByName", /* method name */
|
"StartServiceByName", /* method name */
|
||||||
g_variant_new ("(su)", client->name, 0),
|
g_variant_new ("(su)", client->name, 0),
|
||||||
G_VARIANT_TYPE ("(u)"),
|
G_VARIANT_TYPE ("(u)"),
|
||||||
|
@ -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_debug ("yay, signal_cb %s %s: %s\n", signal_name, object_path, g_variant_print (parameters, TRUE));
|
||||||
|
|
||||||
g_object_ref (manager);
|
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)
|
if (g_strcmp0 (signal_name, "PropertiesChanged") == 0)
|
||||||
{
|
{
|
||||||
@ -1145,9 +1145,9 @@ subscribe_signals (GDBusObjectManagerClient *manager,
|
|||||||
/* The bus daemon may not implement path_namespace so gracefully
|
/* The bus daemon may not implement path_namespace so gracefully
|
||||||
* handle this by using a fallback triggered if @error is set. */
|
* handle this by using a fallback triggered if @error is set. */
|
||||||
ret = g_dbus_connection_call_sync (manager->priv->connection,
|
ret = g_dbus_connection_call_sync (manager->priv->connection,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"AddMatch",
|
"AddMatch",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
manager->priv->match_rule),
|
manager->priv->match_rule),
|
||||||
@ -1230,9 +1230,9 @@ maybe_unsubscribe_signals (GDBusObjectManagerClient *manager)
|
|||||||
* fail - therefore, don't bother checking the return value
|
* fail - therefore, don't bother checking the return value
|
||||||
*/
|
*/
|
||||||
g_dbus_connection_call (manager->priv->connection,
|
g_dbus_connection_call (manager->priv->connection,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"RemoveMatch",
|
"RemoveMatch",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
manager->priv->match_rule),
|
manager->priv->match_rule),
|
||||||
@ -1419,7 +1419,7 @@ initable_init (GInitable *initable,
|
|||||||
NULL, /* GDBusInterfaceInfo* */
|
NULL, /* GDBusInterfaceInfo* */
|
||||||
manager->priv->name,
|
manager->priv->name,
|
||||||
manager->priv->object_path,
|
manager->priv->object_path,
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
cancellable,
|
cancellable,
|
||||||
error);
|
error);
|
||||||
if (manager->priv->control_proxy == NULL)
|
if (manager->priv->control_proxy == NULL)
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -841,7 +843,7 @@ static const GDBusMethodInfo * const manager_method_info_pointers[] =
|
|||||||
static const GDBusInterfaceInfo manager_interface_info =
|
static const GDBusInterfaceInfo manager_interface_info =
|
||||||
{
|
{
|
||||||
-1,
|
-1,
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
(GDBusMethodInfo **) manager_method_info_pointers,
|
(GDBusMethodInfo **) manager_method_info_pointers,
|
||||||
(GDBusSignalInfo **) manager_signal_info_pointers,
|
(GDBusSignalInfo **) manager_signal_info_pointers,
|
||||||
(GDBusPropertyInfo **) NULL,
|
(GDBusPropertyInfo **) NULL,
|
||||||
|
@ -32,6 +32,42 @@ G_BEGIN_DECLS
|
|||||||
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
||||||
#define DBUS_PATH_DBUS "/org/freedesktop/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"
|
||||||
|
|
||||||
|
/* 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"
|
||||||
|
|
||||||
|
/* Frequently-used D-Bus error names */
|
||||||
|
#define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed"
|
||||||
|
#define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs"
|
||||||
|
#define DBUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner"
|
||||||
|
#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod"
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0x4 /**< If we can not become the primary owner do not place us in the queue */
|
||||||
|
|
||||||
|
/* Replies to request for a name */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1 /**< Service has become the primary owner of the requested name */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2 /**< Service could not become the primary owner and has been placed in the queue */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_EXISTS 3 /**< Service is already in the queue */
|
||||||
|
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4 /**< Service is already the primary owner */
|
||||||
|
|
||||||
|
/* Replies to releasing a name */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_RELEASED 1 /**< Service was released from the given name */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */
|
||||||
|
#define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */
|
||||||
|
|
||||||
|
/* Replies to service starts */
|
||||||
|
#define DBUS_START_REPLY_SUCCESS 1 /**< Service was auto started */
|
||||||
|
#define DBUS_START_REPLY_ALREADY_RUNNING 2 /**< Service was already running */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct GDBusWorker GDBusWorker;
|
typedef struct GDBusWorker GDBusWorker;
|
||||||
|
@ -1058,7 +1058,7 @@ on_properties_changed (GDBusConnection *connection,
|
|||||||
g_dbus_connection_call (proxy->priv->connection,
|
g_dbus_connection_call (proxy->priv->connection,
|
||||||
proxy->priv->name_owner,
|
proxy->priv->name_owner,
|
||||||
proxy->priv->object_path,
|
proxy->priv->object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"Get",
|
"Get",
|
||||||
g_variant_new ("(ss)", proxy->priv->interface_name, data->prop_name),
|
g_variant_new ("(ss)", proxy->priv->interface_name, data->prop_name),
|
||||||
G_VARIANT_TYPE ("(v)"),
|
G_VARIANT_TYPE ("(v)"),
|
||||||
@ -1330,7 +1330,7 @@ on_name_owner_changed (GDBusConnection *connection,
|
|||||||
g_dbus_connection_call (proxy->priv->connection,
|
g_dbus_connection_call (proxy->priv->connection,
|
||||||
data->name_owner,
|
data->name_owner,
|
||||||
proxy->priv->object_path,
|
proxy->priv->object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"GetAll",
|
"GetAll",
|
||||||
g_variant_new ("(s)", proxy->priv->interface_name),
|
g_variant_new ("(s)", proxy->priv->interface_name),
|
||||||
G_VARIANT_TYPE ("(a{sv})"),
|
G_VARIANT_TYPE ("(a{sv})"),
|
||||||
@ -1424,7 +1424,7 @@ async_init_data_set_name_owner (GTask *task,
|
|||||||
g_dbus_connection_call (proxy->priv->connection,
|
g_dbus_connection_call (proxy->priv->connection,
|
||||||
name_owner,
|
name_owner,
|
||||||
proxy->priv->object_path,
|
proxy->priv->object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"GetAll",
|
"GetAll",
|
||||||
g_variant_new ("(s)", proxy->priv->interface_name),
|
g_variant_new ("(s)", proxy->priv->interface_name),
|
||||||
G_VARIANT_TYPE ("(a{sv})"),
|
G_VARIANT_TYPE ("(a{sv})"),
|
||||||
@ -1485,9 +1485,9 @@ async_init_call_get_name_owner (GTask *task)
|
|||||||
GDBusProxy *proxy = g_task_get_source_object (task);
|
GDBusProxy *proxy = g_task_get_source_object (task);
|
||||||
|
|
||||||
g_dbus_connection_call (proxy->priv->connection,
|
g_dbus_connection_call (proxy->priv->connection,
|
||||||
"org.freedesktop.DBus", /* name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetNameOwner",
|
"GetNameOwner",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
proxy->priv->name),
|
proxy->priv->name),
|
||||||
@ -1563,8 +1563,8 @@ async_init_start_service_by_name_cb (GDBusConnection *connection,
|
|||||||
"(u)",
|
"(u)",
|
||||||
&start_service_result);
|
&start_service_result);
|
||||||
g_variant_unref (result);
|
g_variant_unref (result);
|
||||||
if (start_service_result == 1 || /* DBUS_START_REPLY_SUCCESS */
|
if (start_service_result == DBUS_START_REPLY_SUCCESS ||
|
||||||
start_service_result == 2) /* DBUS_START_REPLY_ALREADY_RUNNING */
|
start_service_result == DBUS_START_REPLY_ALREADY_RUNNING)
|
||||||
{
|
{
|
||||||
/* continue to invoke GetNameOwner() */
|
/* continue to invoke GetNameOwner() */
|
||||||
}
|
}
|
||||||
@ -1594,9 +1594,9 @@ async_init_call_start_service_by_name (GTask *task)
|
|||||||
GDBusProxy *proxy = g_task_get_source_object (task);
|
GDBusProxy *proxy = g_task_get_source_object (task);
|
||||||
|
|
||||||
g_dbus_connection_call (proxy->priv->connection,
|
g_dbus_connection_call (proxy->priv->connection,
|
||||||
"org.freedesktop.DBus", /* name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"StartServiceByName",
|
"StartServiceByName",
|
||||||
g_variant_new ("(su)",
|
g_variant_new ("(su)",
|
||||||
proxy->priv->name,
|
proxy->priv->name,
|
||||||
@ -1688,7 +1688,7 @@ async_initable_init_first (GAsyncInitable *initable)
|
|||||||
proxy->priv->properties_changed_subscription_id =
|
proxy->priv->properties_changed_subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (proxy->priv->connection,
|
g_dbus_connection_signal_subscribe (proxy->priv->connection,
|
||||||
proxy->priv->name,
|
proxy->priv->name,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
proxy->priv->object_path,
|
proxy->priv->object_path,
|
||||||
proxy->priv->interface_name,
|
proxy->priv->interface_name,
|
||||||
@ -1719,10 +1719,10 @@ async_initable_init_first (GAsyncInitable *initable)
|
|||||||
{
|
{
|
||||||
proxy->priv->name_owner_changed_subscription_id =
|
proxy->priv->name_owner_changed_subscription_id =
|
||||||
g_dbus_connection_signal_subscribe (proxy->priv->connection,
|
g_dbus_connection_signal_subscribe (proxy->priv->connection,
|
||||||
"org.freedesktop.DBus", /* name */
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged", /* signal name */
|
"NameOwnerChanged", /* signal name */
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
proxy->priv->name, /* arg0 */
|
proxy->priv->name, /* arg0 */
|
||||||
signal_flags,
|
signal_flags,
|
||||||
on_name_owner_changed,
|
on_name_owner_changed,
|
||||||
|
@ -241,7 +241,7 @@ set_debug_enabled (GDebugControllerDBus *self,
|
|||||||
g_dbus_connection_emit_signal (priv->connection,
|
g_dbus_connection_emit_signal (priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
"/org/gtk/Debugging",
|
"/org/gtk/Debugging",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new ("(sa{sv}as)",
|
g_variant_new ("(sa{sv}as)",
|
||||||
"org.gtk.Debugging",
|
"org.gtk.Debugging",
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "giomodule-priv.h"
|
#include "giomodule-priv.h"
|
||||||
#include "gdbusconnection.h"
|
#include "gdbusconnection.h"
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gapplication.h"
|
#include "gapplication.h"
|
||||||
#include "gnotification-private.h"
|
#include "gnotification-private.h"
|
||||||
|
|
||||||
@ -58,8 +59,8 @@ g_gtk_notification_backend_is_supported (void)
|
|||||||
if (session_bus == NULL)
|
if (session_bus == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
reply = g_dbus_connection_call_sync (session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus",
|
reply = g_dbus_connection_call_sync (session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetNameOwner", g_variant_new ("(s)", "org.gtk.Notifications"),
|
"GetNameOwner", g_variant_new ("(s)", "org.gtk.Notifications"),
|
||||||
G_VARIANT_TYPE ("(s)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
|
G_VARIANT_TYPE ("(s)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_dbus_basic (void)
|
test_dbus_basic (void)
|
||||||
@ -218,7 +219,7 @@ test_dbus_properties (void)
|
|||||||
|
|
||||||
properties_changed_id = g_dbus_connection_signal_subscribe (remote_connection,
|
properties_changed_id = g_dbus_connection_signal_subscribe (remote_connection,
|
||||||
g_dbus_connection_get_unique_name (controller_connection),
|
g_dbus_connection_get_unique_name (controller_connection),
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
"/org/gtk/Debugging",
|
"/org/gtk/Debugging",
|
||||||
NULL,
|
NULL,
|
||||||
@ -231,7 +232,7 @@ test_dbus_properties (void)
|
|||||||
g_dbus_connection_call (remote_connection,
|
g_dbus_connection_call (remote_connection,
|
||||||
g_dbus_connection_get_unique_name (controller_connection),
|
g_dbus_connection_get_unique_name (controller_connection),
|
||||||
"/org/gtk/Debugging",
|
"/org/gtk/Debugging",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"Get",
|
"Get",
|
||||||
g_variant_new ("(ss)", "org.gtk.Debugging", "DebugEnabled"),
|
g_variant_new ("(ss)", "org.gtk.Debugging", "DebugEnabled"),
|
||||||
G_VARIANT_TYPE ("(v)"),
|
G_VARIANT_TYPE ("(v)"),
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* all tests rely on a shared mainloop */
|
/* all tests rely on a shared mainloop */
|
||||||
@ -213,10 +214,10 @@ test_connection_life_cycle (void)
|
|||||||
/* signal registration */
|
/* signal registration */
|
||||||
g_atomic_int_set (&on_signal_registration_freed_called, FALSE);
|
g_atomic_int_set (&on_signal_registration_freed_called, FALSE);
|
||||||
g_dbus_connection_signal_subscribe (c2,
|
g_dbus_connection_signal_subscribe (c2,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged", /* member */
|
"NameOwnerChanged", /* member */
|
||||||
"/org/freesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
NULL, /* arg0 */
|
NULL, /* arg0 */
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
on_name_owner_changed,
|
on_name_owner_changed,
|
||||||
@ -424,9 +425,9 @@ test_connection_send (void)
|
|||||||
ca = g_cancellable_new ();
|
ca = g_cancellable_new ();
|
||||||
g_cancellable_cancel (ca);
|
g_cancellable_cancel (ca);
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -441,9 +442,9 @@ test_connection_send (void)
|
|||||||
* Check that we get a reply to the GetId() method call.
|
* Check that we get a reply to the GetId() method call.
|
||||||
*/
|
*/
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -457,9 +458,9 @@ test_connection_send (void)
|
|||||||
* Check that we get an error reply to the NonExistantMethod() method call.
|
* Check that we get an error reply to the NonExistantMethod() method call.
|
||||||
*/
|
*/
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NonExistantMethod", /* method name */
|
"NonExistantMethod", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -474,9 +475,9 @@ test_connection_send (void)
|
|||||||
*/
|
*/
|
||||||
ca = g_cancellable_new ();
|
ca = g_cancellable_new ();
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -497,9 +498,9 @@ test_connection_send (void)
|
|||||||
g_assert_true (g_dbus_connection_is_closed (c));
|
g_assert_true (g_dbus_connection_is_closed (c));
|
||||||
|
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -618,10 +619,10 @@ test_connection_signals (void)
|
|||||||
&count_s2,
|
&count_s2,
|
||||||
NULL);
|
NULL);
|
||||||
s3 = g_dbus_connection_signal_subscribe (c1,
|
s3 = g_dbus_connection_signal_subscribe (c1,
|
||||||
"org.freedesktop.DBus", /* sender */
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged", /* member */
|
"NameOwnerChanged", /* member */
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
test_connection_signal_handler,
|
test_connection_signal_handler,
|
||||||
@ -687,9 +688,9 @@ test_connection_signals (void)
|
|||||||
* To ensure this is not the case, do a synchronous call on c1.
|
* To ensure this is not the case, do a synchronous call on c1.
|
||||||
*/
|
*/
|
||||||
result = g_dbus_connection_call_sync (c1,
|
result = g_dbus_connection_call_sync (c1,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, /* parameters */
|
NULL, /* parameters */
|
||||||
NULL, /* return type */
|
NULL, /* return type */
|
||||||
@ -1047,11 +1048,11 @@ test_connection_filter (void)
|
|||||||
&data,
|
&data,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
m = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
m = g_dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetNameOwner");
|
"GetNameOwner");
|
||||||
g_dbus_message_set_body (m, g_variant_new ("(s)", "org.freedesktop.DBus"));
|
g_dbus_message_set_body (m, g_variant_new ("(s)", DBUS_SERVICE_DBUS));
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &serial_temp, &error);
|
g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, &serial_temp, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -1114,10 +1115,10 @@ test_connection_filter (void)
|
|||||||
|
|
||||||
/* wait for service to be available */
|
/* wait for service to be available */
|
||||||
signal_handler_id = g_dbus_connection_signal_subscribe (c,
|
signal_handler_id = g_dbus_connection_signal_subscribe (c,
|
||||||
"org.freedesktop.DBus", /* sender */
|
DBUS_SERVICE_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameOwnerChanged",
|
"NameOwnerChanged",
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
NULL, /* arg0 */
|
NULL, /* arg0 */
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||||
test_connection_filter_name_owner_changed_signal_handler,
|
test_connection_filter_name_owner_changed_signal_handler,
|
||||||
@ -1197,11 +1198,11 @@ send_bogus_message (GDBusConnection *c, guint32 *out_serial)
|
|||||||
GDBusMessage *m;
|
GDBusMessage *m;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
m = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
m = g_dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetNameOwner");
|
"GetNameOwner");
|
||||||
g_dbus_message_set_body (m, g_variant_new ("(s)", "org.freedesktop.DBus"));
|
g_dbus_message_set_body (m, g_variant_new ("(s)", DBUS_SERVICE_DBUS));
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, out_serial, &error);
|
g_dbus_connection_send_message (c, m, G_DBUS_SEND_MESSAGE_FLAGS_NONE, out_serial, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
/* Test that registered errors are properly mapped */
|
/* Test that registered errors are properly mapped */
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
@ -66,13 +68,13 @@ test_registered_errors (void)
|
|||||||
*
|
*
|
||||||
* We just check a couple of well-known errors.
|
* We just check a couple of well-known errors.
|
||||||
*/
|
*/
|
||||||
check_registered_error ("org.freedesktop.DBus.Error.Failed",
|
check_registered_error (DBUS_ERROR_FAILED,
|
||||||
G_DBUS_ERROR,
|
G_DBUS_ERROR,
|
||||||
G_DBUS_ERROR_FAILED);
|
G_DBUS_ERROR_FAILED);
|
||||||
check_registered_error ("org.freedesktop.DBus.Error.AddressInUse",
|
check_registered_error ("org.freedesktop.DBus.Error.AddressInUse",
|
||||||
G_DBUS_ERROR,
|
G_DBUS_ERROR,
|
||||||
G_DBUS_ERROR_ADDRESS_IN_USE);
|
G_DBUS_ERROR_ADDRESS_IN_USE);
|
||||||
check_registered_error ("org.freedesktop.DBus.Error.UnknownMethod",
|
check_registered_error (DBUS_ERROR_UNKNOWN_METHOD,
|
||||||
G_DBUS_ERROR,
|
G_DBUS_ERROR,
|
||||||
G_DBUS_ERROR_UNKNOWN_METHOD);
|
G_DBUS_ERROR_UNKNOWN_METHOD);
|
||||||
check_registered_error ("org.freedesktop.DBus.Error.UnknownObject",
|
check_registered_error ("org.freedesktop.DBus.Error.UnknownObject",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* The object we want to export */
|
/* The object we want to export */
|
||||||
@ -253,7 +255,7 @@ send_property_change (GObject *obj,
|
|||||||
g_dbus_connection_emit_signal (connection,
|
g_dbus_connection_emit_signal (connection,
|
||||||
NULL,
|
NULL,
|
||||||
"/org/myorg/MyObject",
|
"/org/myorg/MyObject",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new ("(sa{sv}as)",
|
g_variant_new ("(sa{sv}as)",
|
||||||
"org.myorg.MyObject",
|
"org.myorg.MyObject",
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static GDBusNodeInfo *introspection_data = NULL;
|
static GDBusNodeInfo *introspection_data = NULL;
|
||||||
@ -243,7 +245,7 @@ handle_set_property (GDBusConnection *connection,
|
|||||||
g_dbus_connection_emit_signal (connection,
|
g_dbus_connection_emit_signal (connection,
|
||||||
NULL,
|
NULL,
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new ("(sa{sv}as)",
|
g_variant_new ("(sa{sv}as)",
|
||||||
interface_name,
|
interface_name,
|
||||||
@ -306,7 +308,7 @@ on_timeout_cb (gpointer user_data)
|
|||||||
g_dbus_connection_emit_signal (connection,
|
g_dbus_connection_emit_signal (connection,
|
||||||
NULL,
|
NULL,
|
||||||
"/org/gtk/GDBus/TestObject",
|
"/org/gtk/GDBus/TestObject",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new ("(sa{sv}as)",
|
g_variant_new ("(sa{sv}as)",
|
||||||
"org.gtk.GDBus.TestInterface",
|
"org.gtk.GDBus.TestInterface",
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* all tests rely on a shared mainloop */
|
/* all tests rely on a shared mainloop */
|
||||||
@ -137,9 +138,9 @@ test_exit_on_close_subprocess (gconstpointer test_data)
|
|||||||
GVariant *v;
|
GVariant *v;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
v = g_dbus_connection_call_sync (c, "org.freedesktop.DBus",
|
v = g_dbus_connection_call_sync (c, DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"ListNames",
|
"ListNames",
|
||||||
NULL,
|
NULL,
|
||||||
G_VARIANT_TYPE ("(as)"),
|
G_VARIANT_TYPE ("(as)"),
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
/* all tests rely on a shared mainloop */
|
/* all tests rely on a shared mainloop */
|
||||||
static GMainLoop *loop = NULL;
|
static GMainLoop *loop = NULL;
|
||||||
@ -377,7 +378,7 @@ get_nodes_at (GDBusConnection *c,
|
|||||||
NULL,
|
NULL,
|
||||||
g_dbus_connection_get_unique_name (c),
|
g_dbus_connection_get_unique_name (c),
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -436,7 +437,7 @@ has_interface (GDBusConnection *c,
|
|||||||
NULL,
|
NULL,
|
||||||
g_dbus_connection_get_unique_name (c),
|
g_dbus_connection_get_unique_name (c),
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -485,7 +486,7 @@ count_interfaces (GDBusConnection *c,
|
|||||||
NULL,
|
NULL,
|
||||||
g_dbus_connection_get_unique_name (c),
|
g_dbus_connection_get_unique_name (c),
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -778,7 +779,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
/* generic interfaces */
|
/* generic interfaces */
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Peer.Ping",
|
DBUS_INTERFACE_PEER ".Ping",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
@ -826,7 +827,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
||||||
g_assert_cmpstr (error->message, ==, "GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: Type of message, “(s)”, does not match expected type “()”");
|
g_assert_cmpstr (error->message, ==, "GDBus.Error:" DBUS_ERROR_INVALID_ARGS ": Type of message, “(s)”, does not match expected type “()”");
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_null (value);
|
g_assert_null (value);
|
||||||
|
|
||||||
@ -839,7 +840,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
|
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 “NonExistantMethod”");
|
g_assert_cmpstr (error->message, ==, "GDBus.Error:" DBUS_ERROR_UNKNOWN_METHOD ": No such method “NonExistantMethod”");
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_null (value);
|
g_assert_null (value);
|
||||||
|
|
||||||
@ -858,7 +859,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
/* user properties */
|
/* user properties */
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.Get",
|
DBUS_INTERFACE_PROPERTIES ".Get",
|
||||||
g_variant_new ("(ss)",
|
g_variant_new ("(ss)",
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"PropertyUno"),
|
"PropertyUno"),
|
||||||
@ -877,7 +878,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.Get",
|
DBUS_INTERFACE_PROPERTIES ".Get",
|
||||||
g_variant_new ("(ss)",
|
g_variant_new ("(ss)",
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"ThisDoesntExist"),
|
"ThisDoesntExist"),
|
||||||
@ -887,12 +888,12 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_null (value);
|
g_assert_null (value);
|
||||||
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
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 “ThisDoesntExist”");
|
g_assert_cmpstr (error->message, ==, "GDBus.Error:" DBUS_ERROR_INVALID_ARGS ": No such property “ThisDoesntExist”");
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.Get",
|
DBUS_INTERFACE_PROPERTIES ".Get",
|
||||||
g_variant_new ("(ss)",
|
g_variant_new ("(ss)",
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"NotReadable"),
|
"NotReadable"),
|
||||||
@ -902,12 +903,12 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_null (value);
|
g_assert_null (value);
|
||||||
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
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 “NotReadable” is not readable");
|
g_assert_cmpstr (error->message, ==, "GDBus.Error:" DBUS_ERROR_INVALID_ARGS ": Property “NotReadable” is not readable");
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.Set",
|
DBUS_INTERFACE_PROPERTIES ".Set",
|
||||||
g_variant_new ("(ssv)",
|
g_variant_new ("(ssv)",
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"NotReadable",
|
"NotReadable",
|
||||||
@ -928,7 +929,7 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.Set",
|
DBUS_INTERFACE_PROPERTIES ".Set",
|
||||||
g_variant_new ("(ssv)",
|
g_variant_new ("(ssv)",
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"NotWritable",
|
"NotWritable",
|
||||||
@ -939,12 +940,12 @@ test_dispatch_thread_func (gpointer user_data)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_null (value);
|
g_assert_null (value);
|
||||||
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
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 “NotWritable” is not writable");
|
g_assert_cmpstr (error->message, ==, "GDBus.Error:" DBUS_ERROR_INVALID_ARGS ": Property “NotWritable” is not writable");
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
value = g_dbus_proxy_call_sync (foo_proxy,
|
value = g_dbus_proxy_call_sync (foo_proxy,
|
||||||
"org.freedesktop.DBus.Properties.GetAll",
|
DBUS_INTERFACE_PROPERTIES ".GetAll",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
"org.example.Foo"),
|
"org.example.Foo"),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -1466,7 +1467,7 @@ static const GDBusInterfaceInfo test_interface_info1 =
|
|||||||
static const GDBusInterfaceInfo test_interface_info2 =
|
static const GDBusInterfaceInfo test_interface_info2 =
|
||||||
{
|
{
|
||||||
-1,
|
-1,
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
(GDBusMethodInfo **) NULL,
|
(GDBusMethodInfo **) NULL,
|
||||||
(GDBusSignalInfo **) NULL,
|
(GDBusSignalInfo **) NULL,
|
||||||
(GDBusPropertyInfo **) NULL,
|
(GDBusPropertyInfo **) NULL,
|
||||||
@ -1491,7 +1492,7 @@ check_interfaces (GDBusConnection *c,
|
|||||||
NULL,
|
NULL,
|
||||||
g_dbus_connection_get_unique_name (c),
|
g_dbus_connection_get_unique_name (c),
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -1555,8 +1556,8 @@ test_registered_interfaces (void)
|
|||||||
guint id1, id2;
|
guint id1, id2;
|
||||||
const gchar *interfaces[] = {
|
const gchar *interfaces[] = {
|
||||||
"org.example.Foo",
|
"org.example.Foo",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1607,10 +1608,10 @@ test_async_method_call (GDBusConnection *connection,
|
|||||||
const GDBusPropertyInfo *property;
|
const GDBusPropertyInfo *property;
|
||||||
|
|
||||||
/* Strictly speaking, this function should also expect to receive
|
/* 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.
|
* 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));
|
g_assert_null (g_dbus_method_invocation_get_method_info (invocation));
|
||||||
|
|
||||||
property = g_dbus_method_invocation_get_property_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);
|
va_start (ap, format_string);
|
||||||
|
|
||||||
g_dbus_connection_call (connection, g_dbus_connection_get_unique_name (connection), "/foo",
|
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);
|
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, ensure_result_cb, (gpointer) expected_reply);
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* all tests rely on a shared mainloop */
|
/* all tests rely on a shared mainloop */
|
||||||
@ -50,7 +51,7 @@ test_introspection (GDBusProxy *proxy)
|
|||||||
* Invoke Introspect(), then parse the output.
|
* Invoke Introspect(), then parse the output.
|
||||||
*/
|
*/
|
||||||
result = g_dbus_proxy_call_sync (proxy,
|
result = g_dbus_proxy_call_sync (proxy,
|
||||||
"org.freedesktop.DBus.Introspectable.Introspect",
|
DBUS_INTERFACE_INTROSPECTABLE ".Introspect",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
@ -69,7 +70,7 @@ test_introspection (GDBusProxy *proxy)
|
|||||||
interface_info = g_dbus_node_info_lookup_interface (node_info, "com.example.NonExistantInterface");
|
interface_info = g_dbus_node_info_lookup_interface (node_info, "com.example.NonExistantInterface");
|
||||||
g_assert (interface_info == NULL);
|
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);
|
g_assert (interface_info != NULL);
|
||||||
method_info = g_dbus_interface_info_lookup_method (interface_info, "NonExistantMethod");
|
method_info = g_dbus_interface_info_lookup_method (interface_info, "NonExistantMethod");
|
||||||
g_assert (method_info == NULL);
|
g_assert (method_info == NULL);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
static const GDBusArgInfo foo_get_fds_in_args =
|
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;
|
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"))
|
g_str_equal (method_name, "Get"))
|
||||||
{
|
{
|
||||||
const gchar *iface_name, *prop_name;
|
const gchar *iface_name, *prop_name;
|
||||||
@ -178,7 +179,7 @@ test_method_invocation_return_method_call (GDBusConnection *connection,
|
|||||||
|
|
||||||
g_test_assert_expected_messages ();
|
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"))
|
g_str_equal (method_name, "Set"))
|
||||||
{
|
{
|
||||||
const gchar *iface_name, *prop_name;
|
const gchar *iface_name, *prop_name;
|
||||||
@ -202,7 +203,7 @@ test_method_invocation_return_method_call (GDBusConnection *connection,
|
|||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
g_variant_unref (value);
|
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"))
|
g_str_equal (method_name, "GetAll"))
|
||||||
{
|
{
|
||||||
const gchar *iface_name;
|
const gchar *iface_name;
|
||||||
@ -325,11 +326,11 @@ test_method_invocation_return (void)
|
|||||||
}
|
}
|
||||||
calls[] =
|
calls[] =
|
||||||
{
|
{
|
||||||
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidType')", TRUE },
|
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidType')", TRUE },
|
||||||
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidTypeNull')", TRUE },
|
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidTypeNull')", TRUE },
|
||||||
{ "org.freedesktop.DBus.Properties", "Get", "('org.example.Foo', 'InvalidValueType')", TRUE },
|
{ DBUS_INTERFACE_PROPERTIES, "Get", "('org.example.Foo', 'InvalidValueType')", TRUE },
|
||||||
{ "org.freedesktop.DBus.Properties", "Set", "('org.example.Foo', 'InvalidType', <'irrelevant'>)", TRUE },
|
{ DBUS_INTERFACE_PROPERTIES, "Set", "('org.example.Foo', 'InvalidType', <'irrelevant'>)", TRUE },
|
||||||
{ "org.freedesktop.DBus.Properties", "GetAll", "('org.example.Foo',)", TRUE },
|
{ DBUS_INTERFACE_PROPERTIES, "GetAll", "('org.example.Foo',)", TRUE },
|
||||||
{ "org.example.Foo", "WrongReturnType", "()", TRUE },
|
{ "org.example.Foo", "WrongReturnType", "()", TRUE },
|
||||||
{ "org.example.Foo", "GetFDs", "('Valid',)", FALSE },
|
{ "org.example.Foo", "GetFDs", "('Valid',)", FALSE },
|
||||||
{ "org.example.Foo", "GetFDs", "('WrongNumber',)", TRUE },
|
{ "org.example.Foo", "GetFDs", "('WrongNumber',)", TRUE },
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
@ -181,9 +182,9 @@ test_bus_own_name (void)
|
|||||||
g_assert (c != NULL);
|
g_assert (c != NULL);
|
||||||
g_assert (!g_dbus_connection_is_closed (c));
|
g_assert (!g_dbus_connection_is_closed (c));
|
||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameHasOwner", /* method name */
|
"NameHasOwner", /* method name */
|
||||||
g_variant_new ("(s)", name),
|
g_variant_new ("(s)", name),
|
||||||
G_VARIANT_TYPE ("(b)"),
|
G_VARIANT_TYPE ("(b)"),
|
||||||
@ -209,9 +210,9 @@ test_bus_own_name (void)
|
|||||||
* Check that the name was actually released.
|
* Check that the name was actually released.
|
||||||
*/
|
*/
|
||||||
result = g_dbus_connection_call_sync (c,
|
result = g_dbus_connection_call_sync (c,
|
||||||
"org.freedesktop.DBus", /* bus name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"NameHasOwner", /* method name */
|
"NameHasOwner", /* method name */
|
||||||
g_variant_new ("(s)", name),
|
g_variant_new ("(s)", name),
|
||||||
G_VARIANT_TYPE ("(b)"),
|
G_VARIANT_TYPE ("(b)"),
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <gio/giowin32-afunix.h>
|
#include <gio/giowin32-afunix.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
#include "gdbus-object-manager-example/objectmanager-gen.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 */
|
/* Poke server and make sure animal is updated */
|
||||||
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal1),
|
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, G_DBUS_CALL_FLAGS_NONE, -1,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -2177,7 +2178,7 @@ codegen_test_peer (void)
|
|||||||
|
|
||||||
/* Some random unrelated call, just to get some test coverage */
|
/* Some random unrelated call, just to get some test coverage */
|
||||||
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal2),
|
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, G_DBUS_CALL_FLAGS_NONE, -1,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
@ -2191,7 +2192,7 @@ codegen_test_peer (void)
|
|||||||
|
|
||||||
/* Poke server and make sure animal is updated */
|
/* Poke server and make sure animal is updated */
|
||||||
value = g_dbus_proxy_call_sync (G_DBUS_PROXY (animal2),
|
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, G_DBUS_CALL_FLAGS_NONE, -1,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
|
@ -28,18 +28,9 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
#ifdef HAVE_DBUS1
|
|
||||||
# include <dbus/dbus-shared.h>
|
|
||||||
#else
|
|
||||||
# define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
|
|
||||||
# define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
|
||||||
# define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
|
|
||||||
# define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
|
|
||||||
# define DBUS_RELEASE_NAME_REPLY_RELEASED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MY_NAME "com.example.Test.Myself"
|
#define MY_NAME "com.example.Test.Myself"
|
||||||
/* This many threads create and destroy GDBusProxy instances, in addition
|
/* This many threads create and destroy GDBusProxy instances, in addition
|
||||||
* to the main thread processing their NameOwnerChanged signals.
|
* to the main thread processing their NameOwnerChanged signals.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* all tests rely on a shared mainloop */
|
/* all tests rely on a shared mainloop */
|
||||||
@ -757,9 +758,9 @@ kill_test_service (GDBusConnection *connection)
|
|||||||
gboolean name_disappeared = FALSE;
|
gboolean name_disappeared = FALSE;
|
||||||
|
|
||||||
ret = g_dbus_connection_call_sync (connection,
|
ret = g_dbus_connection_call_sync (connection,
|
||||||
"org.freedesktop.DBus",
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus",
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus",
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetConnectionUnixProcessID",
|
"GetConnectionUnixProcessID",
|
||||||
g_variant_new ("(s)", name),
|
g_variant_new ("(s)", name),
|
||||||
NULL,
|
NULL,
|
||||||
@ -977,9 +978,9 @@ add_or_remove_match_rule (GDBusConnection *connection,
|
|||||||
GDBusMessage *message = NULL;
|
GDBusMessage *message = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
message = g_dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface */
|
DBUS_INTERFACE_DBUS,
|
||||||
(add_or_remove == ADD_MATCH) ? "AddMatch" : "RemoveMatch");
|
(add_or_remove == ADD_MATCH) ? "AddMatch" : "RemoveMatch");
|
||||||
g_dbus_message_set_body (message, match_rule);
|
g_dbus_message_set_body (message, match_rule);
|
||||||
g_dbus_connection_send_message (connection,
|
g_dbus_connection_send_message (connection,
|
||||||
|
@ -1027,10 +1027,10 @@ test_message_serialize_header_checks (void)
|
|||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_assert_null (blob);
|
g_assert_null (blob);
|
||||||
/* interface reserved value => error */
|
/* 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);
|
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_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_clear_error (&error);
|
||||||
g_assert_null (blob);
|
g_assert_null (blob);
|
||||||
/* reset interface */
|
/* reset interface */
|
||||||
@ -1044,10 +1044,10 @@ test_message_serialize_header_checks (void)
|
|||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_assert_null (blob);
|
g_assert_null (blob);
|
||||||
/* path reserved value => error */
|
/* 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);
|
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_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_clear_error (&error);
|
||||||
g_assert_null (blob);
|
g_assert_null (blob);
|
||||||
/* reset path */
|
/* reset path */
|
||||||
|
@ -5,14 +5,9 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* From the D-Bus Specification */
|
|
||||||
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
|
|
||||||
|
|
||||||
#define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
|
|
||||||
#define DBUS_PATH_DBUS "/org/freedesktop/DBus"
|
|
||||||
#define DBUS_INTERFACE_DBUS DBUS_SERVICE_DBUS
|
|
||||||
#define NAME_OWNER_CHANGED "NameOwnerChanged"
|
#define NAME_OWNER_CHANGED "NameOwnerChanged"
|
||||||
|
|
||||||
/* A signal that each connection emits to indicate that it has finished
|
/* A signal that each connection emits to indicate that it has finished
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
#include "gstdio.h"
|
#include "gstdio.h"
|
||||||
|
|
||||||
@ -1511,7 +1512,7 @@ introspect (GDBusConnection *connection,
|
|||||||
g_dbus_connection_call (connection,
|
g_dbus_connection_call (connection,
|
||||||
name,
|
name,
|
||||||
object_path,
|
object_path,
|
||||||
"org.freedesktop.DBus.Introspectable",
|
DBUS_INTERFACE_INTROSPECTABLE,
|
||||||
"Introspect",
|
"Introspect",
|
||||||
NULL, /* params */
|
NULL, /* params */
|
||||||
G_VARIANT_TYPE ("(s)"),
|
G_VARIANT_TYPE ("(s)"),
|
||||||
@ -1603,7 +1604,7 @@ om_check_get_all (GDBusConnection *c,
|
|||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
g_dbus_connection_get_unique_name (c),
|
g_dbus_connection_get_unique_name (c),
|
||||||
"/managed",
|
"/managed",
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
"GetManagedObjects",
|
"GetManagedObjects",
|
||||||
NULL, /* params */
|
NULL, /* params */
|
||||||
G_VARIANT_TYPE ("(a{oa{sa{sv}}})"),
|
G_VARIANT_TYPE ("(a{oa{sa{sv}}})"),
|
||||||
@ -2016,7 +2017,7 @@ check_object_manager (void)
|
|||||||
|
|
||||||
om_signal_id = g_dbus_connection_signal_subscribe (c,
|
om_signal_id = g_dbus_connection_signal_subscribe (c,
|
||||||
NULL, /* sender */
|
NULL, /* sender */
|
||||||
"org.freedesktop.DBus.ObjectManager",
|
DBUS_INTERFACE_OBJECT_MANAGER,
|
||||||
NULL, /* member */
|
NULL, /* member */
|
||||||
NULL, /* object_path */
|
NULL, /* object_path */
|
||||||
NULL, /* arg0 */
|
NULL, /* arg0 */
|
||||||
@ -2060,7 +2061,7 @@ check_object_manager (void)
|
|||||||
/* Check that the manager object is visible */
|
/* Check that the manager object is visible */
|
||||||
info = introspect (c, g_dbus_connection_get_unique_name (c), "/managed", loop);
|
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_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_assert_cmpint (count_nodes (info), ==, 0);
|
||||||
g_dbus_node_info_unref (info);
|
g_dbus_node_info_unref (info);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
static GDBusNodeInfo *introspection_data = NULL;
|
static GDBusNodeInfo *introspection_data = NULL;
|
||||||
static GMainLoop *loop = NULL;
|
static GMainLoop *loop = NULL;
|
||||||
static GHashTable *properties = NULL;
|
static GHashTable *properties = NULL;
|
||||||
@ -688,7 +690,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
g_dbus_connection_emit_signal (connection,
|
g_dbus_connection_emit_signal (connection,
|
||||||
NULL,
|
NULL,
|
||||||
"/com/example/TestObject",
|
"/com/example/TestObject",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new_parsed ("('com.example.Frob', [{%s, %v}], @as [])", name, value),
|
g_variant_new_parsed ("('com.example.Frob', [{%s, %v}], @as [])", name, value),
|
||||||
NULL);
|
NULL);
|
||||||
@ -703,7 +705,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
g_dbus_connection_emit_signal (connection,
|
g_dbus_connection_emit_signal (connection,
|
||||||
NULL,
|
NULL,
|
||||||
"/com/example/TestObject",
|
"/com/example/TestObject",
|
||||||
"org.freedesktop.DBus.Properties",
|
DBUS_INTERFACE_PROPERTIES,
|
||||||
"PropertiesChanged",
|
"PropertiesChanged",
|
||||||
g_variant_new_parsed ("('com.example.Frob', @a{sv} [], ['PropertyThatWillBeInvalidated'])"),
|
g_variant_new_parsed ("('com.example.Frob', @a{sv} [], ['PropertyThatWillBeInvalidated'])"),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gdbusprivate.h"
|
||||||
#include "gdbus-tests.h"
|
#include "gdbus-tests.h"
|
||||||
|
|
||||||
/* all tests rely on a global connection */
|
/* all tests rely on a global connection */
|
||||||
@ -185,9 +186,9 @@ test_delivery_in_thread_func (gpointer _data)
|
|||||||
* Check that we get a reply to the GetId() method call.
|
* Check that we get a reply to the GetId() method call.
|
||||||
*/
|
*/
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -212,9 +213,9 @@ test_delivery_in_thread_func (gpointer _data)
|
|||||||
ca = g_cancellable_new ();
|
ca = g_cancellable_new ();
|
||||||
g_cancellable_cancel (ca);
|
g_cancellable_cancel (ca);
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -239,9 +240,9 @@ test_delivery_in_thread_func (gpointer _data)
|
|||||||
*/
|
*/
|
||||||
ca = g_cancellable_new ();
|
ca = g_cancellable_new ();
|
||||||
g_dbus_connection_call (c,
|
g_dbus_connection_call (c,
|
||||||
"org.freedesktop.DBus", /* bus_name */
|
DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", /* object path */
|
DBUS_PATH_DBUS,
|
||||||
"org.freedesktop.DBus", /* interface name */
|
DBUS_INTERFACE_DBUS,
|
||||||
"GetId", /* method name */
|
"GetId", /* method name */
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -563,8 +564,8 @@ ensure_connection_works (GDBusConnection *conn)
|
|||||||
GVariant *v;
|
GVariant *v;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
v = g_dbus_connection_call_sync (conn, "org.freedesktop.DBus",
|
v = g_dbus_connection_call_sync (conn, DBUS_SERVICE_DBUS,
|
||||||
"/org/freedesktop/DBus", "org.freedesktop.DBus", "GetId", NULL, NULL, 0, -1,
|
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetId", NULL, NULL, 0, -1,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_assert_nonnull (v);
|
g_assert_nonnull (v);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user