Tue, 18 Oct 2011 00:55:59 +0000
Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
|
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
|
1 | /* $Id: pubdir.c 502 2008-01-10 23:25:17Z wojtekka $ */ |
| 11360 | 2 | |
| 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 | 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 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU Lesser General Public License Version | |
| 10 | * 2.1 as published by the Free Software Foundation. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU Lesser General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU Lesser General Public | |
| 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 | 20 | * USA. |
| 21 | */ | |
| 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 | |
| 11360 | 29 | #include <ctype.h> |
| 30 | #include <errno.h> | |
| 31 | #include <stdarg.h> | |
| 32 | #include <stdio.h> | |
| 33 | #include <stdlib.h> | |
| 34 | #include <string.h> | |
| 35 | #include <unistd.h> | |
| 36 | ||
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
37 | #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
|
38 | |
|
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
|
39 | /** |
|
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 | * Rejestruje nowego użytkownika. |
| 11360 | 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 | * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token(). |
| 11360 | 43 | * |
|
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
|
44 | * \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
|
45 | * \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
|
46 | * \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
|
47 | * \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
|
48 | * \param async Flaga połączenia asynchronicznego |
| 11360 | 49 | * |
|
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
|
50 | * \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
|
51 | * |
|
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
|
52 | * \ingroup register |
| 11360 | 53 | */ |
| 54 | struct gg_http *gg_register3(const char *email, const char *password, const char *tokenid, const char *tokenval, int async) | |
| 55 | { | |
| 56 | struct gg_http *h; | |
| 57 | char *__pwd, *__email, *__tokenid, *__tokenval, *form, *query; | |
| 58 | ||
| 59 | if (!email || !password || !tokenid || !tokenval) { | |
| 60 | gg_debug(GG_DEBUG_MISC, "=> register, NULL parameter\n"); | |
| 61 | errno = EFAULT; | |
| 62 | return NULL; | |
| 63 | } | |
| 64 | ||
| 65 | __pwd = gg_urlencode(password); | |
| 66 | __email = gg_urlencode(email); | |
| 67 | __tokenid = gg_urlencode(tokenid); | |
| 68 | __tokenval = gg_urlencode(tokenval); | |
| 69 | ||
| 70 | if (!__pwd || !__email || !__tokenid || !__tokenval) { | |
| 71 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form fields\n"); | |
| 72 | free(__pwd); | |
| 73 | free(__email); | |
| 74 | free(__tokenid); | |
| 75 | free(__tokenval); | |
| 76 | return NULL; | |
| 77 | } | |
| 78 | ||
| 79 | form = gg_saprintf("pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u", | |
| 80 | __pwd, __email, __tokenid, __tokenval, | |
| 81 | gg_http_hash("ss", email, password)); | |
| 82 | ||
| 83 | free(__pwd); | |
| 84 | free(__email); | |
| 85 | free(__tokenid); | |
| 86 | free(__tokenval); | |
| 87 | ||
| 88 | if (!form) { | |
| 89 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form query\n"); | |
| 90 | return NULL; | |
| 91 | } | |
| 92 | ||
| 93 | gg_debug(GG_DEBUG_MISC, "=> register, %s\n", form); | |
| 94 | ||
| 95 | query = gg_saprintf( | |
| 96 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 97 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 98 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 99 | "Content-Length: %d\r\n" | |
| 100 | "Pragma: no-cache\r\n" | |
| 101 | "\r\n" | |
| 102 | "%s", | |
| 103 | (int) strlen(form), form); | |
| 104 | ||
| 105 | free(form); | |
| 106 | ||
| 107 | if (!query) { | |
| 108 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for query\n"); | |
| 109 | return NULL; | |
| 110 | } | |
| 111 | ||
| 112 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 113 | gg_debug(GG_DEBUG_MISC, "=> register, gg_http_connect() failed mysteriously\n"); | |
| 114 | free(query); | |
| 115 | return NULL; | |
| 116 | } | |
| 117 | ||
| 118 | h->type = GG_SESSION_REGISTER; | |
| 119 | ||
| 120 | free(query); | |
| 121 | ||
| 122 | h->callback = gg_pubdir_watch_fd; | |
| 123 | h->destroy = gg_pubdir_free; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
124 | |
| 11360 | 125 | if (!async) |
| 126 | gg_pubdir_watch_fd(h); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
127 | |
| 11360 | 128 | return h; |
| 129 | } | |
| 130 | ||
|
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
|
131 | #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
|
132 | |
|
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 | * 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
|
135 | * |
|
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 | * 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
|
137 | * 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
|
138 | * 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
|
139 | * |
|
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 | * \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
|
141 | * \c gg_pubdir_watch_fd(). |
| 11360 | 142 | * |
|
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
|
143 | * \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
|
144 | * |
|
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 | * \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
|
146 | * |
|
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 | * \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
|
148 | */ |
|
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 | 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
|
150 | { |
|
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 | 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
|
152 | } |
|
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 | * Zwalnia zasoby po operacji. |
| 11360 | 156 | * |
|
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
|
157 | * \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
|
158 | * |
|
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 | * \param h Struktura połączenia |
| 11360 | 160 | * |
|
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
|
161 | * \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
|
162 | */ |
|
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 | 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
|
164 | { |
|
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 | 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
|
166 | } |
|
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 | #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
|
169 | |
|
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 | * 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
|
172 | * |
|
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 | * 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
|
174 | * |
|
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 | * \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
|
176 | * \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
|
177 | * \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
|
178 | * \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
|
179 | * \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
|
180 | * |
|
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 | * \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
|
182 | * |
|
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 | * \ingroup unregister |
| 11360 | 184 | */ |
| 185 | struct gg_http *gg_unregister3(uin_t uin, const char *password, const char *tokenid, const char *tokenval, int async) | |
| 186 | { | |
| 187 | struct gg_http *h; | |
| 188 | char *__fmpwd, *__pwd, *__tokenid, *__tokenval, *form, *query; | |
| 189 | ||
| 190 | if (!password || !tokenid || !tokenval) { | |
| 191 | gg_debug(GG_DEBUG_MISC, "=> unregister, NULL parameter\n"); | |
| 192 | errno = EFAULT; | |
| 193 | return NULL; | |
| 194 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
195 | |
| 11360 | 196 | __pwd = gg_saprintf("%ld", random()); |
| 197 | __fmpwd = gg_urlencode(password); | |
| 198 | __tokenid = gg_urlencode(tokenid); | |
| 199 | __tokenval = gg_urlencode(tokenval); | |
| 200 | ||
| 201 | if (!__fmpwd || !__pwd || !__tokenid || !__tokenval) { | |
| 202 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form fields\n"); | |
| 203 | free(__pwd); | |
| 204 | free(__fmpwd); | |
| 205 | free(__tokenid); | |
| 206 | free(__tokenval); | |
| 207 | return NULL; | |
| 208 | } | |
| 209 | ||
| 210 | form = gg_saprintf("fmnumber=%d&fmpwd=%s&delete=1&pwd=%s&email=deletedaccount@gadu-gadu.pl&tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __tokenid, __tokenval, gg_http_hash("ss", "deletedaccount@gadu-gadu.pl", __pwd)); | |
| 211 | ||
| 212 | free(__fmpwd); | |
| 213 | free(__pwd); | |
| 214 | free(__tokenid); | |
| 215 | free(__tokenval); | |
| 216 | ||
| 217 | if (!form) { | |
| 218 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form query\n"); | |
| 219 | return NULL; | |
| 220 | } | |
| 221 | ||
| 222 | gg_debug(GG_DEBUG_MISC, "=> unregister, %s\n", form); | |
| 223 | ||
| 224 | query = gg_saprintf( | |
| 225 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 226 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 227 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 228 | "Content-Length: %d\r\n" | |
| 229 | "Pragma: no-cache\r\n" | |
| 230 | "\r\n" | |
| 231 | "%s", | |
| 232 | (int) strlen(form), form); | |
| 233 | ||
| 234 | free(form); | |
| 235 | ||
| 236 | if (!query) { | |
| 237 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for query\n"); | |
| 238 | return NULL; | |
| 239 | } | |
| 240 | ||
| 241 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 242 | gg_debug(GG_DEBUG_MISC, "=> unregister, gg_http_connect() failed mysteriously\n"); | |
| 243 | free(query); | |
| 244 | return NULL; | |
| 245 | } | |
| 246 | ||
| 247 | h->type = GG_SESSION_UNREGISTER; | |
| 248 | ||
| 249 | free(query); | |
| 250 | ||
| 251 | h->callback = gg_pubdir_watch_fd; | |
| 252 | h->destroy = gg_pubdir_free; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
253 | |
| 11360 | 254 | if (!async) |
| 255 | gg_pubdir_watch_fd(h); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
256 | |
| 11360 | 257 | return h; |
| 258 | } | |
| 259 | ||
|
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
|
260 | #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
|
261 | |
|
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
|
262 | /** |
|
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
|
263 | * 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
|
264 | * |
|
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
|
265 | * 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
|
266 | * 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
|
267 | * 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
|
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 | * \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
|
270 | * \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
|
271 | * |
|
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 | * \param h Struktura połączenia |
| 11360 | 273 | * |
|
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
|
274 | * \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
|
275 | * |
|
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 | * \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
|
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 | 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
|
279 | { |
|
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 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
|
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 | |
|
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 | * 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
|
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 | * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free(). |
| 11360 | 287 | * |
|
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
|
288 | * \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
|
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 | * \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
|
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 | 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
|
293 | { |
|
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 | 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
|
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 | |
|
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 | #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
|
298 | |
|
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 | * Zmienia hasło użytkownika. |
| 11360 | 301 | * |
|
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
|
302 | * 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
|
303 | * |
|
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 | * \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
|
305 | * \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
|
306 | * \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
|
307 | * \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
|
308 | * \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
|
309 | * \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
|
310 | * \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
|
311 | * |
|
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 | * \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
|
313 | * |
|
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 | * \ingroup passwd |
| 11360 | 315 | */ |
| 316 | struct gg_http *gg_change_passwd4(uin_t uin, const char *email, const char *passwd, const char *newpasswd, const char *tokenid, const char *tokenval, int async) | |
| 317 | { | |
| 318 | struct gg_http *h; | |
| 319 | char *form, *query, *__email, *__fmpwd, *__pwd, *__tokenid, *__tokenval; | |
| 320 | ||
| 321 | if (!uin || !email || !passwd || !newpasswd || !tokenid || !tokenval) { | |
| 322 | gg_debug(GG_DEBUG_MISC, "=> change, NULL parameter\n"); | |
| 323 | errno = EFAULT; | |
| 324 | return NULL; | |
| 325 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
326 | |
| 11360 | 327 | __fmpwd = gg_urlencode(passwd); |
| 328 | __pwd = gg_urlencode(newpasswd); | |
| 329 | __email = gg_urlencode(email); | |
| 330 | __tokenid = gg_urlencode(tokenid); | |
| 331 | __tokenval = gg_urlencode(tokenval); | |
| 332 | ||
| 333 | if (!__fmpwd || !__pwd || !__email || !__tokenid || !__tokenval) { | |
| 334 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n"); | |
| 335 | free(__fmpwd); | |
| 336 | free(__pwd); | |
| 337 | free(__email); | |
| 338 | free(__tokenid); | |
| 339 | free(__tokenval); | |
| 340 | return NULL; | |
| 341 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
342 | |
| 11360 | 343 | if (!(form = gg_saprintf("fmnumber=%d&fmpwd=%s&pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __email, __tokenid, __tokenval, gg_http_hash("ss", email, newpasswd)))) { |
| 344 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n"); | |
| 345 | free(__fmpwd); | |
| 346 | free(__pwd); | |
| 347 | free(__email); | |
| 348 | free(__tokenid); | |
| 349 | free(__tokenval); | |
| 350 | ||
| 351 | return NULL; | |
| 352 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
353 | |
| 11360 | 354 | free(__fmpwd); |
| 355 | free(__pwd); | |
| 356 | free(__email); | |
| 357 | free(__tokenid); | |
| 358 | free(__tokenval); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
359 | |
| 11360 | 360 | gg_debug(GG_DEBUG_MISC, "=> change, %s\n", form); |
| 361 | ||
| 362 | query = gg_saprintf( | |
| 363 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 364 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 365 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 366 | "Content-Length: %d\r\n" | |
| 367 | "Pragma: no-cache\r\n" | |
| 368 | "\r\n" | |
| 369 | "%s", | |
| 370 | (int) strlen(form), form); | |
| 371 | ||
| 372 | free(form); | |
| 373 | ||
| 374 | if (!query) { | |
| 375 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for query\n"); | |
| 376 | return NULL; | |
| 377 | } | |
| 378 | ||
| 379 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 380 | gg_debug(GG_DEBUG_MISC, "=> change, gg_http_connect() failed mysteriously\n"); | |
| 381 | free(query); | |
| 382 | return NULL; | |
| 383 | } | |
| 384 | ||
| 385 | h->type = GG_SESSION_PASSWD; | |
| 386 | ||
| 387 | free(query); | |
| 388 | ||
| 389 | h->callback = gg_pubdir_watch_fd; | |
| 390 | h->destroy = gg_pubdir_free; | |
| 391 | ||
| 392 | if (!async) | |
| 393 | gg_pubdir_watch_fd(h); | |
| 394 | ||
| 395 | return h; | |
| 396 | } | |
| 397 | ||
|
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
|
398 | #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
|
399 | |
|
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
|
400 | /** |
|
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
|
401 | * 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
|
402 | * |
|
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
|
403 | * 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
|
404 | * 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
|
405 | * 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
|
406 | * |
|
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
|
407 | * \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
|
408 | * \c gg_pubdir_watch_fd(). |
| 11360 | 409 | * |
|
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
|
410 | * \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
|
411 | * |
|
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 | * \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
|
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 | * \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
|
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 | 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
|
417 | { |
|
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 | 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
|
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 | |
|
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 | /** |
|
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
|
422 | * Zwalnia zasoby po operacji. |
| 11360 | 423 | * |
|
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
|
424 | * \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
|
425 | * |
|
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 | * \param h Struktura połączenia |
| 11360 | 427 | * |
|
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
|
428 | * \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
|
429 | */ |
|
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 | 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
|
431 | { |
|
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 | 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
|
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 | #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
|
436 | |
|
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 | /** |
|
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 | * 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
|
439 | * |
|
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
|
440 | * 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
|
441 | * |
|
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 | * \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
|
443 | * \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
|
444 | * \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
|
445 | * \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
|
446 | * \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
|
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 | * \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
|
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 | * \ingroup remind |
| 11360 | 451 | */ |
| 452 | struct gg_http *gg_remind_passwd3(uin_t uin, const char *email, const char *tokenid, const char *tokenval, int async) | |
| 453 | { | |
| 454 | struct gg_http *h; | |
| 455 | char *form, *query, *__tokenid, *__tokenval, *__email; | |
| 456 | ||
| 457 | if (!tokenid || !tokenval || !email) { | |
| 458 | gg_debug(GG_DEBUG_MISC, "=> remind, NULL parameter\n"); | |
| 459 | errno = EFAULT; | |
| 460 | return NULL; | |
| 461 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
462 | |
| 11360 | 463 | __tokenid = gg_urlencode(tokenid); |
| 464 | __tokenval = gg_urlencode(tokenval); | |
| 465 | __email = gg_urlencode(email); | |
| 466 | ||
| 467 | if (!__tokenid || !__tokenval || !__email) { | |
| 468 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n"); | |
| 469 | free(__tokenid); | |
| 470 | free(__tokenval); | |
| 471 | free(__email); | |
| 472 | return NULL; | |
| 473 | } | |
| 474 | ||
| 475 | if (!(form = gg_saprintf("userid=%d&code=%u&tokenid=%s&tokenval=%s&email=%s", uin, gg_http_hash("u", uin), __tokenid, __tokenval, __email))) { | |
| 476 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n"); | |
| 477 | free(__tokenid); | |
| 478 | free(__tokenval); | |
| 479 | free(__email); | |
| 480 | return NULL; | |
| 481 | } | |
| 482 | ||
| 483 | free(__tokenid); | |
| 484 | free(__tokenval); | |
| 485 | free(__email); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
486 | |
| 11360 | 487 | gg_debug(GG_DEBUG_MISC, "=> remind, %s\n", form); |
| 488 | ||
| 489 | query = gg_saprintf( | |
| 490 | "Host: " GG_REMIND_HOST "\r\n" | |
| 491 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 492 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 493 | "Content-Length: %d\r\n" | |
| 494 | "Pragma: no-cache\r\n" | |
| 495 | "\r\n" | |
| 496 | "%s", | |
| 497 | (int) strlen(form), form); | |
| 498 | ||
| 499 | free(form); | |
| 500 | ||
| 501 | if (!query) { | |
| 502 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for query\n"); | |
| 503 | return NULL; | |
| 504 | } | |
| 505 | ||
| 506 | if (!(h = gg_http_connect(GG_REMIND_HOST, GG_REMIND_PORT, async, "POST", "/appsvc/fmsendpwd3.asp", query))) { | |
| 507 | gg_debug(GG_DEBUG_MISC, "=> remind, gg_http_connect() failed mysteriously\n"); | |
| 508 | free(query); | |
| 509 | return NULL; | |
| 510 | } | |
| 511 | ||
| 512 | h->type = GG_SESSION_REMIND; | |
| 513 | ||
| 514 | free(query); | |
| 515 | ||
| 516 | h->callback = gg_pubdir_watch_fd; | |
| 517 | h->destroy = gg_pubdir_free; | |
| 518 | ||
| 519 | if (!async) | |
| 520 | gg_pubdir_watch_fd(h); | |
| 521 | ||
| 522 | return h; | |
| 523 | } | |
| 524 | ||
|
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
|
525 | #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
|
526 | |
|
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
|
527 | /** |
|
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
|
528 | * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia. |
| 11360 | 529 | * |
|
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
|
530 | * 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
|
531 | * 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
|
532 | * 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
|
533 | * |
|
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
|
534 | * \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
|
535 | * \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
|
536 | * |
|
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
|
537 | * \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
|
538 | * |
|
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
|
539 | * \return 0 jeśli się powiodło, -1 w przypadku błędu |
| 11360 | 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 | * \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
|
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 | 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
|
544 | { |
|
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
|
545 | 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
|
546 | } |
|
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 | |
|
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 | /** |
|
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 | * 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
|
550 | * |
|
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 | * \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
|
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 |
| 11360 | 554 | * |
|
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
|
555 | * \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
|
556 | */ |
|
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 | 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
|
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 | 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
|
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 | |
|
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 | #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
|
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 | * 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
|
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 | * 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
|
568 | * 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
|
569 | * 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
|
570 | * |
|
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 | * \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
|
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 | * \return 0 jeśli się powiodło, -1 w przypadku błędu |
| 11360 | 574 | */ |
| 575 | int gg_pubdir_watch_fd(struct gg_http *h) | |
| 576 | { | |
| 577 | struct gg_pubdir *p; | |
| 578 | char *tmp; | |
| 579 | ||
| 580 | if (!h) { | |
| 581 | errno = EFAULT; | |
| 582 | return -1; | |
| 583 | } | |
| 584 | ||
| 585 | if (h->state == GG_STATE_ERROR) { | |
| 586 | gg_debug(GG_DEBUG_MISC, "=> pubdir, watch_fd issued on failed session\n"); | |
| 587 | errno = EINVAL; | |
| 588 | return -1; | |
| 589 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
590 | |
| 11360 | 591 | if (h->state != GG_STATE_PARSING) { |
| 592 | if (gg_http_watch_fd(h) == -1) { | |
| 593 | gg_debug(GG_DEBUG_MISC, "=> pubdir, http failure\n"); | |
| 594 | errno = EINVAL; | |
| 595 | return -1; | |
| 596 | } | |
| 597 | } | |
| 598 | ||
| 599 | if (h->state != GG_STATE_PARSING) | |
| 600 | return 0; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
601 | |
| 11360 | 602 | h->state = GG_STATE_DONE; |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
603 | |
| 11360 | 604 | if (!(h->data = p = malloc(sizeof(struct gg_pubdir)))) { |
| 605 | gg_debug(GG_DEBUG_MISC, "=> pubdir, not enough memory for results\n"); | |
| 606 | return -1; | |
| 607 | } | |
| 608 | ||
| 609 | p->success = 0; | |
| 610 | p->uin = 0; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
611 | |
| 11360 | 612 | gg_debug(GG_DEBUG_MISC, "=> pubdir, let's parse \"%s\"\n", h->body); |
| 613 | ||
|
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
|
614 | 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
|
615 | 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
|
616 | p->uin = strtol(tmp + sizeof("Tokens okregisterreply_packet.reg.dwUserId=") - 1, NULL, 0); |
|
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
|
617 | 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
|
618 | } else if ((tmp = strstr(h->body, "success")) || (tmp = strstr(h->body, "results"))) { |
| 11360 | 619 | p->success = 1; |
| 620 | if (tmp[7] == ':') | |
| 621 | p->uin = strtol(tmp + 8, NULL, 0); | |
| 622 | gg_debug(GG_DEBUG_MISC, "=> pubdir, success (uin=%d)\n", p->uin); | |
| 623 | } else | |
| 624 | gg_debug(GG_DEBUG_MISC, "=> pubdir, error.\n"); | |
| 625 | ||
| 626 | return 0; | |
| 627 | } | |
| 628 | ||
|
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
|
629 | /** |
|
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 | * Zwalnia zasoby po operacji na katalogu publicznym. |
| 11360 | 631 | * |
|
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
|
632 | * \param h Struktura połączenia |
| 11360 | 633 | */ |
| 634 | void gg_pubdir_free(struct gg_http *h) | |
| 635 | { | |
| 636 | if (!h) | |
| 637 | return; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
638 | |
| 11360 | 639 | free(h->data); |
| 640 | gg_http_free(h); | |
| 641 | } | |
| 642 | ||
|
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
|
643 | /** |
|
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
|
644 | * 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
|
645 | * |
|
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
|
646 | * 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
|
647 | * zmiany hasła itd. |
| 11360 | 648 | * |
|
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
|
649 | * \param async Flaga połączenia asynchronicznego |
| 11360 | 650 | * |
|
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
|
651 | * \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
|
652 | * |
|
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
|
653 | * \ingroup token |
| 11360 | 654 | */ |
| 655 | struct gg_http *gg_token(int async) | |
| 656 | { | |
| 657 | struct gg_http *h; | |
| 658 | const char *query; | |
| 659 | ||
| 660 | query = "Host: " GG_REGISTER_HOST "\r\n" | |
| 661 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 662 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 663 | "Content-Length: 0\r\n" | |
| 664 | "Pragma: no-cache\r\n" | |
| 665 | "\r\n"; | |
| 666 | ||
| 667 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/regtoken.asp", query))) { | |
| 668 | gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n"); | |
| 669 | return NULL; | |
| 670 | } | |
| 671 | ||
| 672 | h->type = GG_SESSION_TOKEN; | |
| 673 | ||
| 674 | h->callback = gg_token_watch_fd; | |
| 675 | h->destroy = gg_token_free; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
676 | |
| 11360 | 677 | if (!async) |
| 678 | gg_token_watch_fd(h); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
679 | |
| 11360 | 680 | return h; |
| 681 | } | |
| 682 | ||
|
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
|
683 | /** |
|
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
|
684 | * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia. |
| 11360 | 685 | * |
|
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
|
686 | * 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
|
687 | * 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
|
688 | * znajdzie się w polu \c error. |
| 11360 | 689 | * |
|
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
|
690 | * \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
|
691 | * |
|
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
|
692 | * \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
|
693 | * |
|
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
|
694 | * \ingroup token |
| 11360 | 695 | */ |
| 696 | int gg_token_watch_fd(struct gg_http *h) | |
| 697 | { | |
| 698 | if (!h) { | |
| 699 | errno = EFAULT; | |
| 700 | return -1; | |
| 701 | } | |
| 702 | ||
| 703 | if (h->state == GG_STATE_ERROR) { | |
| 704 | gg_debug(GG_DEBUG_MISC, "=> token, watch_fd issued on failed session\n"); | |
| 705 | errno = EINVAL; | |
| 706 | return -1; | |
| 707 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
708 | |
| 11360 | 709 | if (h->state != GG_STATE_PARSING) { |
| 710 | if (gg_http_watch_fd(h) == -1) { | |
| 711 | gg_debug(GG_DEBUG_MISC, "=> token, http failure\n"); | |
| 712 | errno = EINVAL; | |
| 713 | return -1; | |
| 714 | } | |
| 715 | } | |
| 716 | ||
| 717 | if (h->state != GG_STATE_PARSING) | |
| 718 | return 0; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
719 | |
|
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
|
720 | /* 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
|
721 | * ale jeśli coś tam jest, to znaczy, że mamy drugi etap polegający |
| 11360 | 722 | * na pobieraniu tokenu. */ |
| 723 | if (!h->data) { | |
| 724 | int width, height, length; | |
| 725 | char *url = NULL, *tokenid = NULL, *path, *headers; | |
| 726 | const char *host; | |
| 727 | struct gg_http *h2; | |
| 728 | struct gg_token *t; | |
| 729 | ||
| 730 | gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body); | |
| 731 | ||
| 732 | if (h->body && (!(url = malloc(strlen(h->body))) || !(tokenid = malloc(strlen(h->body))))) { | |
| 733 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n"); | |
| 734 | free(url); | |
| 735 | return -1; | |
| 736 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
737 | |
| 11360 | 738 | if (!h->body || sscanf(h->body, "%d %d %d\r\n%s\r\n%s", &width, &height, &length, tokenid, url) != 5) { |
| 739 | gg_debug(GG_DEBUG_MISC, "=> token, parsing failed\n"); | |
| 740 | free(url); | |
| 741 | free(tokenid); | |
| 742 | errno = EINVAL; | |
| 743 | return -1; | |
| 744 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
745 | |
|
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
|
746 | /* 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
|
747 | * więc pobierzmy obrazek z tokenem */ |
| 11360 | 748 | |
| 749 | if (strncmp(url, "http://", 7)) { | |
| 750 | path = gg_saprintf("%s?tokenid=%s", url, tokenid); | |
| 751 | host = GG_REGISTER_HOST; | |
| 752 | } else { | |
| 753 | char *slash = strchr(url + 7, '/'); | |
| 754 | ||
| 755 | if (slash) { | |
| 756 | path = gg_saprintf("%s?tokenid=%s", slash, tokenid); | |
| 757 | *slash = 0; | |
| 758 | host = url + 7; | |
| 759 | } else { | |
| 760 | gg_debug(GG_DEBUG_MISC, "=> token, url parsing failed\n"); | |
| 761 | free(url); | |
| 762 | free(tokenid); | |
| 763 | errno = EINVAL; | |
| 764 | return -1; | |
| 765 | } | |
| 766 | } | |
| 767 | ||
| 768 | if (!path) { | |
| 769 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n"); | |
| 770 | free(url); | |
| 771 | free(tokenid); | |
| 772 | return -1; | |
| 773 | } | |
| 774 | ||
| 775 | if (!(headers = gg_saprintf("Host: %s\r\nUser-Agent: " GG_HTTP_USERAGENT "\r\n\r\n", host))) { | |
| 776 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n"); | |
| 777 | free(path); | |
| 778 | free(url); | |
| 779 | free(tokenid); | |
| 780 | return -1; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
781 | } |
| 11360 | 782 | |
| 783 | if (!(h2 = gg_http_connect(host, GG_REGISTER_PORT, h->async, "GET", path, headers))) { | |
| 784 | gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n"); | |
| 785 | free(headers); | |
| 786 | free(url); | |
| 787 | free(path); | |
| 788 | free(tokenid); | |
| 789 | return -1; | |
| 790 | } | |
| 791 | ||
| 792 | free(headers); | |
| 793 | free(path); | |
| 794 | free(url); | |
| 795 | ||
|
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
|
796 | 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
|
797 | |
| 11360 | 798 | memcpy(h, h2, sizeof(struct gg_http)); |
| 799 | free(h2); | |
| 800 | ||
| 801 | h->type = GG_SESSION_TOKEN; | |
| 802 | ||
| 803 | h->callback = gg_token_watch_fd; | |
| 804 | h->destroy = gg_token_free; | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
805 | |
| 11360 | 806 | if (!h->async) |
| 807 | gg_token_watch_fd(h); | |
| 808 | ||
| 809 | if (!(h->data = t = malloc(sizeof(struct gg_token)))) { | |
| 810 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token data\n"); | |
| 811 | free(tokenid); | |
| 812 | return -1; | |
| 813 | } | |
| 814 | ||
| 815 | t->width = width; | |
| 816 | t->height = height; | |
| 817 | t->length = length; | |
| 818 | t->tokenid = tokenid; | |
| 819 | } else { | |
| 820 | /* obrazek mamy w h->body */ | |
| 821 | h->state = GG_STATE_DONE; | |
| 822 | } | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
823 | |
| 11360 | 824 | return 0; |
| 825 | } | |
| 826 | ||
|
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
|
827 | /** |
|
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 | * Zwalnia zasoby po operacji pobierania tokenu. |
| 11360 | 829 | * |
|
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
|
830 | * \param h Struktura połączenia |
| 11360 | 831 | * |
|
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
|
832 | * \ingroup token |
| 11360 | 833 | */ |
| 834 | void gg_token_free(struct gg_http *h) | |
| 835 | { | |
| 836 | struct gg_token *t; | |
| 837 | ||
| 838 | if (!h) | |
| 839 | return; | |
| 840 | ||
| 841 | if ((t = h->data)) | |
| 842 | free(t->tokenid); | |
|
31826
0f6ab56fbf9d
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31294
diff
changeset
|
843 | |
| 11360 | 844 | free(h->data); |
| 845 | gg_http_free(h); | |
| 846 | } | |
| 847 | ||
| 848 | /* | |
| 849 | * Local variables: | |
| 850 | * c-indentation-style: k&r | |
| 851 | * c-basic-offset: 8 | |
| 852 | * indent-tabs-mode: notnil | |
| 853 | * End: | |
| 854 | * | |
| 855 | * vim: shiftwidth=8: | |
| 856 | */ |