Mercurial > pidgin.yaz
annotate src/protocols/gg/gg.c @ 2835:d8e67ff8022f
[gaim-migrate @ 2848]
Arkadiusz Miskiewicz writes:
> this time:
- and one bugfix
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 02 Dec 2001 20:42:30 +0000 |
parents | 1ffac7cf4e94 |
children | 4b3f17ca66bf |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
3 * $Id: gg.c 2848 2001-12-02 20:42:30Z warmenhoven $ |
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 |
27 #include <netdb.h> | |
28 #include <unistd.h> | |
29 #include <errno.h> | |
30 #include <netinet/in.h> | |
31 #include <arpa/inet.h> | |
32 #include <fcntl.h> | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
39 #include <ctype.h> | |
40 #ifdef HAVE_LANGINFO_CODESET | |
41 #include <langinfo.h> | |
42 #endif | |
43 #ifdef HAVE_ICONV | |
44 #include <iconv.h> | |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2518
diff
changeset
|
45 #include "iconv_string.h" |
2393 | 46 #endif |
47 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ | |
48 #include "libgg.h" | |
49 #include "multi.h" | |
50 #include "prpl.h" | |
51 #include "gaim.h" | |
52 #include "proxy.h" | |
53 | |
54 #include "pixmaps/gg_suncloud.xpm" | |
55 #include "pixmaps/gg_sunred.xpm" | |
56 #include "pixmaps/gg_sunwhitered.xpm" | |
57 #include "pixmaps/gg_sunyellow.xpm" | |
58 | |
59 #define USEROPT_NICK 0 | |
60 | |
61 #define AGG_BUF_LEN 1024 | |
62 | |
63 #define AGG_GENDER_NONE -1 | |
64 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
65 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
66 #define AGG_PUBDIR_USERLIST_IMPORT_FORM "/appsvc/fmcontactsget.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
67 #define AGG_PUBDIR_SEARCH_FORM "/appsvc/fmpubquery2.asp" |
2393 | 68 #define AGG_PUBDIR_MAX_ENTRIES 200 |
69 | |
70 #define AGG_STATUS_AVAIL _("Available") | |
71 #define AGG_STATUS_AVAIL_FRIENDS _("Available for friends only") | |
72 #define AGG_STATUS_BUSY _("Away") | |
73 #define AGG_STATUS_BUSY_FRIENDS _("Away for friends only") | |
74 #define AGG_STATUS_INVISIBLE _("Invisible") | |
75 #define AGG_STATUS_INVISIBLE_FRIENDS _("Invisible for friends only") | |
76 #define AGG_STATUS_NOT_AVAIL _("Unavailable") | |
77 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
78 #define AGG_HTTP_NONE 0 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
79 #define AGG_HTTP_SEARCH 1 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
80 #define AGG_HTTP_USERLIST_IMPORT 2 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
81 #define AGG_HTTP_USERLIST_EXPORT 3 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
82 #define AGG_HTTP_USERLIST_DELETE 4 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
83 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
84 #define UC_NORMAL 2 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
85 |
2393 | 86 struct agg_data { |
87 struct gg_session *sess; | |
88 }; | |
89 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
90 struct agg_http { |
2393 | 91 struct gaim_connection *gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
92 gchar *request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
93 gchar *form; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
94 gchar *host; |
2393 | 95 int inpa; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
96 int type; |
2393 | 97 }; |
98 | |
99 static char *agg_name() | |
100 { | |
101 return "Gadu-Gadu"; | |
102 } | |
103 | |
104 static gchar *charset_convert(const gchar *locstr, char *encsrc, char *encdst) | |
105 { | |
2563 | 106 #ifdef HAVE_ICONV |
2542
221e1c8e2410
[gaim-migrate @ 2555]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2541
diff
changeset
|
107 gchar *result = NULL; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
108 if (iconv_string(encdst, encsrc, locstr, locstr + strlen(locstr) + 1, &result, NULL) >= 0) |
2542
221e1c8e2410
[gaim-migrate @ 2555]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2541
diff
changeset
|
109 return result; |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2518
diff
changeset
|
110 #endif |
2393 | 111 return g_strdup(locstr); |
112 } | |
113 | |
114 static gboolean invalid_uin(char *uin) | |
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 { | |
132 switch (gc->permdeny) { | |
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. */ | |
143 if (g_slist_find_custom(gc->permit, uin, args_compare)) | |
144 return TRUE; | |
145 return FALSE; | |
146 break; | |
147 case 4: | |
148 /* deny some. */ | |
149 if (g_slist_find_custom(gc->deny, uin, args_compare)) | |
150 return FALSE; | |
151 return TRUE; | |
152 break; | |
153 default: | |
154 return TRUE; | |
155 break; | |
156 } | |
157 } | |
158 | |
159 static gchar *find_local_charset(void) | |
160 { | |
161 gchar *gg_localenc = g_getenv("GG_CHARSET"); | |
162 | |
163 if (gg_localenc == NULL) { | |
164 #ifdef HAVE_LANGINFO_CODESET | |
165 gg_localenc = nl_langinfo(CODESET); | |
166 #else | |
167 gg_localenc = "US-ASCII"; | |
168 #endif | |
169 } | |
170 return gg_localenc; | |
171 } | |
172 | |
173 static char *handle_errcode(int errcode, gboolean show) | |
174 { | |
175 static char msg[AGG_BUF_LEN]; | |
176 | |
177 switch (errcode) { | |
178 case GG_FAILURE_RESOLVING: | |
179 g_snprintf(msg, sizeof(msg), _("Unable to resolve hostname.")); | |
180 break; | |
181 case GG_FAILURE_CONNECTING: | |
182 g_snprintf(msg, sizeof(msg), _("Unable to connect to server.")); | |
183 break; | |
184 case GG_FAILURE_INVALID: | |
185 g_snprintf(msg, sizeof(msg), _("Invalid response from server.")); | |
186 break; | |
187 case GG_FAILURE_READING: | |
188 g_snprintf(msg, sizeof(msg), _("Error while reading from socket.")); | |
189 break; | |
190 case GG_FAILURE_WRITING: | |
191 g_snprintf(msg, sizeof(msg), _("Error while writting to socket.")); | |
192 break; | |
193 case GG_FAILURE_PASSWORD: | |
194 g_snprintf(msg, sizeof(msg), _("Authentification failed.")); | |
195 break; | |
196 default: | |
197 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); | |
198 break; | |
199 } | |
200 | |
201 if (show) | |
202 do_error_dialog(msg, _("Gadu-Gadu Error")); | |
203 | |
204 return msg; | |
205 } | |
206 | |
207 static gchar *encode_postdata(const gchar *data) | |
208 { | |
209 gchar *p = NULL; | |
210 int i, j = 0; | |
211 for (i = 0; i < strlen(data); i++) { | |
212 /* locale insensitive, doesn't reflect RFC (1738 section 2.2, 1866 section 8.2.1) */ | |
213 if ((data[i] >= 'a' && data[i] <= 'z') | |
214 || (data[i] >= 'A' && data[i] <= 'Z') | |
215 || (data[i] >= '0' && data[i] <= '9') | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
216 || data[i] == '=' || data[i] == '&') { |
2393 | 217 p = g_realloc(p, j + 1); |
218 p[j] = data[i]; | |
219 j++; | |
220 } else { | |
221 p = g_realloc(p, j + 4); /* remember, sprintf appends a '\0' */ | |
222 sprintf(p + j, "%%%02x", (unsigned char)data[i]); | |
223 j += 3; | |
224 } | |
225 } | |
226 p = g_realloc(p, j + 1); | |
227 p[j] = '\0'; | |
228 | |
229 if (p && strlen(p)) | |
230 return p; | |
231 else | |
232 return g_strdup(data); | |
233 } | |
234 | |
235 static void agg_set_away(struct gaim_connection *gc, char *state, char *msg) | |
236 { | |
237 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
238 | |
239 if (gc->away) | |
240 gc->away = NULL; | |
241 | |
242 if (!g_strcasecmp(state, AGG_STATUS_AVAIL)) | |
243 gg_change_status(gd->sess, GG_STATUS_AVAIL); | |
244 else if (!g_strcasecmp(state, AGG_STATUS_AVAIL_FRIENDS)) | |
245 gg_change_status(gd->sess, GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK); | |
246 else if (!g_strcasecmp(state, AGG_STATUS_BUSY)) { | |
247 gg_change_status(gd->sess, GG_STATUS_BUSY); | |
248 gc->away = ""; | |
249 } else if (!g_strcasecmp(state, AGG_STATUS_BUSY_FRIENDS)) { | |
250 gg_change_status(gd->sess, GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK); | |
251 gc->away = ""; | |
252 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE)) { | |
253 gg_change_status(gd->sess, GG_STATUS_INVISIBLE); | |
254 gc->away = ""; | |
255 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE_FRIENDS)) { | |
256 gg_change_status(gd->sess, GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK); | |
257 gc->away = ""; | |
258 } else if (!g_strcasecmp(state, AGG_STATUS_NOT_AVAIL)) { | |
259 gg_change_status(gd->sess, GG_STATUS_NOT_AVAIL); | |
260 gc->away = ""; | |
261 } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) { | |
262 if (msg) { | |
263 gg_change_status(gd->sess, GG_STATUS_BUSY); | |
264 gc->away = ""; | |
265 } else | |
266 gg_change_status(gd->sess, GG_STATUS_AVAIL); | |
267 } | |
268 } | |
269 | |
270 static gchar *get_away_text(int uc) | |
271 { | |
272 if (uc == UC_UNAVAILABLE) | |
273 return AGG_STATUS_NOT_AVAIL; | |
274 uc = uc >> 5; | |
275 switch (uc) { | |
276 case GG_STATUS_AVAIL: | |
277 default: | |
278 return AGG_STATUS_AVAIL; | |
279 case GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK: | |
280 return AGG_STATUS_AVAIL_FRIENDS; | |
281 case GG_STATUS_BUSY: | |
282 return AGG_STATUS_BUSY; | |
283 case GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK: | |
284 return AGG_STATUS_BUSY_FRIENDS; | |
285 case GG_STATUS_INVISIBLE: | |
286 return AGG_STATUS_INVISIBLE; | |
287 case GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK: | |
288 return AGG_STATUS_INVISIBLE_FRIENDS; | |
289 case GG_STATUS_NOT_AVAIL: | |
290 return AGG_STATUS_NOT_AVAIL; | |
291 } | |
292 } | |
293 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
294 static GList *agg_away_states(struct gaim_connection *gc) |
2393 | 295 { |
296 GList *m = NULL; | |
297 | |
298 m = g_list_append(m, AGG_STATUS_AVAIL); | |
299 m = g_list_append(m, AGG_STATUS_BUSY); | |
300 m = g_list_append(m, AGG_STATUS_INVISIBLE); | |
301 m = g_list_append(m, AGG_STATUS_AVAIL_FRIENDS); | |
302 m = g_list_append(m, AGG_STATUS_BUSY_FRIENDS); | |
303 m = g_list_append(m, AGG_STATUS_INVISIBLE_FRIENDS); | |
304 m = g_list_append(m, AGG_STATUS_NOT_AVAIL); | |
305 return m; | |
306 } | |
307 | |
308 /* Enhance these functions, more options and such stuff */ | |
309 static GList *agg_buddy_menu(struct gaim_connection *gc, char *who) | |
310 { | |
311 GList *m = NULL; | |
312 struct proto_buddy_menu *pbm; | |
313 struct buddy *b = find_buddy(gc, who); | |
314 static char buf[AGG_BUF_LEN]; | |
315 | |
316 if (!b) { | |
317 return m; | |
318 } | |
319 | |
320 pbm = g_new0(struct proto_buddy_menu, 1); | |
321 g_snprintf(buf, sizeof(buf), _("Status: %s"), get_away_text(b->uc)); | |
322 pbm->label = buf; | |
323 pbm->callback = NULL; | |
324 pbm->gc = gc; | |
325 m = g_list_append(m, pbm); | |
326 | |
327 return m; | |
328 } | |
329 | |
330 static GList *agg_user_opts() | |
331 { | |
332 GList *m = NULL; | |
333 struct proto_user_opt *puo; | |
334 | |
335 puo = g_new0(struct proto_user_opt, 1); | |
336 puo->label = _("Nick:"); | |
337 puo->def = _("Gadu-Gadu User"); | |
338 puo->pos = USEROPT_NICK; | |
339 m = g_list_append(m, puo); | |
340 | |
341 return m; | |
342 } | |
343 | |
344 static void main_callback(gpointer data, gint source, GaimInputCondition cond) | |
345 { | |
346 struct gaim_connection *gc = data; | |
347 struct agg_data *gd = gc->proto_data; | |
348 struct gg_event *e; | |
349 | |
350 debug_printf("main_callback enter: begin\n"); | |
351 | |
352 if (gd->sess->fd != source) | |
353 gd->sess->fd = source; | |
354 | |
355 if (source == -1) { | |
356 signoff(gc); | |
357 return; | |
358 } | |
359 | |
360 if (!(e = gg_watch_fd(gd->sess))) { | |
361 debug_printf("main_callback: gg_watch_fd failed - CRITICAL!\n"); | |
362 signoff(gc); | |
363 return; | |
364 } | |
365 | |
366 switch (e->type) { | |
367 case GG_EVENT_NONE: | |
368 /* do nothing */ | |
369 break; | |
370 case GG_EVENT_CONN_SUCCESS: | |
371 debug_printf("main_callback: CONNECTED AGAIN!?\n"); | |
372 break; | |
373 case GG_EVENT_CONN_FAILED: | |
374 if (gc->inpa) | |
375 gaim_input_remove(gc->inpa); | |
376 handle_errcode(e->event.failure, TRUE); | |
377 signoff(gc); | |
378 break; | |
379 case GG_EVENT_MSG: | |
380 { | |
381 gchar *imsg; | |
382 gchar user[20]; | |
383 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
384 g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender); |
2393 | 385 if (!allowed_uin(gc, user)) |
386 break; | |
387 imsg = charset_convert(e->event.msg.message, "CP1250", find_local_charset()); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
388 /* e->event.msg.time - we don't know what this time is for */ |
2393 | 389 serv_got_im(gc, user, imsg, 0, time((time_t) NULL)); |
390 g_free(imsg); | |
391 } | |
392 break; | |
393 case GG_EVENT_NOTIFY: | |
394 { | |
395 gchar user[20]; | |
396 struct gg_notify_reply *n = e->event.notify; | |
397 guint status; | |
398 | |
399 while (n->uin) { | |
400 switch (n->status) { | |
401 case GG_STATUS_NOT_AVAIL: | |
402 status = UC_UNAVAILABLE; | |
403 break; | |
404 case GG_STATUS_AVAIL: | |
405 case GG_STATUS_BUSY: | |
406 case GG_STATUS_INVISIBLE: | |
407 case GG_STATUS_FRIENDS_MASK: | |
408 status = UC_NORMAL | (e->event.status.status << 5); | |
409 break; | |
410 default: | |
411 status = UC_NORMAL; | |
412 break; | |
413 } | |
414 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
415 g_snprintf(user, sizeof(user), "%lu", n->uin); |
2393 | 416 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
417 status, 0); | |
418 n++; | |
419 } | |
420 } | |
421 break; | |
422 case GG_EVENT_STATUS: | |
423 { | |
424 gchar user[20]; | |
425 guint status; | |
426 | |
427 switch (e->event.status.status) { | |
428 case GG_STATUS_NOT_AVAIL: | |
429 status = UC_UNAVAILABLE; | |
430 break; | |
431 case GG_STATUS_AVAIL: | |
432 case GG_STATUS_BUSY: | |
433 case GG_STATUS_INVISIBLE: | |
434 case GG_STATUS_FRIENDS_MASK: | |
435 status = UC_NORMAL | (e->event.status.status << 5); | |
436 break; | |
437 default: | |
438 status = UC_NORMAL; | |
439 break; | |
440 } | |
441 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
442 g_snprintf(user, sizeof(user), "%lu", e->event.status.uin); |
2393 | 443 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, status, |
444 0); | |
445 } | |
446 break; | |
447 case GG_EVENT_ACK: | |
448 debug_printf("main_callback: message %d to %u sent with status %d\n", | |
449 e->event.ack.seq, e->event.ack.recipient, e->event.ack.status); | |
450 break; | |
451 default: | |
452 debug_printf("main_callback: unsupported event %d\n", e->type); | |
453 break; | |
454 } | |
455 gg_free_event(e); | |
456 } | |
457 | |
458 static void login_callback(gpointer data, gint source, GaimInputCondition cond) | |
459 { | |
460 struct gaim_connection *gc = data; | |
461 struct agg_data *gd = gc->proto_data; | |
462 struct gg_event *e; | |
463 | |
464 if (!g_slist_find(connections, data)) { | |
465 close(source); | |
466 return; | |
467 } | |
468 | |
469 if (gd->sess->fd != source) | |
470 gd->sess->fd = source; | |
471 | |
472 if (source == -1) { | |
473 hide_login_progress(gc, _("Unable to connect.")); | |
474 signoff(gc); | |
475 return; | |
476 } | |
477 | |
478 if (gc->inpa == 0) | |
479 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); | |
480 | |
481 switch (gd->sess->state) { | |
482 case GG_STATE_CONNECTING_HTTP: | |
483 case GG_STATE_WRITING_HTTP: | |
484 set_login_progress(gc, 2, _("Handshake")); | |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
485 break; |
2393 | 486 case GG_STATE_CONNECTING_GG: |
487 set_login_progress(gc, 3, _("Connecting to GG server")); | |
488 break; | |
489 case GG_STATE_WAITING_FOR_KEY: | |
490 set_login_progress(gc, 4, _("Waiting for server key")); | |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
491 break; |
2393 | 492 case GG_STATE_SENDING_KEY: |
493 set_login_progress(gc, 5, _("Sending key")); | |
494 break; | |
495 default: | |
496 break; | |
497 } | |
498 | |
499 if (!(e = gg_watch_fd(gd->sess))) { | |
500 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n"); | |
501 signoff(gc); | |
502 return; | |
503 } | |
504 | |
505 switch (e->type) { | |
506 case GG_EVENT_NONE: | |
507 /* nothing */ | |
508 break; | |
509 case GG_EVENT_CONN_SUCCESS: | |
510 /* Setup new input handler */ | |
511 if (gc->inpa) | |
512 gaim_input_remove(gc->inpa); | |
513 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc); | |
514 | |
515 /* Our signon is complete */ | |
516 account_online(gc); | |
517 serv_finish_login(gc); | |
518 | |
2518
e7478176e760
[gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
519 if (bud_list_cache_exists(gc)) |
e7478176e760
[gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
520 do_import(gc, NULL); |
2393 | 521 break; |
522 case GG_EVENT_CONN_FAILED: | |
523 gaim_input_remove(gc->inpa); | |
524 gc->inpa = 0; | |
525 handle_errcode(e->event.failure, TRUE); | |
526 signoff(gc); | |
527 break; | |
528 default: | |
529 break; | |
530 } | |
531 | |
532 gg_free_event(e); | |
533 } | |
534 | |
535 static void agg_keepalive(struct gaim_connection *gc) | |
536 { | |
537 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
538 if (gg_ping(gd->sess) < 0) { | |
539 signoff(gc); | |
540 return; | |
541 } | |
542 } | |
543 | |
544 static void agg_login(struct aim_user *user) | |
545 { | |
546 struct gaim_connection *gc = new_gaim_conn(user); | |
547 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1); | |
548 char buf[80]; | |
549 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
550 gc->checkbox = _("Send as message"); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
551 |
2393 | 552 gd->sess = g_new0(struct gg_session, 1); |
553 | |
554 if (user->proto_opt[USEROPT_NICK][0]) | |
555 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", | |
556 user->proto_opt[USEROPT_NICK]); | |
557 | |
558 set_login_progress(gc, 1, _("Looking up GG server")); | |
559 | |
560 if (invalid_uin(user->username)) { | |
561 hide_login_progress(gc, _("Invalid Gadu-Gadu UIN specified")); | |
562 signoff(gc); | |
563 return; | |
564 } | |
565 | |
566 gc->inpa = 0; | |
567 | |
568 /* | |
569 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) { | |
570 debug_printf("uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); | |
571 hide_login_progress(gc, "Unable to connect."); | |
572 signoff(gc); | |
573 return; | |
574 } | |
575 | |
576 gg_login() sucks for me, so I'm using proxy_connect() | |
577 */ | |
578 | |
579 gd->sess->uin = (uin_t) strtol(user->username, (char **)NULL, 10); | |
580 gd->sess->password = g_strdup(user->password); | |
581 gd->sess->state = GG_STATE_CONNECTING_HTTP; | |
582 gd->sess->check = GG_CHECK_WRITE; | |
583 gd->sess->async = 1; | |
584 gd->sess->fd = proxy_connect(GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc); | |
585 | |
586 if (gd->sess->fd < 0) { | |
587 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); | |
588 hide_login_progress(gc, buf); | |
589 signoff(gc); | |
590 return; | |
591 } | |
592 } | |
593 | |
594 static void agg_close(struct gaim_connection *gc) | |
595 { | |
596 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
597 if (gc->inpa) | |
598 gaim_input_remove(gc->inpa); | |
599 gg_logoff(gd->sess); | |
600 gg_free_session(gd->sess); | |
601 g_free(gc->proto_data); | |
602 } | |
603 | |
604 static int agg_send_im(struct gaim_connection *gc, char *who, char *msg, int flags) | |
605 { | |
606 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
607 gchar *imsg; | |
608 | |
609 if (invalid_uin(who)) { | |
610 do_error_dialog(_("You are trying to send message to invalid Gadu-Gadu UIN!"), | |
611 _("Gadu-Gadu Error")); | |
612 return -1; | |
613 } | |
614 | |
615 if (strlen(msg) > 0) { | |
616 imsg = charset_convert(msg, find_local_charset(), "CP1250"); | |
617 if (gg_send_message(gd->sess, (flags & IM_FLAG_CHECKBOX) ? GG_CLASS_MSG : GG_CLASS_CHAT, | |
618 strtol(who, (char **)NULL, 10), imsg) < 0) | |
619 return -1; | |
620 g_free(imsg); | |
621 } | |
622 return 1; | |
623 } | |
624 | |
625 static void agg_add_buddy(struct gaim_connection *gc, char *who) | |
626 { | |
627 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
628 if (invalid_uin(who)) | |
629 return; | |
630 gg_add_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
631 } | |
632 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2563
diff
changeset
|
633 static void agg_rem_buddy(struct gaim_connection *gc, char *who, char *group) |
2393 | 634 { |
635 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
636 if (invalid_uin(who)) | |
637 return; | |
638 gg_remove_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
639 } | |
640 | |
641 static void agg_add_buddies(struct gaim_connection *gc, GList *whos) | |
642 { | |
643 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
644 uin_t *userlist = NULL; | |
645 int userlist_size = 0; | |
646 | |
647 while (whos) { | |
648 if (!invalid_uin(whos->data)) { | |
649 userlist_size++; | |
650 userlist = g_renew(uin_t, userlist, userlist_size); | |
651 userlist[userlist_size - 1] = | |
652 (uin_t) strtol((char *)whos->data, (char **)NULL, 10); | |
653 } | |
654 whos = g_list_next(whos); | |
655 } | |
656 | |
657 if (userlist) { | |
658 gg_notify(gd->sess, userlist, userlist_size); | |
659 g_free(userlist); | |
660 } | |
661 } | |
662 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
663 static void search_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 664 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
665 gchar **webdata_tbl; |
2393 | 666 gchar *buf; |
667 char *ptr; | |
668 int i, j; | |
669 | |
670 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { | |
671 debug_printf("search_callback: pubdir result [%s]\n", webdata); | |
672 do_error_dialog(_("Couldn't get search results"), _("Gadu-Gadu Error")); | |
673 return; | |
674 } | |
675 ptr++; | |
676 | |
677 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); | |
678 | |
679 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | |
680 | |
681 j = 0; | |
682 | |
683 /* Parse array */ | |
684 for (i = 0; webdata_tbl[i] != NULL; i++) { | |
685 gchar *p, *oldibuf; | |
686 static gchar *ibuf; | |
687 | |
688 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | |
689 | |
690 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */ | |
691 if (i % 8 == 0) | |
692 j = 0; | |
693 | |
694 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", find_local_charset()); | |
695 | |
696 oldibuf = ibuf; | |
697 | |
698 switch (j) { | |
699 case 0: | |
700 ibuf = g_strconcat("---------------------------------<BR>\n", NULL); | |
701 oldibuf = ibuf; | |
702 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ", | |
703 (atoi(p) == 2) ? _("yes") : _("no"), "<BR>\n", NULL); | |
704 g_free(oldibuf); | |
705 break; | |
706 case 1: | |
707 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL); | |
708 g_free(oldibuf); | |
709 break; | |
710 case 2: | |
711 ibuf = g_strconcat(oldibuf, "<B>", _("First name"), ":</B> ", p, "<BR>\n", NULL); | |
712 g_free(oldibuf); | |
713 break; | |
714 case 3: | |
715 ibuf = | |
716 g_strconcat(oldibuf, "<B>", _("Second Name"), ":</B> ", p, "<BR>\n", NULL); | |
717 g_free(oldibuf); | |
718 break; | |
719 case 4: | |
720 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL); | |
721 g_free(oldibuf); | |
722 break; | |
723 case 5: | |
724 /* Hack, invalid_uin does what we really want here but may change in future */ | |
725 if (invalid_uin(p)) | |
726 ibuf = | |
727 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> <BR>\n", NULL); | |
728 else | |
729 ibuf = | |
730 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> ", p, "<BR>\n", | |
731 NULL); | |
732 g_free(oldibuf); | |
733 break; | |
734 case 6: | |
735 if (atoi(p) == GG_GENDER_FEMALE) | |
736 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL); | |
737 else if (atoi(p) == GG_GENDER_MALE) | |
738 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL); | |
739 else | |
740 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL); | |
741 g_free(oldibuf); | |
742 break; | |
743 case 7: | |
744 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL); | |
745 g_free(oldibuf); | |
746 | |
747 /* We have all lines, so add them to buffer */ | |
748 { | |
749 gchar *oldbuf = buf; | |
750 buf = g_strconcat(oldbuf, ibuf, NULL); | |
751 g_free(oldbuf); | |
752 } | |
753 | |
754 g_free(ibuf); | |
755 break; | |
756 } | |
757 | |
758 g_free(p); | |
759 | |
760 j++; | |
761 } | |
762 | |
763 g_strfreev(webdata_tbl); | |
764 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
765 g_show_info_text(gc, NULL, 2, buf, NULL); |
2393 | 766 |
767 g_free(buf); | |
768 } | |
769 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
770 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
|
771 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
772 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
773 gchar **users_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
774 int i; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
775 if (strstr(webdata, "no_data:")) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
776 do_error_dialog(_("There is no Buddy List stored on server. Sorry!"), |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
777 _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
778 return; |
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 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
781 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
|
782 debug_printf("import_buddies_server_results: import buddies result [%s]\n", webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
783 do_error_dialog(_("Couldn't Import Buddies List from Server"), _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
784 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
785 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
786 ptr++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
787 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
788 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
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 /* Parse array of Buddies List */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
791 for (i = 0; users_tbl[i] != NULL; i++) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
792 gchar **data_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
793 gchar *name, *show; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
794 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
795 g_strdelimit(users_tbl[i], "\r\t\n\015", ' '); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
796 data_tbl = g_strsplit(users_tbl[i], ";", 8); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
797 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
798 show = data_tbl[3]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
799 name = data_tbl[6]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
800 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
801 if (invalid_uin(name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
802 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
803 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
804 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
805 debug_printf("import_buddies_server_results: uin: %s\n", name); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
806 if (!find_buddy(gc, name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
807 /* Default group if none specified on server */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
808 gchar *group = g_strdup("Gadu-Gadu"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
809 if (strlen(data_tbl[5])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
810 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
811 if (strlen(group_tbl[0])) { |
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 group = g_strdup(group_tbl[0]); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
814 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
815 g_strfreev(group_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
816 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
817 /* Add Buddy to our userlist */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
818 add_buddy(gc, group, name, strlen(show) ? show : name); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
819 do_export(gc); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
820 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
821 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
822 g_strfreev(data_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
823 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
824 g_strfreev(users_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
825 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
826 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
827 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 828 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
829 if (strstr(webdata, "put_success:")) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
830 do_error_dialog(_("Buddies List sucessfully transfered into Server"), |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
831 _("Gadu-Gadu Information")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
832 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
833 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
834 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
835 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
836 do_error_dialog(_("Couldn't transfer Buddies List into Server"), _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
837 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
838 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
839 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
|
840 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
841 if (strstr(webdata, "put_success:")) { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
842 do_error_dialog(_("Buddies List sucessfully deleted from Server"), |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
843 _("Gadu-Gadu Information")); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
844 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
845 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
846 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
847 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
848 do_error_dialog(_("Couldn't delete Buddies List from Server"), _("Gadu-Gadu Error")); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
849 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
850 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
851 static void http_results(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
852 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
853 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
854 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
855 char *webdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
856 int len; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
857 char read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
858 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
859 debug_printf("http_results: begin\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
860 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
861 if (!g_slist_find(connections, gc)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
862 debug_printf("search_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
863 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
864 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
865 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
866 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
867 } |
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 webdata = NULL; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
870 len = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
871 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
872 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
873 if (errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
874 errno = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
875 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
876 } |
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 if (!read_data) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
879 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
880 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
881 len++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
882 webdata = g_realloc(webdata, len); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
883 webdata[len - 1] = read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
884 } |
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 webdata = g_realloc(webdata, len + 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
887 webdata[len] = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
888 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
889 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
890 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
891 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
892 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
|
893 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
894 switch (hdata->type) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
895 case AGG_HTTP_SEARCH: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
896 search_results(gc, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
897 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
898 case AGG_HTTP_USERLIST_IMPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
899 import_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
900 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
901 case AGG_HTTP_USERLIST_EXPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
902 export_buddies_server_results(gc, webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
903 break; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
904 case AGG_HTTP_USERLIST_DELETE: |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
905 delete_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
906 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
907 case AGG_HTTP_NONE: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
908 default: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
909 debug_printf("http_results: unsupported type %d\n", hdata->type); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
910 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
911 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
912 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
913 g_free(webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
914 g_free(hdata); |
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 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
917 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
918 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
919 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
920 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
921 gchar *request = hdata->request; |
2393 | 922 gchar *buf; |
923 char *ptr; | |
924 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
925 debug_printf("http_req_callback: begin\n"); |
2393 | 926 |
927 if (!g_slist_find(connections, gc)) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
928 debug_printf("http_req_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
929 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
930 g_free(hdata); |
2393 | 931 close(source); |
932 return; | |
933 } | |
934 | |
935 if (source == -1) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
936 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
937 g_free(hdata); |
2393 | 938 return; |
939 } | |
940 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
941 ptr = encode_postdata(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
942 g_free(request); |
2393 | 943 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
944 debug_printf("http_req_callback: http request [%s]\n", ptr); |
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", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
952 hdata->form, hdata->host, strlen(ptr), ptr); |
2393 | 953 |
954 g_free(ptr); | |
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); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
960 do_error_dialog(_("Couldn't send http request"), _("Gadu-Gadu Error")); |
2393 | 961 return; |
962 } | |
963 | |
964 g_free(buf); | |
965 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
966 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
|
967 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
968 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
969 static void import_buddies_server(struct gaim_connection *gc) |
2792
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 struct agg_http *hi = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
972 static char msg[AGG_BUF_LEN]; |
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 hi->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
975 hi->type = AGG_HTTP_USERLIST_IMPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
976 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
977 hi->host = GG_PUBDIR_HOST; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
978 hi->request = g_strdup_printf("FmNum=%s&Pass=%s", gc->username, gc->password); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
979 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
980 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
981 g_snprintf(msg, sizeof(msg), _("Buddies List import from Server failed (%s)"), |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
982 GG_PUBDIR_HOST); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
983 do_error_dialog(msg, _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
984 g_free(hi->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
985 g_free(hi); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
986 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
987 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
988 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
989 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
990 static void export_buddies_server(struct gaim_connection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
991 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
992 struct agg_http *he = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
993 static char msg[AGG_BUF_LEN]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
994 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
995 GSList *gr = gc->groups; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
996 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
997 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
998 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
999 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1000 he->host = GG_PUBDIR_HOST; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1001 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Contacts=", gc->username, gc->password); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1002 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1003 while (gr) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1004 struct group *g = gr->data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1005 GSList *m = g->members; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1006 while (m) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1007 struct buddy *b = m->data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1008 gchar *newdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1009 /* GG Number */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1010 gchar *name = b->name; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1011 /* GG Pseudo */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1012 gchar *show = strlen(b->show) ? b->show : b->name; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1013 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1014 ptr = he->request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1015 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s\r\n", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1016 show, show, show, show, "", g->name, name); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1017 he->request = g_strconcat(ptr, newdata, NULL); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1018 g_free(newdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1019 g_free(ptr); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1020 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1021 m = g_slist_next(m); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1022 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1023 gr = g_slist_next(gr); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1024 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1025 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1026 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1027 g_snprintf(msg, sizeof(msg), _("Buddies List export to Server failed (%s)"), |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1028 GG_PUBDIR_HOST); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1029 do_error_dialog(msg, _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1030 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1031 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1032 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1033 } |
2393 | 1034 } |
1035 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1036 static void delete_buddies_server(struct gaim_connection *gc) |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1037 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1038 struct agg_http *he = g_new0(struct agg_http, 1); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1039 static char msg[AGG_BUF_LEN]; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1040 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1041 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1042 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1043 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1044 he->host = GG_PUBDIR_HOST; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1045 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", gc->username, gc->password); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1046 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1047 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1048 g_snprintf(msg, sizeof(msg), _("Deletion of Buddies List from Server failed (%s)"), |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1049 GG_PUBDIR_HOST); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1050 do_error_dialog(msg, _("Gadu-Gadu Error")); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1051 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1052 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1053 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1054 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1055 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1056 |
2393 | 1057 static void agg_dir_search(struct gaim_connection *gc, char *first, char *middle, |
1058 char *last, char *maiden, char *city, char *state, char *country, char *email) | |
1059 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1060 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1061 static char msg[AGG_BUF_LEN]; |
1062 | |
1063 srch->gc = gc; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1064 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1065 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1066 srch->host = GG_PUBDIR_HOST; |
2393 | 1067 |
1068 if (email && strlen(email)) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1069 srch->request = g_strdup_printf("Mode=1&Email=%s", email); |
2393 | 1070 } else { |
1071 gchar *new_first = charset_convert(first, find_local_charset(), "CP1250"); | |
1072 gchar *new_last = charset_convert(last, find_local_charset(), "CP1250"); | |
1073 gchar *new_city = charset_convert(city, find_local_charset(), "CP1250"); | |
1074 | |
1075 /* For active only add &ActiveOnly= */ | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1076 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
|
1077 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1078 new_first, new_last, AGG_GENDER_NONE, |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1079 "", new_city, 0, 0); |
2393 | 1080 |
1081 g_free(new_first); | |
1082 g_free(new_last); | |
1083 g_free(new_city); | |
1084 } | |
1085 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1086 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
2393 | 1087 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST); |
1088 do_error_dialog(msg, _("Gadu-Gadu Error")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1089 g_free(srch->request); |
2393 | 1090 g_free(srch); |
1091 return; | |
1092 } | |
1093 } | |
1094 | |
1095 static void agg_do_action(struct gaim_connection *gc, char *action) | |
1096 { | |
1097 if (!strcmp(action, _("Directory Search"))) { | |
1098 show_find_info(gc); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1099 } else if (!strcmp(action, _("Import Buddies List from Server"))) { |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1100 import_buddies_server(gc); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1101 } else if (!strcmp(action, _("Export Buddies List to Server"))) { |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1102 export_buddies_server(gc); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1103 } else if (!strcmp(action, _("Delete Buddies List from Server"))) { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1104 delete_buddies_server(gc); |
2393 | 1105 } |
1106 } | |
1107 | |
1108 static GList *agg_actions() | |
1109 { | |
1110 GList *m = NULL; | |
1111 | |
1112 m = g_list_append(m, _("Directory Search")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1113 m = g_list_append(m, _("Import Buddies List from Server")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1114 m = g_list_append(m, _("Export Buddies List to Server")); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1115 m = g_list_append(m, _("Delete Buddies List from Server")); |
2393 | 1116 |
1117 return m; | |
1118 } | |
1119 | |
1120 static void agg_get_info(struct gaim_connection *gc, char *who) | |
1121 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1122 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1123 static char msg[AGG_BUF_LEN]; |
1124 | |
1125 srch->gc = gc; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1126 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1127 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1128 srch->host = GG_PUBDIR_HOST; |
2393 | 1129 |
1130 /* If it's invalid uin then maybe it's nickname? */ | |
1131 if (invalid_uin(who)) { | |
1132 gchar *new_who = charset_convert(who, find_local_charset(), "CP1250"); | |
1133 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1134 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
|
1135 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1136 "", "", AGG_GENDER_NONE, new_who, "", 0, 0); |
2393 | 1137 |
1138 g_free(new_who); | |
1139 } else | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1140 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1141 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1142 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
2393 | 1143 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST); |
1144 do_error_dialog(msg, _("Gadu-Gadu Error")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1145 g_free(srch->request); |
2393 | 1146 g_free(srch); |
1147 return; | |
1148 } | |
1149 } | |
1150 | |
1151 static char **agg_list_icon(int uc) | |
1152 { | |
1153 guint status; | |
1154 if (uc == UC_UNAVAILABLE) | |
1155 return (char **)gg_sunred_xpm; | |
1156 status = uc >> 5; | |
1157 /* Drop all masks */ | |
1158 status &= ~(GG_STATUS_FRIENDS_MASK); | |
1159 if (status == GG_STATUS_AVAIL) | |
1160 return (char **)gg_sunyellow_xpm; | |
1161 if (status == GG_STATUS_BUSY) | |
1162 return (char **)gg_suncloud_xpm; | |
1163 if (status == GG_STATUS_INVISIBLE) | |
1164 return (char **)gg_sunwhitered_xpm; | |
1165 return (char **)gg_sunyellow_xpm; | |
1166 } | |
1167 | |
1168 static void agg_set_permit_deny_dummy(struct gaim_connection *gc) | |
1169 { | |
1170 /* It's implemented on client side because GG server doesn't support this */ | |
1171 } | |
1172 | |
1173 static void agg_permit_deny_dummy(struct gaim_connection *gc, char *who) | |
1174 { | |
1175 /* It's implemented on client side because GG server doesn't support this */ | |
1176 } | |
1177 | |
1178 static struct prpl *my_protocol = NULL; | |
1179 | |
2423
ce09589b7681
[gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1180 void gg_init(struct prpl *ret) |
2393 | 1181 { |
1182 ret->protocol = PROTO_GADUGADU; | |
1183 ret->options = 0; | |
1184 ret->name = agg_name; | |
1185 ret->list_icon = agg_list_icon; | |
1186 ret->away_states = agg_away_states; | |
1187 ret->actions = agg_actions; | |
1188 ret->do_action = agg_do_action; | |
1189 ret->user_opts = agg_user_opts; | |
1190 ret->buddy_menu = agg_buddy_menu; | |
1191 ret->chat_info = NULL; | |
1192 ret->login = agg_login; | |
1193 ret->close = agg_close; | |
1194 ret->send_im = agg_send_im; | |
1195 ret->set_info = NULL; | |
1196 ret->get_info = agg_get_info; | |
1197 ret->set_away = agg_set_away; | |
1198 ret->set_dir = NULL; | |
1199 ret->get_dir = agg_get_info; | |
1200 ret->dir_search = agg_dir_search; | |
1201 ret->set_idle = NULL; | |
1202 ret->change_passwd = NULL; | |
1203 ret->add_buddy = agg_add_buddy; | |
1204 ret->add_buddies = agg_add_buddies; | |
1205 ret->remove_buddy = agg_rem_buddy; | |
1206 ret->add_permit = agg_permit_deny_dummy; | |
1207 ret->add_deny = agg_permit_deny_dummy; | |
1208 ret->rem_permit = agg_permit_deny_dummy; | |
1209 ret->rem_deny = agg_permit_deny_dummy; | |
1210 ret->set_permit_deny = agg_set_permit_deny_dummy; | |
1211 ret->warn = NULL; | |
1212 ret->join_chat = NULL; | |
1213 ret->chat_invite = NULL; | |
1214 ret->chat_leave = NULL; | |
1215 ret->chat_whisper = NULL; | |
1216 ret->chat_send = NULL; | |
1217 ret->keepalive = agg_keepalive; | |
1218 ret->normalize = NULL; | |
1219 my_protocol = ret; | |
1220 } | |
1221 | |
1222 #ifndef STATIC | |
1223 | |
1224 char *gaim_plugin_init(GModule *handle) | |
1225 { | |
2423
ce09589b7681
[gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1226 load_protocol(gg_init, sizeof(struct prpl)); |
2393 | 1227 return NULL; |
1228 } | |
1229 | |
1230 void gaim_plugin_remove() | |
1231 { | |
1232 struct prpl *p = find_prpl(PROTO_GADUGADU); | |
1233 if (p == my_protocol) | |
1234 unload_protocol(p); | |
1235 } | |
1236 | |
1237 char *name() | |
1238 { | |
1239 return "Gadu-Gadu"; | |
1240 } | |
1241 | |
1242 char *description() | |
1243 { | |
1244 return PRPL_DESC("Gadu-Gadu"); | |
1245 } | |
1246 | |
1247 #endif |