diff libpurple/protocols/gg/lib/pubdir.c @ 32072:3a90a59ddea2

Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk. Fixes 14248
author Ethan Blanton <elb@pidgin.im>
date Sun, 05 Jun 2011 01:28:53 +0000
parents a8cc50c2279f
children ef01f180114b
line wrap: on
line diff
--- a/libpurple/protocols/gg/lib/pubdir.c	Tue May 24 01:48:26 2011 +0000
+++ b/libpurple/protocols/gg/lib/pubdir.c	Sun Jun 05 01:28:53 2011 +0000
@@ -26,9 +26,6 @@
  * \brief Obsługa katalogu publicznego
  */
 
-#include "libgadu.h"
-#include "libgadu-config.h"
-
 #include <ctype.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -37,6 +34,9 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "libgadu.h"
+#include "libgadu-config.h"
+
 /**
  * Rejestruje nowego użytkownika.
  *
@@ -122,10 +122,10 @@
 
 	h->callback = gg_pubdir_watch_fd;
 	h->destroy = gg_pubdir_free;
-
+	
 	if (!async)
 		gg_pubdir_watch_fd(h);
-
+	
 	return h;
 }
 
@@ -193,7 +193,7 @@
 		errno = EFAULT;
 		return NULL;
 	}
-
+    
 	__pwd = gg_saprintf("%ld", random());
 	__fmpwd = gg_urlencode(password);
 	__tokenid = gg_urlencode(tokenid);
@@ -251,10 +251,10 @@
 
 	h->callback = gg_pubdir_watch_fd;
 	h->destroy = gg_pubdir_free;
-
+	
 	if (!async)
 		gg_pubdir_watch_fd(h);
-
+	
 	return h;
 }
 
@@ -324,7 +324,7 @@
 		errno = EFAULT;
 		return NULL;
 	}
-
+	
 	__fmpwd = gg_urlencode(passwd);
 	__pwd = gg_urlencode(newpasswd);
 	__email = gg_urlencode(email);
@@ -340,7 +340,7 @@
 		free(__tokenval);
 		return NULL;
 	}
-
+	
 	if (!(form = gg_saprintf("fmnumber=%d&fmpwd=%s&pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __email, __tokenid, __tokenval, gg_http_hash("ss", email, newpasswd)))) {
 		gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n");
 		free(__fmpwd);
@@ -351,13 +351,13 @@
 
 		return NULL;
 	}
-
+	
 	free(__fmpwd);
 	free(__pwd);
 	free(__email);
 	free(__tokenid);
 	free(__tokenval);
-
+	
 	gg_debug(GG_DEBUG_MISC, "=> change, %s\n", form);
 
 	query = gg_saprintf(
@@ -460,7 +460,7 @@
 		errno = EFAULT;
 		return NULL;
 	}
-
+	
 	__tokenid = gg_urlencode(tokenid);
 	__tokenval = gg_urlencode(tokenval);
 	__email = gg_urlencode(email);
@@ -484,7 +484,7 @@
 	free(__tokenid);
 	free(__tokenval);
 	free(__email);
-
+	
 	gg_debug(GG_DEBUG_MISC, "=> remind, %s\n", form);
 
 	query = gg_saprintf(
@@ -588,7 +588,7 @@
 		errno = EINVAL;
 		return -1;
 	}
-
+	
 	if (h->state != GG_STATE_PARSING) {
 		if (gg_http_watch_fd(h) == -1) {
 			gg_debug(GG_DEBUG_MISC, "=> pubdir, http failure\n");
@@ -599,9 +599,9 @@
 
 	if (h->state != GG_STATE_PARSING)
 		return 0;
-
+	
 	h->state = GG_STATE_DONE;
-
+	
 	if (!(h->data = p = malloc(sizeof(struct gg_pubdir)))) {
 		gg_debug(GG_DEBUG_MISC, "=> pubdir, not enough memory for results\n");
 		return -1;
@@ -609,7 +609,7 @@
 
 	p->success = 0;
 	p->uin = 0;
-
+	
 	gg_debug(GG_DEBUG_MISC, "=> pubdir, let's parse \"%s\"\n", h->body);
 
 	if ((tmp = strstr(h->body, "Tokens okregisterreply_packet.reg.dwUserId="))) {
@@ -636,7 +636,7 @@
 {
 	if (!h)
 		return;
-
+	
 	free(h->data);
 	gg_http_free(h);
 }
@@ -674,10 +674,10 @@
 
 	h->callback = gg_token_watch_fd;
 	h->destroy = gg_token_free;
-
+	
 	if (!async)
 		gg_token_watch_fd(h);
-
+	
 	return h;
 }
 
@@ -706,7 +706,7 @@
 		errno = EINVAL;
 		return -1;
 	}
-
+	
 	if (h->state != GG_STATE_PARSING) {
 		if (gg_http_watch_fd(h) == -1) {
 			gg_debug(GG_DEBUG_MISC, "=> token, http failure\n");
@@ -717,7 +717,7 @@
 
 	if (h->state != GG_STATE_PARSING)
 		return 0;
-
+	
 	/* jeśli h->data jest puste, to ściągaliśmy tokenid i url do niego,
 	 * ale jeśli coś tam jest, to znaczy, że mamy drugi etap polegający
 	 * na pobieraniu tokenu. */
@@ -735,7 +735,7 @@
 			free(url);
 			return -1;
 		}
-
+		
 		if (!h->body || sscanf(h->body, "%d %d %d\r\n%s\r\n%s", &width, &height, &length, tokenid, url) != 5) {
 			gg_debug(GG_DEBUG_MISC, "=> token, parsing failed\n");
 			free(url);
@@ -743,7 +743,7 @@
 			errno = EINVAL;
 			return -1;
 		}
-
+		
 		/* dostaliśmy tokenid i wszystkie niezbędne informacje,
 		 * więc pobierzmy obrazek z tokenem */
 
@@ -779,7 +779,7 @@
 			free(url);
 			free(tokenid);
 			return -1;
-		}
+		}			
 
 		if (!(h2 = gg_http_connect(host, GG_REGISTER_PORT, h->async, "GET", path, headers))) {
 			gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n");
@@ -803,7 +803,7 @@
 
 		h->callback = gg_token_watch_fd;
 		h->destroy = gg_token_free;
-
+	
 		if (!h->async)
 			gg_token_watch_fd(h);
 
@@ -821,7 +821,7 @@
 		/* obrazek mamy w h->body */
 		h->state = GG_STATE_DONE;
 	}
-
+	
 	return 0;
 }
 
@@ -841,7 +841,7 @@
 
 	if ((t = h->data))
 		free(t->tokenid);
-
+	
 	free(h->data);
 	gg_http_free(h);
 }