Mercurial > pidgin
annotate src/protocols/gg/gg.c @ 2831:cf50045c0167
[gaim-migrate @ 2844]
i love this.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 02 Dec 2001 07:49:27 +0000 |
parents | 1ffac7cf4e94 |
children | d8e67ff8022f |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
3 * $Id: gg.c 2819 2001-11-27 22:54:32Z 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")); | |
485 case GG_STATE_CONNECTING_GG: | |
486 set_login_progress(gc, 3, _("Connecting to GG server")); | |
487 break; | |
488 case GG_STATE_WAITING_FOR_KEY: | |
489 set_login_progress(gc, 4, _("Waiting for server key")); | |
490 case GG_STATE_SENDING_KEY: | |
491 set_login_progress(gc, 5, _("Sending key")); | |
492 break; | |
493 default: | |
494 break; | |
495 } | |
496 | |
497 if (!(e = gg_watch_fd(gd->sess))) { | |
498 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n"); | |
499 signoff(gc); | |
500 return; | |
501 } | |
502 | |
503 switch (e->type) { | |
504 case GG_EVENT_NONE: | |
505 /* nothing */ | |
506 break; | |
507 case GG_EVENT_CONN_SUCCESS: | |
508 /* Setup new input handler */ | |
509 if (gc->inpa) | |
510 gaim_input_remove(gc->inpa); | |
511 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc); | |
512 | |
513 /* Our signon is complete */ | |
514 account_online(gc); | |
515 serv_finish_login(gc); | |
516 | |
2518
e7478176e760
[gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
517 if (bud_list_cache_exists(gc)) |
e7478176e760
[gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
518 do_import(gc, NULL); |
2393 | 519 break; |
520 case GG_EVENT_CONN_FAILED: | |
521 gaim_input_remove(gc->inpa); | |
522 gc->inpa = 0; | |
523 handle_errcode(e->event.failure, TRUE); | |
524 signoff(gc); | |
525 break; | |
526 default: | |
527 break; | |
528 } | |
529 | |
530 gg_free_event(e); | |
531 } | |
532 | |
533 static void agg_keepalive(struct gaim_connection *gc) | |
534 { | |
535 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
536 if (gg_ping(gd->sess) < 0) { | |
537 signoff(gc); | |
538 return; | |
539 } | |
540 } | |
541 | |
542 static void agg_login(struct aim_user *user) | |
543 { | |
544 struct gaim_connection *gc = new_gaim_conn(user); | |
545 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1); | |
546 char buf[80]; | |
547 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
548 gc->checkbox = _("Send as message"); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
549 |
2393 | 550 gd->sess = g_new0(struct gg_session, 1); |
551 | |
552 if (user->proto_opt[USEROPT_NICK][0]) | |
553 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", | |
554 user->proto_opt[USEROPT_NICK]); | |
555 | |
556 set_login_progress(gc, 1, _("Looking up GG server")); | |
557 | |
558 if (invalid_uin(user->username)) { | |
559 hide_login_progress(gc, _("Invalid Gadu-Gadu UIN specified")); | |
560 signoff(gc); | |
561 return; | |
562 } | |
563 | |
564 gc->inpa = 0; | |
565 | |
566 /* | |
567 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) { | |
568 debug_printf("uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); | |
569 hide_login_progress(gc, "Unable to connect."); | |
570 signoff(gc); | |
571 return; | |
572 } | |
573 | |
574 gg_login() sucks for me, so I'm using proxy_connect() | |
575 */ | |
576 | |
577 gd->sess->uin = (uin_t) strtol(user->username, (char **)NULL, 10); | |
578 gd->sess->password = g_strdup(user->password); | |
579 gd->sess->state = GG_STATE_CONNECTING_HTTP; | |
580 gd->sess->check = GG_CHECK_WRITE; | |
581 gd->sess->async = 1; | |
582 gd->sess->fd = proxy_connect(GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc); | |
583 | |
584 if (gd->sess->fd < 0) { | |
585 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); | |
586 hide_login_progress(gc, buf); | |
587 signoff(gc); | |
588 return; | |
589 } | |
590 } | |
591 | |
592 static void agg_close(struct gaim_connection *gc) | |
593 { | |
594 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
595 if (gc->inpa) | |
596 gaim_input_remove(gc->inpa); | |
597 gg_logoff(gd->sess); | |
598 gg_free_session(gd->sess); | |
599 g_free(gc->proto_data); | |
600 } | |
601 | |
602 static int agg_send_im(struct gaim_connection *gc, char *who, char *msg, int flags) | |
603 { | |
604 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
605 gchar *imsg; | |
606 | |
607 if (invalid_uin(who)) { | |
608 do_error_dialog(_("You are trying to send message to invalid Gadu-Gadu UIN!"), | |
609 _("Gadu-Gadu Error")); | |
610 return -1; | |
611 } | |
612 | |
613 if (strlen(msg) > 0) { | |
614 imsg = charset_convert(msg, find_local_charset(), "CP1250"); | |
615 if (gg_send_message(gd->sess, (flags & IM_FLAG_CHECKBOX) ? GG_CLASS_MSG : GG_CLASS_CHAT, | |
616 strtol(who, (char **)NULL, 10), imsg) < 0) | |
617 return -1; | |
618 g_free(imsg); | |
619 } | |
620 return 1; | |
621 } | |
622 | |
623 static void agg_add_buddy(struct gaim_connection *gc, char *who) | |
624 { | |
625 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
626 if (invalid_uin(who)) | |
627 return; | |
628 gg_add_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
629 } | |
630 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2563
diff
changeset
|
631 static void agg_rem_buddy(struct gaim_connection *gc, char *who, char *group) |
2393 | 632 { |
633 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
634 if (invalid_uin(who)) | |
635 return; | |
636 gg_remove_notify(gd->sess, strtol(who, (char **)NULL, 10)); | |
637 } | |
638 | |
639 static void agg_add_buddies(struct gaim_connection *gc, GList *whos) | |
640 { | |
641 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
642 uin_t *userlist = NULL; | |
643 int userlist_size = 0; | |
644 | |
645 while (whos) { | |
646 if (!invalid_uin(whos->data)) { | |
647 userlist_size++; | |
648 userlist = g_renew(uin_t, userlist, userlist_size); | |
649 userlist[userlist_size - 1] = | |
650 (uin_t) strtol((char *)whos->data, (char **)NULL, 10); | |
651 } | |
652 whos = g_list_next(whos); | |
653 } | |
654 | |
655 if (userlist) { | |
656 gg_notify(gd->sess, userlist, userlist_size); | |
657 g_free(userlist); | |
658 } | |
659 } | |
660 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
661 static void search_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 662 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
663 gchar **webdata_tbl; |
2393 | 664 gchar *buf; |
665 char *ptr; | |
666 int i, j; | |
667 | |
668 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { | |
669 debug_printf("search_callback: pubdir result [%s]\n", webdata); | |
670 do_error_dialog(_("Couldn't get search results"), _("Gadu-Gadu Error")); | |
671 return; | |
672 } | |
673 ptr++; | |
674 | |
675 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); | |
676 | |
677 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | |
678 | |
679 j = 0; | |
680 | |
681 /* Parse array */ | |
682 for (i = 0; webdata_tbl[i] != NULL; i++) { | |
683 gchar *p, *oldibuf; | |
684 static gchar *ibuf; | |
685 | |
686 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | |
687 | |
688 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */ | |
689 if (i % 8 == 0) | |
690 j = 0; | |
691 | |
692 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", find_local_charset()); | |
693 | |
694 oldibuf = ibuf; | |
695 | |
696 switch (j) { | |
697 case 0: | |
698 ibuf = g_strconcat("---------------------------------<BR>\n", NULL); | |
699 oldibuf = ibuf; | |
700 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ", | |
701 (atoi(p) == 2) ? _("yes") : _("no"), "<BR>\n", NULL); | |
702 g_free(oldibuf); | |
703 break; | |
704 case 1: | |
705 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL); | |
706 g_free(oldibuf); | |
707 break; | |
708 case 2: | |
709 ibuf = g_strconcat(oldibuf, "<B>", _("First name"), ":</B> ", p, "<BR>\n", NULL); | |
710 g_free(oldibuf); | |
711 break; | |
712 case 3: | |
713 ibuf = | |
714 g_strconcat(oldibuf, "<B>", _("Second Name"), ":</B> ", p, "<BR>\n", NULL); | |
715 g_free(oldibuf); | |
716 break; | |
717 case 4: | |
718 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL); | |
719 g_free(oldibuf); | |
720 break; | |
721 case 5: | |
722 /* Hack, invalid_uin does what we really want here but may change in future */ | |
723 if (invalid_uin(p)) | |
724 ibuf = | |
725 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> <BR>\n", NULL); | |
726 else | |
727 ibuf = | |
728 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> ", p, "<BR>\n", | |
729 NULL); | |
730 g_free(oldibuf); | |
731 break; | |
732 case 6: | |
733 if (atoi(p) == GG_GENDER_FEMALE) | |
734 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL); | |
735 else if (atoi(p) == GG_GENDER_MALE) | |
736 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL); | |
737 else | |
738 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL); | |
739 g_free(oldibuf); | |
740 break; | |
741 case 7: | |
742 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL); | |
743 g_free(oldibuf); | |
744 | |
745 /* We have all lines, so add them to buffer */ | |
746 { | |
747 gchar *oldbuf = buf; | |
748 buf = g_strconcat(oldbuf, ibuf, NULL); | |
749 g_free(oldbuf); | |
750 } | |
751 | |
752 g_free(ibuf); | |
753 break; | |
754 } | |
755 | |
756 g_free(p); | |
757 | |
758 j++; | |
759 } | |
760 | |
761 g_strfreev(webdata_tbl); | |
762 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
763 g_show_info_text(gc, NULL, 2, buf, NULL); |
2393 | 764 |
765 g_free(buf); | |
766 } | |
767 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
768 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
|
769 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
770 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
771 gchar **users_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
772 int i; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
773 if (strstr(webdata, "no_data:")) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
774 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
|
775 _("Gadu-Gadu Error")); |
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 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
779 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
|
780 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
|
781 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
|
782 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
783 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
784 ptr++; |
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 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
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 /* Parse array of Buddies List */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
789 for (i = 0; users_tbl[i] != NULL; i++) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
790 gchar **data_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
791 gchar *name, *show; |
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 g_strdelimit(users_tbl[i], "\r\t\n\015", ' '); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
794 data_tbl = g_strsplit(users_tbl[i], ";", 8); |
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 show = data_tbl[3]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
797 name = data_tbl[6]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
798 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
799 if (invalid_uin(name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
800 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
801 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
802 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
803 debug_printf("import_buddies_server_results: uin: %s\n", name); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
804 if (!find_buddy(gc, name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
805 /* Default group if none specified on server */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
806 gchar *group = g_strdup("Gadu-Gadu"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
807 if (strlen(data_tbl[5])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
808 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
809 if (strlen(group_tbl[0])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
810 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
811 group = g_strdup(group_tbl[0]); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
812 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
813 g_strfreev(group_tbl); |
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 /* Add Buddy to our userlist */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
816 add_buddy(gc, group, name, strlen(show) ? show : name); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
817 do_export(gc); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
818 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
819 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
820 g_strfreev(data_tbl); |
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(users_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 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
825 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata) |
2393 | 826 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
827 if (strstr(webdata, "put_success:")) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
828 do_error_dialog(_("Buddies List sucessfully transfered into Server"), |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
829 _("Gadu-Gadu Information")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
830 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
831 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
832 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
833 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
834 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
|
835 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
836 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
837 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
|
838 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
839 if (strstr(webdata, "put_success:")) { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
840 do_error_dialog(_("Buddies List sucessfully deleted from Server"), |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
841 _("Gadu-Gadu Information")); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
842 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
843 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
844 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
845 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
846 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
|
847 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
848 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
849 static void http_results(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
850 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
851 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
852 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
853 char *webdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
854 int len; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
855 char read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
856 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
857 debug_printf("http_results: begin\n"); |
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 if (!g_slist_find(connections, gc)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
860 debug_printf("search_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
861 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
862 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
863 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
864 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
865 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
866 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
867 webdata = NULL; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
868 len = 0; |
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 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
871 if (errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
872 errno = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
873 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
874 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
875 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
876 if (!read_data) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
877 continue; |
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 len++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
880 webdata = g_realloc(webdata, len); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
881 webdata[len - 1] = read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
882 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
883 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
884 webdata = g_realloc(webdata, len + 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
885 webdata[len] = 0; |
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 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
888 close(source); |
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 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
|
891 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
892 switch (hdata->type) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
893 case AGG_HTTP_SEARCH: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
894 search_results(gc, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
895 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
896 case AGG_HTTP_USERLIST_IMPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
897 import_buddies_server_results(gc, webdata); |
2792
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_EXPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
900 export_buddies_server_results(gc, webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
901 break; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
902 case AGG_HTTP_USERLIST_DELETE: |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
903 delete_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
904 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
905 case AGG_HTTP_NONE: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
906 default: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
907 debug_printf("http_results: unsupported type %d\n", hdata->type); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
908 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
909 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
910 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
911 g_free(webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
912 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
913 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
914 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
915 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond) |
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 struct agg_http *hdata = data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
918 struct gaim_connection *gc = hdata->gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
919 gchar *request = hdata->request; |
2393 | 920 gchar *buf; |
921 char *ptr; | |
922 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
923 debug_printf("http_req_callback: begin\n"); |
2393 | 924 |
925 if (!g_slist_find(connections, gc)) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
926 debug_printf("http_req_callback: g_slist_find error\n"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
927 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
928 g_free(hdata); |
2393 | 929 close(source); |
930 return; | |
931 } | |
932 | |
933 if (source == -1) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
934 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
935 g_free(hdata); |
2393 | 936 return; |
937 } | |
938 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
939 ptr = encode_postdata(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
940 g_free(request); |
2393 | 941 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
942 debug_printf("http_req_callback: http request [%s]\n", ptr); |
2393 | 943 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
944 buf = g_strdup_printf("POST %s HTTP/1.0\r\n" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
945 "Host: %s\r\n" |
2393 | 946 "Content-Type: application/x-www-form-urlencoded\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
947 "User-Agent: " GG_HTTP_USERAGENT "\r\n" |
2393 | 948 "Content-Length: %d\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
949 "Pragma: no-cache\r\n" "\r\n" "%s\r\n", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
950 hdata->form, hdata->host, strlen(ptr), ptr); |
2393 | 951 |
952 g_free(ptr); | |
953 | |
954 if (write(source, buf, strlen(buf)) < strlen(buf)) { | |
955 g_free(buf); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
956 g_free(hdata); |
2393 | 957 close(source); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
958 do_error_dialog(_("Couldn't send http request"), _("Gadu-Gadu Error")); |
2393 | 959 return; |
960 } | |
961 | |
962 g_free(buf); | |
963 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
964 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
|
965 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
966 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
967 static void import_buddies_server(struct gaim_connection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
968 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
969 struct agg_http *hi = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
970 static char msg[AGG_BUF_LEN]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
971 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
972 hi->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
973 hi->type = AGG_HTTP_USERLIST_IMPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
974 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
975 hi->host = GG_PUBDIR_HOST; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
976 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
|
977 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
978 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
|
979 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
|
980 GG_PUBDIR_HOST); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
981 do_error_dialog(msg, _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
982 g_free(hi->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
983 g_free(hi); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
984 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
985 } |
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 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
988 static void export_buddies_server(struct gaim_connection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
989 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
990 struct agg_http *he = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
991 static char msg[AGG_BUF_LEN]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
992 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
993 GSList *gr = gc->groups; |
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 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
996 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
997 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
998 he->host = GG_PUBDIR_HOST; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
999 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
|
1000 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1001 while (gr) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1002 struct group *g = gr->data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1003 GSList *m = g->members; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1004 while (m) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1005 struct buddy *b = m->data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1006 gchar *newdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1007 /* GG Number */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1008 gchar *name = b->name; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1009 /* GG Pseudo */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1010 gchar *show = strlen(b->show) ? b->show : b->name; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1011 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1012 ptr = he->request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1013 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
|
1014 show, show, show, show, "", g->name, name); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1015 he->request = g_strconcat(ptr, newdata, NULL); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1016 g_free(newdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1017 g_free(ptr); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1018 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1019 m = g_slist_next(m); |
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 gr = g_slist_next(gr); |
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 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1024 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
|
1025 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
|
1026 GG_PUBDIR_HOST); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1027 do_error_dialog(msg, _("Gadu-Gadu Error")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1028 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1029 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1030 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1031 } |
2393 | 1032 } |
1033 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1034 static void delete_buddies_server(struct gaim_connection *gc) |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1035 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1036 struct agg_http *he = g_new0(struct agg_http, 1); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1037 static char msg[AGG_BUF_LEN]; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1038 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1039 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1040 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1041 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1042 he->host = GG_PUBDIR_HOST; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1043 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
|
1044 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1045 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
|
1046 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
|
1047 GG_PUBDIR_HOST); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1048 do_error_dialog(msg, _("Gadu-Gadu Error")); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1049 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1050 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1051 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1052 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1053 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1054 |
2393 | 1055 static void agg_dir_search(struct gaim_connection *gc, char *first, char *middle, |
1056 char *last, char *maiden, char *city, char *state, char *country, char *email) | |
1057 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1058 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1059 static char msg[AGG_BUF_LEN]; |
1060 | |
1061 srch->gc = gc; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1062 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1063 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1064 srch->host = GG_PUBDIR_HOST; |
2393 | 1065 |
1066 if (email && strlen(email)) { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1067 srch->request = g_strdup_printf("Mode=1&Email=%s", email); |
2393 | 1068 } else { |
1069 gchar *new_first = charset_convert(first, find_local_charset(), "CP1250"); | |
1070 gchar *new_last = charset_convert(last, find_local_charset(), "CP1250"); | |
1071 gchar *new_city = charset_convert(city, find_local_charset(), "CP1250"); | |
1072 | |
1073 /* For active only add &ActiveOnly= */ | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1074 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
|
1075 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1076 new_first, new_last, AGG_GENDER_NONE, |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1077 "", new_city, 0, 0); |
2393 | 1078 |
1079 g_free(new_first); | |
1080 g_free(new_last); | |
1081 g_free(new_city); | |
1082 } | |
1083 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1084 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
2393 | 1085 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST); |
1086 do_error_dialog(msg, _("Gadu-Gadu Error")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1087 g_free(srch->request); |
2393 | 1088 g_free(srch); |
1089 return; | |
1090 } | |
1091 } | |
1092 | |
1093 static void agg_do_action(struct gaim_connection *gc, char *action) | |
1094 { | |
1095 if (!strcmp(action, _("Directory Search"))) { | |
1096 show_find_info(gc); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1097 } else if (!strcmp(action, _("Import Buddies List from Server"))) { |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1098 import_buddies_server(gc); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1099 } else if (!strcmp(action, _("Export Buddies List to Server"))) { |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1100 export_buddies_server(gc); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1101 } else if (!strcmp(action, _("Delete Buddies List from Server"))) { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1102 delete_buddies_server(gc); |
2393 | 1103 } |
1104 } | |
1105 | |
1106 static GList *agg_actions() | |
1107 { | |
1108 GList *m = NULL; | |
1109 | |
1110 m = g_list_append(m, _("Directory Search")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1111 m = g_list_append(m, _("Import Buddies List from Server")); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1112 m = g_list_append(m, _("Export Buddies List to Server")); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1113 m = g_list_append(m, _("Delete Buddies List from Server")); |
2393 | 1114 |
1115 return m; | |
1116 } | |
1117 | |
1118 static void agg_get_info(struct gaim_connection *gc, char *who) | |
1119 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1120 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1121 static char msg[AGG_BUF_LEN]; |
1122 | |
1123 srch->gc = gc; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1124 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1125 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1126 srch->host = GG_PUBDIR_HOST; |
2393 | 1127 |
1128 /* If it's invalid uin then maybe it's nickname? */ | |
1129 if (invalid_uin(who)) { | |
1130 gchar *new_who = charset_convert(who, find_local_charset(), "CP1250"); | |
1131 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1132 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
|
1133 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1134 "", "", AGG_GENDER_NONE, new_who, "", 0, 0); |
2393 | 1135 |
1136 g_free(new_who); | |
1137 } else | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1138 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1139 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1140 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
2393 | 1141 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST); |
1142 do_error_dialog(msg, _("Gadu-Gadu Error")); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1143 g_free(srch->request); |
2393 | 1144 g_free(srch); |
1145 return; | |
1146 } | |
1147 } | |
1148 | |
1149 static char **agg_list_icon(int uc) | |
1150 { | |
1151 guint status; | |
1152 if (uc == UC_UNAVAILABLE) | |
1153 return (char **)gg_sunred_xpm; | |
1154 status = uc >> 5; | |
1155 /* Drop all masks */ | |
1156 status &= ~(GG_STATUS_FRIENDS_MASK); | |
1157 if (status == GG_STATUS_AVAIL) | |
1158 return (char **)gg_sunyellow_xpm; | |
1159 if (status == GG_STATUS_BUSY) | |
1160 return (char **)gg_suncloud_xpm; | |
1161 if (status == GG_STATUS_INVISIBLE) | |
1162 return (char **)gg_sunwhitered_xpm; | |
1163 return (char **)gg_sunyellow_xpm; | |
1164 } | |
1165 | |
1166 static void agg_set_permit_deny_dummy(struct gaim_connection *gc) | |
1167 { | |
1168 /* It's implemented on client side because GG server doesn't support this */ | |
1169 } | |
1170 | |
1171 static void agg_permit_deny_dummy(struct gaim_connection *gc, char *who) | |
1172 { | |
1173 /* It's implemented on client side because GG server doesn't support this */ | |
1174 } | |
1175 | |
1176 static struct prpl *my_protocol = NULL; | |
1177 | |
2423
ce09589b7681
[gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1178 void gg_init(struct prpl *ret) |
2393 | 1179 { |
1180 ret->protocol = PROTO_GADUGADU; | |
1181 ret->options = 0; | |
1182 ret->name = agg_name; | |
1183 ret->list_icon = agg_list_icon; | |
1184 ret->away_states = agg_away_states; | |
1185 ret->actions = agg_actions; | |
1186 ret->do_action = agg_do_action; | |
1187 ret->user_opts = agg_user_opts; | |
1188 ret->buddy_menu = agg_buddy_menu; | |
1189 ret->chat_info = NULL; | |
1190 ret->login = agg_login; | |
1191 ret->close = agg_close; | |
1192 ret->send_im = agg_send_im; | |
1193 ret->set_info = NULL; | |
1194 ret->get_info = agg_get_info; | |
1195 ret->set_away = agg_set_away; | |
1196 ret->set_dir = NULL; | |
1197 ret->get_dir = agg_get_info; | |
1198 ret->dir_search = agg_dir_search; | |
1199 ret->set_idle = NULL; | |
1200 ret->change_passwd = NULL; | |
1201 ret->add_buddy = agg_add_buddy; | |
1202 ret->add_buddies = agg_add_buddies; | |
1203 ret->remove_buddy = agg_rem_buddy; | |
1204 ret->add_permit = agg_permit_deny_dummy; | |
1205 ret->add_deny = agg_permit_deny_dummy; | |
1206 ret->rem_permit = agg_permit_deny_dummy; | |
1207 ret->rem_deny = agg_permit_deny_dummy; | |
1208 ret->set_permit_deny = agg_set_permit_deny_dummy; | |
1209 ret->warn = NULL; | |
1210 ret->join_chat = NULL; | |
1211 ret->chat_invite = NULL; | |
1212 ret->chat_leave = NULL; | |
1213 ret->chat_whisper = NULL; | |
1214 ret->chat_send = NULL; | |
1215 ret->keepalive = agg_keepalive; | |
1216 ret->normalize = NULL; | |
1217 my_protocol = ret; | |
1218 } | |
1219 | |
1220 #ifndef STATIC | |
1221 | |
1222 char *gaim_plugin_init(GModule *handle) | |
1223 { | |
2423
ce09589b7681
[gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2393
diff
changeset
|
1224 load_protocol(gg_init, sizeof(struct prpl)); |
2393 | 1225 return NULL; |
1226 } | |
1227 | |
1228 void gaim_plugin_remove() | |
1229 { | |
1230 struct prpl *p = find_prpl(PROTO_GADUGADU); | |
1231 if (p == my_protocol) | |
1232 unload_protocol(p); | |
1233 } | |
1234 | |
1235 char *name() | |
1236 { | |
1237 return "Gadu-Gadu"; | |
1238 } | |
1239 | |
1240 char *description() | |
1241 { | |
1242 return PRPL_DESC("Gadu-Gadu"); | |
1243 } | |
1244 | |
1245 #endif |