X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusconnection.c;h=680062e951f1863be461425a7e0e1c82d455eaec;hb=3389489f0f25a3a324ad62d9df5a6f1c038d5986;hp=7abc5eb85a9728ab03eec826faeb1f2d22108b46;hpb=14dc0280039a08c4b85ab9a5fbcbb17bf491afa8;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 7abc5eb..680062e 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Author: David Zeuthen */ @@ -105,10 +103,6 @@ #include #include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gdbusauth.h" #include "gdbusutils.h" @@ -128,6 +122,8 @@ #include "gsimpleasyncresult.h" #ifdef G_OS_UNIX +#include "gkdbus.h" +#include "gkdbusconnection.h" #include "gunixconnection.h" #include "gunixfdmessage.h" #endif @@ -145,17 +141,13 @@ * over any transport that can by represented as an #GIOStream. * * This class is rarely used directly in D-Bus clients. If you are writing - * an D-Bus client, it is often easier to use the g_bus_own_name(), + * a D-Bus client, it is often easier to use the g_bus_own_name(), * g_bus_watch_name() or g_dbus_proxy_new_for_bus() APIs. * - * As an exception to the usual GLib rule that a particular object must not be - * used by two threads at the same time, #GDBusConnection's methods may be - * called from any thread - * - * This is so that g_bus_get() and g_bus_get_sync() can safely return the - * same #GDBusConnection when called from any thread. - * - * . + * As an exception to the usual GLib rule that a particular object must not + * be used by two threads at the same time, #GDBusConnection's methods may be + * called from any thread. This is so that g_bus_get() and g_bus_get_sync() + * can safely return the same #GDBusConnection when called from any thread. * * Most of the ways to obtain a #GDBusConnection automatically initialize it * (i.e. connect to D-Bus): for instance, g_dbus_connection_new() and @@ -173,13 +165,25 @@ * #GError, the only valid thing you can do with that #GDBusConnection is to * free it with g_object_unref(). * - * D-Bus server exampleFIXME: MISSING XINCLUDE CONTENT + * ## An example D-Bus server # {#gdbus-server} + * + * Here is an example for a D-Bus server: + * [gdbus-example-server.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-server.c) + * + * ## An example for exporting a subtree # {#gdbus-subtree-server} * - * D-Bus subtree exampleFIXME: MISSING XINCLUDE CONTENT + * Here is an example for exporting a subtree: + * [gdbus-example-subtree.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-subtree.c) * - * D-Bus UNIX File Descriptor exampleFIXME: MISSING XINCLUDE CONTENT + * ## An example for file descriptor passing # {#gdbus-unix-fd-client} * - * Exporting a GObjectFIXME: MISSING XINCLUDE CONTENT + * Here is an example for passing UNIX file descriptors: + * [gdbus-unix-fd-client.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-unix-fd-client.c) + * + * ## An example for exporting a GObject # {#gdbus-export} + * + * Here is an example for exporting a #GObject: + * [gdbus-example-export.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-export.c) */ /* ---------------------------------------------------------------------------------------------------- */ @@ -210,6 +214,8 @@ G_LOCK_DEFINE_STATIC (message_bus_lock); static GWeakRef the_session_bus; static GWeakRef the_system_bus; +static GWeakRef the_user_bus; +static GWeakRef the_machine_bus; /* Extra pseudo-member of GDBusSendMessageFlags. * Set by initable_init() to indicate that despite not being initialized yet, @@ -279,6 +285,7 @@ call_destroy_notify (GMainContext *context, call_destroy_notify_data_in_idle, data, (GDestroyNotify) call_destroy_notify_data_free); + g_source_set_name (idle_source, "[gio] call_destroy_notify_data_in_idle"); g_source_attach (idle_source, data->context); g_source_unref (idle_source); @@ -360,7 +367,7 @@ struct _GDBusConnection GMutex init_lock; /* Set (by loading the contents of /var/lib/dbus/machine-id) the first time - * someone calls org.freedesktop.DBus.GetMachineId(). Protected by @lock. + * someone calls org.freedesktop.DBus.Peer.GetMachineId(). Protected by @lock. */ gchar *machine_id; @@ -803,14 +810,14 @@ g_dbus_connection_real_closed (GDBusConnection *connection, { if (error != NULL) { - g_print ("%s: Remote peer vanished with error: %s (%s, %d). Exiting.\n", - G_STRFUNC, - error->message, - g_quark_to_string (error->domain), error->code); + g_printerr ("%s: Remote peer vanished with error: %s (%s, %d). Exiting.\n", + G_STRFUNC, + error->message, + g_quark_to_string (error->domain), error->code); } else { - g_print ("%s: Remote peer vanished. Exiting.\n", G_STRFUNC); + g_printerr ("%s: Remote peer vanished. Exiting.\n", G_STRFUNC); } raise (SIGTERM); } @@ -970,11 +977,11 @@ g_dbus_connection_class_init (GDBusConnectionClass *klass) * GDBusConnection:exit-on-close: * * A boolean specifying whether the process will be terminated (by - * calling raise(SIGTERM)) if the connection - * is closed by the remote peer. + * calling `raise(SIGTERM)`) if the connection is closed by the + * remote peer. * - * Note that #GDBusConnection objects returned by g_bus_get_finish() and - * g_bus_get_sync() will (usually) have this property set to %TRUE. + * Note that #GDBusConnection objects returned by g_bus_get_finish() + * and g_bus_get_sync() will (usually) have this property set to %TRUE. * * Since: 2.26 */ @@ -1031,29 +1038,23 @@ g_dbus_connection_class_init (GDBusConnectionClass *klass) /** * GDBusConnection::closed: - * @connection: The #GDBusConnection emitting the signal. + * @connection: the #GDBusConnection emitting the signal * @remote_peer_vanished: %TRUE if @connection is closed because the - * remote peer closed its end of the connection. - * @error: (allow-none): A #GError with more details about the event or %NULL. + * remote peer closed its end of the connection + * @error: (allow-none): a #GError with more details about the event or %NULL * * Emitted when the connection is closed. * * The cause of this event can be - * - * - * If g_dbus_connection_close() is called. In this case - * @remote_peer_vanished is set to %FALSE and @error is %NULL. - * - * - * If the remote peer closes the connection. In this case - * @remote_peer_vanished is set to %TRUE and @error is set. - * - * - * If the remote peer sends invalid or malformed data. In this - * case @remote_peer_vanished is set to %FALSE and @error - * is set. - * - * + * + * - If g_dbus_connection_close() is called. In this case + * @remote_peer_vanished is set to %FALSE and @error is %NULL. + * + * - If the remote peer closes the connection. In this case + * @remote_peer_vanished is set to %TRUE and @error is set. + * + * - If the remote peer sends invalid or malformed data. In this + * case @remote_peer_vanished is set to %FALSE and @error is set. * * Upon receiving this signal, you should give up your reference to * @connection. You are guaranteed that this signal is emitted only @@ -1143,7 +1144,7 @@ g_dbus_connection_get_stream (GDBusConnection *connection) /** * g_dbus_connection_start_message_processing: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * If @connection was created with * %G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method @@ -1167,11 +1168,11 @@ g_dbus_connection_start_message_processing (GDBusConnection *connection) /** * g_dbus_connection_is_closed: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Gets whether @connection is closed. * - * Returns: %TRUE if the connection is closed, %FALSE otherwise. + * Returns: %TRUE if the connection is closed, %FALSE otherwise * * Since: 2.26 */ @@ -1189,11 +1190,11 @@ g_dbus_connection_is_closed (GDBusConnection *connection) /** * g_dbus_connection_get_capabilities: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Gets the capabilities negotiated with the remote peer * - * Returns: Zero or more flags from the #GDBusCapabilityFlags enumeration. + * Returns: zero or more flags from the #GDBusCapabilityFlags enumeration * * Since: 2.26 */ @@ -1228,26 +1229,25 @@ flush_in_thread_func (GSimpleAsyncResult *res, /** * g_dbus_connection_flush: - * @connection: A #GDBusConnection. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (allow-none): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't care about the result. - * @user_data: The data to pass to @callback. + * @connection: a #GDBusConnection + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: (allow-none): a #GAsyncReadyCallback to call when the + * request is satisfied or %NULL if you don't care about the result + * @user_data: The data to pass to @callback * * Asynchronously flushes @connection, that is, writes all queued * outgoing message to the transport and then flushes the transport * (using g_output_stream_flush_async()). This is useful in programs - * that wants to emit a D-Bus signal and then exit - * immediately. Without flushing the connection, there is no guarantee - * that the message has been sent to the networking buffers in the OS - * kernel. + * that wants to emit a D-Bus signal and then exit immediately. Without + * flushing the connection, there is no guaranteed that the message has + * been sent to the networking buffers in the OS kernel. * * This is an asynchronous method. When the operation is finished, - * @callback will be invoked in the thread-default main - * loop of the thread you are calling this method from. You can + * @callback will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread you are calling this method from. You can * then call g_dbus_connection_flush_finish() to get the result of the - * operation. See g_dbus_connection_flush_sync() for the synchronous + * operation. See g_dbus_connection_flush_sync() for the synchronous * version. * * Since: 2.26 @@ -1276,13 +1276,14 @@ g_dbus_connection_flush (GDBusConnection *connection, /** * g_dbus_connection_flush_finish: - * @connection: A #GDBusConnection. - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_flush(). - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed + * to g_dbus_connection_flush() + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_flush(). * - * Returns: %TRUE if the operation succeeded, %FALSE if @error is set. + * Returns: %TRUE if the operation succeeded, %FALSE if @error is set * * Since: 2.26 */ @@ -1313,16 +1314,16 @@ g_dbus_connection_flush_finish (GDBusConnection *connection, /** * g_dbus_connection_flush_sync: - * @connection: A #GDBusConnection. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously flushes @connection. The calling thread is blocked * until this is done. See g_dbus_connection_flush() for the * asynchronous version of this method and more details about what it * does. * - * Returns: %TRUE if the operation succeeded, %FALSE if @error is set. + * Returns: %TRUE if the operation succeeded, %FALSE if @error is set * * Since: 2.26 */ @@ -1419,6 +1420,7 @@ schedule_closed_unlocked (GDBusConnection *connection, emit_closed_in_idle, data, (GDestroyNotify) emit_closed_data_free); + g_source_set_name (idle_source, "[gio] emit_closed_in_idle"); g_source_attach (idle_source, connection->main_context_at_construction); g_source_unref (idle_source); } @@ -1427,11 +1429,11 @@ schedule_closed_unlocked (GDBusConnection *connection, /** * g_dbus_connection_close: - * @connection: A #GDBusConnection. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (allow-none): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't care about the result. - * @user_data: The data to pass to @callback. + * @connection: a #GDBusConnection + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: (allow-none): a #GAsyncReadyCallback to call when the request is + * satisfied or %NULL if you don't care about the result + * @user_data: The data to pass to @callback * * Closes @connection. Note that this never causes the process to * exit (this might only happen if the other end of a shared message @@ -1446,16 +1448,16 @@ schedule_closed_unlocked (GDBusConnection *connection, * %G_IO_ERROR_CLOSED. * * When @connection has been closed, the #GDBusConnection::closed - * signal is emitted in the thread-default main - * loop of the thread that @connection was constructed in. + * signal is emitted in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread that @connection was constructed in. * * This is an asynchronous method. When the operation is finished, - * @callback will be invoked in the thread-default main - * loop of the thread you are calling this method from. You can + * @callback will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread you are calling this method from. You can * then call g_dbus_connection_close_finish() to get the result of the - * operation. See g_dbus_connection_close_sync() for the synchronous + * operation. See g_dbus_connection_close_sync() for the synchronous * version. * * Since: 2.26 @@ -1487,13 +1489,14 @@ g_dbus_connection_close (GDBusConnection *connection, /** * g_dbus_connection_close_finish: - * @connection: A #GDBusConnection. - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_close(). - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed + * to g_dbus_connection_close() + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_close(). * - * Returns: %TRUE if the operation succeeded, %FALSE if @error is set. + * Returns: %TRUE if the operation succeeded, %FALSE if @error is set * * Since: 2.26 */ @@ -1541,23 +1544,23 @@ sync_close_cb (GObject *source_object, /** * g_dbus_connection_close_sync: - * @connection: A #GDBusConnection. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously closees @connection. The calling thread is blocked * until this is done. See g_dbus_connection_close() for the * asynchronous version of this method and more details about what it * does. * - * Returns: %TRUE if the operation succeeded, %FALSE if @error is set. + * Returns: %TRUE if the operation succeeded, %FALSE if @error is set * * Since: 2.26 */ gboolean -g_dbus_connection_close_sync (GDBusConnection *connection, - GCancellable *cancellable, - GError **error) +g_dbus_connection_close_sync (GDBusConnection *connection, + GCancellable *cancellable, + GError **error) { gboolean ret; @@ -1592,8 +1595,521 @@ g_dbus_connection_close_sync (GDBusConnection *connection, /* ---------------------------------------------------------------------------------------------------- */ /** + * g_dbus_request_name: + * @connection: a #GDBusConnection + * @name: well-known bus name (name to request) + * @flags: a set of flags from the GBusNameOwnerFlags enumeration + * @error: return location for error or %NULL + * + * Synchronously acquires name on the bus and returns status code. + * + * The calling thread is blocked until a reply is received. + * + * Returns: status code or %G_BUS_REQUEST_NAME_FLAGS_ERROR + * if @error is set. + * + * Since: 2.4x + */ +GBusRequestNameReplyFlags +g_dbus_request_name (GDBusConnection *connection, + const gchar *name, + GBusNameOwnerFlags flags, + GError **error) +{ + GVariant *result; + guint32 request_name_reply; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), G_BUS_RELEASE_NAME_FLAGS_ERROR); + g_return_val_if_fail (g_dbus_is_name (name) && !g_dbus_is_unique_name (name), G_BUS_RELEASE_NAME_FLAGS_ERROR); + g_return_val_if_fail (error == NULL || *error == NULL, G_BUS_RELEASE_NAME_FLAGS_ERROR); + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_RequestName (connection, name, flags, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", + "org.freedesktop.DBus", "RequestName", + g_variant_new ("(su)", name, flags), G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + + if (result != NULL) + { + g_variant_get (result, "(u)", &request_name_reply); + g_variant_unref (result); + } + else + request_name_reply = G_BUS_REQUEST_NAME_FLAGS_ERROR; + + return (GBusRequestNameReplyFlags) request_name_reply; +} + +/** + * g_dbus_release_name: + * @connection: a #GDBusConnection + * @name: well-known bus name (name to release) + * @error: return location for error or %NULL + * + * Synchronously releases name on the bus and returns status code. + * + * The calling thread is blocked until a reply is received. + * + * Returns: status code or %G_BUS_RELEASE_NAME_FLAGS_ERROR + * if @error is set. + * + * Since: 2.4x + */ +GBusReleaseNameReplyFlags +g_dbus_release_name (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + GVariant *result; + guint32 release_name_reply; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), G_BUS_RELEASE_NAME_FLAGS_ERROR); + g_return_val_if_fail (g_dbus_is_name (name) && !g_dbus_is_unique_name (name), G_BUS_RELEASE_NAME_FLAGS_ERROR); + g_return_val_if_fail (error == NULL || *error == NULL, G_BUS_RELEASE_NAME_FLAGS_ERROR); + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_ReleaseName (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", + "org.freedesktop.DBus", "ReleaseName", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + + if (result != NULL) + { + g_variant_get (result, "(u)", &release_name_reply); + g_variant_unref (result); + } + else + release_name_reply = G_BUS_RELEASE_NAME_FLAGS_ERROR; + + return (GBusReleaseNameReplyFlags) release_name_reply; +} + +/** + * g_dbus_get_bus_id: + * @connection: a #GDBusConnection + * @error: return location for error or %NULL + * + * Synchronously returns the unique ID of the bus. + * + * The calling thread is blocked until a reply is received. + * + * Returns: the unique ID of the bus or %NULL if @error is set. + * Free with g_free(). + * + * Since: 2.4x + */ +gchar * +g_dbus_get_bus_id (GDBusConnection *connection, + GError **error) +{ + GVariant *result; + gchar *bus_id; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + result = NULL; + bus_id = NULL; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + { + result = _g_kdbus_GetBusId (connection, error); + } + else + { + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "GetId", + NULL, G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + } + + if (result != NULL) + { + g_variant_get (result, "(s)", &bus_id); + g_variant_unref (result); + } + + return bus_id; +} + +typedef enum +{ + LIST_NAMES, + LIST_ACTIVATABLE_NAMES, + LIST_QUEUED_OWNERS +} GDBusListNameType; + +static gchar ** +_g_dbus_get_list_internal (GDBusConnection *connection, + const gchar *name, + GDBusListNameType list_name_type, + GError **error) +{ + gchar **strv; + GVariant *result; + GVariantIter *iter; + gchar *str; + gsize n, i; + + result = NULL; + strv = NULL; + + if (list_name_type == LIST_QUEUED_OWNERS) + { + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_GetListQueuedOwners (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "ListQueuedOwners", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(as)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + } + else + { + gchar *method_name; + + if (list_name_type == LIST_NAMES) + method_name = "ListNames"; + else + method_name = "ListActivatableNames"; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_GetListNames (connection, list_name_type, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", method_name, + NULL, G_VARIANT_TYPE ("(as)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + } + + if (result != NULL) + { + g_variant_get (result, "(as)", &iter); + n = g_variant_iter_n_children (iter); + strv = g_new (gchar *, n + 1); + + i = 0; + while (g_variant_iter_loop (iter, "s", &str)) + { + strv[i] = g_strdup (str); + i++; + } + strv[i] = NULL; + + g_variant_iter_free (iter); + g_variant_unref (result); + } + + return strv; +} + +/** + * g_dbus_get_list_names: + * @connection: a #GDBusConnection + * @error: return location for error or %NULL + * + * Synchronously returns a list of all currently-owned names on the bus. + * + * The calling thread is blocked until a reply is received. + * + * Returns: a list of all currently-owned names on the bus or %NULL if + * @error is set. Free with g_strfreev(). + * + * Since: 2.4x + */ +gchar ** +g_dbus_get_list_names (GDBusConnection *connection, + GError **error) +{ + gchar **strv; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + strv = _g_dbus_get_list_internal (connection, NULL, LIST_NAMES, error); + + return strv; +} + +/** + * g_dbus_get_list_activatable_names: + * @connection: a #GDBusConnection + * @error: return location for error or %NULL + * + * Synchronously returns a list of all names that can be activated on the bus. + * + * The calling thread is blocked until a reply is received. + * + * Returns: a list of all names that can be activated on the bus or %NULL if + * @error is set. Free with g_strfreev(). + * + * Since: 2.4x + */ +gchar ** +g_dbus_get_list_activatable_names (GDBusConnection *connection, + GError **error) +{ + gchar **strv; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + strv = _g_dbus_get_list_internal (connection, NULL, LIST_ACTIVATABLE_NAMES, error); + + return strv; +} + +/** + * g_dbus_get_list_queued_names: + * @connection: a #GDBusConnection + * @name: a unique or well-known bus name + * @error: return location for error or %NULL + * + * Synchronously returns the unique bus names of connections currently queued + * for the @name. + * + * If @name contains a value not compatible with the D-Bus syntax and naming + * conventions for bus names, the operation returns %NULL and @error is set. + * + * The calling thread is blocked until a reply is received. + * + * Returns: the unique bus names of connections currently queued for the @name + * or %NULL if @error is set. Free with g_strfreev(). + * + * Since: 2.4x + */ +gchar ** +g_dbus_get_list_queued_owners (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + gchar **strv; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (name == NULL || g_dbus_is_name (name), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + strv = _g_dbus_get_list_internal (connection, name, LIST_QUEUED_OWNERS, error); + + return strv; +} + +/** + * g_dbus_get_name_owner: + * @connection: a #GDBusConnection + * @name: well-known bus name to get the owner of + * @error: return location for error or %NULL + * + * Synchronously returns the unique connection name of the primary owner of + * the name given. If the requested name doesn't have an owner, an @error is + * returned. + * + * If @name contains a value not compatible with the D-Bus syntax and naming + * conventions for bus names, the operation returns %NULL and @error is set. + * + * The calling thread is blocked until a reply is received. + * + * Returns: the unique connection name of the primary owner of the + * name given. If the requested name doesn't have an owner, function + * returns %NULL and @error is set. Free with g_free(). + * + * Since: 2.4x + */ +gchar * +g_dbus_get_name_owner (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + GVariant *result; + gchar *name_owner; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (name == NULL || g_dbus_is_name (name), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + name_owner = NULL; + result = NULL; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_GetNameOwner (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "GetNameOwner", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(s)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + if (result != NULL) + { + g_variant_get (result, "(s)", &name_owner); + g_variant_unref (result); + } + else + name_owner = NULL; + + return name_owner; +} + +/** + * g_dbus_name_has_owner: + * @connection: a #GDBusConnection + * @name: a unique or well-known bus name + * @error: return location for error or %NULL + * + * Synchronously checks if the specified name exists (currently has an owner). + * + * If @name contains a value not compatible with the D-Bus syntax and naming + * conventions for bus names, the operation returns %NULL and @error is set. + * + * The calling thread is blocked until a reply is received. + * + * Returns: %TRUE if specified name exists (currently has an owner) + * If the requested name doesn't have an owner or @error is set, + * function returns %FALSE. + * + * Since: 2.4x + */ +gboolean +g_dbus_name_has_owner (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + GVariant *result; + gboolean ret; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + g_return_val_if_fail (name == NULL || g_dbus_is_name (name), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + result = NULL; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_NameHasOwner (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "NameHasOwner", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(b)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + if (result != NULL) + { + g_variant_get (result, "(b)", &ret); + g_variant_unref (result); + } + else + ret = FALSE; + + return ret; +} + +/** + * g_dbus_get_connection_pid: + * @connection: a #GDBusConnection + * @name: a unique or well-known bus name of the connection to query + * @error: return location for error or %NULL + * + * Synchronously returns the Unix process ID of the process connected to the + * bus. If unable to determine it, an @error is returned. + * + * If @name contains a value not compatible with the D-Bus syntax and naming + * conventions for bus names, the operation returns (guint32) -1 and @error + * is set. + * + * The calling thread is blocked until a reply is received. + * + * Returns: the Unix process ID of the process connected to the bus or + * (guint32) -1 if @error is set. + * + * Since: 2.4x + */ +guint32 +g_dbus_get_connection_pid (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + GVariant *result; + guint32 pid; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), -1); + g_return_val_if_fail (name == NULL || g_dbus_is_name (name), -1); + g_return_val_if_fail (error == NULL || *error == NULL, -1); + + result = NULL; + pid = -1; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_GetConnectionUnixProcessID (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "GetConnectionUnixProcessID", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + if (result != NULL) + { + g_variant_get (result, "(u)", &pid); + g_variant_unref (result); + } + + return pid; +} + +/** + * g_dbus_get_connection_uid: + * @connection: a #GDBusConnection + * @name: a unique or well-known bus name of the connection to query + * @error: return location for error or %NULL + * + * Synchronously returns the Unix user ID of the process connected to the + * bus. If unable to determine it, an @error is returned. + * + * If @name contains a value not compatible with the D-Bus syntax and naming + * conventions for bus names, the operation returns (guint32) -1 and @error + * is set. + * + * The calling thread is blocked until a reply is received. + * + * Returns: the Unix user ID of the process connected to the bus or + * (guint32) -1 if @error is set. + * + * Since: 2.4x + */ +guint32 +g_dbus_get_connection_uid (GDBusConnection *connection, + const gchar *name, + GError **error) +{ + GVariant *result; + guint32 uid; + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), -1); + g_return_val_if_fail (name == NULL || g_dbus_is_name (name), -1); + g_return_val_if_fail (error == NULL || *error == NULL, -1); + + result = NULL; + uid = -1; + + if (G_IS_KDBUS_CONNECTION (connection->stream)) + result = _g_kdbus_GetConnectionUnixUser (connection, name, error); + else + result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", "/", + "org.freedesktop.DBus", "GetConnectionUnixUser", + g_variant_new ("(s)", name), G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); + if (result != NULL) + { + g_variant_get (result, "(u)", &uid); + g_variant_unref (result); + } + + return uid; +} + +/* ---------------------------------------------------------------------------------------------------- */ + +/** * g_dbus_connection_get_last_serial: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Retrieves the last serial number assigned to a #GDBusMessage on * the current thread. This includes messages sent via both low-level @@ -1602,7 +2118,7 @@ g_dbus_connection_close_sync (GDBusConnection *connection, * g_dbus_connection_call() or g_dbus_proxy_call(). * * Returns: the last used serial or zero when no message has been sent - * within the current thread. + * within the current thread * * Since: 2.34 */ @@ -1726,12 +2242,12 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection, /** * g_dbus_connection_send_message: - * @connection: A #GDBusConnection. - * @message: A #GDBusMessage - * @flags: Flags affecting how the message is sent. - * @out_serial: (out) (allow-none): Return location for serial number assigned - * to @message when sending it or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @message: a #GDBusMessage + * @flags: flags affecting how the message is sent + * @out_serial: (out) (allow-none): return location for serial number assigned + * to @message when sending it or %NULL + * @error: Return location for error or %NULL * * Asynchronously sends @message to the peer represented by @connection. * @@ -1746,24 +2262,24 @@ g_dbus_connection_send_message_unlocked (GDBusConnection *connection, * %G_IO_ERROR_CLOSED. If @message is not well-formed, * the operation fails with %G_IO_ERROR_INVALID_ARGUMENT. * - * See and for an example of how to use this - * low-level API to send and receive UNIX file descriptors. + * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] + * for an example of how to use this low-level API to send and receive + * UNIX file descriptors. * * Note that @message must be unlocked, unless @flags contain the * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. * * Returns: %TRUE if the message was well-formed and queued for - * transmission, %FALSE if @error is set. + * transmission, %FALSE if @error is set * * Since: 2.26 */ gboolean -g_dbus_connection_send_message (GDBusConnection *connection, - GDBusMessage *message, - GDBusSendMessageFlags flags, - volatile guint32 *out_serial, - GError **error) +g_dbus_connection_send_message (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + volatile guint32 *out_serial, + GError **error) { gboolean ret; @@ -1920,6 +2436,7 @@ send_message_with_reply_cancelled_cb (GCancellable *cancellable, send_message_with_reply_cancelled_idle_cb, send_message_data_ref (data), (GDestroyNotify) send_message_data_unref); + g_source_set_name (idle_source, "[gio] send_message_with_reply_cancelled_idle_cb"); g_source_attach (idle_source, data->main_context); g_source_unref (idle_source); } @@ -2039,17 +2556,17 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect /** * g_dbus_connection_send_message_with_reply: - * @connection: A #GDBusConnection. - * @message: A #GDBusMessage. - * @flags: Flags affecting how the message is sent. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @out_serial: (out) (allow-none): Return location for serial number assigned - * to @message when sending it or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (allow-none): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't care about the result. - * @user_data: The data to pass to @callback. + * @connection: a #GDBusConnection + * @message: a #GDBusMessage + * @flags: flags affecting how the message is sent + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @out_serial: (out) (allow-none): return location for serial number assigned + * to @message when sending it or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: (allow-none): a #GAsyncReadyCallback to call when the request + * is satisfied or %NULL if you don't care about the result + * @user_data: The data to pass to @callback * * Asynchronously sends @message to the peer represented by @connection. * @@ -2065,8 +2582,9 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect * fail with %G_IO_ERROR_CANCELLED. If @message is not well-formed, * the operation fails with %G_IO_ERROR_INVALID_ARGUMENT. * - * This is an asynchronous method. When the operation is finished, @callback will be invoked - * in the thread-default main loop + * This is an asynchronous method. When the operation is finished, @callback + * will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] * of the thread you are calling this method from. You can then call * g_dbus_connection_send_message_with_reply_finish() to get the result of the operation. * See g_dbus_connection_send_message_with_reply_sync() for the synchronous version. @@ -2074,21 +2592,21 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect * Note that @message must be unlocked, unless @flags contain the * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. * - * See and for an example of how to use this - * low-level API to send and receive UNIX file descriptors. + * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] + * for an example of how to use this low-level API to send and receive + * UNIX file descriptors. * * Since: 2.26 */ void -g_dbus_connection_send_message_with_reply (GDBusConnection *connection, - GDBusMessage *message, - GDBusSendMessageFlags flags, - gint timeout_msec, - volatile guint32 *out_serial, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_dbus_connection_send_message_with_reply (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + gint timeout_msec, + volatile guint32 *out_serial, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { g_return_if_fail (G_IS_DBUS_CONNECTION (connection)); g_return_if_fail (G_IS_DBUS_MESSAGE (message)); @@ -2110,8 +2628,9 @@ g_dbus_connection_send_message_with_reply (GDBusConnection *connection, /** * g_dbus_connection_send_message_with_reply_finish: * @connection: a #GDBusConnection - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_send_message_with_reply(). - * @error: Return location for error or %NULL. + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed to + * g_dbus_connection_send_message_with_reply() + * @error: teturn location for error or %NULL * * Finishes an operation started with g_dbus_connection_send_message_with_reply(). * @@ -2120,11 +2639,11 @@ g_dbus_connection_send_message_with_reply (GDBusConnection *connection, * be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use * g_dbus_message_to_gerror() to transcode this to a #GError. * - * See and for an example of how to use this - * low-level API to send and receive UNIX file descriptors. + * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] + * for an example of how to use this low-level API to send and receive + * UNIX file descriptors. * - * Returns: (transfer full): A locked #GDBusMessage or %NULL if @error is set. + * Returns: (transfer full): a locked #GDBusMessage or %NULL if @error is set * * Since: 2.26 */ @@ -2174,15 +2693,15 @@ send_message_with_reply_sync_cb (GDBusConnection *connection, /** * g_dbus_connection_send_message_with_reply_sync: - * @connection: A #GDBusConnection. - * @message: A #GDBusMessage. - * @flags: Flags affecting how the message is sent. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @out_serial: (out) (allow-none): Return location for serial number assigned - * to @message when sending it or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @message: a #GDBusMessage + * @flags: flags affecting how the message is sent. + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @out_serial: (out) (allow-none): return location for serial number + * assigned to @message when sending it or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously sends @message to the peer represented by @connection * and blocks the calling thread until a reply is received or the @@ -2206,25 +2725,26 @@ send_message_with_reply_sync_cb (GDBusConnection *connection, * be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use * g_dbus_message_to_gerror() to transcode this to a #GError. * - * See and for an example of how to use this - * low-level API to send and receive UNIX file descriptors. + * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] + * for an example of how to use this low-level API to send and receive + * UNIX file descriptors. * * Note that @message must be unlocked, unless @flags contain the * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. * - * Returns: (transfer full): A locked #GDBusMessage that is the reply to @message or %NULL if @error is set. + * Returns: (transfer full): a locked #GDBusMessage that is the reply + * to @message or %NULL if @error is set * * Since: 2.26 */ GDBusMessage * -g_dbus_connection_send_message_with_reply_sync (GDBusConnection *connection, - GDBusMessage *message, - GDBusSendMessageFlags flags, - gint timeout_msec, - volatile guint32 *out_serial, - GCancellable *cancellable, - GError **error) +g_dbus_connection_send_message_with_reply_sync (GDBusConnection *connection, + GDBusMessage *message, + GDBusSendMessageFlags flags, + gint timeout_msec, + volatile guint32 *out_serial, + GCancellable *cancellable, + GError **error) { SendMessageSyncData *data; GDBusMessage *reply; @@ -2591,6 +3111,12 @@ initable_init (GInitable *initable, g_assert_not_reached (); } + /* [KDBUS] Skip authentication process for kdbus transport */ + if (G_IS_KDBUS_CONNECTION (connection->stream)) + { + goto authenticated; + } + /* Authenticate the connection */ if (connection->flags & G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER) { @@ -2629,6 +3155,8 @@ initable_init (GInitable *initable, connection->authentication_observer = NULL; } +authenticated: + //g_output_stream_flush (G_SOCKET_CONNECTION (connection->stream) //g_debug ("haz unix fd passing powers: %d", connection->capabilities & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING); @@ -2672,17 +3200,25 @@ initable_init (GInitable *initable, goto out; } - hello_result = g_dbus_connection_call_sync (connection, - "org.freedesktop.DBus", /* name */ - "/org/freedesktop/DBus", /* path */ - "org.freedesktop.DBus", /* interface */ - "Hello", - NULL, /* parameters */ - G_VARIANT_TYPE ("(s)"), - CALL_FLAGS_INITIALIZING, - -1, - NULL, /* TODO: cancellable */ - &connection->initialization_error); + if (G_IS_KDBUS_CONNECTION (connection->stream)) + { + hello_result = _g_kdbus_Hello (connection->stream, &connection->initialization_error); + } + else + { + hello_result = g_dbus_connection_call_sync (connection, + "org.freedesktop.DBus", /* name */ + "/org/freedesktop/DBus", /* path */ + "org.freedesktop.DBus", /* interface */ + "Hello", + NULL, /* parameters */ + G_VARIANT_TYPE ("(s)"), + CALL_FLAGS_INITIALIZING, + -1, + NULL, /* TODO: cancellable */ + &connection->initialization_error); + } + if (hello_result == NULL) goto out; @@ -2723,13 +3259,13 @@ async_initable_iface_init (GAsyncInitableIface *async_initable_iface) /** * g_dbus_connection_new: - * @stream: A #GIOStream. - * @guid: (allow-none): The GUID to use if a authenticating as a server or %NULL. - * @flags: Flags describing how to make the connection. - * @observer: (allow-none): A #GDBusAuthObserver or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: A #GAsyncReadyCallback to call when the request is satisfied. - * @user_data: The data to pass to @callback. + * @stream: a #GIOStream + * @guid: (allow-none): the GUID to use if a authenticating as a server or %NULL + * @flags: flags describing how to make the connection + * @observer: (allow-none): a #GDBusAuthObserver or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: a #GAsyncReadyCallback to call when the request is satisfied + * @user_data: the data to pass to @callback * * Asynchronously sets up a D-Bus connection for exchanging D-Bus messages * with the end represented by @stream. @@ -2778,12 +3314,14 @@ g_dbus_connection_new (GIOStream *stream, /** * g_dbus_connection_new_finish: - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_new(). - * @error: Return location for error or %NULL. + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback + * passed to g_dbus_connection_new(). + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_new(). * - * Returns: A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: a #GDBusConnection or %NULL if @error is set. Free + * with g_object_unref(). * * Since: 2.26 */ @@ -2811,12 +3349,12 @@ g_dbus_connection_new_finish (GAsyncResult *res, /** * g_dbus_connection_new_sync: - * @stream: A #GIOStream. - * @guid: (allow-none): The GUID to use if a authenticating as a server or %NULL. - * @flags: Flags describing how to make the connection. - * @observer: (allow-none): A #GDBusAuthObserver or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @stream: a #GIOStream + * @guid: (allow-none): the GUID to use if a authenticating as a server or %NULL + * @flags: flags describing how to make the connection + * @observer: (allow-none): a #GDBusAuthObserver or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously sets up a D-Bus connection for exchanging D-Bus messages * with the end represented by @stream. @@ -2834,7 +3372,7 @@ g_dbus_connection_new_finish (GAsyncResult *res, * This is a synchronous failable constructor. See * g_dbus_connection_new() for the asynchronous version. * - * Returns: A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: a #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). * * Since: 2.26 */ @@ -2862,12 +3400,12 @@ g_dbus_connection_new_sync (GIOStream *stream, /** * g_dbus_connection_new_for_address: - * @address: A D-Bus address. - * @flags: Flags describing how to make the connection. - * @observer: (allow-none): A #GDBusAuthObserver or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: A #GAsyncReadyCallback to call when the request is satisfied. - * @user_data: The data to pass to @callback. + * @address: a D-Bus address + * @flags: flags describing how to make the connection + * @observer: (allow-none): a #GDBusAuthObserver or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: a #GAsyncReadyCallback to call when the request is satisfied + * @user_data: the data to pass to @callback * * Asynchronously connects and sets up a D-Bus client connection for * exchanging D-Bus messages with an endpoint specified by @address @@ -2914,12 +3452,14 @@ g_dbus_connection_new_for_address (const gchar *address, /** * g_dbus_connection_new_for_address_finish: - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_new(). - * @error: Return location for error or %NULL. + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed + * to g_dbus_connection_new() + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_new_for_address(). * - * Returns: A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: a #GDBusConnection or %NULL if @error is set. Free with + * g_object_unref(). * * Since: 2.26 */ @@ -2947,11 +3487,11 @@ g_dbus_connection_new_for_address_finish (GAsyncResult *res, /** * g_dbus_connection_new_for_address_sync: - * @address: A D-Bus address. - * @flags: Flags describing how to make the connection. - * @observer: (allow-none): A #GDBusAuthObserver or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @address: a D-Bus address + * @flags: flags describing how to make the connection + * @observer: (allow-none): a #GDBusAuthObserver or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously connects and sets up a D-Bus client connection for * exchanging D-Bus messages with an endpoint specified by @address @@ -2969,7 +3509,8 @@ g_dbus_connection_new_for_address_finish (GAsyncResult *res, * If @observer is not %NULL it may be used to control the * authentication process. * - * Returns: A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: a #GDBusConnection or %NULL if @error is set. Free with + * g_object_unref(). * * Since: 2.26 */ @@ -2995,9 +3536,9 @@ g_dbus_connection_new_for_address_sync (const gchar *address, /** * g_dbus_connection_set_exit_on_close: - * @connection: A #GDBusConnection. - * @exit_on_close: Whether the process should be terminated - * when @connection is closed by the remote peer. + * @connection: a #GDBusConnection + * @exit_on_close: whether the process should be terminated + * when @connection is closed by the remote peer * * Sets whether the process should be terminated when @connection is * closed by the remote peer. See #GDBusConnection:exit-on-close for @@ -3027,14 +3568,14 @@ g_dbus_connection_set_exit_on_close (GDBusConnection *connection, /** * g_dbus_connection_get_exit_on_close: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Gets whether the process is terminated when @connection is * closed by the remote peer. See * #GDBusConnection:exit-on-close for more details. * - * Returns: Whether the process is terminated when @connection is - * closed by the remote peer. + * Returns: whether the process is terminated when @connection is + * closed by the remote peer * * Since: 2.26 */ @@ -3051,13 +3592,13 @@ g_dbus_connection_get_exit_on_close (GDBusConnection *connection) /** * g_dbus_connection_get_guid: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * The GUID of the peer performing the role of server when * authenticating. See #GDBusConnection:guid for more details. * * Returns: The GUID. Do not free this string, it is owned by - * @connection. + * @connection. * * Since: 2.26 */ @@ -3070,15 +3611,15 @@ g_dbus_connection_get_guid (GDBusConnection *connection) /** * g_dbus_connection_get_unique_name: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Gets the unique name of @connection as assigned by the message * bus. This can also be used to figure out if @connection is a * message bus connection. * - * Returns: The unique name or %NULL if @connection is not a message - * bus connection. Do not free this string, it is owned by - * @connection. + * Returns: the unique name or %NULL if @connection is not a message + * bus connection. Do not free this string, it is owned by + * @connection. * * Since: 2.26 */ @@ -3096,7 +3637,7 @@ g_dbus_connection_get_unique_name (GDBusConnection *connection) /** * g_dbus_connection_get_peer_credentials: - * @connection: A #GDBusConnection. + * @connection: a #GDBusConnection * * Gets the credentials of the authenticated peer. This will always * return %NULL unless @connection acted as a server @@ -3108,8 +3649,8 @@ g_dbus_connection_get_unique_name (GDBusConnection *connection) * each application is a client. So this method will always return * %NULL for message bus clients. * - * Returns: (transfer none): A #GCredentials or %NULL if not available. Do not free - * this object, it is owned by @connection. + * Returns: (transfer none): a #GCredentials or %NULL if not available. + * Do not free this object, it is owned by @connection. * * Since: 2.26 */ @@ -3131,11 +3672,11 @@ static guint _global_filter_id = 1; /** * g_dbus_connection_add_filter: - * @connection: A #GDBusConnection. - * @filter_function: A filter function. - * @user_data: User data to pass to @filter_function. - * @user_data_free_func: Function to free @user_data with when filter - * is removed or %NULL. + * @connection: a #GDBusConnection + * @filter_function: a filter function + * @user_data: user data to pass to @filter_function + * @user_data_free_func: function to free @user_data with when filter + * is removed or %NULL * * Adds a message filter. Filters are handlers that are run on all * incoming and outgoing messages, prior to standard dispatch. Filters @@ -3158,8 +3699,8 @@ static guint _global_filter_id = 1; * message. Similary, if a filter consumes an outgoing message, the * message will not be sent to the other peer. * - * Returns: A filter identifier that can be used with - * g_dbus_connection_remove_filter(). + * Returns: a filter identifier that can be used with + * g_dbus_connection_remove_filter() * * Since: 2.26 */ @@ -3407,26 +3948,27 @@ is_signal_data_for_name_lost_or_acquired (SignalData *signal_data) /** * g_dbus_connection_signal_subscribe: - * @connection: A #GDBusConnection. - * @sender: (allow-none): Sender name to match on (unique or well-known name) - * or %NULL to listen from all senders. + * @connection: a #GDBusConnection + * @sender: (allow-none): sender name to match on (unique or well-known name) + * or %NULL to listen from all senders * @interface_name: (allow-none): D-Bus interface name to match on or %NULL to - * match on all interfaces. - * @member: (allow-none): D-Bus signal name to match on or %NULL to match on all signals. - * @object_path: (allow-none): Object path to match on or %NULL to match on all object paths. - * @arg0: (allow-none): Contents of first string argument to match on or %NULL - * to match on all kinds of arguments. - * @flags: Flags describing how to subscribe to the signal (currently unused). - * @callback: Callback to invoke when there is a signal matching the requested data. - * @user_data: User data to pass to @callback. - * @user_data_free_func: (allow-none): Function to free @user_data with when - * subscription is removed or %NULL. - * - * Subscribes to signals on @connection and invokes @callback with a - * whenever the signal is received. Note that @callback - * will be invoked in the thread-default main - * loop of the thread you are calling this method from. + * match on all interfaces + * @member: (allow-none): D-Bus signal name to match on or %NULL to match on + * all signals + * @object_path: (allow-none): object path to match on or %NULL to match on + * all object paths + * @arg0: (allow-none): contents of first string argument to match on or %NULL + * to match on all kinds of arguments + * @flags: flags describing how to subscribe to the signal (currently unused) + * @callback: callback to invoke when there is a signal matching the requested data + * @user_data: user data to pass to @callback + * @user_data_free_func: (allow-none): function to free @user_data with when + * subscription is removed or %NULL + * + * Subscribes to signals on @connection and invokes @callback with a whenever + * the signal is received. Note that @callback will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread you are calling this method from. * * If @connection is not a message bus connection, @sender must be * %NULL. @@ -3443,7 +3985,7 @@ is_signal_data_for_name_lost_or_acquired (SignalData *signal_data) * interpreted as part of a namespace or path. The first argument * of a signal is matched against that part as specified by D-Bus. * - * Returns: A subscription identifier that can be used with g_dbus_connection_signal_unsubscribe(). + * Returns: a subscription identifier that can be used with g_dbus_connection_signal_unsubscribe() * * Since: 2.26 */ @@ -3542,6 +4084,16 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection, { if (!is_signal_data_for_name_lost_or_acquired (signal_data)) add_match_rule (connection, signal_data->rule); + else + { + if (G_IS_KDBUS_CONNECTION (connection->stream)) + { + if (g_strcmp0 (signal_data->member, "NameAcquired") == 0) + _g_kdbus_subscribe_name_acquired (connection, arg0); + else if (g_strcmp0 (signal_data->member, "NameLost") == 0) + _g_kdbus_subscribe_name_lost (connection, arg0); + } + } } signal_data_array = g_hash_table_lookup (connection->map_sender_unique_name_to_signal_data_array, @@ -3628,6 +4180,13 @@ unsubscribe_id_internal (GDBusConnection *connection, */ remove_match_rule (connection, signal_data->rule); } + else + { + if (G_IS_KDBUS_CONNECTION (connection->stream)) + { + //_g_kdbus_unsubscribe_name_lost_and_acquired (connection, arg0); + } + } signal_data_free (signal_data); } @@ -3643,8 +4202,9 @@ unsubscribe_id_internal (GDBusConnection *connection, /** * g_dbus_connection_signal_unsubscribe: - * @connection: A #GDBusConnection. - * @subscription_id: A subscription id obtained from g_dbus_connection_signal_subscribe(). + * @connection: a #GDBusConnection + * @subscription_id: a subscription id obtained from + * g_dbus_connection_signal_subscribe() * * Unsubscribes from signals. * @@ -3718,7 +4278,7 @@ emit_signal_instance_in_idle_cb (gpointer data) } else { - g_variant_ref_sink (parameters); + g_variant_ref (parameters); } #if 0 @@ -3895,6 +4455,7 @@ schedule_callbacks (GDBusConnection *connection, emit_signal_instance_in_idle_cb, signal_instance, (GDestroyNotify) signal_instance_free); + g_source_set_name (idle_source, "[gio] emit_signal_instance_in_idle_cb"); g_source_attach (idle_source, subscriber->context); g_source_unref (idle_source); } @@ -4272,17 +4833,8 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect &property_name, NULL); - - if (is_get) - { - if (vtable == NULL || vtable->get_property == NULL) - goto out; - } - else - { - if (vtable == NULL || vtable->set_property == NULL) - goto out; - } + if (vtable == NULL) + goto out; /* Check that the property exists - if not fail with org.freedesktop.DBus.Error.InvalidArgs */ @@ -4350,6 +4902,32 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect g_variant_unref (value); } + /* If the vtable pointer for get_property() resp. set_property() is + * NULL then dispatch the call via the method_call() handler. + */ + if (is_get) + { + if (vtable->get_property == NULL) + { + schedule_method_call (connection, message, registration_id, subtree_registration_id, + interface_info, NULL, property_info, g_dbus_message_get_body (message), + vtable, main_context, user_data); + handled = TRUE; + goto out; + } + } + else + { + if (vtable->set_property == NULL) + { + schedule_method_call (connection, message, registration_id, subtree_registration_id, + interface_info, NULL, property_info, g_dbus_message_get_body (message), + vtable, main_context, user_data); + handled = TRUE; + goto out; + } + } + /* ok, got the property info - call user code in an idle handler */ property_data = g_new0 (PropertyData, 1); property_data->connection = g_object_ref (connection); @@ -4368,6 +4946,10 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect is_get ? invoke_get_property_in_idle_cb : invoke_set_property_in_idle_cb, property_data, (GDestroyNotify) property_data_free); + if (is_get) + g_source_set_name (idle_source, "[gio] invoke_get_property_in_idle_cb"); + else + g_source_set_name (idle_source, "[gio] invoke_set_property_in_idle_cb"); g_source_attach (idle_source, main_context); g_source_unref (idle_source); @@ -4521,6 +5103,21 @@ invoke_get_all_properties_in_idle_cb (gpointer _data) return FALSE; } +static gboolean +interface_has_readable_properties (GDBusInterfaceInfo *interface_info) +{ + gint i; + + if (!interface_info->properties) + return FALSE; + + for (i = 0; interface_info->properties[i]; i++) + if (interface_info->properties[i]->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE) + return TRUE; + + return FALSE; +} + /* called in any thread with connection's lock held */ static gboolean validate_and_maybe_schedule_property_get_all (GDBusConnection *connection, @@ -4538,9 +5135,22 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec handled = FALSE; - if (vtable == NULL || vtable->get_property == NULL) + if (vtable == NULL) goto out; + /* If the vtable pointer for get_property() is NULL but we have a + * non-zero number of readable properties, then dispatch the call via + * the method_call() handler. + */ + if (vtable->get_property == NULL && interface_has_readable_properties (interface_info)) + { + schedule_method_call (connection, message, registration_id, subtree_registration_id, + interface_info, NULL, NULL, g_dbus_message_get_body (message), + vtable, main_context, user_data); + handled = TRUE; + goto out; + } + /* ok, got the property info - call user in an idle handler */ property_get_all_data = g_new0 (PropertyGetAllData, 1); property_get_all_data->connection = g_object_ref (connection); @@ -4557,6 +5167,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec invoke_get_all_properties_in_idle_cb, property_get_all_data, (GDestroyNotify) property_get_all_data_free); + g_source_set_name (idle_source, "[gio] invoke_get_all_properties_in_idle_cb"); g_source_attach (idle_source, main_context); g_source_unref (idle_source); @@ -4841,6 +5452,7 @@ schedule_method_call (GDBusConnection *connection, guint subtree_registration_id, const GDBusInterfaceInfo *interface_info, const GDBusMethodInfo *method_info, + const GDBusPropertyInfo *property_info, GVariant *parameters, const GDBusInterfaceVTable *vtable, GMainContext *main_context, @@ -4854,6 +5466,7 @@ schedule_method_call (GDBusConnection *connection, g_dbus_message_get_interface (message), g_dbus_message_get_member (message), method_info, + property_info, connection, message, parameters, @@ -4871,6 +5484,7 @@ schedule_method_call (GDBusConnection *connection, call_in_idle_cb, invocation, g_object_unref); + g_source_set_name (idle_source, "[gio] call_in_idle_cb"); g_source_attach (idle_source, main_context); g_source_unref (idle_source); } @@ -4950,7 +5564,7 @@ validate_and_maybe_schedule_method_call (GDBusConnection *connection, /* schedule the call in idle */ schedule_method_call (connection, message, registration_id, subtree_registration_id, - interface_info, method_info, parameters, + interface_info, method_info, NULL, parameters, vtable, main_context, user_data); g_variant_unref (parameters); handled = TRUE; @@ -5038,30 +5652,31 @@ obj_message_func (GDBusConnection *connection, /** * g_dbus_connection_register_object: - * @connection: A #GDBusConnection. - * @object_path: The object path to register at. - * @interface_info: Introspection data for the interface. - * @vtable: (allow-none): A #GDBusInterfaceVTable to call into or %NULL. - * @user_data: (allow-none): Data to pass to functions in @vtable. - * @user_data_free_func: Function to call when the object path is unregistered. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @object_path: the object path to register at + * @interface_info: introspection data for the interface + * @vtable: (allow-none): a #GDBusInterfaceVTable to call into or %NULL + * @user_data: (allow-none): data to pass to functions in @vtable + * @user_data_free_func: function to call when the object path is unregistered + * @error: return location for error or %NULL * * Registers callbacks for exported objects at @object_path with the * D-Bus interface that is described in @interface_info. * - * Calls to functions in @vtable (and @user_data_free_func) will - * happen in the thread-default main - * loop of the thread you are calling this method from. + * Calls to functions in @vtable (and @user_data_free_func) will happen + * in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread you are calling this method from. * * Note that all #GVariant values passed to functions in @vtable will match * the signature given in @interface_info - if a remote caller passes - * incorrect values, the org.freedesktop.DBus.Error.InvalidArgs + * incorrect values, the `org.freedesktop.DBus.Error.InvalidArgs` * is returned to the remote caller. * * Additionally, if the remote caller attempts to invoke methods or * access properties not mentioned in @interface_info the - * org.freedesktop.DBus.Error.UnknownMethod resp. - * org.freedesktop.DBus.Error.InvalidArgs errors + * `org.freedesktop.DBus.Error.UnknownMethod` resp. + * `org.freedesktop.DBus.Error.InvalidArgs` errors * are returned to the caller. * * It is considered a programming error if the @@ -5073,31 +5688,30 @@ obj_message_func (GDBusConnection *connection, * * GDBus automatically implements the standard D-Bus interfaces * org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable - * and org.freedesktop.Peer, so you don't have to implement those for - * the objects you export. You can implement - * org.freedesktop.DBus.Properties yourself, e.g. to handle getting - * and setting of properties asynchronously. + * and org.freedesktop.Peer, so you don't have to implement those for the + * objects you export. You can implement org.freedesktop.DBus.Properties + * yourself, e.g. to handle getting and setting of properties asynchronously. * * Note that the reference count on @interface_info will be * incremented by 1 (unless allocated statically, e.g. if the * reference count is -1, see g_dbus_interface_info_ref()) for as long * as the object is exported. Also note that @vtable will be copied. * - * See for an example of how to use this method. + * See this [server][gdbus-server] for an example of how to use this method. * * Returns: 0 if @error is set, otherwise a registration id (never 0) - * that can be used with g_dbus_connection_unregister_object() . + * that can be used with g_dbus_connection_unregister_object() * * Since: 2.26 */ guint -g_dbus_connection_register_object (GDBusConnection *connection, - const gchar *object_path, - GDBusInterfaceInfo *interface_info, - const GDBusInterfaceVTable *vtable, - gpointer user_data, - GDestroyNotify user_data_free_func, - GError **error) +g_dbus_connection_register_object (GDBusConnection *connection, + const gchar *object_path, + GDBusInterfaceInfo *interface_info, + const GDBusInterfaceVTable *vtable, + gpointer user_data, + GDestroyNotify user_data_free_func, + GError **error) { ExportedObject *eo; ExportedInterface *ei; @@ -5167,12 +5781,13 @@ g_dbus_connection_register_object (GDBusConnection *connection, /** * g_dbus_connection_unregister_object: - * @connection: A #GDBusConnection. - * @registration_id: A registration id obtained from g_dbus_connection_register_object(). + * @connection: a #GDBusConnection + * @registration_id: a registration id obtained from + * g_dbus_connection_register_object() * * Unregisters an object. * - * Returns: %TRUE if the object was unregistered, %FALSE otherwise. + * Returns: %TRUE if the object was unregistered, %FALSE otherwise * * Since: 2.26 */ @@ -5217,15 +5832,15 @@ g_dbus_connection_unregister_object (GDBusConnection *connection, /** * g_dbus_connection_emit_signal: - * @connection: A #GDBusConnection. - * @destination_bus_name: (allow-none): The unique bus name for the destination - * for the signal or %NULL to emit to all listeners. - * @object_path: Path of remote object. - * @interface_name: D-Bus interface to emit a signal on. - * @signal_name: The name of the signal to emit. - * @parameters: (allow-none): A #GVariant tuple with parameters for the signal - * or %NULL if not passing parameters. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @destination_bus_name: (allow-none): the unique bus name for the destination + * for the signal or %NULL to emit to all listeners + * @object_path: path of remote object + * @interface_name: D-Bus interface to emit a signal on + * @signal_name: the name of the signal to emit + * @parameters: (allow-none): a #GVariant tuple with parameters for the signal + * or %NULL if not passing parameters + * @error: Return location for error or %NULL * * Emits a signal. * @@ -5233,7 +5848,7 @@ g_dbus_connection_unregister_object (GDBusConnection *connection, * * This can only fail if @parameters is not compatible with the D-Bus protocol. * - * Returns: %TRUE unless @error is set. + * Returns: %TRUE unless @error is set * * Since: 2.26 */ @@ -5718,23 +6333,23 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection, /** * g_dbus_connection_call: - * @connection: A #GDBusConnection. - * @bus_name: (allow-none): A unique or well-known bus name or %NULL if - * @connection is not a message bus connection. - * @object_path: Path of remote object. - * @interface_name: D-Bus interface to invoke method on. - * @method_name: The name of the method to invoke. - * @parameters: (allow-none): A #GVariant tuple with parameters for the method - * or %NULL if not passing parameters. - * @reply_type: (allow-none): The expected type of the reply, or %NULL. - * @flags: Flags from the #GDBusCallFlags enumeration. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (allow-none): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't care about the result of the - * method invocation. - * @user_data: The data to pass to @callback. + * @connection: a #GDBusConnection + * @bus_name: (allow-none): a unique or well-known bus name or %NULL if + * @connection is not a message bus connection + * @object_path: path of remote object + * @interface_name: D-Bus interface to invoke method on + * @method_name: the name of the method to invoke + * @parameters: (allow-none): a #GVariant tuple with parameters for the method + * or %NULL if not passing parameters + * @reply_type: (allow-none): the expected type of the reply, or %NULL + * @flags: flags from the #GDBusCallFlags enumeration + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: (allow-none): a #GAsyncReadyCallback to call when the request + * is satisfied or %NULL if you don't care about the result of the + * method invocation + * @user_data: the data to pass to @callback * * Asynchronously invokes the @method_name method on the * @interface_name D-Bus interface on the remote object at @@ -5752,7 +6367,7 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection, * * If the @parameters #GVariant is floating, it is consumed. This allows * convenient 'inline' use of g_variant_new(), e.g.: - * |[ + * |[ * g_dbus_connection_call (connection, * "org.freedesktop.StringThings", * "/org/freedesktop/StringThings", @@ -5769,8 +6384,9 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection, * NULL); * ]| * - * This is an asynchronous method. When the operation is finished, @callback will be invoked - * in the thread-default main loop + * This is an asynchronous method. When the operation is finished, + * @callback will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] * of the thread you are calling this method from. You can then call * g_dbus_connection_call_finish() to get the result of the operation. * See g_dbus_connection_call_sync() for the synchronous version of this @@ -5782,32 +6398,32 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection, * Since: 2.26 */ void -g_dbus_connection_call (GDBusConnection *connection, - const gchar *bus_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - const GVariantType *reply_type, - GDBusCallFlags flags, - gint timeout_msec, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_dbus_connection_call (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { g_dbus_connection_call_internal (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, NULL, cancellable, callback, user_data); } /** * g_dbus_connection_call_finish: - * @connection: A #GDBusConnection. - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_call(). - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_call() + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_call(). * * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with - * return values. Free with g_variant_unref(). + * return values. Free with g_variant_unref(). * * Since: 2.26 */ @@ -5821,20 +6437,20 @@ g_dbus_connection_call_finish (GDBusConnection *connection, /** * g_dbus_connection_call_sync: - * @connection: A #GDBusConnection. - * @bus_name: (allow-none): A unique or well-known bus name or %NULL if - * @connection is not a message bus connection. - * @object_path: Path of remote object. - * @interface_name: D-Bus interface to invoke method on. - * @method_name: The name of the method to invoke. - * @parameters: (allow-none): A #GVariant tuple with parameters for the method - * or %NULL if not passing parameters. - * @reply_type: (allow-none): The expected type of the reply, or %NULL. - * @flags: Flags from the #GDBusCallFlags enumeration. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @bus_name: (allow-none): a unique or well-known bus name or %NULL if + * @connection is not a message bus connection + * @object_path: path of remote object + * @interface_name: D-Bus interface to invoke method on + * @method_name: the name of the method to invoke + * @parameters: (allow-none): a #GVariant tuple with parameters for the method + * or %NULL if not passing parameters + * @reply_type: (allow-none): the expected type of the reply, or %NULL + * @flags: flags from the #GDBusCallFlags enumeration + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously invokes the @method_name method on the * @interface_name D-Bus interface on the remote object at @@ -5853,7 +6469,7 @@ g_dbus_connection_call_finish (GDBusConnection *connection, * * If the @parameters #GVariant is floating, it is consumed. * This allows convenient 'inline' use of g_variant_new(), e.g.: - * |[ + * |[ * g_dbus_connection_call_sync (connection, * "org.freedesktop.StringThings", * "/org/freedesktop/StringThings", @@ -5866,7 +6482,7 @@ g_dbus_connection_call_finish (GDBusConnection *connection, * G_DBUS_CALL_FLAGS_NONE, * -1, * NULL, - * &error); + * &error); * ]| * * The calling thread is blocked until a reply is received. See @@ -5874,22 +6490,22 @@ g_dbus_connection_call_finish (GDBusConnection *connection, * this method. * * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with - * return values. Free with g_variant_unref(). + * return values. Free with g_variant_unref(). * * Since: 2.26 */ GVariant * -g_dbus_connection_call_sync (GDBusConnection *connection, - const gchar *bus_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - const GVariantType *reply_type, - GDBusCallFlags flags, - gint timeout_msec, - GCancellable *cancellable, - GError **error) +g_dbus_connection_call_sync (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error) { return g_dbus_connection_call_sync_internal (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, NULL, NULL, cancellable, error); } @@ -5900,23 +6516,23 @@ g_dbus_connection_call_sync (GDBusConnection *connection, /** * g_dbus_connection_call_with_unix_fd_list: - * @connection: A #GDBusConnection. - * @bus_name: (allow-none): A unique or well-known bus name or %NULL if - * @connection is not a message bus connection. - * @object_path: Path of remote object. - * @interface_name: D-Bus interface to invoke method on. - * @method_name: The name of the method to invoke. - * @parameters: (allow-none): A #GVariant tuple with parameters for the method - * or %NULL if not passing parameters. - * @reply_type: (allow-none): The expected type of the reply, or %NULL. - * @flags: Flags from the #GDBusCallFlags enumeration. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @fd_list: (allow-none): A #GUnixFDList or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: (allow-none): A #GAsyncReadyCallback to call when the request is - * satisfied or %NULL if you don't * care about the result of the - * method invocation. + * @connection: a #GDBusConnection + * @bus_name: (allow-none): a unique or well-known bus name or %NULL if + * @connection is not a message bus connection + * @object_path: path of remote object + * @interface_name: D-Bus interface to invoke method on + * @method_name: the name of the method to invoke + * @parameters: (allow-none): a #GVariant tuple with parameters for the method + * or %NULL if not passing parameters + * @reply_type: (allow-none): the expected type of the reply, or %NULL + * @flags: flags from the #GDBusCallFlags enumeration + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @fd_list: (allow-none): a #GUnixFDList or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: (allow-none): a #GAsyncReadyCallback to call when the request is + * satisfied or %NULL if you don't * care about the result of the + * method invocation * @user_data: The data to pass to @callback. * * Like g_dbus_connection_call() but also takes a #GUnixFDList object. @@ -5926,34 +6542,35 @@ g_dbus_connection_call_sync (GDBusConnection *connection, * Since: 2.30 */ void -g_dbus_connection_call_with_unix_fd_list (GDBusConnection *connection, - const gchar *bus_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - const GVariantType *reply_type, - GDBusCallFlags flags, - gint timeout_msec, - GUnixFDList *fd_list, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +g_dbus_connection_call_with_unix_fd_list (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { g_dbus_connection_call_internal (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, fd_list, cancellable, callback, user_data); } /** * g_dbus_connection_call_with_unix_fd_list_finish: - * @connection: A #GDBusConnection. - * @out_fd_list: (out) (allow-none): Return location for a #GUnixFDList or %NULL. - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_call_with_unix_fd_list(). - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @out_fd_list: (out) (allow-none): return location for a #GUnixFDList or %NULL + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed to + * g_dbus_connection_call_with_unix_fd_list() + * @error: return location for error or %NULL * * Finishes an operation started with g_dbus_connection_call_with_unix_fd_list(). * * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with - * return values. Free with g_variant_unref(). + * return values. Free with g_variant_unref(). * * Since: 2.30 */ @@ -5968,46 +6585,46 @@ g_dbus_connection_call_with_unix_fd_list_finish (GDBusConnection *connection, /** * g_dbus_connection_call_with_unix_fd_list_sync: - * @connection: A #GDBusConnection. - * @bus_name: (allow-none): A unique or well-known bus name or %NULL if - * @connection is not a message bus connection. - * @object_path: Path of remote object. - * @interface_name: D-Bus interface to invoke method on. - * @method_name: The name of the method to invoke. - * @parameters: (allow-none): A #GVariant tuple with parameters for the method - * or %NULL if not passing parameters. - * @reply_type: (allow-none): The expected type of the reply, or %NULL. - * @flags: Flags from the #GDBusCallFlags enumeration. - * @timeout_msec: The timeout in milliseconds, -1 to use the default - * timeout or %G_MAXINT for no timeout. - * @fd_list: (allow-none): A #GUnixFDList or %NULL. - * @out_fd_list: (out) (allow-none): Return location for a #GUnixFDList or %NULL. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @bus_name: (allow-none): a unique or well-known bus name or %NULL + * if @connection is not a message bus connection + * @object_path: path of remote object + * @interface_name: D-Bus interface to invoke method on + * @method_name: the name of the method to invoke + * @parameters: (allow-none): a #GVariant tuple with parameters for + * the method or %NULL if not passing parameters + * @reply_type: (allow-none): the expected type of the reply, or %NULL + * @flags: flags from the #GDBusCallFlags enumeration + * @timeout_msec: the timeout in milliseconds, -1 to use the default + * timeout or %G_MAXINT for no timeout + * @fd_list: (allow-none): a #GUnixFDList or %NULL + * @out_fd_list: (out) (allow-none): return location for a #GUnixFDList or %NULL + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Like g_dbus_connection_call_sync() but also takes and returns #GUnixFDList objects. * * This method is only available on UNIX. * * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with - * return values. Free with g_variant_unref(). + * return values. Free with g_variant_unref(). * * Since: 2.30 */ GVariant * -g_dbus_connection_call_with_unix_fd_list_sync (GDBusConnection *connection, - const gchar *bus_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - const GVariantType *reply_type, - GDBusCallFlags flags, - gint timeout_msec, - GUnixFDList *fd_list, - GUnixFDList **out_fd_list, - GCancellable *cancellable, - GError **error) +g_dbus_connection_call_with_unix_fd_list_sync (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GUnixFDList *fd_list, + GUnixFDList **out_fd_list, + GCancellable *cancellable, + GError **error) { return g_dbus_connection_call_sync_internal (connection, bus_name, object_path, interface_name, method_name, parameters, reply_type, flags, timeout_msec, fd_list, out_fd_list, cancellable, error); } @@ -6443,6 +7060,7 @@ subtree_message_func (GDBusConnection *connection, process_subtree_vtable_message_in_idle_cb, data, (GDestroyNotify) subtree_deferred_data_free); + g_source_set_name (idle_source, "[gio] process_subtree_vtable_message_in_idle_cb"); g_source_attach (idle_source, es->context); g_source_unref (idle_source); @@ -6455,15 +7073,16 @@ subtree_message_func (GDBusConnection *connection, /** * g_dbus_connection_register_subtree: - * @connection: A #GDBusConnection. - * @object_path: The object path to register the subtree at. - * @vtable: A #GDBusSubtreeVTable to enumerate, introspect and dispatch nodes in the subtree. - * @flags: Flags used to fine tune the behavior of the subtree. - * @user_data: Data to pass to functions in @vtable. - * @user_data_free_func: Function to call when the subtree is unregistered. - * @error: Return location for error or %NULL. + * @connection: a #GDBusConnection + * @object_path: the object path to register the subtree at + * @vtable: a #GDBusSubtreeVTable to enumerate, introspect and + * dispatch nodes in the subtree + * @flags: flags used to fine tune the behavior of the subtree + * @user_data: data to pass to functions in @vtable + * @user_data_free_func: function to call when the subtree is unregistered + * @error: return location for error or %NULL * - * Registers a whole subtree of dynamic objects. + * Registers a whole subtree of dynamic objects. * * The @enumerate and @introspection functions in @vtable are used to * convey, to remote callers, what nodes exist in the subtree rooted @@ -6478,9 +7097,9 @@ subtree_message_func (GDBusConnection *connection, * #gpointer will be used to call into the interface vtable for processing * the request. * - * All calls into user-provided code will be invoked in the thread-default main - * loop of the thread you are calling this method from. + * All calls into user-provided code will be invoked in the + * [thread-default main context][g-main-context-push-thread-default] + * of the thread you are calling this method from. * * If an existing subtree is already registered at @object_path or * then @error is set to #G_IO_ERROR_EXISTS. @@ -6489,14 +7108,14 @@ subtree_message_func (GDBusConnection *connection, * g_dbus_connection_register_object()) in a subtree registered with * g_dbus_connection_register_subtree() - if so, the subtree handler * is tried as the last resort. One way to think about a subtree - * handler is to consider it a fallback handler - * for object paths not registered via g_dbus_connection_register_object() - * or other bindings. + * handler is to consider it a fallback handler for object paths not + * registered via g_dbus_connection_register_object() or other bindings. * * Note that @vtable will be copied so you cannot change it after * registration. * - * See for an example of how to use this method. + * See this [server][gdbus-subtree-server] for an example of how to use + * this method. * * Returns: 0 if @error is set, otherwise a subtree registration id (never 0) * that can be used with g_dbus_connection_unregister_subtree() . @@ -6564,12 +7183,13 @@ g_dbus_connection_register_subtree (GDBusConnection *connection, /** * g_dbus_connection_unregister_subtree: - * @connection: A #GDBusConnection. - * @registration_id: A subtree registration id obtained from g_dbus_connection_register_subtree(). + * @connection: a #GDBusConnection + * @registration_id: a subtree registration id obtained from + * g_dbus_connection_register_subtree() * * Unregisters a subtree. * - * Returns: %TRUE if the subtree was unregistered, %FALSE otherwise. + * Returns: %TRUE if the subtree was unregistered, %FALSE otherwise * * Since: 2.26 */ @@ -6839,6 +7459,14 @@ message_bus_get_singleton (GBusType bus_type, ret = &the_system_bus; break; + case G_BUS_TYPE_USER: + ret = &the_user_bus; + break; + + case G_BUS_TYPE_MACHINE: + ret = &the_machine_bus; + break; + case G_BUS_TYPE_STARTER: starter_bus = g_getenv ("DBUS_STARTER_BUS_TYPE"); if (g_strcmp0 (starter_bus, "session") == 0) @@ -6945,9 +7573,9 @@ _g_bus_get_singleton_if_exists (GBusType bus_type) /** * g_bus_get_sync: - * @bus_type: A #GBusType. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @error: Return location for error or %NULL. + * @bus_type: a #GBusType + * @cancellable: (allow-none): a #GCancellable or %NULL + * @error: return location for error or %NULL * * Synchronously connects to the message bus specified by @bus_type. * Note that the returned object may shared with other callers, @@ -6966,7 +7594,8 @@ _g_bus_get_singleton_if_exists (GBusType bus_type) * Note that the returned #GDBusConnection object will (usually) have * the #GDBusConnection:exit-on-close property set to %TRUE. * - * Returns: (transfer full): A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: (transfer full): a #GDBusConnection or %NULL if @error is set. + * Free with g_object_unref(). * * Since: 2.26 */ @@ -7022,10 +7651,10 @@ bus_get_async_initable_cb (GObject *source_object, /** * g_bus_get: - * @bus_type: A #GBusType. - * @cancellable: (allow-none): A #GCancellable or %NULL. - * @callback: A #GAsyncReadyCallback to call when the request is satisfied. - * @user_data: The data to pass to @callback. + * @bus_type: a #GBusType + * @cancellable: (allow-none): a #GCancellable or %NULL + * @callback: a #GAsyncReadyCallback to call when the request is satisfied + * @user_data: the data to pass to @callback * * Asynchronously connects to the message bus specified by @bus_type. * @@ -7074,8 +7703,9 @@ g_bus_get (GBusType bus_type, /** * g_bus_get_finish: - * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_bus_get(). - * @error: Return location for error or %NULL. + * @res: a #GAsyncResult obtained from the #GAsyncReadyCallback passed + * to g_bus_get() + * @error: return location for error or %NULL * * Finishes an operation started with g_bus_get(). * @@ -7088,7 +7718,8 @@ g_bus_get (GBusType bus_type, * Note that the returned #GDBusConnection object will (usually) have * the #GDBusConnection:exit-on-close property set to %TRUE. * - * Returns: (transfer full): A #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). + * Returns: (transfer full): a #GDBusConnection or %NULL if @error is set. + * Free with g_object_unref(). * * Since: 2.26 */