Tue, 04 Jan 2011 06:55:30 +0000
Remove trailing whitespace
|
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 | |
|
29752
5cb6314b2477
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29751
diff
changeset
|
29 | #include "libgadu.h" |
|
5cb6314b2477
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29751
diff
changeset
|
30 | #include "libgadu-config.h" |
|
5cb6314b2477
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29751
diff
changeset
|
31 | |
| 11360 | 32 | #include <ctype.h> |
| 33 | #include <errno.h> | |
| 34 | #include <stdarg.h> | |
| 35 | #include <stdio.h> | |
| 36 | #include <stdlib.h> | |
| 37 | #include <string.h> | |
| 38 | #include <unistd.h> | |
| 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 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
41 | * Rejestruje nowego użytkownika. |
| 11360 | 42 | * |
|
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
|
43 | * Wymaga wcześniejszego pobrania tokenu za pomocą \c gg_token(). |
| 11360 | 44 | * |
|
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
|
45 | * \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
|
46 | * \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
|
47 | * \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
|
48 | * \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
|
49 | * \param async Flaga połączenia asynchronicznego |
| 11360 | 50 | * |
|
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
|
51 | * \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
|
52 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
53 | * \ingroup register |
| 11360 | 54 | */ |
| 55 | struct gg_http *gg_register3(const char *email, const char *password, const char *tokenid, const char *tokenval, int async) | |
| 56 | { | |
| 57 | struct gg_http *h; | |
| 58 | char *__pwd, *__email, *__tokenid, *__tokenval, *form, *query; | |
| 59 | ||
| 60 | if (!email || !password || !tokenid || !tokenval) { | |
| 61 | gg_debug(GG_DEBUG_MISC, "=> register, NULL parameter\n"); | |
| 62 | errno = EFAULT; | |
| 63 | return NULL; | |
| 64 | } | |
| 65 | ||
| 66 | __pwd = gg_urlencode(password); | |
| 67 | __email = gg_urlencode(email); | |
| 68 | __tokenid = gg_urlencode(tokenid); | |
| 69 | __tokenval = gg_urlencode(tokenval); | |
| 70 | ||
| 71 | if (!__pwd || !__email || !__tokenid || !__tokenval) { | |
| 72 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form fields\n"); | |
| 73 | free(__pwd); | |
| 74 | free(__email); | |
| 75 | free(__tokenid); | |
| 76 | free(__tokenval); | |
| 77 | return NULL; | |
| 78 | } | |
| 79 | ||
| 80 | form = gg_saprintf("pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u", | |
| 81 | __pwd, __email, __tokenid, __tokenval, | |
| 82 | gg_http_hash("ss", email, password)); | |
| 83 | ||
| 84 | free(__pwd); | |
| 85 | free(__email); | |
| 86 | free(__tokenid); | |
| 87 | free(__tokenval); | |
| 88 | ||
| 89 | if (!form) { | |
| 90 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for form query\n"); | |
| 91 | return NULL; | |
| 92 | } | |
| 93 | ||
| 94 | gg_debug(GG_DEBUG_MISC, "=> register, %s\n", form); | |
| 95 | ||
| 96 | query = gg_saprintf( | |
| 97 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 98 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 99 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 100 | "Content-Length: %d\r\n" | |
| 101 | "Pragma: no-cache\r\n" | |
| 102 | "\r\n" | |
| 103 | "%s", | |
| 104 | (int) strlen(form), form); | |
| 105 | ||
| 106 | free(form); | |
| 107 | ||
| 108 | if (!query) { | |
| 109 | gg_debug(GG_DEBUG_MISC, "=> register, not enough memory for query\n"); | |
| 110 | return NULL; | |
| 111 | } | |
| 112 | ||
| 113 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 114 | gg_debug(GG_DEBUG_MISC, "=> register, gg_http_connect() failed mysteriously\n"); | |
| 115 | free(query); | |
| 116 | return NULL; | |
| 117 | } | |
| 118 | ||
| 119 | h->type = GG_SESSION_REGISTER; | |
| 120 | ||
| 121 | free(query); | |
| 122 | ||
| 123 | h->callback = gg_pubdir_watch_fd; | |
| 124 | h->destroy = gg_pubdir_free; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
125 | |
| 11360 | 126 | if (!async) |
| 127 | gg_pubdir_watch_fd(h); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
128 | |
| 11360 | 129 | return h; |
| 130 | } | |
| 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 | 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 | 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 | 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 | 185 | */ |
| 186 | struct gg_http *gg_unregister3(uin_t uin, const char *password, const char *tokenid, const char *tokenval, int async) | |
| 187 | { | |
| 188 | struct gg_http *h; | |
| 189 | char *__fmpwd, *__pwd, *__tokenid, *__tokenval, *form, *query; | |
| 190 | ||
| 191 | if (!password || !tokenid || !tokenval) { | |
| 192 | gg_debug(GG_DEBUG_MISC, "=> unregister, NULL parameter\n"); | |
| 193 | errno = EFAULT; | |
| 194 | return NULL; | |
| 195 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
196 | |
| 11360 | 197 | __pwd = gg_saprintf("%ld", random()); |
| 198 | __fmpwd = gg_urlencode(password); | |
| 199 | __tokenid = gg_urlencode(tokenid); | |
| 200 | __tokenval = gg_urlencode(tokenval); | |
| 201 | ||
| 202 | if (!__fmpwd || !__pwd || !__tokenid || !__tokenval) { | |
| 203 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form fields\n"); | |
| 204 | free(__pwd); | |
| 205 | free(__fmpwd); | |
| 206 | free(__tokenid); | |
| 207 | free(__tokenval); | |
| 208 | return NULL; | |
| 209 | } | |
| 210 | ||
| 211 | 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)); | |
| 212 | ||
| 213 | free(__fmpwd); | |
| 214 | free(__pwd); | |
| 215 | free(__tokenid); | |
| 216 | free(__tokenval); | |
| 217 | ||
| 218 | if (!form) { | |
| 219 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for form query\n"); | |
| 220 | return NULL; | |
| 221 | } | |
| 222 | ||
| 223 | gg_debug(GG_DEBUG_MISC, "=> unregister, %s\n", form); | |
| 224 | ||
| 225 | query = gg_saprintf( | |
| 226 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 227 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 228 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 229 | "Content-Length: %d\r\n" | |
| 230 | "Pragma: no-cache\r\n" | |
| 231 | "\r\n" | |
| 232 | "%s", | |
| 233 | (int) strlen(form), form); | |
| 234 | ||
| 235 | free(form); | |
| 236 | ||
| 237 | if (!query) { | |
| 238 | gg_debug(GG_DEBUG_MISC, "=> unregister, not enough memory for query\n"); | |
| 239 | return NULL; | |
| 240 | } | |
| 241 | ||
| 242 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 243 | gg_debug(GG_DEBUG_MISC, "=> unregister, gg_http_connect() failed mysteriously\n"); | |
| 244 | free(query); | |
| 245 | return NULL; | |
| 246 | } | |
| 247 | ||
| 248 | h->type = GG_SESSION_UNREGISTER; | |
| 249 | ||
| 250 | free(query); | |
| 251 | ||
| 252 | h->callback = gg_pubdir_watch_fd; | |
| 253 | h->destroy = gg_pubdir_free; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
254 | |
| 11360 | 255 | if (!async) |
| 256 | gg_pubdir_watch_fd(h); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
257 | |
| 11360 | 258 | return h; |
| 259 | } | |
| 260 | ||
|
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
|
261 | #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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
265 | * |
|
438f88ecc11e
Update 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 | * 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
|
267 | * 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
|
268 | * 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
|
269 | * |
|
438f88ecc11e
Update 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 | * \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
|
271 | * \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
|
272 | * |
|
438f88ecc11e
Update 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 | * \param h Struktura połączenia |
| 11360 | 274 | * |
|
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
|
275 | * \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
|
276 | * |
|
438f88ecc11e
Update 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 | * \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
|
278 | */ |
|
438f88ecc11e
Update 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 | 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
|
280 | { |
|
438f88ecc11e
Update 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 | 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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
286 | * |
|
438f88ecc11e
Update 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 | * \note W rzeczywistości funkcja jest makrem rozwijanym do \c gg_pubdir_free(). |
| 11360 | 288 | * |
|
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
|
289 | * \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
|
290 | * |
|
438f88ecc11e
Update 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 | * \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
|
292 | */ |
|
438f88ecc11e
Update 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 | 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
|
294 | { |
|
438f88ecc11e
Update 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 | 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
|
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 | |
|
438f88ecc11e
Update 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 | #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
|
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 | /** |
|
438f88ecc11e
Update 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 | * Zmienia hasło użytkownika. |
| 11360 | 302 | * |
|
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
|
303 | * 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
|
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 | * \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
|
306 | * \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
|
307 | * \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
|
308 | * \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
|
309 | * \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
|
310 | * \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
|
311 | * \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
|
312 | * |
|
438f88ecc11e
Update 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 | * \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
|
314 | * |
|
438f88ecc11e
Update 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 | * \ingroup passwd |
| 11360 | 316 | */ |
| 317 | 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) | |
| 318 | { | |
| 319 | struct gg_http *h; | |
| 320 | char *form, *query, *__email, *__fmpwd, *__pwd, *__tokenid, *__tokenval; | |
| 321 | ||
| 322 | if (!uin || !email || !passwd || !newpasswd || !tokenid || !tokenval) { | |
| 323 | gg_debug(GG_DEBUG_MISC, "=> change, NULL parameter\n"); | |
| 324 | errno = EFAULT; | |
| 325 | return NULL; | |
| 326 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
327 | |
| 11360 | 328 | __fmpwd = gg_urlencode(passwd); |
| 329 | __pwd = gg_urlencode(newpasswd); | |
| 330 | __email = gg_urlencode(email); | |
| 331 | __tokenid = gg_urlencode(tokenid); | |
| 332 | __tokenval = gg_urlencode(tokenval); | |
| 333 | ||
| 334 | if (!__fmpwd || !__pwd || !__email || !__tokenid || !__tokenval) { | |
| 335 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n"); | |
| 336 | free(__fmpwd); | |
| 337 | free(__pwd); | |
| 338 | free(__email); | |
| 339 | free(__tokenid); | |
| 340 | free(__tokenval); | |
| 341 | return NULL; | |
| 342 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
343 | |
| 11360 | 344 | 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)))) { |
| 345 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n"); | |
| 346 | free(__fmpwd); | |
| 347 | free(__pwd); | |
| 348 | free(__email); | |
| 349 | free(__tokenid); | |
| 350 | free(__tokenval); | |
| 351 | ||
| 352 | return NULL; | |
| 353 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
354 | |
| 11360 | 355 | free(__fmpwd); |
| 356 | free(__pwd); | |
| 357 | free(__email); | |
| 358 | free(__tokenid); | |
| 359 | free(__tokenval); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
360 | |
| 11360 | 361 | gg_debug(GG_DEBUG_MISC, "=> change, %s\n", form); |
| 362 | ||
| 363 | query = gg_saprintf( | |
| 364 | "Host: " GG_REGISTER_HOST "\r\n" | |
| 365 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 366 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 367 | "Content-Length: %d\r\n" | |
| 368 | "Pragma: no-cache\r\n" | |
| 369 | "\r\n" | |
| 370 | "%s", | |
| 371 | (int) strlen(form), form); | |
| 372 | ||
| 373 | free(form); | |
| 374 | ||
| 375 | if (!query) { | |
| 376 | gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for query\n"); | |
| 377 | return NULL; | |
| 378 | } | |
| 379 | ||
| 380 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) { | |
| 381 | gg_debug(GG_DEBUG_MISC, "=> change, gg_http_connect() failed mysteriously\n"); | |
| 382 | free(query); | |
| 383 | return NULL; | |
| 384 | } | |
| 385 | ||
| 386 | h->type = GG_SESSION_PASSWD; | |
| 387 | ||
| 388 | free(query); | |
| 389 | ||
| 390 | h->callback = gg_pubdir_watch_fd; | |
| 391 | h->destroy = gg_pubdir_free; | |
| 392 | ||
| 393 | if (!async) | |
| 394 | gg_pubdir_watch_fd(h); | |
| 395 | ||
| 396 | return h; | |
| 397 | } | |
| 398 | ||
|
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
|
399 | #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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
403 | * |
|
438f88ecc11e
Update 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 | * 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
|
405 | * 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
|
406 | * 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
|
407 | * |
|
438f88ecc11e
Update 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 | * \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
|
409 | * \c gg_pubdir_watch_fd(). |
| 11360 | 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 | * \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
|
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 | * \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
|
414 | * |
|
438f88ecc11e
Update 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 | * \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
|
416 | */ |
|
438f88ecc11e
Update 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 | 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
|
418 | { |
|
438f88ecc11e
Update 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 | 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
|
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 | /** |
|
438f88ecc11e
Update 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 | * Zwalnia zasoby po operacji. |
| 11360 | 424 | * |
|
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
|
425 | * \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
|
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 | * \param h Struktura połączenia |
| 11360 | 428 | * |
|
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
|
429 | * \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
|
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 | 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
|
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 | 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
|
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 | |
|
438f88ecc11e
Update 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 | #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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
440 | * |
|
438f88ecc11e
Update 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 | * 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
|
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 | * \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
|
444 | * \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
|
445 | * \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
|
446 | * \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
|
447 | * \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
|
448 | * |
|
438f88ecc11e
Update 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 | * \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
|
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 | * \ingroup remind |
| 11360 | 452 | */ |
| 453 | struct gg_http *gg_remind_passwd3(uin_t uin, const char *email, const char *tokenid, const char *tokenval, int async) | |
| 454 | { | |
| 455 | struct gg_http *h; | |
| 456 | char *form, *query, *__tokenid, *__tokenval, *__email; | |
| 457 | ||
| 458 | if (!tokenid || !tokenval || !email) { | |
| 459 | gg_debug(GG_DEBUG_MISC, "=> remind, NULL parameter\n"); | |
| 460 | errno = EFAULT; | |
| 461 | return NULL; | |
| 462 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
463 | |
| 11360 | 464 | __tokenid = gg_urlencode(tokenid); |
| 465 | __tokenval = gg_urlencode(tokenval); | |
| 466 | __email = gg_urlencode(email); | |
| 467 | ||
| 468 | if (!__tokenid || !__tokenval || !__email) { | |
| 469 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n"); | |
| 470 | free(__tokenid); | |
| 471 | free(__tokenval); | |
| 472 | free(__email); | |
| 473 | return NULL; | |
| 474 | } | |
| 475 | ||
| 476 | if (!(form = gg_saprintf("userid=%d&code=%u&tokenid=%s&tokenval=%s&email=%s", uin, gg_http_hash("u", uin), __tokenid, __tokenval, __email))) { | |
| 477 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n"); | |
| 478 | free(__tokenid); | |
| 479 | free(__tokenval); | |
| 480 | free(__email); | |
| 481 | return NULL; | |
| 482 | } | |
| 483 | ||
| 484 | free(__tokenid); | |
| 485 | free(__tokenval); | |
| 486 | free(__email); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
487 | |
| 11360 | 488 | gg_debug(GG_DEBUG_MISC, "=> remind, %s\n", form); |
| 489 | ||
| 490 | query = gg_saprintf( | |
| 491 | "Host: " GG_REMIND_HOST "\r\n" | |
| 492 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 493 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 494 | "Content-Length: %d\r\n" | |
| 495 | "Pragma: no-cache\r\n" | |
| 496 | "\r\n" | |
| 497 | "%s", | |
| 498 | (int) strlen(form), form); | |
| 499 | ||
| 500 | free(form); | |
| 501 | ||
| 502 | if (!query) { | |
| 503 | gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for query\n"); | |
| 504 | return NULL; | |
| 505 | } | |
| 506 | ||
| 507 | if (!(h = gg_http_connect(GG_REMIND_HOST, GG_REMIND_PORT, async, "POST", "/appsvc/fmsendpwd3.asp", query))) { | |
| 508 | gg_debug(GG_DEBUG_MISC, "=> remind, gg_http_connect() failed mysteriously\n"); | |
| 509 | free(query); | |
| 510 | return NULL; | |
| 511 | } | |
| 512 | ||
| 513 | h->type = GG_SESSION_REMIND; | |
| 514 | ||
| 515 | free(query); | |
| 516 | ||
| 517 | h->callback = gg_pubdir_watch_fd; | |
| 518 | h->destroy = gg_pubdir_free; | |
| 519 | ||
| 520 | if (!async) | |
| 521 | gg_pubdir_watch_fd(h); | |
| 522 | ||
| 523 | return h; | |
| 524 | } | |
| 525 | ||
|
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
|
526 | #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
|
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 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
529 | * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia. |
| 11360 | 530 | * |
|
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
|
531 | * 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
|
532 | * 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
|
533 | * 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
|
534 | * |
|
438f88ecc11e
Update 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 | * \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
|
536 | * \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
|
537 | * |
|
438f88ecc11e
Update 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 | * \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
|
539 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
540 | * \return 0 jeśli się powiodło, -1 w przypadku błędu |
| 11360 | 541 | * |
|
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
|
542 | * \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
|
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 | 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
|
545 | { |
|
438f88ecc11e
Update 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 | 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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
551 | * |
|
438f88ecc11e
Update 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 | * \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
|
553 | * |
|
438f88ecc11e
Update 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 | * \param h Struktura połączenia |
| 11360 | 555 | * |
|
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
|
556 | * \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
|
557 | */ |
|
438f88ecc11e
Update 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 | 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
|
559 | { |
|
438f88ecc11e
Update 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 | 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
|
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 | |
|
438f88ecc11e
Update 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 | #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
|
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 | /** |
|
438f88ecc11e
Update 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 | * 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
|
567 | * |
|
438f88ecc11e
Update 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 | * 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
|
569 | * 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
|
570 | * 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
|
571 | * |
|
438f88ecc11e
Update 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 | * \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
|
573 | * |
|
438f88ecc11e
Update 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 | * \return 0 jeśli się powiodło, -1 w przypadku błędu |
| 11360 | 575 | */ |
| 576 | int gg_pubdir_watch_fd(struct gg_http *h) | |
| 577 | { | |
| 578 | struct gg_pubdir *p; | |
| 579 | char *tmp; | |
| 580 | ||
| 581 | if (!h) { | |
| 582 | errno = EFAULT; | |
| 583 | return -1; | |
| 584 | } | |
| 585 | ||
| 586 | if (h->state == GG_STATE_ERROR) { | |
| 587 | gg_debug(GG_DEBUG_MISC, "=> pubdir, watch_fd issued on failed session\n"); | |
| 588 | errno = EINVAL; | |
| 589 | return -1; | |
| 590 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
591 | |
| 11360 | 592 | if (h->state != GG_STATE_PARSING) { |
| 593 | if (gg_http_watch_fd(h) == -1) { | |
| 594 | gg_debug(GG_DEBUG_MISC, "=> pubdir, http failure\n"); | |
| 595 | errno = EINVAL; | |
| 596 | return -1; | |
| 597 | } | |
| 598 | } | |
| 599 | ||
| 600 | if (h->state != GG_STATE_PARSING) | |
| 601 | return 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
602 | |
| 11360 | 603 | h->state = GG_STATE_DONE; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
604 | |
| 11360 | 605 | if (!(h->data = p = malloc(sizeof(struct gg_pubdir)))) { |
| 606 | gg_debug(GG_DEBUG_MISC, "=> pubdir, not enough memory for results\n"); | |
| 607 | return -1; | |
| 608 | } | |
| 609 | ||
| 610 | p->success = 0; | |
| 611 | p->uin = 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
612 | |
| 11360 | 613 | gg_debug(GG_DEBUG_MISC, "=> pubdir, let's parse \"%s\"\n", h->body); |
| 614 | ||
|
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
|
615 | 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
|
616 | 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
|
617 | 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
|
618 | 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
|
619 | } else if ((tmp = strstr(h->body, "success")) || (tmp = strstr(h->body, "results"))) { |
| 11360 | 620 | p->success = 1; |
| 621 | if (tmp[7] == ':') | |
| 622 | p->uin = strtol(tmp + 8, NULL, 0); | |
| 623 | gg_debug(GG_DEBUG_MISC, "=> pubdir, success (uin=%d)\n", p->uin); | |
| 624 | } else | |
| 625 | gg_debug(GG_DEBUG_MISC, "=> pubdir, error.\n"); | |
| 626 | ||
| 627 | return 0; | |
| 628 | } | |
| 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 | /** |
|
438f88ecc11e
Update 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 | * Zwalnia zasoby po operacji na katalogu publicznym. |
| 11360 | 632 | * |
|
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
|
633 | * \param h Struktura połączenia |
| 11360 | 634 | */ |
| 635 | void gg_pubdir_free(struct gg_http *h) | |
| 636 | { | |
| 637 | if (!h) | |
| 638 | return; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
639 | |
| 11360 | 640 | free(h->data); |
| 641 | gg_http_free(h); | |
| 642 | } | |
| 643 | ||
|
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
|
644 | /** |
|
438f88ecc11e
Update 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 | * 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
|
646 | * |
|
438f88ecc11e
Update 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 | * 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
|
648 | * zmiany hasła itd. |
| 11360 | 649 | * |
|
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
|
650 | * \param async Flaga połączenia asynchronicznego |
| 11360 | 651 | * |
|
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
|
652 | * \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
|
653 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
654 | * \ingroup token |
| 11360 | 655 | */ |
| 656 | struct gg_http *gg_token(int async) | |
| 657 | { | |
| 658 | struct gg_http *h; | |
| 659 | const char *query; | |
| 660 | ||
| 661 | query = "Host: " GG_REGISTER_HOST "\r\n" | |
| 662 | "Content-Type: application/x-www-form-urlencoded\r\n" | |
| 663 | "User-Agent: " GG_HTTP_USERAGENT "\r\n" | |
| 664 | "Content-Length: 0\r\n" | |
| 665 | "Pragma: no-cache\r\n" | |
| 666 | "\r\n"; | |
| 667 | ||
| 668 | if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/regtoken.asp", query))) { | |
| 669 | gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n"); | |
| 670 | return NULL; | |
| 671 | } | |
| 672 | ||
| 673 | h->type = GG_SESSION_TOKEN; | |
| 674 | ||
| 675 | h->callback = gg_token_watch_fd; | |
| 676 | h->destroy = gg_token_free; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
677 | |
| 11360 | 678 | if (!async) |
| 679 | gg_token_watch_fd(h); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
680 | |
| 11360 | 681 | return h; |
| 682 | } | |
| 683 | ||
|
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
|
684 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
685 | * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia. |
| 11360 | 686 | * |
|
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
|
687 | * 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
|
688 | * 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
|
689 | * znajdzie się w polu \c error. |
| 11360 | 690 | * |
|
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
|
691 | * \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
|
692 | * |
|
438f88ecc11e
Update 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 | * \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
|
694 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
695 | * \ingroup token |
| 11360 | 696 | */ |
| 697 | int gg_token_watch_fd(struct gg_http *h) | |
| 698 | { | |
| 699 | if (!h) { | |
| 700 | errno = EFAULT; | |
| 701 | return -1; | |
| 702 | } | |
| 703 | ||
| 704 | if (h->state == GG_STATE_ERROR) { | |
| 705 | gg_debug(GG_DEBUG_MISC, "=> token, watch_fd issued on failed session\n"); | |
| 706 | errno = EINVAL; | |
| 707 | return -1; | |
| 708 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
709 | |
| 11360 | 710 | if (h->state != GG_STATE_PARSING) { |
| 711 | if (gg_http_watch_fd(h) == -1) { | |
| 712 | gg_debug(GG_DEBUG_MISC, "=> token, http failure\n"); | |
| 713 | errno = EINVAL; | |
| 714 | return -1; | |
| 715 | } | |
| 716 | } | |
| 717 | ||
| 718 | if (h->state != GG_STATE_PARSING) | |
| 719 | return 0; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
720 | |
|
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
|
721 | /* 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
|
722 | * ale jeśli coś tam jest, to znaczy, że mamy drugi etap polegający |
| 11360 | 723 | * na pobieraniu tokenu. */ |
| 724 | if (!h->data) { | |
| 725 | int width, height, length; | |
| 726 | char *url = NULL, *tokenid = NULL, *path, *headers; | |
| 727 | const char *host; | |
| 728 | struct gg_http *h2; | |
| 729 | struct gg_token *t; | |
| 730 | ||
| 731 | gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body); | |
| 732 | ||
| 733 | if (h->body && (!(url = malloc(strlen(h->body))) || !(tokenid = malloc(strlen(h->body))))) { | |
| 734 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n"); | |
| 735 | free(url); | |
| 736 | return -1; | |
| 737 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
738 | |
| 11360 | 739 | if (!h->body || sscanf(h->body, "%d %d %d\r\n%s\r\n%s", &width, &height, &length, tokenid, url) != 5) { |
| 740 | gg_debug(GG_DEBUG_MISC, "=> token, parsing failed\n"); | |
| 741 | free(url); | |
| 742 | free(tokenid); | |
| 743 | errno = EINVAL; | |
| 744 | return -1; | |
| 745 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
746 | |
|
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
|
747 | /* 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
|
748 | * więc pobierzmy obrazek z tokenem */ |
| 11360 | 749 | |
| 750 | if (strncmp(url, "http://", 7)) { | |
| 751 | path = gg_saprintf("%s?tokenid=%s", url, tokenid); | |
| 752 | host = GG_REGISTER_HOST; | |
| 753 | } else { | |
| 754 | char *slash = strchr(url + 7, '/'); | |
| 755 | ||
| 756 | if (slash) { | |
| 757 | path = gg_saprintf("%s?tokenid=%s", slash, tokenid); | |
| 758 | *slash = 0; | |
| 759 | host = url + 7; | |
| 760 | } else { | |
| 761 | gg_debug(GG_DEBUG_MISC, "=> token, url parsing failed\n"); | |
| 762 | free(url); | |
| 763 | free(tokenid); | |
| 764 | errno = EINVAL; | |
| 765 | return -1; | |
| 766 | } | |
| 767 | } | |
| 768 | ||
| 769 | if (!path) { | |
| 770 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n"); | |
| 771 | free(url); | |
| 772 | free(tokenid); | |
| 773 | return -1; | |
| 774 | } | |
| 775 | ||
| 776 | if (!(headers = gg_saprintf("Host: %s\r\nUser-Agent: " GG_HTTP_USERAGENT "\r\n\r\n", host))) { | |
| 777 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token url\n"); | |
| 778 | free(path); | |
| 779 | free(url); | |
| 780 | free(tokenid); | |
| 781 | return -1; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
782 | } |
| 11360 | 783 | |
| 784 | if (!(h2 = gg_http_connect(host, GG_REGISTER_PORT, h->async, "GET", path, headers))) { | |
| 785 | gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n"); | |
| 786 | free(headers); | |
| 787 | free(url); | |
| 788 | free(path); | |
| 789 | free(tokenid); | |
| 790 | return -1; | |
| 791 | } | |
| 792 | ||
| 793 | free(headers); | |
| 794 | free(path); | |
| 795 | free(url); | |
| 796 | ||
|
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
|
797 | 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
|
798 | |
| 11360 | 799 | memcpy(h, h2, sizeof(struct gg_http)); |
| 800 | free(h2); | |
| 801 | ||
| 802 | h->type = GG_SESSION_TOKEN; | |
| 803 | ||
| 804 | h->callback = gg_token_watch_fd; | |
| 805 | h->destroy = gg_token_free; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
806 | |
| 11360 | 807 | if (!h->async) |
| 808 | gg_token_watch_fd(h); | |
| 809 | ||
| 810 | if (!(h->data = t = malloc(sizeof(struct gg_token)))) { | |
| 811 | gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for token data\n"); | |
| 812 | free(tokenid); | |
| 813 | return -1; | |
| 814 | } | |
| 815 | ||
| 816 | t->width = width; | |
| 817 | t->height = height; | |
| 818 | t->length = length; | |
| 819 | t->tokenid = tokenid; | |
| 820 | } else { | |
| 821 | /* obrazek mamy w h->body */ | |
| 822 | h->state = GG_STATE_DONE; | |
| 823 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
824 | |
| 11360 | 825 | return 0; |
| 826 | } | |
| 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 | /** |
|
438f88ecc11e
Update 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 | * Zwalnia zasoby po operacji pobierania tokenu. |
| 11360 | 830 | * |
|
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
|
831 | * \param h Struktura połączenia |
| 11360 | 832 | * |
|
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
|
833 | * \ingroup token |
| 11360 | 834 | */ |
| 835 | void gg_token_free(struct gg_http *h) | |
| 836 | { | |
| 837 | struct gg_token *t; | |
| 838 | ||
| 839 | if (!h) | |
| 840 | return; | |
| 841 | ||
| 842 | if ((t = h->data)) | |
| 843 | free(t->tokenid); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29752
diff
changeset
|
844 | |
| 11360 | 845 | free(h->data); |
| 846 | gg_http_free(h); | |
| 847 | } | |
| 848 | ||
| 849 | /* | |
| 850 | * Local variables: | |
| 851 | * c-indentation-style: k&r | |
| 852 | * c-basic-offset: 8 | |
| 853 | * indent-tabs-mode: notnil | |
| 854 | * End: | |
| 855 | * | |
| 856 | * vim: shiftwidth=8: | |
| 857 | */ |