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