GDBus: Add GDBusAuthObserver param in g_dbus_connection_new_for_address()

This is to match g_dbus_connection_new(). This extension allows us to
extend GDBusAuthObserver to also be used in client-side authentication
in the future (right now it's only used on the server-side).
This commit is contained in:
David Zeuthen 2010-05-13 16:32:11 -04:00
parent cb753dfd49
commit 60e7ae26af
6 changed files with 23 additions and 4 deletions

View File

@ -424,6 +424,7 @@ connection_get_dbus_connection (GError **error)
{ {
c = g_dbus_connection_new_for_address_sync (opt_connection_address, c = g_dbus_connection_new_for_address_sync (opt_connection_address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* GCancellable */ NULL, /* GCancellable */
error); error);
} }

View File

@ -1948,8 +1948,7 @@ async_initable_iface_init (GAsyncInitableIface *async_initable_iface)
* Asynchronously sets up a D-Bus connection for exchanging D-Bus messages * Asynchronously sets up a D-Bus connection for exchanging D-Bus messages
* with the end represented by @stream. * with the end represented by @stream.
* *
* If %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER is set in @flags, * If @observer is not %NULL it may be used to control the
* @observer (if not %NULL) is used to assist in the client
* authentication process. * authentication process.
* *
* When the operation is finished, @callback will be invoked. You can * When the operation is finished, @callback will be invoked. You can
@ -2029,8 +2028,7 @@ g_dbus_connection_new_finish (GAsyncResult *res,
* Synchronously sets up a D-Bus connection for exchanging D-Bus messages * Synchronously sets up a D-Bus connection for exchanging D-Bus messages
* with the end represented by @stream. * with the end represented by @stream.
* *
* If %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER is set in @flags, * If @observer is not %NULL it may be used to control the
* @observer (if not %NULL) is used to assist in the client
* authentication process. * authentication process.
* *
* This is a synchronous failable constructor. See * This is a synchronous failable constructor. See
@ -2066,6 +2064,7 @@ g_dbus_connection_new_sync (GIOStream *stream,
* g_dbus_connection_new_for_address: * g_dbus_connection_new_for_address:
* @address: A D-Bus address. * @address: A D-Bus address.
* @flags: Flags describing how to make the connection. * @flags: Flags describing how to make the connection.
* @observer: A #GDBusAuthObserver or %NULL.
* @cancellable: A #GCancellable or %NULL. * @cancellable: A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied. * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
* @user_data: The data to pass to @callback. * @user_data: The data to pass to @callback.
@ -2084,6 +2083,9 @@ g_dbus_connection_new_sync (GIOStream *stream,
* then call g_dbus_connection_new_finish() to get the result of the * then call g_dbus_connection_new_finish() to get the result of the
* operation. * operation.
* *
* If @observer is not %NULL it may be used to control the
* authentication process.
*
* This is a asynchronous failable constructor. See * This is a asynchronous failable constructor. See
* g_dbus_connection_new_for_address_sync() for the synchronous * g_dbus_connection_new_for_address_sync() for the synchronous
* version. * version.
@ -2093,6 +2095,7 @@ g_dbus_connection_new_sync (GIOStream *stream,
void void
g_dbus_connection_new_for_address (const gchar *address, g_dbus_connection_new_for_address (const gchar *address,
GDBusConnectionFlags flags, GDBusConnectionFlags flags,
GDBusAuthObserver *observer,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
@ -2105,6 +2108,7 @@ g_dbus_connection_new_for_address (const gchar *address,
user_data, user_data,
"address", address, "address", address,
"flags", flags, "flags", flags,
"authentication-observer", observer,
NULL); NULL);
} }
@ -2145,6 +2149,7 @@ g_dbus_connection_new_for_address_finish (GAsyncResult *res,
* g_dbus_connection_new_for_address_sync: * g_dbus_connection_new_for_address_sync:
* @address: A D-Bus address. * @address: A D-Bus address.
* @flags: Flags describing how to make the connection. * @flags: Flags describing how to make the connection.
* @observer: A #GDBusAuthObserver or %NULL.
* @cancellable: A #GCancellable or %NULL. * @cancellable: A #GCancellable or %NULL.
* @error: Return location for error or %NULL. * @error: Return location for error or %NULL.
* *
@ -2161,6 +2166,9 @@ g_dbus_connection_new_for_address_finish (GAsyncResult *res,
* This is a synchronous failable constructor. See * This is a synchronous failable constructor. See
* g_dbus_connection_new_for_address() for the asynchronous version. * g_dbus_connection_new_for_address() for the asynchronous version.
* *
* 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 * Since: 2.26
@ -2168,6 +2176,7 @@ g_dbus_connection_new_for_address_finish (GAsyncResult *res,
GDBusConnection * GDBusConnection *
g_dbus_connection_new_for_address_sync (const gchar *address, g_dbus_connection_new_for_address_sync (const gchar *address,
GDBusConnectionFlags flags, GDBusConnectionFlags flags,
GDBusAuthObserver *observer,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
@ -2178,6 +2187,7 @@ g_dbus_connection_new_for_address_sync (const gchar *address,
error, error,
"address", address, "address", address,
"flags", flags, "flags", flags,
"authentication-observer", observer,
NULL); NULL);
} }

View File

@ -117,6 +117,7 @@ GDBusConnection *g_dbus_connection_new_sync (GIOStream
void g_dbus_connection_new_for_address (const gchar *address, void g_dbus_connection_new_for_address (const gchar *address,
GDBusConnectionFlags flags, GDBusConnectionFlags flags,
GDBusAuthObserver *observer,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
@ -124,6 +125,7 @@ GDBusConnection *g_dbus_connection_new_for_address_finish (GAsyncResult
GError **error); GError **error);
GDBusConnection *g_dbus_connection_new_for_address_sync (const gchar *address, GDBusConnection *g_dbus_connection_new_for_address_sync (const gchar *address,
GDBusConnectionFlags flags, GDBusConnectionFlags flags,
GDBusAuthObserver *observer,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);

View File

@ -259,6 +259,7 @@ main (int argc, char *argv[])
error = NULL; error = NULL;
connection = g_dbus_connection_new_for_address_sync (opt_address, connection = g_dbus_connection_new_for_address_sync (opt_address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* GCancellable */ NULL, /* GCancellable */
&error); &error);
if (connection == NULL) if (connection == NULL)

View File

@ -478,6 +478,7 @@ test_peer (void)
* will fail because the nonce file doesn't exist */ * will fail because the nonce file doesn't exist */
"nonce-tcp:host=localhost,port=12345,noncefile=this-does-not-exist-gdbus", "nonce-tcp:host=localhost,port=12345,noncefile=this-does-not-exist-gdbus",
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* cancellable */ NULL, /* cancellable */
&error); &error);
_g_assert_error_domain (error, G_IO_ERROR); _g_assert_error_domain (error, G_IO_ERROR);
@ -500,6 +501,7 @@ test_peer (void)
error = NULL; error = NULL;
c = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server), c = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server),
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* cancellable */ NULL, /* cancellable */
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
@ -624,6 +626,7 @@ test_peer (void)
error = NULL; error = NULL;
c2 = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server), c2 = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server),
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* cancellable */ NULL, /* cancellable */
&error); &error);
_g_assert_error_domain (error, G_IO_ERROR); _g_assert_error_domain (error, G_IO_ERROR);
@ -639,6 +642,7 @@ test_peer (void)
data.accept_connection = TRUE; data.accept_connection = TRUE;
c2 = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server), c2 = g_dbus_connection_new_for_address_sync (g_dbus_server_get_client_address (server),
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
NULL, /* GDBusAuthObserver */
NULL, /* cancellable */ NULL, /* cancellable */
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);

View File

@ -147,6 +147,7 @@ _g_bus_get_priv (GBusType bus_type,
ret = g_dbus_connection_new_for_address_sync (address, ret = g_dbus_connection_new_for_address_sync (address,
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL, /* GDBusAuthObserver */
cancellable, cancellable,
error); error);
g_free (address); g_free (address);