diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-20 14:04:50 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-12-06 17:52:29 +0000 |
commit | 6b8656685c4c640a4e753cc94379b87a2ffbfadf (patch) | |
tree | 6d836de315ca916de53095de8dd2f20701a46001 | |
parent | 8fd563ccf66e89aaa20bb37f397aa21b23b7d012 (diff) |
auth-manager: simplify chaining up in _start_auth_async()
Rather than using whether or not priv->channel is NULL in
_start_auth_finish() to determine how to handle the result, let's always
keep our own GSimpleAsyncResult.
In this case it doesn't matter very much, because priv->channel in
practice can't become NULL in the gap between the callback being called
and Wocky calling _start_auth_finish(). In the other cases it does
matter, and causes crashes. I'll be fixing those next.
-rw-r--r-- | src/auth-manager.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/auth-manager.c b/src/auth-manager.c index 59fc1a39e..19593cd58 100644 --- a/src/auth-manager.c +++ b/src/auth-manager.c @@ -218,7 +218,7 @@ gabble_auth_manager_set_property (GObject *object, } static void -gabble_auth_manager_start_fallback_cb (GObject *self_object, +gabble_auth_manager_start_parent_cb (GObject *self_object, GAsyncResult *result, gpointer user_data) { @@ -270,7 +270,7 @@ gabble_auth_manager_start_auth_cb (GObject *channel, start_data->initial_response->str, self->priv->server, self->priv->session_id, - gabble_auth_manager_start_fallback_cb, user_data); + gabble_auth_manager_start_parent_cb, user_data); /* we've transferred ownership of the result */ goto finally; } @@ -305,6 +305,8 @@ gabble_auth_manager_start_auth_async (WockyAuthRegistry *registry, gpointer user_data) { GabbleAuthManager *self = GABBLE_AUTH_MANAGER (registry); + GSimpleAsyncResult *result = g_simple_async_result_new ((GObject *) self, + callback, user_data, gabble_auth_manager_start_auth_async); /* assumption: Wocky's API guarantees that we never have more than one * auth request outstanding */ @@ -359,8 +361,7 @@ gabble_auth_manager_start_auth_async (WockyAuthRegistry *registry, gabble_server_sasl_channel_start_auth_async (self->priv->channel, gabble_auth_manager_start_auth_cb, - g_simple_async_result_new ((GObject *) self, - callback, user_data, gabble_auth_manager_start_auth_async)); + result); g_assert (!tp_base_channel_is_destroyed ( (TpBaseChannel *) self->priv->channel)); @@ -374,7 +375,8 @@ gabble_auth_manager_start_auth_async (WockyAuthRegistry *registry, WOCKY_AUTH_REGISTRY_CLASS ( gabble_auth_manager_parent_class)->start_auth_async_func ( registry, mechanisms, allow_plain, is_secure_channel, - username, password, server, session_id, callback, user_data); + username, password, server, session_id, + gabble_auth_manager_start_parent_cb, result); } } @@ -386,19 +388,9 @@ gabble_auth_manager_start_auth_finish (WockyAuthRegistry *registry, { GabbleAuthManager *self = GABBLE_AUTH_MANAGER (registry); - if (self->priv->channel != NULL) - { - wocky_implement_finish_copy_pointer (self, - gabble_auth_manager_start_auth_async, - wocky_auth_registry_start_data_dup, start_data); - } - else - { - return WOCKY_AUTH_REGISTRY_CLASS - (gabble_auth_manager_parent_class)->start_auth_finish_func ( - registry, result, start_data, error); - } - + wocky_implement_finish_copy_pointer (self, + gabble_auth_manager_start_auth_async, + wocky_auth_registry_start_data_dup, start_data); } static void |