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