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