diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2015-03-20 16:22:11 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2015-04-08 16:56:43 +0200 |
commit | 18cf9a2090bb846c92d19d416cd56080eb20f7bd (patch) | |
tree | 852a89e7d25574f0be4698a7a6957b26371c81b5 | |
parent | 08f1fc35e3c77aecedacf08aa510e82c91ac7f2a (diff) | |
download | librest-18cf9a2090bb846c92d19d416cd56080eb20f7bd.tar.gz |
rest-proxy-auth: Add rest_proxy_auth_cancel for cancelling authentication
It can be helpful when handling the "authenticate" signal to allow
to cancel the authentication instead of failing with an error.
-rw-r--r-- | rest/rest-proxy-auth.c | 17 | ||||
-rw-r--r-- | rest/rest-proxy-auth.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/rest/rest-proxy-auth.c b/rest/rest-proxy-auth.c index 0cb6d7c..79f21e0 100644 --- a/rest/rest-proxy-auth.c +++ b/rest/rest-proxy-auth.c @@ -135,6 +135,23 @@ rest_proxy_auth_unpause (RestProxyAuth *auth) auth->priv->paused = FALSE; } +/** + * rest_proxy_auth_cancel: + * @auth: a #RestProxyAuth + * + * Cancel the authentication process + * by cancelling the associated #SoupMessage. + * It results in returning #GError REST_PROXY_ERROR_CANCELLED + * to the function that requested the authentication. + */ +void +rest_proxy_auth_cancel (RestProxyAuth *auth) +{ + g_return_if_fail (REST_IS_PROXY_AUTH (auth)); + + soup_session_cancel_message (auth->priv->session, auth->priv->message, SOUP_STATUS_CANCELLED); +} + G_GNUC_INTERNAL gboolean rest_proxy_auth_is_paused (RestProxyAuth *auth) { g_return_val_if_fail (REST_IS_PROXY_AUTH (auth), FALSE); diff --git a/rest/rest-proxy-auth.h b/rest/rest-proxy-auth.h index 6358e1a..816aaa9 100644 --- a/rest/rest-proxy-auth.h +++ b/rest/rest-proxy-auth.h @@ -66,6 +66,7 @@ GType rest_proxy_auth_get_type (void); void rest_proxy_auth_pause (RestProxyAuth *auth); void rest_proxy_auth_unpause (RestProxyAuth *auth); +void rest_proxy_auth_cancel (RestProxyAuth *auth); G_END_DECLS |