libpurple/protocols/msn/soap.c

branch
cpw.darkrain42.xmpp.bosh
changeset 24714
2ba5d09cf046
parent 23955
18bd5d80fb7b
parent 24672
3e12ba88e3b9
child 24801
73fdc6b7590e
--- a/libpurple/protocols/msn/soap.c	Thu Nov 20 21:13:56 2008 +0000
+++ b/libpurple/protocols/msn/soap.c	Thu Nov 20 21:57:52 2008 +0000
@@ -38,7 +38,7 @@
 #endif
 
 #define SOAP_TIMEOUT (5 * 60)
-#define MSN_UNSAFE_DEBUG 1
+
 typedef struct _MsnSoapRequest {
 	char *path;
 	MsnSoapMessage *message;
@@ -134,7 +134,7 @@
 	}
 
 	if (session->soap_cleanup_handle == 0)
-		session->soap_cleanup_handle = purple_timeout_add(SOAP_TIMEOUT * 1000,
+		session->soap_cleanup_handle = purple_timeout_add_seconds(SOAP_TIMEOUT,
 			msn_soap_cleanup_for_session, session);
 
 	if (conn == NULL) {
@@ -268,6 +268,7 @@
 		(something weird with the login.live.com server). With NSS it works
 		fine, so I believe it's some bug with OS X */ 
 	char buf[16 * 1024];
+	gsize cursor;
 
 	if (conn->message == NULL) {
 		conn->message = msn_soap_message_new(NULL, NULL);
@@ -276,13 +277,26 @@
 	if (conn->buf == NULL) {
 		conn->buf = g_string_new_len(buf, 0);
 	}
-	
+
+	cursor = conn->buf->len;
 	while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) {
 		purple_debug_info("soap", "read %d bytes\n", cnt);
 		count += cnt;
 		g_string_append_len(conn->buf, buf, cnt);
 	}
 
+	perrno = errno;
+	if (cnt < 0 && perrno != EAGAIN)
+		purple_debug_info("soap", "read: %s\n", g_strerror(perrno));
+
+#ifndef MSN_UNSAFE_DEBUG
+	if (conn->current_request->secure)
+		purple_debug_misc("soap", "Received secure request.\n");
+	else
+#endif
+	if (count != 0)
+		purple_debug_misc("soap", "current %s\n", conn->buf->str + cursor);
+
 	/* && count is necessary for Adium, on OS X the last read always
 	   return an error, so we want to proceed anyway. See #5212 for
 	   discussion on this and the above buffer size issues */
@@ -290,11 +304,9 @@
 		return;
 
 	/* msn_soap_process could alter errno */
-	perrno = errno;
 	msn_soap_process(conn);
 	
 	if (cnt < 0 && perrno != EAGAIN) {
-		purple_debug_info("soap", "read: %s\n", g_strerror(perrno));
 		/* It's possible msn_soap_process closed the ssl connection */
 		if (conn->ssl) {
 			purple_ssl_close(conn->ssl);
@@ -310,13 +322,6 @@
 	char *cursor;
 	char *linebreak;
 
-#ifndef MSN_UNSAFE_DEBUG
-	if (conn->current_request->secure)
-		purple_debug_info("soap", "Received secure request.\n");
-	else
-#endif
-	purple_debug_info("soap", "current %s\n", conn->buf->str);
-
 	cursor = conn->buf->str + conn->handled_len;
 
 	if (!conn->headers_done) {
@@ -514,10 +519,10 @@
 
 #ifndef MSN_UNSAFE_DEBUG
 			if (req->secure)
-				purple_debug_info("soap", "Sending secure request.\n");
+				purple_debug_misc("soap", "Sending secure request.\n");
 			else
 #endif
-			purple_debug_info("soap", "%s\n", conn->buf->str);
+			purple_debug_misc("soap", "%s\n", conn->buf->str);
 
 			conn->handled_len = 0;
 			conn->current_request = req;

mercurial