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