From 9b0a08449fd966aff7a6c164c9913b01106a37cc Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Tue, 20 Jul 2010 15:02:36 -0400 Subject: [PATCH] GDBusAuthObserver: Fix docs Signed-off-by: David Zeuthen --- gio/gdbusauthobserver.c | 53 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/gio/gdbusauthobserver.c b/gio/gdbusauthobserver.c index f1971c0ce..46af595a5 100644 --- a/gio/gdbusauthobserver.c +++ b/gio/gdbusauthobserver.c @@ -42,7 +42,8 @@ * in the future * * For example, if you only want to allow D-Bus connections from - * processes owned by the same uid as the server, you would do this: + * processes owned by the same uid as the server, you would use a + * signal handler like the following: * Controlling Authentication * static gboolean * on_authorize_authenticated_peer (GDBusAuthObserver *observer, @@ -50,52 +51,20 @@ * GCredentials *credentials, * gpointer user_data) * { - * GCredentials *me; * gboolean authorized; * * authorized = FALSE; - * me = g_credentials_new (); - * - * if (credentials != NULL && - * !g_credentials_is_same_user (credentials, me)) - * authorized = TRUE; - * - * g_object_unref (me); + * if (credentials != NULL) + * { + * GCredentials *own_credentials; + * own_credentials = g_credentials_new (); + * if (g_credentials_is_same_user (credentials, own_credentials, NULL)) + * authorized = TRUE; + * g_object_unref (own_credentials); + * } * * return authorized; * } - * - * static gboolean - * on_new_connection (GDBusServer *server, - * GDBusConnection *connection, - * gpointer user_data) - * { - * /* Guaranteed here that @connection is from a process owned by the same user */ - * } - * - * [...] - * - * GDBusAuthObserver *observer; - * GDBusServer *server; - * GError *error; - * - * error = NULL; - * observer = g_dbus_auth_observer_new (); - * server = g_dbus_server_new_sync ("unix:tmpdir=/tmp/my-app-name", - * G_DBUS_SERVER_FLAGS_NONE, - * observer, - * NULL, /* GCancellable */ - * &error); - * g_signal_connect (observer, - * "authorize-authenticated-peer", - * G_CALLBACK (on_authorize_authenticated_peer), - * NULL); - * g_signal_connect (server, - * "new-connection", - * G_CALLBACK (on_new_connection), - * NULL); - * g_object_unref (observer); - * g_dbus_server_start (server); * */ @@ -243,7 +212,7 @@ g_dbus_auth_observer_new (void) * * Emits the #GDBusAuthObserver::authorize-authenticated-peer signal on @observer. * - * Returns: %TRUE if the peer should be denied, %FALSE otherwise. + * Returns: %TRUE if the peer is authorized, %FALSE if not. * * Since: 2.26 */