[librest] Add rest_proxy_auth_[un]pause



commit 5e22174503a61a04f0335c691e526ac5770d22ab
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Tue Jun 12 21:45:03 2012 +0200

    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

 rest/rest-proxy-auth-private.h |    1 +
 rest/rest-proxy-auth.c         |   38 ++++++++++++++++++++++++++++++++++++++
 rest/rest-proxy-auth.h         |    3 +++
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/rest/rest-proxy-auth-private.h b/rest/rest-proxy-auth-private.h
index 056174e..3b92782 100644
--- a/rest/rest-proxy-auth-private.h
+++ b/rest/rest-proxy-auth-private.h
@@ -32,6 +32,7 @@ RestProxyAuth* rest_proxy_auth_new (RestProxy *proxy,
                                     SoupSession *session,
                                     SoupMessage *message,
                                     SoupAuth *auth);
+gboolean rest_proxy_auth_is_paused (RestProxyAuth *auth);
 
 G_END_DECLS
 
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;
+}
diff --git a/rest/rest-proxy-auth.h b/rest/rest-proxy-auth.h
index 9761f75..6358e1a 100644
--- a/rest/rest-proxy-auth.h
+++ b/rest/rest-proxy-auth.h
@@ -64,6 +64,9 @@ typedef struct {
 
 GType rest_proxy_auth_get_type (void);
 
+void rest_proxy_auth_pause (RestProxyAuth *auth);
+void rest_proxy_auth_unpause (RestProxyAuth *auth);
+
 G_END_DECLS
 
 #endif /* _REST_PROXY_AUTH */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]