summaryrefslogtreecommitdiff
path: root/rest/rest-proxy-auth.c
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-06-12 21:45:03 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2012-06-28 12:33:48 +0200
commit5e22174503a61a04f0335c691e526ac5770d22ab (patch)
tree53f41b5d46c1c7a101c759de1187e71dd37401ca /rest/rest-proxy-auth.c
parent948e5d908e1a9cf25375668d9167da7051021ce6 (diff)
downloadlibrest-5e22174503a61a04f0335c691e526ac5770d22ab.tar.gz
Add rest_proxy_auth_[un]pause
They can be used in RestProxy::authenticate signals to suspend the current authentication attempt. This allows to get back to the mainloop to get the credentials, and to then rerun the call with the correct credentials. https://bugzilla.gnome.org/show_bug.cgi?id=658937
Diffstat (limited to 'rest/rest-proxy-auth.c')
-rw-r--r--rest/rest-proxy-auth.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/rest/rest-proxy-auth.c b/rest/rest-proxy-auth.c
index f336e7f..3d808d4 100644
--- a/rest/rest-proxy-auth.c
+++ b/rest/rest-proxy-auth.c
@@ -87,3 +87,41 @@ rest_proxy_auth_new (RestProxy *proxy,
return rest_auth;
}
+
+void
+rest_proxy_auth_pause (RestProxyAuth *auth)
+{
+ g_return_if_fail (REST_IS_PROXY_AUTH (auth));
+
+ if (auth->priv->paused)
+ return;
+
+ auth->priv->paused = TRUE;
+ soup_session_pause_message (auth->priv->session, auth->priv->message);
+}
+
+void
+rest_proxy_auth_unpause (RestProxyAuth *auth)
+{
+ RestProxy *proxy;
+ gchar *username;
+ gchar *password;
+
+ g_return_if_fail (REST_IS_PROXY_AUTH (auth));
+ g_return_if_fail (auth->priv->paused);
+
+ proxy = REST_PROXY (auth->priv->proxy);
+ g_object_get (G_OBJECT (proxy), "username", &username, "password", &password, NULL);
+ soup_auth_authenticate (auth->priv->auth, username, password);
+ g_free (username);
+ g_free (password);
+ soup_session_unpause_message (auth->priv->session, auth->priv->message);
+ auth->priv->paused = FALSE;
+}
+
+G_GNUC_INTERNAL gboolean rest_proxy_auth_is_paused (RestProxyAuth *auth)
+{
+ g_return_val_if_fail (REST_IS_PROXY_AUTH (auth), FALSE);
+
+ return auth->priv->paused;
+}