libpurple/protocols/gg/lib/pubdir.c

Sat, 22 Mar 2014 00:42:07 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Sat, 22 Mar 2014 00:42:07 +0100
branch
release-2.x.y
changeset 35645
0143226782bb
parent 35627
fd11790cc4d6
child 35630
8e5d0d726b09
permissions
-rw-r--r--

Update libgadu to the current version from repo

35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
1 /* $Id$ */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
3 /*
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
4 * (C) Copyright 2001-2006 Wojtek Kaniewski <wojtekka@irc.pl>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
5 * Dawid Jarosz <dawjar@poczta.onet.pl>
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
6 * Adam Wysocki <gophi@ekg.chmurka.net>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
7 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU Lesser General Public License Version
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
10 * 2.1 as published by the Free Software Foundation.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
11 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
15 * GNU Lesser General Public License for more details.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
16 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
18 * License along with this program; if not, write to the Free Software
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
20 * USA.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
21 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
22
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
23 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
24 * \file pubdir.c
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
25 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
26 * \brief Obsługa katalogu publicznego
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
27 */
29106
51c7b2177e42 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents: 19859
diff changeset
28
35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
29 #include "network.h"
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
30 #include <ctype.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
31 #include <errno.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
32 #include <stdlib.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
33 #include <string.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
34
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31294
diff changeset
35 #include "libgadu.h"
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31294
diff changeset
36
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
37 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
38 * Rejestruje nowego użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
39 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
40 * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token().
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
41 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
42 * \param email Adres e-mail
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
43 * \param password Hasło
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
44 * \param tokenid Identyfikator tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
45 * \param tokenval Zawartość tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
46 * \param async Flaga połączenia asynchronicznego
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
47 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
48 * \return Struktura \c gg_http lub \c NULL w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
49 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
50 * \ingroup register
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
51 */
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
52 struct gg_http *gg_register3(const char *email, const char *password,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
53 const char *tokenid, const char *tokenval, int async)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
54 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
55 struct gg_http *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
56 char *__pwd, *__email, *__tokenid, *__tokenval, *form, *query;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
57
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
58 if (!email || !password || !tokenid || !tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
59 gg_debug(GG_DEBUG_MISC, "=> register, NULL parameter\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
60 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
61 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
62 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
63
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
64 __pwd = gg_urlencode(password);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
65 __email = gg_urlencode(email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
66 __tokenid = gg_urlencode(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
67 __tokenval = gg_urlencode(tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
68
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
69 if (!__pwd || !__email || !__tokenid || !__tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
70 gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
71 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
72 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
73 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
74 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
75 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
76 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
77
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
78 form = gg_saprintf("pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u",
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
79 __pwd, __email, __tokenid, __tokenval,
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
80 gg_http_hash("ss", email, password));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
81
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
82 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
83 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
84 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
85 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
86
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
87 if (!form) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
88 gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
89 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
90 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
91
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
92 gg_debug(GG_DEBUG_MISC, "=> register, %s\n", form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
93
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
94 query = gg_saprintf(
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
95 "Host: " GG_REGISTER_HOST "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
96 "Content-Type: application/x-www-form-urlencoded\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
97 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
98 "Content-Length: %d\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
99 "Pragma: no-cache\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
100 "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
101 "%s",
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
102 (int) strlen(form), form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
103
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
104 free(form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
105
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
106 if (!query) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
107 gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
108 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
109 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
110
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
111 if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
112 "POST", "/appsvc/fmregister3.asp", query)))
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
113 {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
114 gg_debug(GG_DEBUG_MISC, "=> register, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
115 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
116 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
117 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
118
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
119 h->type = GG_SESSION_REGISTER;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
120
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
121 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
122
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
123 h->callback = gg_pubdir_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
124 h->destroy = gg_pubdir_free;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
125
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
126 if (!async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
127 gg_pubdir_watch_fd(h);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
128
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
129 return h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
130 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
131
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
132 #ifdef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
133
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
134 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
135 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
136 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
137 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
138 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
139 * znajdzie się w polu \c error.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
140 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
141 * \note W rzeczywistości funkcja jest makrem rozwijanym do
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
142 * \c gg_pubdir_watch_fd().
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
143 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
144 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
145 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
146 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
147 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
148 * \ingroup register
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
149 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
150 int gg_register_watch_fd(struct gg_httpd *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
151 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
152 return gg_pubdir_watch_fd(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
153 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
154
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
155 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
156 * Zwalnia zasoby po operacji.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
157 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
158 * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
159 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
160 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
161 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
162 * \ingroup register
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
163 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
164 void gg_register_free(struct gg_http *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
165 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
166 return gg_pubdir_free(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
167 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
168
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
169 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
170
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
171 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
172 * Usuwa użytkownika.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
173 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
174 * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
175 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
176 * \param uin Numer Gadu-Gadu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
177 * \param password Hasło
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
178 * \param tokenid Identyfikator tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
179 * \param tokenval Zawartość tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
180 * \param async Flaga połączenia asynchronicznego
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
181 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
182 * \return Struktura \c gg_http lub \c NULL w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
183 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
184 * \ingroup unregister
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
185 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
186 struct gg_http *gg_unregister3(uin_t uin, const char *password, const char *tokenid, const char *tokenval, int async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
187 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
188 struct gg_http *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
189 char *__fmpwd, *__pwd, *__tokenid, *__tokenval, *form, *query;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
190
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
191 if (!password || !tokenid || !tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
192 gg_debug(GG_DEBUG_MISC, "=> unregister, NULL parameter\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
193 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
194 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
195 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
196
35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
197 __pwd = gg_saprintf("%d", rand());
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
198 __fmpwd = gg_urlencode(password);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
199 __tokenid = gg_urlencode(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
200 __tokenval = gg_urlencode(tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
201
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
202 if (!__fmpwd || !__pwd || !__tokenid || !__tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
203 gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
204 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
205 free(__fmpwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
206 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
207 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
208 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
209 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
210
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
211 form = gg_saprintf("fmnumber=%d&fmpwd=%s&delete=1&pwd=%s&"
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
212 "email=deletedaccount@gadu-gadu.pl&tokenid=%s&tokenval=%s&"
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
213 "code=%u", uin, __fmpwd, __pwd, __tokenid, __tokenval,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
214 gg_http_hash("ss", "deletedaccount@gadu-gadu.pl", __pwd));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
215
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
216 free(__fmpwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
217 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
218 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
219 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
220
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
221 if (!form) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
222 gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
223 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
224 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
225
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
226 gg_debug(GG_DEBUG_MISC, "=> unregister, %s\n", form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
227
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
228 query = gg_saprintf(
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
229 "Host: " GG_REGISTER_HOST "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
230 "Content-Type: application/x-www-form-urlencoded\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
231 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
232 "Content-Length: %d\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
233 "Pragma: no-cache\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
234 "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
235 "%s",
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
236 (int) strlen(form), form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
237
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
238 free(form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
239
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
240 if (!query) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
241 gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
242 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
243 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
244
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
245 if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
246 "POST", "/appsvc/fmregister3.asp", query)))
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
247 {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
248 gg_debug(GG_DEBUG_MISC, "=> unregister, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
249 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
250 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
251 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
252
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
253 h->type = GG_SESSION_UNREGISTER;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
254
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
255 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
256
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
257 h->callback = gg_pubdir_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
258 h->destroy = gg_pubdir_free;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
259
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
260 if (!async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
261 gg_pubdir_watch_fd(h);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
262
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
263 return h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
264 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
265
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
266 #ifdef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
267
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
268 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
269 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
270 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
271 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
272 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
273 * znajdzie się w polu \c error.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
274 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
275 * \note W rzeczywistości funkcja jest makrem rozwijanym do
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
276 * \c gg_pubdir_watch_fd().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
277 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
278 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
279 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
280 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
281 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
282 * \ingroup unregister
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
283 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
284 int gg_unregister_watch_fd(struct gg_httpd *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
285 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
286 return gg_pubdir_watch_fd(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
287 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
288
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
289 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
290 * Zwalnia zasoby po operacji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
291 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
292 * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free().
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
293 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
294 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
295 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
296 * \ingroup unregister
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
297 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
298 void gg_unregister_free(struct gg_http *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
299 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
300 return gg_pubdir_free(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
301 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
302
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
303 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
304
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
305 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
306 * Zmienia hasło użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
307 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
308 * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
309 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
310 * \param uin Numer Gadu-Gadu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
311 * \param email Adres e-mail
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
312 * \param passwd Obecne hasło
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
313 * \param newpasswd Nowe hasło
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
314 * \param tokenid Identyfikator tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
315 * \param tokenval Zawartość tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
316 * \param async Flaga połączenia asynchronicznego
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
317 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
318 * \return Struktura \c gg_http lub \c NULL w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
319 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
320 * \ingroup passwd
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
321 */
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
322 struct gg_http *gg_change_passwd4(uin_t uin, const char *email,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
323 const char *passwd, const char *newpasswd, const char *tokenid,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
324 const char *tokenval, int async)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
325 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
326 struct gg_http *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
327 char *form, *query, *__email, *__fmpwd, *__pwd, *__tokenid, *__tokenval;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
328
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
329 if (!uin || !email || !passwd || !newpasswd || !tokenid || !tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
330 gg_debug(GG_DEBUG_MISC, "=> change, NULL parameter\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
331 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
332 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
333 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
334
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
335 __fmpwd = gg_urlencode(passwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
336 __pwd = gg_urlencode(newpasswd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
337 __email = gg_urlencode(email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
338 __tokenid = gg_urlencode(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
339 __tokenval = gg_urlencode(tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
340
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
341 if (!__fmpwd || !__pwd || !__email || !__tokenid || !__tokenval) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
342 gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
343 free(__fmpwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
344 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
345 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
346 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
347 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
348 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
349 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
350
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
351 if (!(form = gg_saprintf("fmnumber=%d&fmpwd=%s&pwd=%s&email=%s&"
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
352 "tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __email,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
353 __tokenid, __tokenval, gg_http_hash("ss", email, newpasswd))))
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
354 {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
355 gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
356 free(__fmpwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
357 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
358 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
359 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
360 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
361
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
362 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
363 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
364
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
365 free(__fmpwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
366 free(__pwd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
367 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
368 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
369 free(__tokenval);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
370
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
371 gg_debug(GG_DEBUG_MISC, "=> change, %s\n", form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
372
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
373 query = gg_saprintf(
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
374 "Host: " GG_REGISTER_HOST "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
375 "Content-Type: application/x-www-form-urlencoded\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
376 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
377 "Content-Length: %d\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
378 "Pragma: no-cache\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
379 "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
380 "%s",
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
381 (int) strlen(form), form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
382
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
383 free(form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
384
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
385 if (!query) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
386 gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
387 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
388 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
389
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
390 if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
391 "POST", "/appsvc/fmregister3.asp", query)))
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
392 {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
393 gg_debug(GG_DEBUG_MISC, "=> change, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
394 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
395 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
396 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
397
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
398 h->type = GG_SESSION_PASSWD;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
399
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
400 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
401
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
402 h->callback = gg_pubdir_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
403 h->destroy = gg_pubdir_free;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
404
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
405 if (!async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
406 gg_pubdir_watch_fd(h);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
407
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
408 return h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
409 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
410
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
411 #ifdef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
412
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
413 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
414 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
415 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
416 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
417 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
418 * znajdzie się w polu \c error.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
419 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
420 * \note W rzeczywistości funkcja jest makrem rozwijanym do
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
421 * \c gg_pubdir_watch_fd().
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
422 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
423 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
424 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
425 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
426 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
427 * \ingroup passwd
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
428 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
429 int gg_change_passwd_watch_fd(struct gg_httpd *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
430 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
431 return gg_pubdir_watch_fd(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
432 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
433
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
434 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
435 * Zwalnia zasoby po operacji.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
436 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
437 * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
438 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
439 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
440 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
441 * \ingroup passwd
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
442 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
443 void gg_change_passwd_free(struct gg_http *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
444 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
445 return gg_pubdir_free(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
446 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
447
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
448 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
449
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
450 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
451 * Wysyła hasło użytkownika na e-mail.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
452 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
453 * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
454 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
455 * \param uin Numer Gadu-Gadu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
456 * \param email Adres e-mail (podany przy rejestracji)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
457 * \param tokenid Identyfikator tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
458 * \param tokenval Zawartość tokenu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
459 * \param async Flaga połączenia asynchronicznego
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
460 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
461 * \return Struktura \c gg_http lub \c NULL w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
462 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
463 * \ingroup remind
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
464 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
465 struct gg_http *gg_remind_passwd3(uin_t uin, const char *email, const char *tokenid, const char *tokenval, int async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
466 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
467 struct gg_http *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
468 char *form, *query, *__tokenid, *__tokenval, *__email;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
469
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
470 if (!tokenid || !tokenval || !email) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
471 gg_debug(GG_DEBUG_MISC, "=> remind, NULL parameter\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
472 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
473 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
474 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
475
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
476 __tokenid = gg_urlencode(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
477 __tokenval = gg_urlencode(tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
478 __email = gg_urlencode(email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
479
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
480 if (!__tokenid || !__tokenval || !__email) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
481 gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
482 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
483 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
484 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
485 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
486 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
487
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
488 if (!(form = gg_saprintf("userid=%d&code=%u&tokenid=%s&tokenval=%s&"
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
489 "email=%s", uin, gg_http_hash("u", uin), __tokenid, __tokenval,
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
490 __email)))
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
491 {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
492 gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
493 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
494 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
495 free(__email);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
496 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
497 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
498
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
499 free(__tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
500 free(__tokenval);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
501 free(__email);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
502
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
503 gg_debug(GG_DEBUG_MISC, "=> remind, %s\n", form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
504
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
505 query = gg_saprintf(
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
506 "Host: " GG_REMIND_HOST "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
507 "Content-Type: application/x-www-form-urlencoded\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
508 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
509 "Content-Length: %d\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
510 "Pragma: no-cache\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
511 "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
512 "%s",
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
513 (int) strlen(form), form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
514
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
515 free(form);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
516
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
517 if (!query) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
518 gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for query\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
519 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
520 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
521
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
522 if (!(h = gg_http_connect(GG_REMIND_HOST, GG_REMIND_PORT, async, "POST", "/appsvc/fmsendpwd3.asp", query))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
523 gg_debug(GG_DEBUG_MISC, "=> remind, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
524 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
525 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
526 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
527
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
528 h->type = GG_SESSION_REMIND;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
529
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
530 free(query);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
531
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
532 h->callback = gg_pubdir_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
533 h->destroy = gg_pubdir_free;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
534
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
535 if (!async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
536 gg_pubdir_watch_fd(h);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
537
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
538 return h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
539 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
540
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
541 #ifdef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
542
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
543 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
544 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
545 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
546 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
547 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
548 * znajdzie się w polu \c error.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
549 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
550 * \note W rzeczywistości funkcja jest makrem rozwijanym do
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
551 * \c gg_pubdir_watch_fd().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
552 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
553 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
554 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
555 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
556 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
557 * \ingroup remind
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
558 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
559 int gg_remind_watch_fd(struct gg_httpd *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
560 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
561 return gg_pubdir_watch_fd(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
562 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
563
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
564 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
565 * Zwalnia zasoby po operacji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
566 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
567 * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
568 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
569 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
570 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
571 * \ingroup remind
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
572 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
573 void gg_remind_free(struct gg_http *h)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
574 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
575 return gg_pubdir_free(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
576 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
577
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
578 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
579
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
580 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
581 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
582 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
583 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
584 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
585 * znajdzie się w polu \c error.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
586 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
587 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
588 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
589 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
590 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
591 int gg_pubdir_watch_fd(struct gg_http *h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
592 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
593 struct gg_pubdir *p;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
594 char *tmp;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
595
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
596 if (!h) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
597 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
598 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
599 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
600
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
601 if (h->state == GG_STATE_ERROR) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
602 gg_debug(GG_DEBUG_MISC, "=> pubdir, watch_fd issued on failed session\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
603 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
604 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
605 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
606
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
607 if (h->state != GG_STATE_PARSING) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
608 if (gg_http_watch_fd(h) == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
609 gg_debug(GG_DEBUG_MISC, "=> pubdir, http failure\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
610 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
611 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
612 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
613 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
614
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
615 if (h->state != GG_STATE_PARSING)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
616 return 0;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
617
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
618 h->state = GG_STATE_DONE;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
619
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
620 if (!(h->data = p = malloc(sizeof(struct gg_pubdir)))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
621 gg_debug(GG_DEBUG_MISC, "=> pubdir, not enough memory for results\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
622 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
623 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
624
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
625 p->success = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
626 p->uin = 0;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
627
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
628 gg_debug(GG_DEBUG_MISC, "=> pubdir, let's parse \"%s\"\n", h->body);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
629
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
630 if ((tmp = strstr(h->body, "Tokens okregisterreply_packet.reg.dwUserId="))) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
631 p->success = 1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
632 p->uin = strtol(tmp + sizeof("Tokens okregisterreply_packet.reg.dwUserId=") - 1, NULL, 0);
35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
633 p->error = GG_PUBDIR_ERROR_NONE;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
634 gg_debug(GG_DEBUG_MISC, "=> pubdir, success (okregisterreply, uin=%d)\n", p->uin);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
635 } else if ((tmp = strstr(h->body, "success")) || (tmp = strstr(h->body, "results"))) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
636 p->success = 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
637 if (tmp[7] == ':')
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
638 p->uin = strtol(tmp + 8, NULL, 0);
35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
639 p->error = GG_PUBDIR_ERROR_NONE;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
640 gg_debug(GG_DEBUG_MISC, "=> pubdir, success (uin=%d)\n", p->uin);
35617
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
641 } else if (strncmp(h->body, "error1", 6) == 0 || strncmp(h->body, "error3", 6) == 0) {
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
642 p->error = GG_PUBDIR_ERROR_NEW_PASSWORD;
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
643 gg_debug(GG_DEBUG_MISC, "=> pubdir, invalid new password\n");
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
644 } else if (strncmp(h->body, "not authenticated", 17) == 0) {
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
645 p->error = GG_PUBDIR_ERROR_OLD_PASSWORD;
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
646 gg_debug(GG_DEBUG_MISC, "=> pubdir, invalid old password\n");
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
647 } else if (strncmp(h->body, "bad_tokenval", 12) == 0) {
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
648 p->error = GG_PUBDIR_ERROR_TOKEN;
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
649 gg_debug(GG_DEBUG_MISC, "=> pubdir, invalid token\n");
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
650 } else {
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
651 p->error = GG_PUBDIR_ERROR_OTHER;
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
652 gg_debug(GG_DEBUG_MISC, "=> pubdir, unknown error\n");
c9069e0e3c36 Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31826
diff changeset
653 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
654
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
655 return 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
656 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
657
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
658 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
659 * Zwalnia zasoby po operacji na katalogu publicznym.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
660 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
661 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
662 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
663 void gg_pubdir_free(struct gg_http *h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
664 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
665 if (!h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
666 return;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
667
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
668 free(h->data);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
669 gg_http_free(h);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
670 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
671
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
672 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
673 * Pobiera token do autoryzacji operacji na katalogu publicznym.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
674 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
675 * Token jest niezbędny do tworzenia nowego i usuwania użytkownika,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
676 * zmiany hasła itd.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
677 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
678 * \param async Flaga połączenia asynchronicznego
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
679 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
680 * \return Struktura \c gg_http lub \c NULL w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
681 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
682 * \ingroup token
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
683 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
684 struct gg_http *gg_token(int async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
685 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
686 struct gg_http *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
687 const char *query;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
688
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
689 query = "Host: " GG_REGISTER_HOST "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
690 "Content-Type: application/x-www-form-urlencoded\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
691 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
692 "Content-Length: 0\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
693 "Pragma: no-cache\r\n"
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
694 "\r\n";
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
695
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
696 if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/regtoken.asp", query))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
697 gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
698 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
699 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
700
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
701 h->type = GG_SESSION_TOKEN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
702
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
703 h->callback = gg_token_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
704 h->destroy = gg_token_free;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
705
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
706 if (!async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
707 gg_token_watch_fd(h);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
708
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
709 return h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
710 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
711
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
712 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
713 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
714 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
715 * Operacja będzie zakończona, gdy pole \c state będzie równe \c GG_STATE_DONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
716 * Jeśli wystąpi błąd, \c state będzie równe \c GG_STATE_ERROR, a kod błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
717 * znajdzie się w polu \c error.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
718 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
719 * \param h Struktura połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
720 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
721 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
722 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
723 * \ingroup token
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
724 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
725 int gg_token_watch_fd(struct gg_http *h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
726 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
727 if (!h) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
728 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
729 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
730 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
731
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
732 if (h->state == GG_STATE_ERROR) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
733 gg_debug(GG_DEBUG_MISC, "=> token, watch_fd issued on failed session\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
734 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
735 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
736 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
737
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
738 if (h->state != GG_STATE_PARSING) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
739 if (gg_http_watch_fd(h) == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
740 gg_debug(GG_DEBUG_MISC, "=> token, http failure\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
741 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
742 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
743 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
744 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
745
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
746 if (h->state != GG_STATE_PARSING)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
747 return 0;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
748
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
749 /* jeśli h->data jest puste, to ściągaliśmy tokenid i url do niego,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
750 * ale jeśli coś tam jest, to znaczy, że mamy drugi etap polegający
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
751 * na pobieraniu tokenu. */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
752 if (!h->data) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
753 int width, height, length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
754 char *url = NULL, *tokenid = NULL, *path, *headers;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
755 const char *host;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
756 struct gg_http *h2;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
757 struct gg_token *t;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
758 size_t results_len;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
759
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
760 gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
761
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
762 results_len = h->body ? strlen(h->body) : 0;
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
763
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
764 if (h->body && (!(url = malloc(results_len)) || !(tokenid = malloc(results_len)))) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
765 gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
766 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
767 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
768 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
769
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
770 if (!h->body || sscanf(h->body, "%d %d %d\r\n%s\r\n%s", &width, &height, &length, tokenid, url) != 5) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
771 gg_debug(GG_DEBUG_MISC, "=> token, parsing failed\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
772 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
773 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
774 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
775 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
776 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
777
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
778 /* dostaliśmy tokenid i wszystkie niezbędne informacje,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
779 * więc pobierzmy obrazek z tokenem */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
780
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
781 if (strncmp(url, "http://", 7)) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
782 path = gg_saprintf("%s?tokenid=%s", url, tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
783 host = GG_REGISTER_HOST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
784 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
785 char *slash = strchr(url + 7, '/');
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
786
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
787 if (slash) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
788 path = gg_saprintf("%s?tokenid=%s", slash, tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
789 *slash = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
790 host = url + 7;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
791 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
792 gg_debug(GG_DEBUG_MISC, "=> token, url parsing failed\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
793 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
794 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
795 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
796 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
797 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
798 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
799
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
800 if (!path) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
801 gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
802 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
803 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
804 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
805 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
806
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
807 if (!(headers = gg_saprintf("Host: %s\r\nUser-Agent: " GG_HTTP_USERAGENT "\r\n\r\n", host))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
808 gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
809 free(path);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
810 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
811 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
812 return -1;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
813 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
814
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
815 if (!(h2 = gg_http_connect(host, GG_REGISTER_PORT, h->async, "GET", path, headers))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
816 gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
817 free(headers);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
818 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
819 free(path);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
820 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
821 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
822 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
823
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
824 free(headers);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
825 free(path);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
826 free(url);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
827
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
828 gg_http_free_fields(h);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
829
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
830 memcpy(h, h2, sizeof(struct gg_http));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
831 free(h2);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
832
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
833 h->type = GG_SESSION_TOKEN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
834
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
835 h->callback = gg_token_watch_fd;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
836 h->destroy = gg_token_free;
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
837
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
838 if (!h->async)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
839 gg_token_watch_fd(h);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
840
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
841 if (!(h->data = t = malloc(sizeof(struct gg_token)))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
842 gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token data\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
843 free(tokenid);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
844 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
845 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
846
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
847 t->width = width;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
848 t->height = height;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
849 t->length = length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
850 t->tokenid = tokenid;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
851 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
852 /* obrazek mamy w h->body */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
853 h->state = GG_STATE_DONE;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
854 }
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
855
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
856 return 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
857 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
858
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
859 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
860 * Zwalnia zasoby po operacji pobierania tokenu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
861 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
862 * \param h Struktura połączenia
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
863 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
864 * \ingroup token
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
865 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
866 void gg_token_free(struct gg_http *h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
867 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
868 struct gg_token *t;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
869
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
870 if (!h)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
871 return;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
872
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
873 if ((t = h->data))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
874 free(t->tokenid);
35627
fd11790cc4d6 Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35617
diff changeset
875
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
876 free(h->data);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
877 gg_http_free(h);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
878 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
879
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
880 /*
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
881 * Local variables:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
882 * c-indentation-style: k&r
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
883 * c-basic-offset: 8
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
884 * indent-tabs-mode: notnil
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
885 * End:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
886 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
887 * vim: shiftwidth=8:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
888 */

mercurial