[libdmapsharing] Implement dmap_connection_authenticate_message to encapsulate details of authenticating a request Si



commit 33b52aebcd9109690b6f7873da2cb57ad5f8269b
Author: W. Michael Petullo <mike flyn org>
Date:   Tue May 10 13:10:34 2011 -0500

    Implement dmap_connection_authenticate_message to encapsulate details of authenticating a request
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/dmap-connection.c |   15 +++++++++++++++
 libdmapsharing/dmap-connection.h |   21 +++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/libdmapsharing/dmap-connection.c b/libdmapsharing/dmap-connection.c
index c0a6a3b..5db34bf 100644
--- a/libdmapsharing/dmap-connection.c
+++ b/libdmapsharing/dmap-connection.c
@@ -1200,11 +1200,26 @@ authenticate_cb (SoupSession *session, SoupMessage *msg, SoupAuth *auth, gboolea
 			       retrying);
 		// FIXME: GDK_THREADS_LEAVE ();
 	} else {
+		g_debug ("Using cached credentials");
 		soup_auth_authenticate (auth, connection->priv->username, connection->priv->password);
 	}
 }
 
 void
+dmap_connection_authenticate_message (DMAPConnection * connection, SoupSession *session, SoupMessage *message, SoupAuth *auth, const char *password)
+{
+	char *username = NULL;
+
+	g_object_set (connection, "password", password, NULL);
+
+	g_object_get (connection, "username", &username, NULL);
+	g_assert (username);
+
+	soup_auth_authenticate (auth, username, password);
+	soup_session_unpause_message (session, message);
+}
+
+void
 dmap_connection_setup (DMAPConnection * connection)
 {
 	connection->priv->session = soup_session_async_new ();
diff --git a/libdmapsharing/dmap-connection.h b/libdmapsharing/dmap-connection.h
index cf2362e..f438e8c 100644
--- a/libdmapsharing/dmap-connection.h
+++ b/libdmapsharing/dmap-connection.h
@@ -166,6 +166,27 @@ SoupMessage *dmap_connection_build_message (DMAPConnection * connection,
 					    gdouble version,
 					    gint req_id, gboolean send_close);
 
+/**
+ * dmap_connection_authenticate_message
+ * @connection: A #DMAPConnection
+ * @session: A #SoupSession
+ * @message: A #SoupMessage
+ * @auth: A #SoupAuth
+ * @password: A password
+ *     
+ * Attach an authentication credential to a request. This
+ * method should be called by a function that is connected to the
+ * #DMAPConnection::authenticate signal. The signal will provide the
+ * connection, session, message and auth to that function. That function
+ * should obtain a password and provide it to this method.
+ */
+void dmap_connection_authenticate_message (DMAPConnection *connection,
+                                           SoupSession *session,
+                                           SoupMessage *message,
+					   SoupAuth *auth,
+					   const char *password);
+
+
 gboolean dmap_connection_get (DMAPConnection * self,
 			      const gchar * path,
 			      gboolean need_hash,



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