Mercurial > pidgin.yaz
annotate src/protocols/gg/gg.c @ 4349:0c68d402f59f
[gaim-migrate @ 4614]
XML Blist
Gaim stores all the buddy lists in one big happy file now. You can order
the buddies however you want, and they'll stay ordered that way.
We can also store some per-buddy information now, which will be cool.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 19 Jan 2003 22:16:52 +0000 |
parents | cc2f780c0505 |
children | dcc6c130c6d9 |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
4349 | 3 * $Id: gg.c 4614 2003-01-19 22:16:52Z faceprint $ |
2393 | 4 * |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
2393 | 6 * |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
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 General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2518
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
2393 | 24 #include <config.h> |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2518
diff
changeset
|
25 #endif |
2393 | 26 |
3630 | 27 #ifndef _WIN32 |
2393 | 28 #include <netdb.h> |
29 #include <unistd.h> | |
30 #include <netinet/in.h> | |
31 #include <arpa/inet.h> | |
3630 | 32 #include <sys/socket.h> |
33 #else | |
34 #include <winsock.h> | |
35 #endif | |
36 | |
37 #include <errno.h> | |
2393 | 38 #include <fcntl.h> |
39 #include <string.h> | |
40 #include <stdlib.h> | |
41 #include <stdio.h> | |
42 #include <time.h> | |
43 #include <sys/stat.h> | |
44 #include <ctype.h> | |
45 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ | |
46 #include "libgg.h" | |
47 #include "multi.h" | |
48 #include "prpl.h" | |
49 #include "gaim.h" | |
50 #include "proxy.h" | |
51 | |
3630 | 52 #ifdef _WIN32 |
53 #include "win32dep.h" | |
54 #endif | |
55 | |
3578 | 56 #include "pixmaps/protocols/gg/gg_suncloud.xpm" |
57 #include "pixmaps/protocols/gg/gg_sunred.xpm" | |
58 #include "pixmaps/protocols/gg/gg_sunwhitered.xpm" | |
59 #include "pixmaps/protocols/gg/gg_sunyellow.xpm" | |
2393 | 60 |
61 #define USEROPT_NICK 0 | |
62 | |
63 #define AGG_BUF_LEN 1024 | |
64 | |
65 #define AGG_GENDER_NONE -1 | |
66 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
67 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
68 #define AGG_PUBDIR_USERLIST_IMPORT_FORM "/appsvc/fmcontactsget.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
69 #define AGG_PUBDIR_SEARCH_FORM "/appsvc/fmpubquery2.asp" |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
70 #define AGG_REGISTER_DATA_FORM "/appsvc/fmregister.asp" |
2393 | 71 #define AGG_PUBDIR_MAX_ENTRIES 200 |
72 | |
73 #define AGG_STATUS_AVAIL _("Available") | |
74 #define AGG_STATUS_AVAIL_FRIENDS _("Available for friends only") | |
75 #define AGG_STATUS_BUSY _("Away") | |
76 #define AGG_STATUS_BUSY_FRIENDS _("Away for friends only") | |
77 #define AGG_STATUS_INVISIBLE _("Invisible") | |
78 #define AGG_STATUS_INVISIBLE_FRIENDS _("Invisible for friends only") | |
79 #define AGG_STATUS_NOT_AVAIL _("Unavailable") | |
80 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
81 #define AGG_HTTP_NONE 0 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
82 #define AGG_HTTP_SEARCH 1 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
83 #define AGG_HTTP_USERLIST_IMPORT 2 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
84 #define AGG_HTTP_USERLIST_EXPORT 3 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
85 #define AGG_HTTP_USERLIST_DELETE 4 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
86 #define AGG_HTTP_PASSWORD_CHANGE 5 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
87 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
88 #define UC_NORMAL 2 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
89 |
3630 | 90 /* for win32 compatability */ |
91 G_MODULE_IMPORT GSList *connections; | |
92 | |
93 | |
2393 | 94 struct agg_data { |
95 struct gg_session *sess; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
96 int own_status; |
2393 | 97 }; |
98 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
99 struct agg_http { |
2393 | 100 struct gaim_connection *gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
101 gchar *request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
102 gchar *form; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
103 gchar *host; |
2393 | 104 int inpa; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
105 int type; |
2393 | 106 }; |
107 | |
108 | |
3466 | 109 static gchar *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) |
2393 | 110 { |
4051 | 111 return (g_convert (locstr, strlen (locstr), encdst, encsrc, NULL, NULL, NULL)); |
2393 | 112 } |
113 | |
3466 | 114 static gboolean invalid_uin(const char *uin) |
2393 | 115 { |
116 unsigned long int res = strtol(uin, (char **)NULL, 10); | |
117 if (res == LONG_MIN || res == LONG_MAX || res == 0) | |
118 return TRUE; | |
119 return FALSE; | |
120 } | |
121 | |
122 static gint args_compare(gconstpointer a, gconstpointer b) | |
123 { | |
124 gchar *arg_a = (gchar *)a; | |
125 gchar *arg_b = (gchar *)b; | |
126 | |
127 return g_strcasecmp(arg_a, arg_b); | |
128 } | |
129 | |
130 static gboolean allowed_uin(struct gaim_connection *gc, char *uin) | |
131 { | |
4349 | 132 switch (gc->user->permdeny) { |
2393 | 133 case 1: |
134 /* permit all, deny none */ | |
135 return TRUE; | |
136 break; | |
137 case 2: | |
138 /* deny all, permit none. */ | |
139 return FALSE; | |
140 break; | |
141 case 3: | |
142 /* permit some. */ | |
4349 | 143 if (g_slist_find_custom(gc->user->permit, uin, args_compare)) |
2393 | 144 return TRUE; |
145 return FALSE; | |
146 break; | |
147 case 4: | |
148 /* deny some. */ | |
4349 | 149 if (g_slist_find_custom(gc->user->deny, uin, args_compare)) |
2393 | 150 return FALSE; |
151 return TRUE; | |
152 break; | |
153 default: | |
154 return TRUE; | |
155 break; | |
156 } | |
157 } | |
158 | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
159 static char *handle_errcode(struct gaim_connection *gc, int errcode) |
2393 | 160 { |
161 static char msg[AGG_BUF_LEN]; | |
162 | |
163 switch (errcode) { | |
164 case GG_FAILURE_RESOLVING: | |
165 g_snprintf(msg, sizeof(msg), _("Unable to resolve hostname.")); | |
166 break; | |
167 case GG_FAILURE_CONNECTING: | |
168 g_snprintf(msg, sizeof(msg), _("Unable to connect to server.")); | |
169 break; | |
170 case GG_FAILURE_INVALID: | |
171 g_snprintf(msg, sizeof(msg), _("Invalid response from server.")); | |
172 break; | |
173 case GG_FAILURE_READING: | |
174 g_snprintf(msg, sizeof(msg), _("Error while reading from socket.")); | |
175 break; | |
176 case GG_FAILURE_WRITING: | |
3100 | 177 g_snprintf(msg, sizeof(msg), _("Error while writing to socket.")); |
2393 | 178 break; |
179 case GG_FAILURE_PASSWORD: | |
3100 | 180 g_snprintf(msg, sizeof(msg), _("Authentication failed.")); |
2393 | 181 break; |
182 default: | |
183 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); | |
184 break; | |
185 } | |
186 | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
187 hide_login_progress(gc, msg); |
2393 | 188 |
189 return msg; | |
190 } | |
191 | |
192 static void agg_set_away(struct gaim_connection *gc, char *state, char *msg) | |
193 { | |
194 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
195 int status = gd->own_status; |
2393 | 196 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
197 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
198 g_free(gc->away); |
2393 | 199 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
200 } |
2393 | 201 |
202 if (!g_strcasecmp(state, AGG_STATUS_AVAIL)) | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
203 status = GG_STATUS_AVAIL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
204 else if (!g_strcasecmp(state, AGG_STATUS_AVAIL_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
205 status = GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
206 gc->away = g_strdup(""); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
207 } else if (!g_strcasecmp(state, AGG_STATUS_BUSY)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
208 status = GG_STATUS_BUSY; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
209 gc->away = g_strdup(""); |
2393 | 210 } else if (!g_strcasecmp(state, AGG_STATUS_BUSY_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
211 status = GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
212 gc->away = g_strdup(""); |
2393 | 213 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
214 status = GG_STATUS_INVISIBLE; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
215 gc->away = g_strdup(""); |
2393 | 216 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE_FRIENDS)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
217 status = GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
218 gc->away = g_strdup(""); |
2393 | 219 } else if (!g_strcasecmp(state, AGG_STATUS_NOT_AVAIL)) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
220 status = GG_STATUS_NOT_AVAIL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
221 gc->away = g_strdup(""); |
2393 | 222 } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) { |
223 if (msg) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
224 status = GG_STATUS_BUSY; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4059
diff
changeset
|
225 gc->away = g_strdup(""); |
2393 | 226 } else |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
227 status = GG_STATUS_AVAIL; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
228 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
229 if (gd->own_status & GG_STATUS_FRIENDS_MASK) |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
230 status |= GG_STATUS_FRIENDS_MASK; |
2393 | 231 } |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
232 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
233 gd->own_status = status; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
234 gg_change_status(gd->sess, status); |
2393 | 235 } |
236 | |
237 static gchar *get_away_text(int uc) | |
238 { | |
239 if (uc == UC_UNAVAILABLE) | |
240 return AGG_STATUS_NOT_AVAIL; | |
241 uc = uc >> 5; | |
242 switch (uc) { | |
243 case GG_STATUS_AVAIL: | |
244 default: | |
245 return AGG_STATUS_AVAIL; | |
246 case GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK: | |
247 return AGG_STATUS_AVAIL_FRIENDS; | |
248 case GG_STATUS_BUSY: | |
249 return AGG_STATUS_BUSY; | |
250 case GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK: | |
251 return AGG_STATUS_BUSY_FRIENDS; | |
252 case GG_STATUS_INVISIBLE: | |
253 return AGG_STATUS_INVISIBLE; | |
254 case GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK: | |
255 return AGG_STATUS_INVISIBLE_FRIENDS; | |
256 case GG_STATUS_NOT_AVAIL: | |
257 return AGG_STATUS_NOT_AVAIL; | |
258 } | |
259 } | |
260 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
261 static GList *agg_away_states(struct gaim_connection *gc) |
2393 | 262 { |
263 GList *m = NULL; | |
264 | |
265 m = g_list_append(m, AGG_STATUS_AVAIL); | |
266 m = g_list_append(m, AGG_STATUS_BUSY); | |
267 m = g_list_append(m, AGG_STATUS_INVISIBLE); | |
268 m = g_list_append(m, AGG_STATUS_AVAIL_FRIENDS); | |
269 m = g_list_append(m, AGG_STATUS_BUSY_FRIENDS); | |
270 m = g_list_append(m, AGG_STATUS_INVISIBLE_FRIENDS); | |
271 m = g_list_append(m, AGG_STATUS_NOT_AVAIL); | |
272 return m; | |
273 } | |
274 | |
275 /* Enhance these functions, more options and such stuff */ | |
276 static GList *agg_buddy_menu(struct gaim_connection *gc, char *who) | |
277 { | |
278 GList *m = NULL; | |
279 struct proto_buddy_menu *pbm; | |
4349 | 280 struct buddy *b = find_buddy(gc->user, who); |
2393 | 281 static char buf[AGG_BUF_LEN]; |
282 | |
283 if (!b) { | |
284 return m; | |
285 } | |
286 | |
287 pbm = g_new0(struct proto_buddy_menu, 1); | |
288 g_snprintf(buf, sizeof(buf), _("Status: %s"), get_away_text(b->uc)); | |
289 pbm->label = buf; | |
290 pbm->callback = NULL; | |
291 pbm->gc = gc; | |
292 m = g_list_append(m, pbm); | |
293 | |
294 return m; | |
295 } | |
296 | |
297 static void main_callback(gpointer data, gint source, GaimInputCondition cond) | |
298 { | |
299 struct gaim_connection *gc = data; | |
300 struct agg_data *gd = gc->proto_data; | |
301 struct gg_event *e; | |
302 | |
303 debug_printf("main_callback enter: begin\n"); | |
304 | |
305 if (gd->sess->fd != source) | |
306 gd->sess->fd = source; | |
307 | |
308 if (source == -1) { | |
2915
7a158753b8d6
[gaim-migrate @ 2928]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
309 hide_login_progress(gc, _("Could not connect")); |
2393 | 310 signoff(gc); |
311 return; | |
312 } | |
313 | |
314 if (!(e = gg_watch_fd(gd->sess))) { | |
315 debug_printf("main_callback: gg_watch_fd failed - CRITICAL!\n"); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
316 hide_login_progress(gc, _("Unable to read socket")); |
2393 | 317 signoff(gc); |
318 return; | |
319 } | |
320 | |
321 switch (e->type) { | |
322 case GG_EVENT_NONE: | |
323 /* do nothing */ | |
324 break; | |
325 case GG_EVENT_CONN_SUCCESS: | |
326 debug_printf("main_callback: CONNECTED AGAIN!?\n"); | |
327 break; | |
328 case GG_EVENT_CONN_FAILED: | |
329 if (gc->inpa) | |
330 gaim_input_remove(gc->inpa); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
331 handle_errcode(gc, e->event.failure); |
2393 | 332 signoff(gc); |
333 break; | |
334 case GG_EVENT_MSG: | |
335 { | |
336 gchar *imsg; | |
337 gchar user[20]; | |
338 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
339 g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender); |
2393 | 340 if (!allowed_uin(gc, user)) |
341 break; | |
4051 | 342 imsg = charset_convert(e->event.msg.message, "CP1250", "UTF-8"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
343 strip_linefeed(imsg); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
344 /* e->event.msg.time - we don't know what this time is for */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2846
diff
changeset
|
345 serv_got_im(gc, user, imsg, 0, time(NULL), -1); |
2393 | 346 g_free(imsg); |
347 } | |
348 break; | |
349 case GG_EVENT_NOTIFY: | |
350 { | |
351 gchar user[20]; | |
352 struct gg_notify_reply *n = e->event.notify; | |
353 guint status; | |
354 | |
355 while (n->uin) { | |
356 switch (n->status) { | |
357 case GG_STATUS_NOT_AVAIL: | |
358 status = UC_UNAVAILABLE; | |
359 break; | |
360 case GG_STATUS_AVAIL: | |
361 case GG_STATUS_BUSY: | |
362 case GG_STATUS_INVISIBLE: | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
363 status = UC_NORMAL | (n->status << 5); |
2393 | 364 break; |
365 default: | |
366 status = UC_NORMAL; | |
367 break; | |
368 } | |
369 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
370 g_snprintf(user, sizeof(user), "%lu", n->uin); |
2393 | 371 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
372 status, 0); | |
373 n++; | |
374 } | |
375 } | |
376 break; | |
377 case GG_EVENT_STATUS: | |
378 { | |
379 gchar user[20]; | |
380 guint status; | |
381 | |
382 switch (e->event.status.status) { | |
383 case GG_STATUS_NOT_AVAIL: | |
384 status = UC_UNAVAILABLE; | |
385 break; | |
386 case GG_STATUS_AVAIL: | |
387 case GG_STATUS_BUSY: | |
388 case GG_STATUS_INVISIBLE: | |
389 status = UC_NORMAL | (e->event.status.status << 5); | |
390 break; | |
391 default: | |
392 status = UC_NORMAL; | |
393 break; | |
394 } | |
395 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
396 g_snprintf(user, sizeof(user), "%lu", e->event.status.uin); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
397 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
398 status, 0); |
2393 | 399 } |
400 break; | |
401 case GG_EVENT_ACK: | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
402 debug_printf("main_callback: message %d to %lu sent with status %d\n", |
2393 | 403 e->event.ack.seq, e->event.ack.recipient, e->event.ack.status); |
404 break; | |
405 default: | |
406 debug_printf("main_callback: unsupported event %d\n", e->type); | |
407 break; | |
408 } | |
409 gg_free_event(e); | |
410 } | |
411 | |
3630 | 412 void login_callback(gpointer data, gint source, GaimInputCondition cond) |
2393 | 413 { |
414 struct gaim_connection *gc = data; | |
415 struct agg_data *gd = gc->proto_data; | |
416 struct gg_event *e; | |
417 | |
3630 | 418 debug_printf("GG login_callback...\n"); |
419 if (!g_slist_find(connections, gc)) { | |
2393 | 420 close(source); |
421 return; | |
422 } | |
3630 | 423 debug_printf("Found GG connection\n"); |
424 if (gd->sess->fd != source) { | |
2393 | 425 gd->sess->fd = source; |
3630 | 426 debug_printf("Setting sess->fd to source\n"); |
427 } | |
2393 | 428 if (source == -1) { |
429 hide_login_progress(gc, _("Unable to connect.")); | |
430 signoff(gc); | |
431 return; | |
432 } | |
3630 | 433 debug_printf("Source is valid.\n"); |
434 if (gc->inpa == 0) { | |
435 debug_printf("login_callback.. checking gc->inpa .. is 0.. setting fd watch\n"); | |
2393 | 436 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); |
3630 | 437 debug_printf("Adding watch on fd\n"); |
438 } | |
439 debug_printf("Checking State.\n"); | |
2393 | 440 switch (gd->sess->state) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
441 case GG_STATE_READING_DATA: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
442 set_login_progress(gc, 2, _("Reading data")); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
443 break; |
2393 | 444 case GG_STATE_CONNECTING_GG: |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
445 set_login_progress(gc, 3, _("Balancer handshake")); |
2393 | 446 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
447 case GG_STATE_READING_KEY: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
448 set_login_progress(gc, 4, _("Reading server key")); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
449 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
450 case GG_STATE_READING_REPLY: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
451 set_login_progress(gc, 5, _("Exchanging key hash")); |
2393 | 452 break; |
453 default: | |
3630 | 454 debug_printf("No State found\n"); |
2393 | 455 break; |
456 } | |
3630 | 457 debug_printf("gg_watch_fd\n"); |
2393 | 458 if (!(e = gg_watch_fd(gd->sess))) { |
459 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n"); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
460 hide_login_progress(gc, _("Critical error in GG library\n")); |
2393 | 461 signoff(gc); |
462 return; | |
463 } | |
464 | |
3630 | 465 /* If we are GG_STATE_CONNECTING_GG then we still need to connect, as |
466 we could not use proxy_connect in libgg.c */ | |
467 switch( gd->sess->state ) { | |
468 case GG_STATE_CONNECTING_GG: | |
469 { | |
470 struct in_addr ip; | |
471 char buf[256]; | |
472 | |
473 /* Remove watch on initial socket - now that we have ip and port of login server */ | |
474 gaim_input_remove(gc->inpa); | |
475 | |
476 ip.s_addr = gd->sess->server_ip; | |
477 gd->sess->fd = proxy_connect(inet_ntoa(ip), gd->sess->port, login_callback, gc); | |
478 | |
479 if (gd->sess->fd < 0) { | |
480 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); | |
481 hide_login_progress(gc, buf); | |
482 signoff(gc); | |
483 return; | |
484 } | |
485 break; | |
486 } | |
487 case GG_STATE_READING_KEY: | |
488 /* Set new watch on login server ip */ | |
489 if(gc->inpa) | |
490 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); | |
491 debug_printf("Setting watch on connection with login server.\n"); | |
492 break; | |
493 }/* end switch() */ | |
494 | |
495 debug_printf("checking gg_event\n"); | |
2393 | 496 switch (e->type) { |
497 case GG_EVENT_NONE: | |
498 /* nothing */ | |
499 break; | |
500 case GG_EVENT_CONN_SUCCESS: | |
501 /* Setup new input handler */ | |
502 if (gc->inpa) | |
503 gaim_input_remove(gc->inpa); | |
504 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc); | |
505 | |
506 /* Our signon is complete */ | |
507 account_online(gc); | |
508 serv_finish_login(gc); | |
509 | |
510 break; | |
511 case GG_EVENT_CONN_FAILED: | |
512 gaim_input_remove(gc->inpa); | |
513 gc->inpa = 0; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
514 handle_errcode(gc, e->event.failure); |
2393 | 515 signoff(gc); |
516 break; | |
517 default: | |
3630 | 518 debug_printf("no gg_event\n"); |
2393 | 519 break; |
520 } | |
3630 | 521 debug_printf("Returning from login_callback\n"); |
2393 | 522 gg_free_event(e); |
523 } | |
524 | |
525 static void agg_keepalive(struct gaim_connection *gc) | |
526 { | |
527 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
528 if (gg_ping(gd->sess) < 0) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
529 hide_login_progress(gc, _("Unable to ping server")); |
2393 | 530 signoff(gc); |
531 return; | |
532 } | |
533 } | |
534 | |
535 static void agg_login(struct aim_user *user) | |
536 { | |
537 struct gaim_connection *gc = new_gaim_conn(user); | |
538 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1); | |
539 char buf[80]; | |
540 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
541 gc->checkbox = _("Send as message"); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
542 |
2393 | 543 gd->sess = g_new0(struct gg_session, 1); |
544 | |
545 if (user->proto_opt[USEROPT_NICK][0]) | |
546 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", | |
547 user->proto_opt[USEROPT_NICK]); | |
548 | |
549 set_login_progress(gc, 1, _("Looking up GG server")); | |
550 | |
551 if (invalid_uin(user->username)) { | |
552 hide_login_progress(gc, _("Invalid Gadu-Gadu UIN specified")); | |
553 signoff(gc); | |
554 return; | |
555 } | |
556 | |
557 gc->inpa = 0; | |
558 | |
559 /* | |
560 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) { | |
561 debug_printf("uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); | |
562 hide_login_progress(gc, "Unable to connect."); | |
563 signoff(gc); | |
564 return; | |
565 } | |
566 | |
567 gg_login() sucks for me, so I'm using proxy_connect() | |
568 */ | |
569 | |
570 gd->sess->uin = (uin_t) strtol(user->username, (char **)NULL, 10); | |
571 gd->sess->password = g_strdup(user->password); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
572 gd->sess->state = GG_STATE_CONNECTING; |
2393 | 573 gd->sess->check = GG_CHECK_WRITE; |
574 gd->sess->async = 1; | |
575 gd->sess->fd = proxy_connect(GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc); | |
576 | |
577 if (gd->sess->fd < 0) { | |
578 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); | |
579 hide_login_progress(gc, buf); | |
580 signoff(gc); | |
581 return; | |
582 } | |
583 } | |
584 | |
585 static void agg_close(struct gaim_connection *gc) | |
586 { | |
587 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
588 if (gc->inpa) | |
589 gaim_input_remove(gc->inpa); | |
590 gg_logoff(gd->sess); | |
3339 | 591 gd->own_status = GG_STATUS_NOT_AVAIL; |
2393 | 592 gg_free_session(gd->sess); |
593 g_free(gc->proto_data); | |
594 } | |
595 | |
3033 | 596 static int agg_send_im(struct gaim_connection *gc, char *who, char *msg, int len, int flags) |
2393 | 597 { |
598 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
599 gchar *imsg; | |
600 | |
601 if (invalid_uin(who)) { | |
3427 | 602 do_error_dialog(_("You are trying to send a message to an invalid Gadu-Gadu UIN."), NULL, |
603 GAIM_ERROR); | |
2393 | 604 return -1; |
605 } | |
606 | |
607 if (strlen(msg) > 0) { | |
4051 | 608 imsg = charset_convert(msg, "UTF-8", "CP1250"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
609 if (gg_send_message(gd->sess, (flags & IM_FLAG_CHECKBOX) |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
610 ? GG_CLASS_MSG : GG_CLASS_CHAT, |
2393 | 611 strtol(who, (char **)NULL, 10), imsg) < 0) |
612 return -1; | |
613 g_free(imsg); | |
614 } | |
615 return 1; | |
616 } | |
617 | |
3466 | 618 static void agg_add_buddy(struct gaim_connection *gc, const char *who) |
2393 | 619 { |
620 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
621 if (invalid_uin(who)) | |
622 return; | |
623 gg_add_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
624 } | |
625 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2563
diff
changeset
|
626 static void agg_rem_buddy(struct gaim_connection *gc, char *who, char *group) |
2393 | 627 { |
628 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
629 if (invalid_uin(who)) | |
630 return; | |
631 gg_remove_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
632 } | |
633 | |
634 static void agg_add_buddies(struct gaim_connection *gc, GList *whos) | |
635 { | |
636 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
637 uin_t *userlist = NULL; | |
638 int userlist_size = 0; | |
639 | |
640 while (whos) { | |
641 if (!invalid_uin(whos->data)) { | |
642 userlist_size++; | |
643 userlist = g_renew(uin_t, userlist, userlist_size); | |
644 userlist[userlist_size - 1] = | |
645 (uin_t) strtol((char *)whos->data, (char **)NULL, 10); | |
646 } | |
647 whos = g_list_next(whos); | |
648 } | |
649 | |
650 if (userlist) { | |
651 gg_notify(gd->sess, userlist, userlist_size); | |
652 g_free(userlist); | |
653 } | |
654 } | |
655 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
656 static void search_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 657 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
658 gchar **webdata_tbl; |
2393 | 659 gchar *buf; |
660 char *ptr; | |
661 int i, j; | |
662 | |
663 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { | |
664 debug_printf("search_callback: pubdir result [%s]\n", webdata); | |
3427 | 665 do_error_dialog(_("Couldn't get search results"), NULL, GAIM_ERROR); |
2393 | 666 return; |
667 } | |
668 ptr++; | |
669 | |
670 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); | |
671 | |
672 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | |
673 | |
674 j = 0; | |
675 | |
676 /* Parse array */ | |
677 for (i = 0; webdata_tbl[i] != NULL; i++) { | |
678 gchar *p, *oldibuf; | |
679 static gchar *ibuf; | |
680 | |
681 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | |
682 | |
683 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */ | |
684 if (i % 8 == 0) | |
685 j = 0; | |
686 | |
4051 | 687 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", "UTF-8"); |
2393 | 688 |
689 oldibuf = ibuf; | |
690 | |
691 switch (j) { | |
692 case 0: | |
693 ibuf = g_strconcat("---------------------------------<BR>\n", NULL); | |
694 oldibuf = ibuf; | |
695 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ", | |
696 (atoi(p) == 2) ? _("yes") : _("no"), "<BR>\n", NULL); | |
697 g_free(oldibuf); | |
698 break; | |
699 case 1: | |
700 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL); | |
701 g_free(oldibuf); | |
702 break; | |
703 case 2: | |
704 ibuf = g_strconcat(oldibuf, "<B>", _("First name"), ":</B> ", p, "<BR>\n", NULL); | |
705 g_free(oldibuf); | |
706 break; | |
707 case 3: | |
708 ibuf = | |
709 g_strconcat(oldibuf, "<B>", _("Second Name"), ":</B> ", p, "<BR>\n", NULL); | |
710 g_free(oldibuf); | |
711 break; | |
712 case 4: | |
713 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL); | |
714 g_free(oldibuf); | |
715 break; | |
716 case 5: | |
717 /* Hack, invalid_uin does what we really want here but may change in future */ | |
718 if (invalid_uin(p)) | |
719 ibuf = | |
720 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> <BR>\n", NULL); | |
721 else | |
722 ibuf = | |
723 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> ", p, "<BR>\n", | |
724 NULL); | |
725 g_free(oldibuf); | |
726 break; | |
727 case 6: | |
728 if (atoi(p) == GG_GENDER_FEMALE) | |
729 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL); | |
730 else if (atoi(p) == GG_GENDER_MALE) | |
731 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL); | |
732 else | |
733 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL); | |
734 g_free(oldibuf); | |
735 break; | |
736 case 7: | |
737 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL); | |
738 g_free(oldibuf); | |
739 | |
740 /* We have all lines, so add them to buffer */ | |
741 { | |
742 gchar *oldbuf = buf; | |
743 buf = g_strconcat(oldbuf, ibuf, NULL); | |
744 g_free(oldbuf); | |
745 } | |
746 | |
747 g_free(ibuf); | |
748 break; | |
749 } | |
750 | |
751 g_free(p); | |
752 | |
753 j++; | |
754 } | |
755 | |
756 g_strfreev(webdata_tbl); | |
757 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
758 g_show_info_text(gc, NULL, 2, buf, NULL); |
2393 | 759 |
760 g_free(buf); | |
761 } | |
762 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
763 static void import_buddies_server_results(struct gaim_connection *gc, gchar *webdata) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
764 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
765 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
766 gchar **users_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
767 int i; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
768 if (strstr(webdata, "no_data:")) { |
3427 | 769 do_error_dialog(_("There is no Buddy List stored on the Gadu-Gadu server."), NULL, GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
770 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
771 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
772 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
773 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) { |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
774 debug_printf("import_buddies_server_results: import buddies result [%s]\n", webdata); |
4059 | 775 do_error_dialog(_("Couldn't Import Buddy List from Server"), NULL, GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
776 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
777 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
778 ptr++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
779 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
780 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
781 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
782 /* Parse array of Buddies List */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
783 for (i = 0; users_tbl[i] != NULL; i++) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
784 gchar **data_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
785 gchar *name, *show; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
786 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
787 g_strdelimit(users_tbl[i], "\r\t\n\015", ' '); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
788 data_tbl = g_strsplit(users_tbl[i], ";", 8); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
789 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
790 show = data_tbl[3]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
791 name = data_tbl[6]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
792 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
793 if (invalid_uin(name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
794 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
795 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
796 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
797 debug_printf("import_buddies_server_results: uin: %s\n", name); |
4349 | 798 if (!find_buddy(gc->user, name)) { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
799 /* Default group if none specified on server */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
800 gchar *group = g_strdup("Gadu-Gadu"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
801 if (strlen(data_tbl[5])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
802 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
803 if (strlen(group_tbl[0])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
804 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
805 group = g_strdup(group_tbl[0]); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
806 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
807 g_strfreev(group_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
808 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
809 /* Add Buddy to our userlist */ |
4349 | 810 add_buddy(gc->user, group, name, strlen(show) ? show : name); |
811 gaim_blist_save(); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
812 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
813 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
814 g_strfreev(data_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
815 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
816 g_strfreev(users_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
817 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
818 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
819 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 820 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
821 if (strstr(webdata, "put_success:")) { |
3427 | 822 do_error_dialog(_("Buddy List successfully transferred to Gadu-Gadu server"), NULL, GAIM_INFO); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
823 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
824 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
825 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
826 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata); |
3427 | 827 do_error_dialog(_("Couldn't transfer Buddy List to Gadu-Gadu server"), NULL, GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
828 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
829 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
830 static void delete_buddies_server_results(struct gaim_connection *gc, gchar *webdata) |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
831 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
832 if (strstr(webdata, "put_success:")) { |
4059 | 833 do_error_dialog(_("Buddy List successfully deleted from Gadu-Gadu server"), NULL, GAIM_INFO); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
834 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
835 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
836 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
837 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); |
3427 | 838 do_error_dialog(_("Couldn't delete Buddy List from Gadu-Gadu server"), NULL, GAIM_ERROR); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
839 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
840 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
841 static void password_change_server_results(struct gaim_connection *gc, gchar *webdata) |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
842 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
843 if (strstr(webdata, "reg_success:")) { |
3427 | 844 do_error_dialog(_("Password changed successfully"), NULL, GAIM_INFO); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
845 return; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
846 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
847 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
848 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); |
3427 | 849 do_error_dialog(_("Password couldn't be changed"), NULL, GAIM_ERROR); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
850 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
851 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
852 static void http_results(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
853 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
854 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
855 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
856 char *webdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
857 int len; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
858 char read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
859 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
860 debug_printf("http_results: begin\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
861 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
862 if (!g_slist_find(connections, gc)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
863 debug_printf("search_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
864 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
865 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
866 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
867 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
868 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
869 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
870 webdata = NULL; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
871 len = 0; |
3717
988485669631
[gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
872 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
873 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
874 if (errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
875 errno = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
876 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
877 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
878 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
879 if (!read_data) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
880 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
881 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
882 len++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
883 webdata = g_realloc(webdata, len); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
884 webdata[len - 1] = read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
885 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
886 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
887 webdata = g_realloc(webdata, len + 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
888 webdata[len] = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
889 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
890 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
891 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
892 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
893 debug_printf("http_results: type %d, webdata [%s]\n", hdata->type, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
894 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
895 switch (hdata->type) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
896 case AGG_HTTP_SEARCH: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
897 search_results(gc, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
898 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
899 case AGG_HTTP_USERLIST_IMPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
900 import_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
901 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
902 case AGG_HTTP_USERLIST_EXPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
903 export_buddies_server_results(gc, webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
904 break; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
905 case AGG_HTTP_USERLIST_DELETE: |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
906 delete_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
907 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
908 case AGG_HTTP_PASSWORD_CHANGE: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
909 password_change_server_results(gc, webdata); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
910 break; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
911 case AGG_HTTP_NONE: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
912 default: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
913 debug_printf("http_results: unsupported type %d\n", hdata->type); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
914 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
915 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
916 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
917 g_free(webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
918 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
919 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
920 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
921 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
922 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
923 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
924 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
925 gchar *request = hdata->request; |
2393 | 926 gchar *buf; |
927 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
928 debug_printf("http_req_callback: begin\n"); |
2393 | 929 |
930 if (!g_slist_find(connections, gc)) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
931 debug_printf("http_req_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
932 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
933 g_free(hdata); |
2393 | 934 close(source); |
935 return; | |
936 } | |
937 | |
938 if (source == -1) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
939 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
940 g_free(hdata); |
2393 | 941 return; |
942 } | |
943 | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
944 debug_printf("http_req_callback: http request [%s]\n", request); |
2393 | 945 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
946 buf = g_strdup_printf("POST %s HTTP/1.0\r\n" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
947 "Host: %s\r\n" |
2393 | 948 "Content-Type: application/x-www-form-urlencoded\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
949 "User-Agent: " GG_HTTP_USERAGENT "\r\n" |
2393 | 950 "Content-Length: %d\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
951 "Pragma: no-cache\r\n" "\r\n" "%s\r\n", |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
952 hdata->form, hdata->host, strlen(request), request); |
2393 | 953 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
954 g_free(request); |
2393 | 955 |
956 if (write(source, buf, strlen(buf)) < strlen(buf)) { | |
957 g_free(buf); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
958 g_free(hdata); |
2393 | 959 close(source); |
3427 | 960 do_error_dialog(_("Error communicating with Gadu-Gadu server"), |
961 _("Gaim was unable to complete your request due to a problem " | |
4059 | 962 "communicating with the Gadu-Gadu HTTP server. Please try again " |
3427 | 963 "later."), GAIM_ERROR); |
2393 | 964 return; |
965 } | |
966 | |
967 g_free(buf); | |
968 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
969 hdata->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_results, hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
970 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
971 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
972 static void import_buddies_server(struct gaim_connection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
973 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
974 struct agg_http *hi = g_new0(struct agg_http, 1); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
975 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
976 gchar *p = gg_urlencode(gc->password); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
977 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
978 hi->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
979 hi->type = AGG_HTTP_USERLIST_IMPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
980 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
981 hi->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
982 hi->request = g_strdup_printf("FmNum=%s&Pass=%s", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
983 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
984 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
985 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
986 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
987 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { |
3427 | 988 do_error_dialog(_("Unable to import Gadu-Gadu buddy list"), |
989 _("Gaim was unable to connect to the Gadu-Gadu buddy list " | |
990 "server. Please try again later."), GAIM_ERROR); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
991 g_free(hi->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
992 g_free(hi); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
993 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
994 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
995 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
996 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
997 static void export_buddies_server(struct gaim_connection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
998 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
999 struct agg_http *he = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1000 gchar *ptr; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1001 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1002 gchar *p = gg_urlencode(gc->password); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1003 |
4349 | 1004 GSList *gr = groups; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1005 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1006 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1007 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1008 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1009 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1010 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Contacts=", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1011 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1012 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1013 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1014 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1015 while (gr) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1016 struct group *g = gr->data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1017 GSList *m = g->members; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1018 while (m) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1019 struct buddy *b = m->data; |
4349 | 1020 |
1021 if(b->user->gc == gc) { | |
1022 gchar *newdata; | |
1023 /* GG Number */ | |
1024 gchar *name = gg_urlencode(b->name); | |
1025 /* GG Pseudo */ | |
1026 gchar *show = gg_urlencode(b->alias[0] ? b->alias : b->name); | |
1027 /* Group Name */ | |
1028 gchar *gname = gg_urlencode(g->name); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1029 |
4349 | 1030 ptr = he->request; |
1031 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s\r\n", | |
1032 show, show, show, show, "", gname, name); | |
1033 he->request = g_strconcat(ptr, newdata, NULL); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1034 |
4349 | 1035 g_free(newdata); |
1036 g_free(ptr); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1037 |
4349 | 1038 g_free(gname); |
1039 g_free(show); | |
1040 g_free(name); | |
1041 } | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1042 m = g_slist_next(m); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1043 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1044 gr = g_slist_next(gr); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1045 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1046 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1047 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
3427 | 1048 do_error_dialog(_("Couldn't export buddy list"), |
1049 _("Gaim was unable to connect to the buddy list server. " | |
1050 "Please try again later."), GAIM_ERROR); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1051 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1052 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1053 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1054 } |
2393 | 1055 } |
1056 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1057 static void delete_buddies_server(struct gaim_connection *gc) |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1058 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1059 struct agg_http *he = g_new0(struct agg_http, 1); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1060 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1061 gchar *p = gg_urlencode(gc->password); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1062 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1063 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1064 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1065 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1066 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1067 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1068 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1069 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
3427 | 1070 do_error_dialog(_("Unable to delete Gadu-Gadu buddy list"), |
1071 _("Gaim was unable to connect to the buddy list server. " | |
1072 "Please try again later."), GAIM_ERROR); | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1073 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1074 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1075 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1076 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1077 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1078 |
3466 | 1079 static void agg_dir_search(struct gaim_connection *gc, const char *first, const char *middle, |
1080 const char *last, const char *maiden, const char *city, const char *state, | |
1081 const char *country, const char *email) | |
2393 | 1082 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1083 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1084 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1085 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1086 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1087 srch->host = GG_PUBDIR_HOST; |
2393 | 1088 |
1089 if (email && strlen(email)) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1090 gchar *eemail = gg_urlencode(email); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1091 srch->request = g_strdup_printf("Mode=1&Email=%s", eemail); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1092 g_free(eemail); |
2393 | 1093 } else { |
4051 | 1094 gchar *new_first = charset_convert(first, "UTF-8", "CP1250"); |
1095 gchar *new_last = charset_convert(last, "UTF-8", "CP1250"); | |
1096 gchar *new_city = charset_convert(city, "UTF-8", "CP1250"); | |
2393 | 1097 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1098 gchar *enew_first = gg_urlencode(new_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1099 gchar *enew_last = gg_urlencode(new_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1100 gchar *enew_city = gg_urlencode(new_city); |
2393 | 1101 |
1102 g_free(new_first); | |
1103 g_free(new_last); | |
1104 g_free(new_city); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1105 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1106 /* For active only add &ActiveOnly= */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1107 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d" |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1108 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1109 enew_first, enew_last, AGG_GENDER_NONE, |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1110 "", enew_city, 0, 0); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1111 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1112 g_free(enew_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1113 g_free(enew_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1114 g_free(enew_city); |
2393 | 1115 } |
1116 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1117 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
3427 | 1118 do_error_dialog(_("Unable to access directory"), |
1119 _("Gaim was unable to search the Directory because it " | |
4059 | 1120 "was unable to connect to the directory server. Please try " |
3427 | 1121 "again later."), GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1122 g_free(srch->request); |
2393 | 1123 g_free(srch); |
1124 return; | |
1125 } | |
1126 } | |
1127 | |
3466 | 1128 static void agg_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1129 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1130 struct agg_http *hpass = g_new0(struct agg_http, 1); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1131 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1132 gchar *p = gg_urlencode(gc->password); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1133 gchar *enew = gg_urlencode(new); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1134 gchar *eold = gg_urlencode(old); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1135 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1136 hpass->gc = gc; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1137 hpass->type = AGG_HTTP_PASSWORD_CHANGE; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1138 hpass->form = AGG_REGISTER_DATA_FORM; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1139 hpass->host = GG_REGISTER_HOST; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1140 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1141 /* We are using old password as place for email - it's ugly */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1142 hpass->request = g_strdup_printf("fmnumber=%s&fmpwd=%s&pwd=%s&email=%s&code=%u", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1143 u, p, enew, eold, gg_http_hash(old, new)); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1144 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1145 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1146 g_free(p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1147 g_free(enew); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1148 g_free(eold); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1149 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1150 if (proxy_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { |
3427 | 1151 do_error_dialog(_("Unable to change Gadu-Gadu password"), |
1152 _("Gaim was unable to change your password due to an error connecting " | |
1153 "to the Gadu-Gadu server. Please try again later."), GAIM_ERROR); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1154 g_free(hpass->request); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1155 g_free(hpass); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1156 return; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1157 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1158 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1159 |
4333 | 1160 static GList *agg_actions(struct gaim_connection *gc) |
2393 | 1161 { |
1162 GList *m = NULL; | |
4333 | 1163 struct proto_actions_menu *pam; |
2393 | 1164 |
4333 | 1165 pam = g_new0(struct proto_actions_menu, 1); |
1166 pam->label = _("Directory Search"); | |
1167 pam->callback = show_find_info; | |
1168 pam->gc = gc; | |
1169 m = g_list_append(m, pam); | |
1170 | |
1171 m = g_list_append(m, NULL); | |
1172 | |
1173 pam = g_new0(struct proto_actions_menu, 1); | |
1174 pam->label = _("Change Password"); | |
1175 pam->callback = show_change_passwd; | |
1176 pam->gc = gc; | |
1177 m = g_list_append(m, pam); | |
1178 | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1179 m = g_list_append(m, NULL); |
4333 | 1180 |
1181 pam = g_new0(struct proto_actions_menu, 1); | |
1182 pam->label = _("Import Buddy List from Server"); | |
1183 pam->callback = import_buddies_server; | |
1184 pam->gc = gc; | |
1185 m = g_list_append(m, pam); | |
1186 | |
1187 pam = g_new0(struct proto_actions_menu, 1); | |
1188 pam->label = _("Export Buddy List to Server"); | |
1189 pam->callback = export_buddies_server; | |
1190 pam->gc = gc; | |
1191 m = g_list_append(m, pam); | |
1192 | |
1193 pam = g_new0(struct proto_actions_menu, 1); | |
1194 pam->label = _("Delete Buddy List from Server"); | |
1195 pam->callback = delete_buddies_server; | |
1196 pam->gc = gc; | |
1197 m = g_list_append(m, pam); | |
2393 | 1198 |
1199 return m; | |
1200 } | |
1201 | |
1202 static void agg_get_info(struct gaim_connection *gc, char *who) | |
1203 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1204 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1205 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1206 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1207 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1208 srch->host = GG_PUBDIR_HOST; |
2393 | 1209 |
1210 /* If it's invalid uin then maybe it's nickname? */ | |
1211 if (invalid_uin(who)) { | |
4051 | 1212 gchar *new_who = charset_convert(who, "UTF-8", "CP1250"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1213 gchar *enew_who = gg_urlencode(new_who); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1214 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1215 g_free(new_who); |
2393 | 1216 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1217 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1218 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1219 "", "", AGG_GENDER_NONE, enew_who, "", 0, 0); |
2393 | 1220 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1221 g_free(enew_who); |
2393 | 1222 } else |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1223 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1224 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1225 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
3427 | 1226 do_error_dialog(_("Unable to access user profile."), |
4059 | 1227 _("Gaim was unable to access this user's profile due to an error " |
3427 | 1228 "connecting to the directory server. Please try again later."), GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1229 g_free(srch->request); |
2393 | 1230 g_free(srch); |
1231 return; | |
1232 } | |
1233 } | |
1234 | |
1235 static char **agg_list_icon(int uc) | |
1236 { | |
1237 guint status; | |
1238 if (uc == UC_UNAVAILABLE) | |
1239 return (char **)gg_sunred_xpm; | |
1240 status = uc >> 5; | |
1241 /* Drop all masks */ | |
1242 status &= ~(GG_STATUS_FRIENDS_MASK); | |
1243 if (status == GG_STATUS_AVAIL) | |
1244 return (char **)gg_sunyellow_xpm; | |
1245 if (status == GG_STATUS_BUSY) | |
1246 return (char **)gg_suncloud_xpm; | |
1247 if (status == GG_STATUS_INVISIBLE) | |
1248 return (char **)gg_sunwhitered_xpm; | |
1249 return (char **)gg_sunyellow_xpm; | |
1250 } | |
1251 | |
1252 static void agg_set_permit_deny_dummy(struct gaim_connection *gc) | |
1253 { | |
1254 /* It's implemented on client side because GG server doesn't support this */ | |
1255 } | |
1256 | |
4349 | 1257 static void agg_permit_deny_dummy(struct gaim_connection *gc, const char *who) |
2393 | 1258 { |
1259 /* It's implemented on client side because GG server doesn't support this */ | |
1260 } | |
1261 | |
1262 static struct prpl *my_protocol = NULL; | |
1263 | |
3630 | 1264 G_MODULE_EXPORT void gg_init(struct prpl *ret) |
2393 | 1265 { |
3572 | 1266 struct proto_user_opt *puo; |
2393 | 1267 ret->protocol = PROTO_GADUGADU; |
1268 ret->options = 0; | |
3572 | 1269 ret->name = g_strdup("Gadu-Gadu"); |
2393 | 1270 ret->list_icon = agg_list_icon; |
1271 ret->away_states = agg_away_states; | |
1272 ret->actions = agg_actions; | |
1273 ret->buddy_menu = agg_buddy_menu; | |
1274 ret->chat_info = NULL; | |
1275 ret->login = agg_login; | |
1276 ret->close = agg_close; | |
1277 ret->send_im = agg_send_im; | |
1278 ret->set_info = NULL; | |
1279 ret->get_info = agg_get_info; | |
1280 ret->set_away = agg_set_away; | |
1281 ret->set_dir = NULL; | |
1282 ret->get_dir = agg_get_info; | |
1283 ret->dir_search = agg_dir_search; | |
1284 ret->set_idle = NULL; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1285 ret->change_passwd = agg_change_passwd; |
2393 | 1286 ret->add_buddy = agg_add_buddy; |
1287 ret->add_buddies = agg_add_buddies; | |
1288 ret->remove_buddy = agg_rem_buddy; | |
1289 ret->add_permit = agg_permit_deny_dummy; | |
1290 ret->add_deny = agg_permit_deny_dummy; | |
1291 ret->rem_permit = agg_permit_deny_dummy; | |
1292 ret->rem_deny = agg_permit_deny_dummy; | |
1293 ret->set_permit_deny = agg_set_permit_deny_dummy; | |
1294 ret->warn = NULL; | |
1295 ret->join_chat = NULL; | |
1296 ret->chat_invite = NULL; | |
1297 ret->chat_leave = NULL; | |
1298 ret->chat_whisper = NULL; | |
1299 ret->chat_send = NULL; | |
1300 ret->keepalive = agg_keepalive; | |
1301 ret->normalize = NULL; | |
3572 | 1302 |
1303 puo = g_new0(struct proto_user_opt, 1); | |
1304 puo->label = g_strdup(_("Nick:")); | |
1305 puo->def = g_strdup(_("Gadu-Gadu User")); | |
1306 puo->pos = USEROPT_NICK; | |
1307 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1308 | |
2393 | 1309 my_protocol = ret; |
1310 } | |
1311 | |
1312 #ifndef STATIC | |
1313 | |
3630 | 1314 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2393 | 1315 { |
3572 | 1316 gg_init(prpl); |
1317 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2393 | 1318 } |
1319 | |
1320 #endif | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1321 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1322 /* |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1323 * Local variables: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1324 * c-indentation-style: k&r |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1325 * c-basic-offset: 8 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1326 * indent-tabs-mode: notnil |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1327 * End: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1328 * |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1329 * vim: shiftwidth=8: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1330 */ |