Mercurial > pidgin.yaz
annotate src/protocols/gg/gg.c @ 4770:c4c28874ecd3
[gaim-migrate @ 5088]
I want to go to sleep. This is drag-n-drop moving of buddies in the list.
I think it works, but I didn't actually test it... I really should have though;
I can't imagine it working fine as-is. ;)
I'm holding off on the rest of my Edit Buddy List stuff for tomorrow... I love
last minute things, don't I?
Note: I created gaim_blist_members and gaim_blist_groups to reproduce the
effects of the old groups GSList and the members GSList of the group struct
that I removed. This is really sub-optimal and should be replaced to iterate
the Buddy List directly. If someone wants to do that, please do. Even if you
don't want to do that, just review the changes I made and make sure I didn't
do anything stupid. It is past 6am and I'm a bit tired and prone to mistake
making.
Thanks.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 14 Mar 2003 11:38:21 +0000 |
parents | c15e0699acae |
children | 92ae181271e9 |
rev | line source |
---|---|
2393 | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | |
4770 | 3 * $Id: gg.c 5088 2003-03-14 11:38:21Z seanegan $ |
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 */ |
4687 | 809 if (!(g = gaim_find_group(group))) |
810 g = gaim_group_new(group); | |
811 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); | |
812 gaim_blist_add_buddy(b,g,NULL); | |
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 |
4634 | 990 if (proxy_connect(gc->account, 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 |
4770 | 1007 GSList *gr = gaim_blist_groups(); |
1008 GSList *gr1 = gr; | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1009 |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1010 he->gc = gc; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1011 he->type = AGG_HTTP_USERLIST_EXPORT; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1012 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1013 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1014 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
|
1015 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1016 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1017 g_free(p); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1018 |
4770 | 1019 while (gr1) { |
1020 struct group *g = gr1->data; | |
1021 GSList *m = gaim_blist_members(g); | |
1022 GSList *m1 = m; | |
4516 | 1023 int num_added=0; |
4770 | 1024 while (m1) { |
1025 struct buddy *b = m1->data; | |
4349 | 1026 |
4516 | 1027 if(b->account == gc->account) { |
4349 | 1028 gchar *newdata; |
1029 /* GG Number */ | |
1030 gchar *name = gg_urlencode(b->name); | |
1031 /* GG Pseudo */ | |
4705 | 1032 gchar *show = gg_urlencode(b->alias ? b->alias : b->name); |
4349 | 1033 /* Group Name */ |
1034 gchar *gname = gg_urlencode(g->name); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1035 |
4349 | 1036 ptr = he->request; |
4516 | 1037 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s", |
4349 | 1038 show, show, show, show, "", gname, name); |
4516 | 1039 |
1040 if(num_added > 0) | |
1041 he->request = g_strconcat(ptr, "%0d%0a", newdata, NULL); | |
1042 else | |
1043 he->request = g_strconcat(ptr, newdata, NULL); | |
1044 | |
1045 num_added++; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1046 |
4349 | 1047 g_free(newdata); |
1048 g_free(ptr); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1049 |
4349 | 1050 g_free(gname); |
1051 g_free(show); | |
1052 g_free(name); | |
1053 } | |
4770 | 1054 m1 = g_slist_next(m1); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1055 } |
4770 | 1056 g_slist_free(m); |
1057 gr = g_slist_next(gr1); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1058 } |
4770 | 1059 g_slist_free(gr); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1060 |
4634 | 1061 if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
3427 | 1062 do_error_dialog(_("Couldn't export buddy list"), |
1063 _("Gaim was unable to connect to the buddy list server. " | |
1064 "Please try again later."), GAIM_ERROR); | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1065 g_free(he->request); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1066 g_free(he); |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1067 return; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1068 } |
2393 | 1069 } |
1070 | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1071 static void delete_buddies_server(struct gaim_connection *gc) |
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 struct agg_http *he = g_new0(struct agg_http, 1); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1074 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1075 gchar *p = gg_urlencode(gc->password); |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1076 |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1077 he->gc = gc; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1078 he->type = AGG_HTTP_USERLIST_DELETE; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1079 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1080 he->host = GG_PUBDIR_HOST; |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1081 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
|
1082 |
4634 | 1083 if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { |
3427 | 1084 do_error_dialog(_("Unable to delete Gadu-Gadu buddy list"), |
1085 _("Gaim was unable to connect to the buddy list server. " | |
1086 "Please try again later."), GAIM_ERROR); | |
2806
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1087 g_free(he->request); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1088 g_free(he); |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1089 return; |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1090 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1091 } |
1ffac7cf4e94
[gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2792
diff
changeset
|
1092 |
3466 | 1093 static void agg_dir_search(struct gaim_connection *gc, const char *first, const char *middle, |
1094 const char *last, const char *maiden, const char *city, const char *state, | |
1095 const char *country, const char *email) | |
2393 | 1096 { |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1097 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1098 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1099 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1100 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1101 srch->host = GG_PUBDIR_HOST; |
2393 | 1102 |
1103 if (email && strlen(email)) { | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1104 gchar *eemail = gg_urlencode(email); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1105 srch->request = g_strdup_printf("Mode=1&Email=%s", eemail); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1106 g_free(eemail); |
2393 | 1107 } else { |
4051 | 1108 gchar *new_first = charset_convert(first, "UTF-8", "CP1250"); |
1109 gchar *new_last = charset_convert(last, "UTF-8", "CP1250"); | |
1110 gchar *new_city = charset_convert(city, "UTF-8", "CP1250"); | |
2393 | 1111 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1112 gchar *enew_first = gg_urlencode(new_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1113 gchar *enew_last = gg_urlencode(new_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1114 gchar *enew_city = gg_urlencode(new_city); |
2393 | 1115 |
1116 g_free(new_first); | |
1117 g_free(new_last); | |
1118 g_free(new_city); | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1119 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1120 /* For active only add &ActiveOnly= */ |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1121 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
|
1122 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1123 enew_first, enew_last, AGG_GENDER_NONE, |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1124 "", enew_city, 0, 0); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1125 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1126 g_free(enew_first); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1127 g_free(enew_last); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1128 g_free(enew_city); |
2393 | 1129 } |
1130 | |
4634 | 1131 if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
3427 | 1132 do_error_dialog(_("Unable to access directory"), |
1133 _("Gaim was unable to search the Directory because it " | |
4059 | 1134 "was unable to connect to the directory server. Please try " |
3427 | 1135 "again later."), GAIM_ERROR); |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1136 g_free(srch->request); |
2393 | 1137 g_free(srch); |
1138 return; | |
1139 } | |
1140 } | |
1141 | |
3466 | 1142 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
|
1143 { |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1144 struct agg_http *hpass = g_new0(struct agg_http, 1); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1145 gchar *u = gg_urlencode(gc->username); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1146 gchar *p = gg_urlencode(gc->password); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1147 gchar *enew = gg_urlencode(new); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1148 gchar *eold = gg_urlencode(old); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1149 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1150 hpass->gc = gc; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1151 hpass->type = AGG_HTTP_PASSWORD_CHANGE; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1152 hpass->form = AGG_REGISTER_DATA_FORM; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1153 hpass->host = GG_REGISTER_HOST; |
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 /* 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
|
1156 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
|
1157 u, p, enew, eold, gg_http_hash(old, new)); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1158 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1159 g_free(u); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1160 g_free(p); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1161 g_free(enew); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1162 g_free(eold); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1163 |
4634 | 1164 if (proxy_connect(gc->account, GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { |
3427 | 1165 do_error_dialog(_("Unable to change Gadu-Gadu password"), |
1166 _("Gaim was unable to change your password due to an error connecting " | |
1167 "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
|
1168 g_free(hpass->request); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1169 g_free(hpass); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1170 return; |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1171 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1172 } |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1173 |
4333 | 1174 static GList *agg_actions(struct gaim_connection *gc) |
2393 | 1175 { |
1176 GList *m = NULL; | |
4333 | 1177 struct proto_actions_menu *pam; |
2393 | 1178 |
4333 | 1179 pam = g_new0(struct proto_actions_menu, 1); |
1180 pam->label = _("Directory Search"); | |
1181 pam->callback = show_find_info; | |
1182 pam->gc = gc; | |
1183 m = g_list_append(m, pam); | |
1184 | |
1185 m = g_list_append(m, NULL); | |
1186 | |
1187 pam = g_new0(struct proto_actions_menu, 1); | |
1188 pam->label = _("Change Password"); | |
1189 pam->callback = show_change_passwd; | |
1190 pam->gc = gc; | |
1191 m = g_list_append(m, pam); | |
1192 | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1193 m = g_list_append(m, NULL); |
4333 | 1194 |
1195 pam = g_new0(struct proto_actions_menu, 1); | |
1196 pam->label = _("Import Buddy List from Server"); | |
1197 pam->callback = import_buddies_server; | |
1198 pam->gc = gc; | |
1199 m = g_list_append(m, pam); | |
1200 | |
1201 pam = g_new0(struct proto_actions_menu, 1); | |
1202 pam->label = _("Export Buddy List to Server"); | |
1203 pam->callback = export_buddies_server; | |
1204 pam->gc = gc; | |
1205 m = g_list_append(m, pam); | |
1206 | |
1207 pam = g_new0(struct proto_actions_menu, 1); | |
1208 pam->label = _("Delete Buddy List from Server"); | |
1209 pam->callback = delete_buddies_server; | |
1210 pam->gc = gc; | |
1211 m = g_list_append(m, pam); | |
2393 | 1212 |
1213 return m; | |
1214 } | |
1215 | |
1216 static void agg_get_info(struct gaim_connection *gc, char *who) | |
1217 { | |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1218 struct agg_http *srch = g_new0(struct agg_http, 1); |
2393 | 1219 srch->gc = gc; |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1220 srch->type = AGG_HTTP_SEARCH; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1221 srch->form = AGG_PUBDIR_SEARCH_FORM; |
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1222 srch->host = GG_PUBDIR_HOST; |
2393 | 1223 |
1224 /* If it's invalid uin then maybe it's nickname? */ | |
1225 if (invalid_uin(who)) { | |
4051 | 1226 gchar *new_who = charset_convert(who, "UTF-8", "CP1250"); |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1227 gchar *enew_who = gg_urlencode(new_who); |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1228 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1229 g_free(new_who); |
2393 | 1230 |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1231 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
|
1232 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d", |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1233 "", "", AGG_GENDER_NONE, enew_who, "", 0, 0); |
2393 | 1234 |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1235 g_free(enew_who); |
2393 | 1236 } else |
2792
9123abd0db92
[gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1237 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); |
2393 | 1238 |
4634 | 1239 if (proxy_connect(gc->account, GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { |
3427 | 1240 do_error_dialog(_("Unable to access user profile."), |
4059 | 1241 _("Gaim was unable to access this user's profile due to an error " |
3427 | 1242 "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
|
1243 g_free(srch->request); |
2393 | 1244 g_free(srch); |
1245 return; | |
1246 } | |
1247 } | |
1248 | |
4687 | 1249 static const char *agg_list_icon(struct gaim_account *a, struct buddy *b) |
2393 | 1250 { |
4687 | 1251 return "gadu-gadu"; |
1252 } | |
1253 #if 0 | |
2393 | 1254 guint status; |
1255 if (uc == UC_UNAVAILABLE) | |
1256 return (char **)gg_sunred_xpm; | |
1257 status = uc >> 5; | |
1258 /* Drop all masks */ | |
1259 status &= ~(GG_STATUS_FRIENDS_MASK); | |
1260 if (status == GG_STATUS_AVAIL) | |
1261 return (char **)gg_sunyellow_xpm; | |
1262 if (status == GG_STATUS_BUSY) | |
1263 return (char **)gg_suncloud_xpm; | |
1264 if (status == GG_STATUS_INVISIBLE) | |
1265 return (char **)gg_sunwhitered_xpm; | |
1266 return (char **)gg_sunyellow_xpm; | |
1267 } | |
4687 | 1268 #endif |
2393 | 1269 |
1270 static void agg_set_permit_deny_dummy(struct gaim_connection *gc) | |
1271 { | |
1272 /* It's implemented on client side because GG server doesn't support this */ | |
1273 } | |
1274 | |
4349 | 1275 static void agg_permit_deny_dummy(struct gaim_connection *gc, const char *who) |
2393 | 1276 { |
1277 /* It's implemented on client side because GG server doesn't support this */ | |
1278 } | |
1279 | |
1280 static struct prpl *my_protocol = NULL; | |
1281 | |
3630 | 1282 G_MODULE_EXPORT void gg_init(struct prpl *ret) |
2393 | 1283 { |
3572 | 1284 struct proto_user_opt *puo; |
2393 | 1285 ret->protocol = PROTO_GADUGADU; |
1286 ret->options = 0; | |
3572 | 1287 ret->name = g_strdup("Gadu-Gadu"); |
2393 | 1288 ret->list_icon = agg_list_icon; |
1289 ret->away_states = agg_away_states; | |
1290 ret->actions = agg_actions; | |
1291 ret->buddy_menu = agg_buddy_menu; | |
1292 ret->chat_info = NULL; | |
1293 ret->login = agg_login; | |
1294 ret->close = agg_close; | |
1295 ret->send_im = agg_send_im; | |
1296 ret->set_info = NULL; | |
1297 ret->get_info = agg_get_info; | |
1298 ret->set_away = agg_set_away; | |
1299 ret->set_dir = NULL; | |
1300 ret->get_dir = agg_get_info; | |
1301 ret->dir_search = agg_dir_search; | |
1302 ret->set_idle = NULL; | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1303 ret->change_passwd = agg_change_passwd; |
2393 | 1304 ret->add_buddy = agg_add_buddy; |
1305 ret->add_buddies = agg_add_buddies; | |
1306 ret->remove_buddy = agg_rem_buddy; | |
1307 ret->add_permit = agg_permit_deny_dummy; | |
1308 ret->add_deny = agg_permit_deny_dummy; | |
1309 ret->rem_permit = agg_permit_deny_dummy; | |
1310 ret->rem_deny = agg_permit_deny_dummy; | |
1311 ret->set_permit_deny = agg_set_permit_deny_dummy; | |
1312 ret->warn = NULL; | |
1313 ret->join_chat = NULL; | |
1314 ret->chat_invite = NULL; | |
1315 ret->chat_leave = NULL; | |
1316 ret->chat_whisper = NULL; | |
1317 ret->chat_send = NULL; | |
1318 ret->keepalive = agg_keepalive; | |
1319 ret->normalize = NULL; | |
3572 | 1320 |
1321 puo = g_new0(struct proto_user_opt, 1); | |
1322 puo->label = g_strdup(_("Nick:")); | |
1323 puo->def = g_strdup(_("Gadu-Gadu User")); | |
1324 puo->pos = USEROPT_NICK; | |
1325 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1326 | |
2393 | 1327 my_protocol = ret; |
1328 } | |
1329 | |
1330 #ifndef STATIC | |
1331 | |
3630 | 1332 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2393 | 1333 { |
3572 | 1334 gg_init(prpl); |
1335 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2393 | 1336 } |
1337 | |
1338 #endif | |
2846
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1339 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1340 /* |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1341 * Local variables: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1342 * c-indentation-style: k&r |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1343 * c-basic-offset: 8 |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1344 * indent-tabs-mode: notnil |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1345 * End: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1346 * |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1347 * vim: shiftwidth=8: |
4b3f17ca66bf
[gaim-migrate @ 2859]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2835
diff
changeset
|
1348 */ |