Mercurial > pidgin
annotate src/protocols/gg/gg.c @ 11118:134d0001983d
[gaim-migrate @ 13174]
Some new xsubs for the perl interpreter and a work around to get it all working again.
committer: Tailor Script <tailor@pidgin.im>
author | John H. Kelm <johnkelm@gmail.com> |
---|---|
date | Mon, 18 Jul 2005 13:37:38 +0000 |
parents | 64895571248f |
children | bb0d7b719af2 |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
3 * | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
4 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5 * |
2393 | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
21 #include "internal.h" |
2393 | 22 |
23 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */ | |
24 #include "libgg.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
25 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
26 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
27 #include "accountopt.h" |
9030 | 28 #include "blist.h" |
10740 | 29 #include "connection.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
30 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
31 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
32 #include "proxy.h" |
2393 | 33 #include "prpl.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
34 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
35 #include "util.h" |
9943 | 36 #include "version.h" |
2393 | 37 |
5603 | 38 #define GG_CONNECT_STEPS 5 |
39 | |
2393 | 40 #define AGG_BUF_LEN 1024 |
41 | |
42 #define AGG_GENDER_NONE -1 | |
43 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
44 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
45 #define AGG_PUBDIR_USERLIST_IMPORT_FORM "/appsvc/fmcontactsget.asp" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
46 #define AGG_PUBDIR_SEARCH_FORM "/appsvc/fmpubquery2.asp" |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
47 #define AGG_REGISTER_DATA_FORM "/appsvc/fmregister.asp" |
2393 | 48 #define AGG_PUBDIR_MAX_ENTRIES 200 |
49 | |
50 #define AGG_STATUS_AVAIL _("Available") | |
51 #define AGG_STATUS_AVAIL_FRIENDS _("Available for friends only") | |
52 #define AGG_STATUS_BUSY _("Away") | |
53 #define AGG_STATUS_BUSY_FRIENDS _("Away for friends only") | |
54 #define AGG_STATUS_INVISIBLE _("Invisible") | |
55 #define AGG_STATUS_INVISIBLE_FRIENDS _("Invisible for friends only") | |
56 #define AGG_STATUS_NOT_AVAIL _("Unavailable") | |
57 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
58 #define AGG_HTTP_NONE 0 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
59 #define AGG_HTTP_SEARCH 1 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
60 #define AGG_HTTP_USERLIST_IMPORT 2 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
61 #define AGG_HTTP_USERLIST_EXPORT 3 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
62 #define AGG_HTTP_USERLIST_DELETE 4 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
63 #define AGG_HTTP_PASSWORD_CHANGE 5 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
64 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
65 #define UC_NORMAL 2 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2423
diff
changeset
|
66 |
2393 | 67 struct agg_data { |
68 struct gg_session *sess; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
69 int own_status; |
2393 | 70 }; |
71 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
72 struct agg_http { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
73 GaimConnection *gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
74 gchar *request; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
75 gchar *form; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
76 gchar *host; |
2393 | 77 int inpa; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
78 int type; |
2393 | 79 }; |
80 | |
81 | |
3466 | 82 static gchar *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) |
2393 | 83 { |
10407 | 84 gchar *msg; |
85 GError *err = NULL; | |
86 | |
87 msg = g_convert_with_fallback(locstr, strlen(locstr), encdst, encsrc, "?", NULL, NULL, &err); | |
88 if (err != NULL) { | |
89 gaim_debug_error("gg", "Error converting from %s to %s: %s\n", | |
90 encsrc, encdst, err->message); | |
91 g_error_free(err); | |
92 } | |
93 | |
94 /* Just in case? */ | |
95 if (msg == NULL) | |
96 msg = g_strdup(locstr); | |
97 | |
98 return msg; | |
2393 | 99 } |
100 | |
3466 | 101 static gboolean invalid_uin(const char *uin) |
2393 | 102 { |
103 unsigned long int res = strtol(uin, (char **)NULL, 10); | |
7631 | 104 if (res == ULONG_MAX || res == 0) |
2393 | 105 return TRUE; |
106 return FALSE; | |
107 } | |
108 | |
109 static gint args_compare(gconstpointer a, gconstpointer b) | |
110 { | |
4793 | 111 return g_ascii_strcasecmp((const gchar *)a,(const gchar *)b); |
2393 | 112 } |
113 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
114 static gboolean allowed_uin(GaimConnection *gc, char *uin) |
2393 | 115 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
116 GaimAccount *account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
117 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
118 switch (account->perm_deny) { |
2393 | 119 case 1: |
120 /* permit all, deny none */ | |
121 return TRUE; | |
122 break; | |
123 case 2: | |
124 /* deny all, permit none. */ | |
125 return FALSE; | |
126 break; | |
127 case 3: | |
128 /* permit some. */ | |
4491 | 129 if (g_slist_find_custom(gc->account->permit, uin, args_compare)) |
2393 | 130 return TRUE; |
131 return FALSE; | |
132 break; | |
133 case 4: | |
134 /* deny some. */ | |
4491 | 135 if (g_slist_find_custom(gc->account->deny, uin, args_compare)) |
2393 | 136 return FALSE; |
137 return TRUE; | |
138 break; | |
139 default: | |
140 return TRUE; | |
141 break; | |
142 } | |
143 } | |
144 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
145 static char *handle_errcode(GaimConnection *gc, int errcode) |
2393 | 146 { |
147 static char msg[AGG_BUF_LEN]; | |
148 | |
149 switch (errcode) { | |
150 case GG_FAILURE_RESOLVING: | |
151 g_snprintf(msg, sizeof(msg), _("Unable to resolve hostname.")); | |
152 break; | |
153 case GG_FAILURE_CONNECTING: | |
154 g_snprintf(msg, sizeof(msg), _("Unable to connect to server.")); | |
155 break; | |
156 case GG_FAILURE_INVALID: | |
157 g_snprintf(msg, sizeof(msg), _("Invalid response from server.")); | |
158 break; | |
159 case GG_FAILURE_READING: | |
160 g_snprintf(msg, sizeof(msg), _("Error while reading from socket.")); | |
161 break; | |
162 case GG_FAILURE_WRITING: | |
3100 | 163 g_snprintf(msg, sizeof(msg), _("Error while writing to socket.")); |
2393 | 164 break; |
165 case GG_FAILURE_PASSWORD: | |
3100 | 166 g_snprintf(msg, sizeof(msg), _("Authentication failed.")); |
2393 | 167 break; |
168 default: | |
169 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); | |
170 break; | |
171 } | |
172 | |
5603 | 173 gaim_connection_error(gc, msg); |
2393 | 174 |
175 return msg; | |
176 } | |
177 | |
9950 | 178 static void agg_set_status(GaimAccount *account, GaimStatus *status) |
2393 | 179 { |
10751 | 180 GaimConnection *gc; |
181 struct agg_data *gd; | |
10863 | 182 gboolean connected; |
183 GaimStatusType *type; | |
184 int primitive; | |
10751 | 185 int status_num; |
9950 | 186 const char *status_id; |
187 char *msg = NULL; | |
10206 | 188 |
10863 | 189 connected = gaim_account_is_connected(account); |
190 type = gaim_status_get_type(status); | |
191 primitive = gaim_status_type_get_primitive(type); | |
10751 | 192 |
10863 | 193 if (!gaim_status_is_active(status)) |
10751 | 194 return; |
195 | |
10863 | 196 if (!connected) { |
197 if (primitive != GAIM_STATUS_OFFLINE) | |
198 gaim_account_connect(account); | |
199 return; | |
200 } | |
201 | |
202 if (primitive == GAIM_STATUS_OFFLINE) { | |
203 gaim_account_disconnect(account); | |
204 return; | |
205 } | |
206 | |
207 gc = gaim_account_get_connection(account); | |
10751 | 208 gd = (struct agg_data *)gc->proto_data; |
209 status_num = gd->own_status; | |
9950 | 210 status_id = gaim_status_get_id(status); |
10206 | 211 |
9950 | 212 if (!strcmp(status_id, "available")) |
213 status_num = GG_STATUS_AVAIL; | |
214 else if (!strcmp(status_id, "available-friends")) | |
215 status_num = GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK; | |
216 else if (!strcmp(status_id, "away")) | |
217 status_num = GG_STATUS_BUSY; | |
218 else if (!strcmp(status_id, "away-friends")) | |
219 status_num = GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK; | |
220 else if (!strcmp(status_id, "invisible")) | |
221 status_num = GG_STATUS_INVISIBLE; | |
222 else if (!strcmp(status_id, "invisible-friends")) | |
223 status_num = GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK; | |
224 else if (!strcmp(status_id, "unavailable")) | |
225 status_num = GG_STATUS_NOT_AVAIL; | |
226 else | |
10206 | 227 /* Don't need to do anything */ |
228 return; | |
2393 | 229 |
9950 | 230 /* XXX: this was added between the status_rewrite and now and needs to be fixed */ |
10206 | 231 if (msg != NULL) { |
9950 | 232 switch (status_num) { |
9415 | 233 case GG_STATUS_AVAIL: |
9950 | 234 status_num = GG_STATUS_AVAIL_DESCR; |
9415 | 235 break; |
236 case GG_STATUS_BUSY: | |
9950 | 237 status_num = GG_STATUS_BUSY_DESCR; |
9415 | 238 break; |
239 case GG_STATUS_INVISIBLE: | |
9950 | 240 status_num = GG_STATUS_INVISIBLE_DESCR; |
9415 | 241 break; |
242 case GG_STATUS_NOT_AVAIL: | |
9950 | 243 status_num = GG_STATUS_NOT_AVAIL_DESCR; |
9415 | 244 break; |
245 } | |
246 } | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
247 |
9950 | 248 gd->own_status = status_num; |
249 | |
9415 | 250 if (msg) |
9950 | 251 gg_change_status_descr(gd->sess, status_num, msg); |
9415 | 252 else |
9950 | 253 gg_change_status(gd->sess, status_num); |
9415 | 254 } |
255 | |
9950 | 256 |
9421 | 257 #if 0 |
9415 | 258 static void agg_get_away(GaimConnection *gc, const char *who) |
259 { | |
260 GaimBuddy *buddy; | |
261 char *dialog_msg, **splitmsg; | |
262 | |
263 if (invalid_uin(who)) | |
9421 | 264 return; |
9415 | 265 |
266 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | |
267 if (buddy->proto_data) { | |
9421 | 268 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ |
269 splitmsg = g_strsplit(buddy->proto_data, "\r\n", 0); | |
9415 | 270 |
9421 | 271 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, (char *)buddy->proto_data, g_strjoinv("<BR>", splitmsg)); |
9797 | 272 gaim_notify_userinfo(gc, who, NULL, _("Buddy Information"), buddy->proto_data, dialog_msg, NULL, NULL); |
9415 | 273 } |
2393 | 274 } |
9421 | 275 #endif |
2393 | 276 |
9950 | 277 static gchar *get_away_text(GaimBuddy *buddy) |
2393 | 278 { |
9950 | 279 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
280 | |
281 if (gaim_presence_is_status_active(presence, "available")) | |
2393 | 282 return AGG_STATUS_AVAIL; |
9950 | 283 else if (gaim_presence_is_status_active(presence, "available-friends")) |
2393 | 284 return AGG_STATUS_AVAIL_FRIENDS; |
9950 | 285 else if (gaim_presence_is_status_active(presence, "away")) |
2393 | 286 return AGG_STATUS_BUSY; |
9950 | 287 else if (gaim_presence_is_status_active(presence, "away-friends")) |
2393 | 288 return AGG_STATUS_BUSY_FRIENDS; |
9950 | 289 else if (gaim_presence_is_status_active(presence, "invisible")) |
290 return AGG_STATUS_INVISIBLE; | |
291 else if (gaim_presence_is_status_active(presence, "invisible-friends")) | |
292 return AGG_STATUS_INVISIBLE_FRIENDS; | |
293 else if (gaim_presence_is_status_active(presence, "unavailable")) | |
2393 | 294 return AGG_STATUS_NOT_AVAIL; |
9950 | 295 |
296 return AGG_STATUS_AVAIL; | |
2393 | 297 } |
298 | |
9950 | 299 |
300 static GList *agg_status_types(GaimAccount *account) | |
2393 | 301 { |
9950 | 302 GaimStatusType *type; |
303 GList *types = NULL; | |
304 | |
305 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, "offline", | |
306 _("Offline"), FALSE); | |
307 types = g_list_append(types, type); | |
308 | |
309 type = gaim_status_type_new(GAIM_STATUS_ONLINE, "online", | |
310 _("Online"), FALSE); | |
311 types = g_list_append(types, type); | |
312 | |
313 type = gaim_status_type_new_with_attrs( | |
314 GAIM_STATUS_AVAILABLE, "available", AGG_STATUS_AVAIL, | |
315 TRUE, TRUE, FALSE, | |
10009 | 316 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 317 types = g_list_append(types, type); |
318 | |
319 type = gaim_status_type_new_with_attrs( | |
320 GAIM_STATUS_AWAY, "away", AGG_STATUS_BUSY, | |
321 TRUE, TRUE, FALSE, | |
10009 | 322 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 323 types = g_list_append(types, type); |
2393 | 324 |
9950 | 325 type = gaim_status_type_new_with_attrs( |
326 GAIM_STATUS_HIDDEN, "invisible", AGG_STATUS_INVISIBLE, | |
327 TRUE, TRUE, FALSE, | |
10009 | 328 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 329 types = g_list_append(types, type); |
330 | |
331 type = gaim_status_type_new_with_attrs( | |
332 GAIM_STATUS_AVAILABLE, "available-friends", AGG_STATUS_AVAIL_FRIENDS, | |
333 TRUE, TRUE, FALSE, | |
10009 | 334 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 335 types = g_list_append(types, type); |
336 | |
337 type = gaim_status_type_new_with_attrs( | |
338 GAIM_STATUS_AWAY, "away-friends", AGG_STATUS_BUSY_FRIENDS, | |
339 TRUE, TRUE, FALSE, | |
10009 | 340 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 341 types = g_list_append(types, type); |
342 | |
343 type = gaim_status_type_new_with_attrs( | |
10206 | 344 GAIM_STATUS_HIDDEN, "invisible-friends", AGG_STATUS_INVISIBLE_FRIENDS, |
9950 | 345 TRUE, TRUE, FALSE, |
10009 | 346 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 347 types = g_list_append(types, type); |
348 | |
349 type = gaim_status_type_new_with_attrs( | |
350 GAIM_STATUS_UNAVAILABLE, "unavailable", AGG_STATUS_NOT_AVAIL, | |
351 TRUE, TRUE, FALSE, | |
10009 | 352 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9950 | 353 types = g_list_append(types, type); |
354 | |
355 return types; | |
2393 | 356 } |
357 | |
358 /* Enhance these functions, more options and such stuff */ | |
9030 | 359 static GList *agg_buddy_menu(GaimBuddy *buddy) |
2393 | 360 { |
361 GList *m = NULL; | |
9030 | 362 GaimBlistNodeAction *act; |
363 | |
2393 | 364 static char buf[AGG_BUF_LEN]; |
9950 | 365 g_snprintf(buf, sizeof(buf), _("Status: %s"), get_away_text(buddy)); |
2393 | 366 |
9030 | 367 /* um... this seems silly. since in this pass, I'm only converting |
368 over the menu building, I'm not going to mess with it though */ | |
369 /* XXX: shouldn't this be in the tooltip instead? */ | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10630
diff
changeset
|
370 act = gaim_blist_node_action_new(buf, NULL, NULL, NULL); |
9030 | 371 m = g_list_append(m, act); |
2393 | 372 |
373 return m; | |
374 } | |
375 | |
9030 | 376 |
377 static GList * | |
378 agg_blist_node_menu(GaimBlistNode *node) | |
379 { | |
380 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
381 return agg_buddy_menu((GaimBuddy *) node); | |
382 } else { | |
383 return NULL; | |
384 } | |
385 } | |
386 | |
387 | |
8775 | 388 static void agg_load_buddy_list(GaimConnection *gc, char *buddylist) |
389 { | |
390 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
391 gchar *ptr = buddylist; | |
392 gchar **users_tbl; | |
393 int i; | |
394 uin_t *userlist = NULL; | |
395 int userlist_size = 0; | |
396 | |
397 users_tbl = g_strsplit(ptr, "\r\n", AGG_PUBDIR_MAX_ENTRIES); | |
398 | |
399 /* Parse array of Buddies List */ | |
400 for (i = 0; users_tbl[i] != NULL; i++) { | |
401 gchar **data_tbl; | |
402 gchar *name, *show; | |
403 | |
404 if (strlen(users_tbl[i])==0) { | |
405 gaim_debug(GAIM_DEBUG_MISC, "gg", | |
406 "import_buddies_server_results: users_tbl[i] is empty\n"); | |
407 continue; | |
408 } | |
409 | |
410 data_tbl = g_strsplit(users_tbl[i], ";", 8); | |
411 | |
412 show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); | |
413 name = data_tbl[6]; | |
8996 | 414 |
8775 | 415 if (invalid_uin(name)) { |
416 continue; | |
417 } | |
418 | |
419 gaim_debug(GAIM_DEBUG_MISC, "gg", | |
420 "import_buddies_server_results: uin: %s\n", name); | |
421 if (!gaim_find_buddy(gc->account, name)) { | |
422 GaimBuddy *b; | |
423 GaimGroup *g; | |
424 /* Default group if none specified on server */ | |
425 gchar *group = g_strdup("Gadu-Gadu"); | |
426 if (strlen(data_tbl[5])) { | |
427 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); | |
428 if (strlen(group_tbl[0])) { | |
429 g_free(group); | |
430 group = g_strdup(group_tbl[0]); | |
431 } | |
432 g_strfreev(group_tbl); | |
433 } | |
434 /* Add Buddy to our userlist */ | |
435 if (!(g = gaim_find_group(group))) { | |
436 g = gaim_group_new(group); | |
437 gaim_blist_add_group(g, NULL); | |
438 } | |
439 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); | |
440 gaim_blist_add_buddy(b,NULL,g,NULL); | |
8996 | 441 |
8775 | 442 userlist_size++; |
443 userlist = g_renew(uin_t, userlist, userlist_size); | |
444 userlist[userlist_size - 1] = | |
445 (uin_t) strtol((char *)name, (char **)NULL, 10); | |
8996 | 446 |
8775 | 447 g_free(group); |
448 } | |
449 g_free(show); | |
450 g_strfreev(data_tbl); | |
451 } | |
452 g_strfreev(users_tbl); | |
8996 | 453 |
8775 | 454 if (userlist) { |
455 gg_notify(gd->sess, userlist, userlist_size); | |
456 g_free(userlist); | |
457 } | |
458 } | |
459 | |
9285 | 460 static void agg_save_buddy_list(GaimConnection *gc, char *existlist) |
8775 | 461 { |
9285 | 462 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
8775 | 463 GaimBlistNode *gnode, *cnode, *bnode; |
464 char *buddylist = g_strdup(existlist ? existlist : ""); | |
465 char *ptr; | |
466 | |
467 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
468 GaimGroup *g = (GaimGroup *)gnode; | |
469 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
470 continue; | |
471 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
472 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
473 continue; | |
474 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
475 GaimBuddy *b = (GaimBuddy *)bnode; | |
476 | |
477 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
478 continue; | |
479 | |
480 if(b->account == gc->account) { | |
481 gchar *newdata; | |
482 /* GG Number */ | |
483 gchar *name = b->name; | |
484 /* GG Pseudo */ | |
485 gchar *show = b->alias ? b->alias : b->name; | |
486 /* Group Name */ | |
487 gchar *gname = g->name; | |
488 | |
489 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", | |
490 show, show, show, show, "", gname, name, "", ""); | |
8996 | 491 |
8775 | 492 ptr = buddylist; |
493 buddylist = g_strconcat(ptr, newdata, NULL); | |
8996 | 494 |
8775 | 495 g_free(newdata); |
496 g_free(ptr); | |
497 } | |
498 } | |
499 } | |
500 } | |
8996 | 501 |
8775 | 502 /* save the list to the gadu gadu server */ |
503 gg_userlist_request(gd->sess, GG_USERLIST_PUT, buddylist); | |
504 } | |
505 | |
2393 | 506 static void main_callback(gpointer data, gint source, GaimInputCondition cond) |
507 { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
508 GaimConnection *gc = data; |
9944 | 509 GaimAccount *account = gaim_connection_get_account(gc); |
2393 | 510 struct agg_data *gd = gc->proto_data; |
511 struct gg_event *e; | |
512 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
513 gaim_debug(GAIM_DEBUG_INFO, "gg", "main_callback enter: begin\n"); |
2393 | 514 |
515 if (gd->sess->fd != source) | |
516 gd->sess->fd = source; | |
517 | |
4511 | 518 if (source == 0) { |
5603 | 519 gaim_connection_error(gc, _("Could not connect")); |
2393 | 520 return; |
521 } | |
522 | |
523 if (!(e = gg_watch_fd(gd->sess))) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
524 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
525 "main_callback: gg_watch_fd failed - CRITICAL!\n"); |
5603 | 526 gaim_connection_error(gc, _("Unable to read socket")); |
2393 | 527 return; |
528 } | |
529 | |
530 switch (e->type) { | |
531 case GG_EVENT_NONE: | |
532 /* do nothing */ | |
533 break; | |
534 case GG_EVENT_CONN_SUCCESS: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
535 gaim_debug(GAIM_DEBUG_WARNING, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
536 "main_callback: CONNECTED AGAIN!?\n"); |
2393 | 537 break; |
538 case GG_EVENT_CONN_FAILED: | |
539 if (gc->inpa) | |
540 gaim_input_remove(gc->inpa); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
541 handle_errcode(gc, e->event.failure); |
2393 | 542 break; |
543 case GG_EVENT_MSG: | |
544 { | |
545 gchar *imsg; | |
8442 | 546 gchar *jmsg; |
2393 | 547 gchar user[20]; |
548 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
549 g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender); |
2393 | 550 if (!allowed_uin(gc, user)) |
551 break; | |
4051 | 552 imsg = charset_convert(e->event.msg.message, "CP1250", "UTF-8"); |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7386
diff
changeset
|
553 gaim_str_strip_cr(imsg); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
554 jmsg = g_markup_escape_text(imsg, -1); |
10630 | 555 serv_got_im(gc, user, jmsg, 0, e->event.msg.time); |
2393 | 556 g_free(imsg); |
8442 | 557 g_free(jmsg); |
2393 | 558 } |
559 break; | |
560 case GG_EVENT_NOTIFY: | |
561 { | |
562 gchar user[20]; | |
563 struct gg_notify_reply *n = e->event.notify; | |
9950 | 564 const char *status_id; |
2393 | 565 |
566 while (n->uin) { | |
567 switch (n->status) { | |
9950 | 568 case GG_STATUS_NOT_AVAIL: |
569 status_id = "unavailable"; | |
570 break; | |
571 | |
572 case GG_STATUS_AVAIL: | |
573 status_id = "available"; | |
574 break; | |
575 | |
576 case GG_STATUS_BUSY: | |
577 status_id = "away"; | |
578 break; | |
579 | |
580 case GG_STATUS_INVISIBLE: | |
581 status_id = "invisible"; | |
582 break; | |
583 | |
584 default: | |
585 status_id = "available"; | |
586 break; | |
587 | |
2393 | 588 } |
589 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
590 g_snprintf(user, sizeof(user), "%lu", n->uin); |
9950 | 591 gaim_prpl_got_user_status(account, user, status_id, NULL); |
2393 | 592 n++; |
593 } | |
594 } | |
595 break; | |
8775 | 596 case GG_EVENT_NOTIFY60: |
597 { | |
598 gchar user[20]; | |
9950 | 599 const char *status_id; |
9415 | 600 guint i = 0; |
601 | |
602 for (i = 0; e->event.notify60[i].uin; i++) { | |
603 GaimBuddy *buddy; | |
604 | |
605 g_snprintf(user, sizeof(user), "%lu", (long unsigned int)e->event.notify60[i].uin); | |
8775 | 606 |
9415 | 607 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); |
608 if (buddy && buddy->proto_data != NULL) { | |
609 g_free(buddy->proto_data); | |
610 buddy->proto_data = NULL; | |
611 } | |
612 | |
613 switch (e->event.notify60[i].status) { | |
9950 | 614 case GG_STATUS_NOT_AVAIL: |
615 case GG_STATUS_NOT_AVAIL_DESCR: | |
616 status_id = "unavailable"; | |
617 break; | |
618 | |
619 case GG_STATUS_AVAIL: | |
620 case GG_STATUS_AVAIL_DESCR: | |
621 status_id = "available"; | |
622 break; | |
623 | |
624 case GG_STATUS_BUSY: | |
625 case GG_STATUS_BUSY_DESCR: | |
626 status_id = "away"; | |
627 break; | |
628 | |
629 case GG_STATUS_INVISIBLE: | |
630 case GG_STATUS_INVISIBLE_DESCR: | |
631 status_id = "invisible"; | |
632 break; | |
633 | |
634 default: | |
635 status_id = "available"; | |
636 break; | |
8775 | 637 } |
9415 | 638 |
639 if (buddy && e->event.notify60[i].descr != NULL) { | |
640 buddy->proto_data = g_strdup(e->event.notify60[i].descr); | |
641 } | |
8775 | 642 |
9950 | 643 gaim_prpl_got_user_status(account, user, status_id, NULL); |
9415 | 644 i++; |
8775 | 645 } |
646 } | |
647 break; | |
2393 | 648 case GG_EVENT_STATUS: |
649 { | |
650 gchar user[20]; | |
9950 | 651 const char *status_id; |
2393 | 652 |
653 switch (e->event.status.status) { | |
9950 | 654 case GG_STATUS_NOT_AVAIL: |
655 status_id = "unavailable"; | |
656 break; | |
657 | |
658 case GG_STATUS_AVAIL: | |
659 status_id = "available"; | |
660 break; | |
661 | |
662 case GG_STATUS_BUSY: | |
663 status_id = "away"; | |
664 break; | |
665 | |
666 case GG_STATUS_INVISIBLE: | |
667 status_id = "invisible"; | |
668 break; | |
669 | |
670 default: | |
671 status_id = "available"; | |
672 break; | |
2393 | 673 } |
674 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
675 g_snprintf(user, sizeof(user), "%lu", e->event.status.uin); |
9950 | 676 gaim_prpl_got_user_status(account, user, status_id, NULL); |
2393 | 677 } |
678 break; | |
8775 | 679 case GG_EVENT_STATUS60: |
680 { | |
681 gchar user[20]; | |
9950 | 682 const char *status_id; |
8775 | 683 |
9415 | 684 GaimBuddy *buddy; |
685 | |
686 g_snprintf(user, sizeof(user), "%lu", e->event.status60.uin); | |
687 | |
688 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); | |
689 if (buddy && buddy->proto_data != NULL) { | |
690 g_free(buddy->proto_data); | |
691 buddy->proto_data = NULL; | |
692 } | |
693 | |
8775 | 694 switch (e->event.status60.status) { |
9950 | 695 case GG_STATUS_NOT_AVAIL_DESCR: |
696 case GG_STATUS_NOT_AVAIL: | |
697 status_id = "unavailable"; | |
698 break; | |
699 | |
700 case GG_STATUS_AVAIL: | |
701 case GG_STATUS_AVAIL_DESCR: | |
702 status_id = "available"; | |
703 break; | |
704 | |
705 case GG_STATUS_BUSY: | |
706 case GG_STATUS_BUSY_DESCR: | |
707 status_id = "away"; | |
708 break; | |
709 | |
710 case GG_STATUS_INVISIBLE: | |
711 case GG_STATUS_INVISIBLE_DESCR: | |
712 status_id = "invisible"; | |
713 break; | |
714 | |
715 default: | |
716 status_id = "available"; | |
717 break; | |
8775 | 718 } |
9950 | 719 |
9415 | 720 if (buddy && e->event.status60.descr != NULL) { |
721 buddy->proto_data = g_strdup(e->event.status60.descr); | |
722 } | |
9950 | 723 |
724 gaim_prpl_got_user_status(account, user, status_id, NULL); | |
8775 | 725 } |
8997 | 726 break; |
2393 | 727 case GG_EVENT_ACK: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
728 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
729 "main_callback: message %d to %lu sent with status %d\n", |
2393 | 730 e->event.ack.seq, e->event.ack.recipient, e->event.ack.status); |
731 break; | |
8775 | 732 case GG_EVENT_USERLIST: |
733 { | |
734 gaim_debug(GAIM_DEBUG_MISC, "gg", "main_callback: received userlist reply\n"); | |
735 switch (e->event.userlist.type) { | |
736 case GG_USERLIST_GET_REPLY: | |
737 { | |
8996 | 738 |
8775 | 739 if (e->event.userlist.reply) { |
740 agg_load_buddy_list(gc, e->event.userlist.reply); | |
741 } | |
742 break; | |
743 } | |
744 | |
745 case GG_USERLIST_PUT_REPLY: | |
746 { | |
747 /* ignored */ | |
748 } | |
749 } | |
750 } | |
751 | |
2393 | 752 default: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
753 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
754 "main_callback: unsupported event %d\n", e->type); |
2393 | 755 break; |
756 } | |
757 gg_free_event(e); | |
758 } | |
759 | |
10869 | 760 static void agg_send_buddylist(GaimConnection *gc) |
761 { | |
762 GaimBuddyList *blist; | |
763 GaimBlistNode *gnode, *cnode, *bnode; | |
764 GaimBuddy *buddy; | |
765 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
766 uin_t *userlist = NULL; | |
767 int userlist_size = 0; | |
768 | |
769 if ((blist = gaim_get_blist()) != NULL) | |
770 { | |
771 for (gnode = blist->root; gnode != NULL; gnode = gnode->next) | |
772 { | |
773 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
774 continue; | |
775 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) | |
776 { | |
777 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
778 continue; | |
779 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) | |
780 { | |
781 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
782 continue; | |
783 buddy = (GaimBuddy *)bnode; | |
784 if (invalid_uin(buddy->name)) | |
785 continue; | |
786 userlist_size++; | |
787 userlist = g_renew(uin_t, userlist, userlist_size); | |
788 userlist[userlist_size - 1] = | |
789 (uin_t) strtol(buddy->name, (char **)NULL, 10); | |
790 } | |
791 } | |
792 } | |
793 } | |
794 | |
795 if (userlist) { | |
796 gg_notify(gd->sess, userlist, userlist_size); | |
797 g_free(userlist); | |
798 } | |
799 | |
800 agg_save_buddy_list(gc, NULL); | |
801 } | |
802 | |
3630 | 803 void login_callback(gpointer data, gint source, GaimInputCondition cond) |
2393 | 804 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
805 GaimConnection *gc = data; |
2393 | 806 struct agg_data *gd = gc->proto_data; |
807 struct gg_event *e; | |
808 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
809 gaim_debug(GAIM_DEBUG_INFO, "gg", "login_callback...\n"); |
5605 | 810 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2393 | 811 close(source); |
812 return; | |
813 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
814 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
815 gaim_debug(GAIM_DEBUG_INFO, "gg", "Found GG connection\n"); |
5603 | 816 |
4511 | 817 if (source == 0) { |
5603 | 818 gaim_connection_error(gc, _("Unable to connect.")); |
2393 | 819 return; |
820 } | |
4452 | 821 |
822 gd->sess->fd = source; | |
823 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
824 gaim_debug(GAIM_DEBUG_MISC, "gg", "Source is valid.\n"); |
3630 | 825 if (gc->inpa == 0) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
826 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
827 "login_callback.. checking gc->inpa .. is 0.. setting fd watch\n"); |
2393 | 828 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
829 gaim_debug(GAIM_DEBUG_INFO, "gg", "Adding watch on fd\n"); |
3630 | 830 } |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
831 gaim_debug(GAIM_DEBUG_INFO, "gg", "Checking State.\n"); |
2393 | 832 switch (gd->sess->state) { |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
833 case GG_STATE_READING_DATA: |
8896 | 834 gaim_connection_update_progress(gc, _("Reading data"), 1, GG_CONNECT_STEPS); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
835 break; |
2393 | 836 case GG_STATE_CONNECTING_GG: |
8896 | 837 gaim_connection_update_progress(gc, _("Balancer handshake"), 2, GG_CONNECT_STEPS); |
2393 | 838 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
839 case GG_STATE_READING_KEY: |
8896 | 840 gaim_connection_update_progress(gc, _("Reading server key"), 3, GG_CONNECT_STEPS); |
2835
d8e67ff8022f
[gaim-migrate @ 2848]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2806
diff
changeset
|
841 break; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
842 case GG_STATE_READING_REPLY: |
8896 | 843 gaim_connection_update_progress(gc, _("Exchanging key hash"), 4, GG_CONNECT_STEPS); |
2393 | 844 break; |
845 default: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
846 gaim_debug(GAIM_DEBUG_INFO, "gg", "No State found\n"); |
2393 | 847 break; |
848 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
849 gaim_debug(GAIM_DEBUG_MISC, "gg", "gg_watch_fd\n"); |
2393 | 850 if (!(e = gg_watch_fd(gd->sess))) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
851 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
852 "login_callback: gg_watch_fd failed - CRITICAL!\n"); |
5603 | 853 gaim_connection_error(gc, _("Critical error in GG library\n")); |
2393 | 854 return; |
855 } | |
856 | |
3630 | 857 /* If we are GG_STATE_CONNECTING_GG then we still need to connect, as |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
858 we could not use gaim_proxy_connect in libgg.c */ |
3630 | 859 switch( gd->sess->state ) { |
860 case GG_STATE_CONNECTING_GG: | |
861 { | |
862 struct in_addr ip; | |
863 char buf[256]; | |
4634 | 864 |
3630 | 865 /* Remove watch on initial socket - now that we have ip and port of login server */ |
866 gaim_input_remove(gc->inpa); | |
867 | |
868 ip.s_addr = gd->sess->server_ip; | |
4634 | 869 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
870 if (gaim_proxy_connect(gc->account, inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { |
3630 | 871 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); |
5603 | 872 gaim_connection_error(gc, buf); |
3630 | 873 return; |
874 } | |
875 break; | |
876 } | |
877 case GG_STATE_READING_KEY: | |
878 /* Set new watch on login server ip */ | |
879 if(gc->inpa) | |
880 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc); | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
881 gaim_debug(GAIM_DEBUG_INFO, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
882 "Setting watch on connection with login server.\n"); |
3630 | 883 break; |
884 }/* end switch() */ | |
885 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
886 gaim_debug(GAIM_DEBUG_MISC, "gg", "checking gg_event\n"); |
2393 | 887 switch (e->type) { |
888 case GG_EVENT_NONE: | |
889 /* nothing */ | |
890 break; | |
891 case GG_EVENT_CONN_SUCCESS: | |
892 /* Setup new input handler */ | |
893 if (gc->inpa) | |
894 gaim_input_remove(gc->inpa); | |
895 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc); | |
896 | |
897 /* Our signon is complete */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
898 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2393 | 899 |
10869 | 900 /* Send the server our buddy list */ |
901 agg_send_buddylist(gc); | |
902 | |
2393 | 903 break; |
904 case GG_EVENT_CONN_FAILED: | |
905 gaim_input_remove(gc->inpa); | |
906 gc->inpa = 0; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
907 handle_errcode(gc, e->event.failure); |
2393 | 908 break; |
909 default: | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
910 gaim_debug(GAIM_DEBUG_MISC, "gg", "no gg_event\n"); |
2393 | 911 break; |
912 } | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
913 gaim_debug(GAIM_DEBUG_INFO, "gg", "Returning from login_callback\n"); |
2393 | 914 gg_free_event(e); |
915 } | |
916 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
917 static void agg_keepalive(GaimConnection *gc) |
2393 | 918 { |
919 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
920 if (gg_ping(gd->sess) < 0) { | |
5603 | 921 gaim_connection_error(gc, _("Unable to ping server")); |
2393 | 922 return; |
923 } | |
924 } | |
925 | |
10401 | 926 static void agg_login(GaimAccount *account, GaimStatus *status) |
2393 | 927 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
928 GaimConnection *gc = gaim_account_get_connection(account); |
2393 | 929 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1); |
930 char buf[80]; | |
931 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
932 #if 0 |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
933 gc->checkbox = _("Send as message"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
934 #endif |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
935 |
2393 | 936 gd->sess = g_new0(struct gg_session, 1); |
937 | |
8896 | 938 gaim_connection_update_progress(gc, _("Looking up GG server"), 0, GG_CONNECT_STEPS); |
2393 | 939 |
4491 | 940 if (invalid_uin(account->username)) { |
5603 | 941 gaim_connection_error(gc, _("Invalid Gadu-Gadu UIN specified")); |
2393 | 942 return; |
943 } | |
944 | |
945 gc->inpa = 0; | |
946 | |
947 /* | |
948 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
949 gaim_debug(GAIM_DEBUG_MISC, "gg", "uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password); |
6321 | 950 gaim_connection_error(gc, _("Unable to connect.")); |
2393 | 951 signoff(gc); |
952 return; | |
953 } | |
954 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
955 gg_login() sucks for me, so I'm using gaim_proxy_connect() |
2393 | 956 */ |
957 | |
4491 | 958 gd->sess->uin = (uin_t) strtol(account->username, (char **)NULL, 10); |
10751 | 959 gd->sess->password = g_strdup(gaim_connection_get_password(gc)); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
960 gd->sess->state = GG_STATE_CONNECTING; |
2393 | 961 gd->sess->check = GG_CHECK_WRITE; |
962 gd->sess->async = 1; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
963 if (gaim_proxy_connect(account, GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { |
2393 | 964 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); |
5603 | 965 gaim_connection_error(gc, buf); |
2393 | 966 return; |
967 } | |
968 } | |
969 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
970 static void agg_close(GaimConnection *gc) |
2393 | 971 { |
972 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
973 if (gc->inpa) | |
974 gaim_input_remove(gc->inpa); | |
975 gg_logoff(gd->sess); | |
3339 | 976 gd->own_status = GG_STATUS_NOT_AVAIL; |
2393 | 977 gg_free_session(gd->sess); |
978 g_free(gc->proto_data); | |
979 } | |
980 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
981 static int agg_send_im(GaimConnection *gc, const char *who, const char *msg, GaimConvImFlags flags) |
2393 | 982 { |
983 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
984 | |
985 if (invalid_uin(who)) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
986 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
987 _("You are trying to send a message to an " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
988 "invalid Gadu-Gadu UIN."), NULL); |
2393 | 989 return -1; |
990 } | |
991 | |
992 if (strlen(msg) > 0) { | |
10868
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
993 gchar *imsg = charset_convert(msg, "UTF-8", "CP1250"); |
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
994 if (imsg != NULL && strlen(imsg) > 0) { |
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
995 if (gg_send_message(gd->sess, GG_CLASS_CHAT, |
2393 | 996 strtol(who, (char **)NULL, 10), imsg) < 0) |
10868
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
997 return -1; |
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
998 } |
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
999 if (imsg != NULL) |
4a56b48dbaa6
[gaim-migrate @ 12555]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10863
diff
changeset
|
1000 g_free(imsg); |
2393 | 1001 } |
1002 return 1; | |
1003 } | |
1004 | |
9285 | 1005 static void agg_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2393 | 1006 { |
1007 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
9285 | 1008 if (invalid_uin(buddy->name)) |
2393 | 1009 return; |
9285 | 1010 gg_add_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
8775 | 1011 agg_save_buddy_list(gc, NULL); |
2393 | 1012 } |
1013 | |
9285 | 1014 static void agg_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
2393 | 1015 { |
1016 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
9285 | 1017 if (invalid_uin(buddy->name)) |
2393 | 1018 return; |
9285 | 1019 gg_remove_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
8775 | 1020 agg_save_buddy_list(gc, NULL); |
2393 | 1021 } |
1022 | |
9415 | 1023 static void agg_buddy_free (GaimBuddy *buddy) |
1024 { | |
1025 if (buddy->proto_data) { | |
1026 g_free(buddy->proto_data); | |
1027 buddy->proto_data = NULL; | |
1028 } | |
1029 } | |
1030 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1031 static void search_results(GaimConnection *gc, gchar *webdata) |
2393 | 1032 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1033 gchar **webdata_tbl; |
2393 | 1034 gchar *buf; |
1035 char *ptr; | |
1036 int i, j; | |
1037 | |
1038 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1039 gaim_debug(GAIM_DEBUG_MISC, "gg", "search_callback: pubdir result [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1040 gaim_notify_error(gc, NULL, _("Couldn't get search results"), NULL); |
2393 | 1041 return; |
1042 } | |
1043 ptr++; | |
1044 | |
1045 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); | |
1046 | |
1047 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | |
1048 | |
1049 j = 0; | |
1050 | |
1051 /* Parse array */ | |
9285 | 1052 /* XXX - Make this use a GString */ |
2393 | 1053 for (i = 0; webdata_tbl[i] != NULL; i++) { |
1054 gchar *p, *oldibuf; | |
1055 static gchar *ibuf; | |
1056 | |
1057 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | |
1058 | |
1059 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */ | |
1060 if (i % 8 == 0) | |
1061 j = 0; | |
1062 | |
4051 | 1063 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", "UTF-8"); |
2393 | 1064 |
1065 oldibuf = ibuf; | |
1066 | |
1067 switch (j) { | |
1068 case 0: | |
1069 ibuf = g_strconcat("---------------------------------<BR>\n", NULL); | |
1070 oldibuf = ibuf; | |
1071 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ", | |
4606 | 1072 (atoi(p) == 2) ? _("Yes") : _("No"), "<BR>\n", NULL); |
2393 | 1073 g_free(oldibuf); |
1074 break; | |
1075 case 1: | |
1076 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL); | |
1077 g_free(oldibuf); | |
1078 break; | |
1079 case 2: | |
7981 | 1080 ibuf = g_strconcat(oldibuf, "<B>", _("First Name"), ":</B> ", p, "<BR>\n", NULL); |
2393 | 1081 g_free(oldibuf); |
1082 break; | |
1083 case 3: | |
1084 ibuf = | |
6623 | 1085 g_strconcat(oldibuf, "<B>", _("Last Name"), ":</B> ", p, "<BR>\n", NULL); |
2393 | 1086 g_free(oldibuf); |
1087 break; | |
1088 case 4: | |
1089 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL); | |
1090 g_free(oldibuf); | |
1091 break; | |
1092 case 5: | |
1093 /* Hack, invalid_uin does what we really want here but may change in future */ | |
1094 if (invalid_uin(p)) | |
1095 ibuf = | |
8063 | 1096 g_strconcat(oldibuf, "<B>", _("Birth Year"), ":</B> <BR>\n", NULL); |
2393 | 1097 else |
1098 ibuf = | |
8063 | 1099 g_strconcat(oldibuf, "<B>", _("Birth Year"), ":</B> ", p, "<BR>\n", |
2393 | 1100 NULL); |
1101 g_free(oldibuf); | |
1102 break; | |
1103 case 6: | |
1104 if (atoi(p) == GG_GENDER_FEMALE) | |
1105 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL); | |
1106 else if (atoi(p) == GG_GENDER_MALE) | |
1107 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL); | |
1108 else | |
1109 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL); | |
1110 g_free(oldibuf); | |
1111 break; | |
1112 case 7: | |
1113 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL); | |
1114 g_free(oldibuf); | |
1115 | |
1116 /* We have all lines, so add them to buffer */ | |
1117 { | |
1118 gchar *oldbuf = buf; | |
1119 buf = g_strconcat(oldbuf, ibuf, NULL); | |
1120 g_free(oldbuf); | |
1121 } | |
1122 | |
1123 g_free(ibuf); | |
1124 break; | |
1125 } | |
1126 | |
1127 g_free(p); | |
1128 | |
1129 j++; | |
1130 } | |
1131 | |
1132 g_strfreev(webdata_tbl); | |
1133 | |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1134 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, |
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1135 buf, NULL, NULL); |
2393 | 1136 |
1137 g_free(buf); | |
1138 } | |
1139 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1140 static void |
9015 | 1141 change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1142 { |
9015 | 1143 GaimConnection *gc = (GaimConnection *) action->context; |
1144 GaimAccount *account = gaim_connection_get_account(gc); | |
1145 gaim_account_request_change_password(account); | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1146 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1147 |
8775 | 1148 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1149 static void import_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1150 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1151 gchar *ptr; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1152 gchar **users_tbl; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1153 int i; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1154 if (strstr(webdata, "no_data:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1155 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1156 _("There is no Buddy List stored on the " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1157 "Gadu-Gadu server."), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1158 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1159 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1160 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1161 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1162 gaim_debug(GAIM_DEBUG_MISC, "gg", "import_buddies_server_results: import buddies result [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1163 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1164 _("Couldn't Import Buddy List from Server"), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1165 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1166 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1167 ptr++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1168 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1169 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1170 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1171 /* Parse array of Buddies List */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1172 for (i = 0; users_tbl[i] != NULL; i++) { |
4520
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1173 gchar **data_tbl; |
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1174 gchar *name, *show; |
4fe661860577
[gaim-migrate @ 4798]
Christian Hammond <chipx86@chipx86.com>
parents:
4516
diff
changeset
|
1175 |
4516 | 1176 if (strlen(users_tbl[i])==0) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1177 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1178 "import_buddies_server_results: users_tbl[i] is empty\n"); |
4530 | 1179 continue; |
4516 | 1180 } |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1181 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1182 g_strdelimit(users_tbl[i], "\r\t\n\015", ' '); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1183 data_tbl = g_strsplit(users_tbl[i], ";", 8); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1184 |
4437 | 1185 show = charset_convert(data_tbl[3], "CP1250", "UTF-8"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1186 name = data_tbl[6]; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1187 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1188 if (invalid_uin(name)) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1189 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1190 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1191 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1192 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1193 "import_buddies_server_results: uin: %s\n", name); |
4687 | 1194 if (!gaim_find_buddy(gc->account, name)) { |
6695 | 1195 GaimBuddy *b; |
1196 GaimGroup *g; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1197 /* Default group if none specified on server */ |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1198 gchar *group = g_strdup("Gadu-Gadu"); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1199 if (strlen(data_tbl[5])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1200 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1201 if (strlen(group_tbl[0])) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1202 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1203 group = g_strdup(group_tbl[0]); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1204 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1205 g_strfreev(group_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1206 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1207 /* Add Buddy to our userlist */ |
4775 | 1208 if (!(g = gaim_find_group(group))) { |
4687 | 1209 g = gaim_group_new(group); |
4775 | 1210 gaim_blist_add_group(g, NULL); |
1211 } | |
4687 | 1212 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); |
9295 | 1213 gaim_blist_add_buddy(b, NULL, g, NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1214 g_free(group); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1215 } |
4437 | 1216 g_free(show); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1217 g_strfreev(data_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1218 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1219 g_strfreev(users_tbl); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1220 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1221 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1222 static void export_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2393 | 1223 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1224 if (strstr(webdata, "put_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1225 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1226 _("Buddy List successfully transferred to " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1227 "Gadu-Gadu server"), NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1228 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1229 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1230 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1231 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1232 "export_buddies_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1233 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1234 _("Couldn't transfer Buddy List to Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1235 NULL); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1236 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1237 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1238 static void delete_buddies_server_results(GaimConnection *gc, gchar *webdata) |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1239 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1240 if (strstr(webdata, "put_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1241 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1242 _("Buddy List successfully deleted from " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1243 "Gadu-Gadu server"), NULL); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1244 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1245 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1246 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1247 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1248 "delete_buddies_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1249 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1250 _("Couldn't delete Buddy List from Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1251 NULL); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1252 } |
8775 | 1253 #endif |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1254 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1255 static void password_change_server_results(GaimConnection *gc, gchar *webdata) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1256 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1257 if (strstr(webdata, "reg_success:")) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1258 gaim_notify_info(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1259 _("Password changed successfully"), NULL); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1260 return; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1261 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1262 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1263 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1264 "password_change_server_results: webdata [%s]\n", webdata); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1265 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1266 _("Password couldn't be changed"), NULL); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1267 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1268 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1269 static void http_results(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1270 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1271 struct agg_http *hdata = data; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1272 GaimConnection *gc = hdata->gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1273 char *webdata; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1274 int len; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1275 char read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1276 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1277 gaim_debug(GAIM_DEBUG_INFO, "gg", "http_results: begin\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1278 |
5605 | 1279 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1280 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1281 "search_callback: g_slist_find error\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1282 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1283 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1284 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1285 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1286 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1287 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1288 webdata = NULL; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1289 len = 0; |
3717
988485669631
[gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
1290 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1291 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1292 if (errno == EWOULDBLOCK) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1293 errno = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1294 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1295 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1296 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1297 if (!read_data) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1298 continue; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1299 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1300 len++; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1301 webdata = g_realloc(webdata, len); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1302 webdata[len - 1] = read_data; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1303 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1304 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1305 webdata = g_realloc(webdata, len + 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1306 webdata[len] = 0; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1307 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1308 gaim_input_remove(hdata->inpa); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1309 close(source); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1310 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1311 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1312 "http_results: type %d, webdata [%s]\n", hdata->type, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1313 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1314 switch (hdata->type) { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1315 case AGG_HTTP_SEARCH: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1316 search_results(gc, webdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1317 break; |
8775 | 1318 #if 0 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1319 case AGG_HTTP_USERLIST_IMPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1320 import_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1321 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1322 case AGG_HTTP_USERLIST_EXPORT: |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1323 export_buddies_server_results(gc, webdata); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1324 break; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1325 case AGG_HTTP_USERLIST_DELETE: |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1326 delete_buddies_server_results(gc, webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1327 break; |
8775 | 1328 #endif |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1329 case AGG_HTTP_PASSWORD_CHANGE: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1330 password_change_server_results(gc, webdata); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1331 break; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1332 case AGG_HTTP_NONE: |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1333 default: |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1334 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1335 "http_results: unsupported type %d\n", hdata->type); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1336 break; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1337 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1338 |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1339 g_free(webdata); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1340 g_free(hdata); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1341 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1342 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1343 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond) |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1344 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1345 struct agg_http *hdata = data; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1346 GaimConnection *gc = hdata->gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1347 gchar *request = hdata->request; |
2393 | 1348 gchar *buf; |
1349 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1350 gaim_debug(GAIM_DEBUG_INFO, "gg", "http_req_callback: begin\n"); |
2393 | 1351 |
5605 | 1352 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1353 gaim_debug(GAIM_DEBUG_ERROR, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1354 "http_req_callback: g_slist_find error\n"); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1355 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1356 g_free(hdata); |
2393 | 1357 close(source); |
1358 return; | |
1359 } | |
1360 | |
4511 | 1361 if (source == 0) { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1362 g_free(request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1363 g_free(hdata); |
2393 | 1364 return; |
1365 } | |
1366 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1367 gaim_debug(GAIM_DEBUG_MISC, "gg", |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1368 "http_req_callback: http request [%s]\n", request); |
2393 | 1369 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1370 buf = g_strdup_printf("POST %s HTTP/1.0\r\n" |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1371 "Host: %s\r\n" |
2393 | 1372 "Content-Type: application/x-www-form-urlencoded\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1373 "User-Agent: " GG_HTTP_USERAGENT "\r\n" |
2393 | 1374 "Content-Length: %d\r\n" |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1375 "Pragma: no-cache\r\n" "\r\n" "%s\r\n", |
7386 | 1376 hdata->form, hdata->host, (int)strlen(request), request); |
2393 | 1377 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1378 g_free(request); |
2393 | 1379 |
1380 if (write(source, buf, strlen(buf)) < strlen(buf)) { | |
1381 g_free(buf); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1382 g_free(hdata); |
2393 | 1383 close(source); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1384 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1385 _("Error communicating with Gadu-Gadu server"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1386 _("Gaim was unable to complete your request due " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1387 "to a problem communicating with the Gadu-Gadu " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1388 "HTTP server. Please try again later.")); |
2393 | 1389 return; |
1390 } | |
1391 | |
1392 g_free(buf); | |
1393 | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1394 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
|
1395 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1396 |
8775 | 1397 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1398 static void import_buddies_server(GaimConnection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1399 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1400 struct agg_http *hi = g_new0(struct agg_http, 1); |
5603 | 1401 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
10740 | 1402 gchar *p = gg_urlencode(gaim_connection_get_password(gc)); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1403 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1404 hi->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1405 hi->type = AGG_HTTP_USERLIST_IMPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1406 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1407 hi->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1408 hi->request = g_strdup_printf("FmNum=%s&Pass=%s", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1409 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1410 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1411 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1412 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1413 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1414 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1415 _("Unable to import Gadu-Gadu buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1416 _("Gaim was unable to connect to the Gadu-Gadu " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1417 "buddy list server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1418 g_free(hi->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1419 g_free(hi); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1420 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1421 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1422 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1423 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1424 static void export_buddies_server(GaimConnection *gc) |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1425 { |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1426 struct agg_http *he = g_new0(struct agg_http, 1); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1427 gchar *ptr; |
5603 | 1428 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
10740 | 1429 gchar *p = gg_urlencode(gaim_connection_get_password(gc)); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1430 |
6695 | 1431 GaimBlistNode *gnode, *cnode, *bnode; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1432 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1433 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1434 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1435 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1436 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1437 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Contacts=", u, p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1438 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1439 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1440 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1441 |
4785 | 1442 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 1443 GaimGroup *g = (GaimGroup *)gnode; |
4516 | 1444 int num_added=0; |
4785 | 1445 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
1446 continue; | |
6695 | 1447 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
1448 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
1449 continue; | |
1450 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
1451 GaimBuddy *b = (GaimBuddy *)bnode; | |
4785 | 1452 |
6695 | 1453 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
1454 continue; | |
4349 | 1455 |
6695 | 1456 if(b->account == gc->account) { |
1457 gchar *newdata; | |
1458 /* GG Number */ | |
1459 gchar *name = gg_urlencode(b->name); | |
1460 /* GG Pseudo */ | |
1461 gchar *show = gg_urlencode(b->alias ? b->alias : b->name); | |
1462 /* Group Name */ | |
1463 gchar *gname = gg_urlencode(g->name); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1464 |
6695 | 1465 ptr = he->request; |
1466 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s", | |
1467 show, show, show, show, "", gname, name); | |
4516 | 1468 |
6695 | 1469 if(num_added > 0) |
1470 he->request = g_strconcat(ptr, "%0d%0a", newdata, NULL); | |
1471 else | |
1472 he->request = g_strconcat(ptr, newdata, NULL); | |
4516 | 1473 |
6695 | 1474 num_added++; |
1475 | |
1476 g_free(newdata); | |
1477 g_free(ptr); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1478 |
6695 | 1479 g_free(gname); |
1480 g_free(show); | |
1481 g_free(name); | |
1482 } | |
4349 | 1483 } |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1484 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1485 } |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1486 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1487 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1488 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1489 _("Couldn't export buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1490 _("Gaim was unable to connect to the buddy " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1491 "list server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1492 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1493 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1494 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1495 } |
2393 | 1496 } |
1497 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1498 static void delete_buddies_server(GaimConnection *gc) |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1499 { |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1500 struct agg_http *he = g_new0(struct agg_http, 1); |
5603 | 1501 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
10740 | 1502 gchar *p = gg_urlencode(gaim_connection_get_password(gc)); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1503 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1504 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1505 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1506 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1507 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1508 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1509 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1510 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1511 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1512 _("Unable to delete Gadu-Gadu buddy list"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1513 _("Gaim was unable to connect to the buddy " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1514 "list server. Please try again later.")); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1515 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1516 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1517 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1518 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1519 } |
8775 | 1520 #endif |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1521 |
8950 | 1522 #if 0 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1523 static void agg_dir_search(GaimConnection *gc, const char *first, const char *middle, |
3466 | 1524 const char *last, const char *maiden, const char *city, const char *state, |
1525 const char *country, const char *email) | |
2393 | 1526 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1527 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1528 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1529 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1530 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1531 srch->host = GG_PUBDIR_HOST; |
2393 | 1532 |
1533 if (email && strlen(email)) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1534 gchar *eemail = gg_urlencode(email); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1535 srch->request = g_strdup_printf("Mode=1&Email=%s", eemail); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1536 g_free(eemail); |
2393 | 1537 } else { |
4051 | 1538 gchar *new_first = charset_convert(first, "UTF-8", "CP1250"); |
1539 gchar *new_last = charset_convert(last, "UTF-8", "CP1250"); | |
1540 gchar *new_city = charset_convert(city, "UTF-8", "CP1250"); | |
2393 | 1541 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1542 gchar *enew_first = gg_urlencode(new_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1543 gchar *enew_last = gg_urlencode(new_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1544 gchar *enew_city = gg_urlencode(new_city); |
2393 | 1545 |
1546 g_free(new_first); | |
1547 g_free(new_last); | |
1548 g_free(new_city); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1549 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1550 /* For active only add &ActiveOnly= */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1551 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d" |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1552 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1553 enew_first, enew_last, AGG_GENDER_NONE, |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1554 "", enew_city, 0, 0); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1555 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1556 g_free(enew_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1557 g_free(enew_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1558 g_free(enew_city); |
2393 | 1559 } |
1560 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1561 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1562 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1563 _("Unable to access directory"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1564 _("Gaim was unable to search the Directory " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1565 "because it was unable to connect to the " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1566 "directory server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1567 g_free(srch->request); |
2393 | 1568 g_free(srch); |
1569 return; | |
1570 } | |
1571 } | |
8950 | 1572 #endif |
2393 | 1573 |
10395 | 1574 static void agg_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1575 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1576 struct agg_http *hpass = g_new0(struct agg_http, 1); |
5603 | 1577 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
10740 | 1578 gchar *p = gg_urlencode(gaim_connection_get_password(gc)); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1579 gchar *enew = gg_urlencode(new); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1580 gchar *eold = gg_urlencode(old); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1581 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1582 hpass->gc = gc; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1583 hpass->type = AGG_HTTP_PASSWORD_CHANGE; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1584 hpass->form = AGG_REGISTER_DATA_FORM; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1585 hpass->host = GG_REGISTER_HOST; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1586 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1587 /* We are using old password as place for email - it's ugly */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1588 hpass->request = g_strdup_printf("fmnumber=%s&fmpwd=%s&pwd=%s&email=%s&code=%u", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1589 u, p, enew, eold, gg_http_hash(old, new)); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1590 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1591 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1592 g_free(p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1593 g_free(enew); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1594 g_free(eold); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1595 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1596 if (gaim_proxy_connect(gc->account, GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { |
8997 | 1597 gaim_notify_error(gc, NULL, |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1598 _("Unable to change Gadu-Gadu password"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1599 _("Gaim was unable to change your password " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1600 "due to an error connecting to the " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1601 "Gadu-Gadu server. Please try again " |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1602 "later.")); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1603 g_free(hpass->request); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1604 g_free(hpass); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1605 return; |
8997 | 1606 } |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1607 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1608 |
9015 | 1609 static GList *agg_actions(GaimPlugin *plugin, gpointer context) |
2393 | 1610 { |
1611 GList *m = NULL; | |
9015 | 1612 GaimPluginAction *act = NULL; |
2393 | 1613 |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1614 #if 0 |
9015 | 1615 act = gaim_plugin_action_new(_("Directory Search"), show_find_info); |
1616 m = g_list_append(m, act); | |
4333 | 1617 m = g_list_append(m, NULL); |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1618 #endif |
4333 | 1619 |
9015 | 1620 act = gaim_plugin_action_new(_("Change Password"), change_pass); |
1621 m = g_list_append(m, act); | |
4333 | 1622 |
8775 | 1623 #if 0 |
9015 | 1624 act = gaim_plugin_action_new(_("Import Buddy List from Server"), |
1625 import_buddies_server); | |
1626 m = g_list_append(m, act); | |
4333 | 1627 |
9015 | 1628 act = gaim_plugin_action_new(_("Export Buddy List to Server"), |
1629 export_buddies_server); | |
1630 m = g_list_append(m, act); | |
4333 | 1631 |
9015 | 1632 act = gaim_plugin_action_new(_("Delete Buddy List from Server"), |
1633 delete_buddies_server); | |
1634 m = g_list_append(m, act); | |
8775 | 1635 #endif |
2393 | 1636 |
1637 return m; | |
1638 } | |
1639 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1640 static void agg_get_info(GaimConnection *gc, const char *who) |
2393 | 1641 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1642 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1643 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1644 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1645 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1646 srch->host = GG_PUBDIR_HOST; |
2393 | 1647 |
1648 /* If it's invalid uin then maybe it's nickname? */ | |
1649 if (invalid_uin(who)) { | |
4051 | 1650 gchar *new_who = charset_convert(who, "UTF-8", "CP1250"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1651 gchar *enew_who = gg_urlencode(new_who); |
8997 | 1652 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1653 g_free(new_who); |
2393 | 1654 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1655 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
|
1656 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1657 "", "", AGG_GENDER_NONE, enew_who, "", 0, 0); |
2393 | 1658 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1659 g_free(enew_who); |
2393 | 1660 } else |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1661 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1662 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5645
diff
changeset
|
1663 if (gaim_proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1664 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1665 _("Unable to access user profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1666 _("Gaim was unable to access this user's " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1667 "profile due to an error connecting to the " |
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1668 "directory server. Please try again later.")); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1669 g_free(srch->request); |
2393 | 1670 g_free(srch); |
1671 return; | |
1672 } | |
1673 } | |
1674 | |
6695 | 1675 static const char *agg_list_icon(GaimAccount *a, GaimBuddy *b) |
2393 | 1676 { |
4687 | 1677 return "gadu-gadu"; |
1678 } | |
4916 | 1679 |
9953 | 1680 static void agg_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
1681 const char **nw, const char **ne) | |
4916 | 1682 { |
9944 | 1683 GaimPresence *presence = gaim_buddy_get_presence(b); |
1684 | |
1685 if (!GAIM_BUDDY_IS_ONLINE(b)) | |
4916 | 1686 *se = "offline"; |
9944 | 1687 else if (gaim_presence_is_status_active(presence, "away") || |
1688 gaim_presence_is_status_active(presence, "away-friends")) | |
1689 { | |
4916 | 1690 *se = "away"; |
9944 | 1691 } |
1692 else if (gaim_presence_is_status_active(presence, "invisible") || | |
1693 gaim_presence_is_status_active(presence, "invisible-friends")) | |
1694 { | |
1695 *se = "invisible"; | |
4916 | 1696 } |
2393 | 1697 } |
4916 | 1698 |
2393 | 1699 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1700 static void agg_set_permit_deny_dummy(GaimConnection *gc) |
2393 | 1701 { |
1702 /* It's implemented on client side because GG server doesn't support this */ | |
1703 } | |
1704 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
1705 static void agg_permit_deny_dummy(GaimConnection *gc, const char *who) |
2393 | 1706 { |
1707 /* It's implemented on client side because GG server doesn't support this */ | |
1708 } | |
1709 | |
8796 | 1710 static void agg_group_buddy (GaimConnection *gc, const char *who, |
8775 | 1711 const char *old_group, const char *new_group) |
1712 { | |
1713 GaimBuddy *buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | |
1714 gchar *newdata; | |
1715 /* GG Number */ | |
1716 gchar *name = buddy->name; | |
1717 /* GG Pseudo */ | |
1718 gchar *show = buddy->alias ? buddy->alias : buddy->name; | |
1719 /* Group Name */ | |
1720 const gchar *gname = new_group; | |
1721 | |
1722 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", | |
1723 show, show, show, show, "", gname, name, "", ""); | |
1724 agg_save_buddy_list(gc, newdata); | |
1725 g_free(newdata); | |
1726 } | |
1727 | |
9285 | 1728 static void agg_rename_group (GaimConnection *gc, const char *old_name, |
1729 GaimGroup *group, GList *moved_buddies) | |
8775 | 1730 { |
1731 agg_save_buddy_list(gc, NULL); | |
1732 } | |
1733 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1734 static GaimPlugin *my_protocol = NULL; |
2393 | 1735 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1736 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1737 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1738 0, |
9475 | 1739 NULL, /* user_splits */ |
1740 NULL, /* protocol_options */ | |
9950 | 1741 NO_BUDDY_ICONS, /* icon_spec */ |
1742 agg_list_icon, /* list_icon */ | |
1743 agg_list_emblems, /* list_emblems */ | |
9475 | 1744 NULL, /* status_text */ |
1745 NULL, /* tooltip_text */ | |
9950 | 1746 agg_status_types, /* status_types */ |
9475 | 1747 agg_blist_node_menu, /* blist_node_menu */ |
1748 NULL, /* chat_info */ | |
9754 | 1749 NULL, /* chat_info_defaults */ |
9950 | 1750 agg_login, /* login */ |
1751 agg_close, /* close */ | |
1752 agg_send_im, /* send_im */ | |
9475 | 1753 NULL, /* set_info */ |
1754 NULL, /* send_typing */ | |
9950 | 1755 agg_get_info, /* get_info */ |
1756 agg_set_status, /* set_away */ | |
9475 | 1757 NULL, /* set_idle */ |
10869 | 1758 agg_change_passwd, /* change_passwd */ |
1759 agg_add_buddy, /* add_buddy */ | |
1760 NULL, /* add_buddies */ | |
1761 agg_rem_buddy, /* remove_buddy */ | |
9475 | 1762 NULL, /* remove_buddies */ |
1763 agg_permit_deny_dummy, /* add_permit */ | |
1764 agg_permit_deny_dummy, /* add_deny */ | |
1765 agg_permit_deny_dummy, /* rem_permit */ | |
1766 agg_permit_deny_dummy, /* rem_deny */ | |
1767 agg_set_permit_deny_dummy, /* set_permit_deny */ | |
1768 NULL, /* warn */ | |
1769 NULL, /* join_chat */ | |
1770 NULL, /* reject_chat */ | |
9917 | 1771 NULL, /* get_chat_name */ |
9475 | 1772 NULL, /* chat_invite */ |
1773 NULL, /* chat_leave */ | |
1774 NULL, /* chat_whisper */ | |
1775 NULL, /* chat_send */ | |
9950 | 1776 agg_keepalive, /* keepalive */ |
9475 | 1777 NULL, /* register_user */ |
1778 NULL, /* get_cb_info */ | |
1779 NULL, /* get_cb_away */ | |
1780 NULL, /* alias_buddy */ | |
9950 | 1781 agg_group_buddy, /* group_buddy */ |
1782 agg_rename_group, /* rename_group */ | |
1783 agg_buddy_free, /* buddy_free */ | |
9475 | 1784 NULL, /* convo_closed */ |
1785 NULL, /* normalize */ | |
1786 NULL, /* set_buddy_icon */ | |
1787 NULL, /* remove_group */ | |
1788 NULL, /* get_cb_real_name */ | |
1789 NULL, /* set_chat_topic */ | |
1790 NULL, /* find_blist_chat */ | |
1791 NULL, /* roomlist_get_list */ | |
1792 NULL, /* roomlist_cancel */ | |
1793 NULL, /* roomlist_expand_category */ | |
1794 NULL, /* can_receive_file */ | |
1795 NULL /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1796 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1797 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1798 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1799 { |
9943 | 1800 GAIM_PLUGIN_MAGIC, |
1801 GAIM_MAJOR_VERSION, | |
1802 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1803 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1804 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1805 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1806 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1807 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1808 |
9030 | 1809 "prpl-gg", /**< id */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1810 "Gadu-Gadu", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1811 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1812 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1813 N_("Gadu-Gadu Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1814 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1815 N_("Gadu-Gadu Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1816 "Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>", /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
1817 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1818 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1819 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1820 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1821 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1822 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1823 NULL, /**< ui_info */ |
8993 | 1824 &prpl_info, /**< extra_info */ |
1825 NULL, | |
9015 | 1826 agg_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1827 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1828 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1829 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1830 init_plugin(GaimPlugin *plugin) |
2393 | 1831 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1832 GaimAccountOption *option; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1833 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10869
diff
changeset
|
1834 gaim_debug_register_category("gg"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10869
diff
changeset
|
1835 |
5645
a9cd11fd0d6f
[gaim-migrate @ 6059]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
1836 option = gaim_account_option_string_new(_("Nick"), "nick", |
9030 | 1837 "Gadu-Gadu User"); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1838 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
9030 | 1839 option); |
3572 | 1840 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
1841 my_protocol = plugin; |
2393 | 1842 } |
1843 | |
9863 | 1844 GAIM_INIT_PLUGIN(gg, init_plugin, info) |