Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 2191:657dbe515608
[gaim-migrate @ 2201]
genericize buddy icon stuff
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 29 Aug 2001 23:41:43 +0000 |
parents | cdf43acb5b83 |
children | 177397ceac57 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
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 | |
23 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <config.h> |
2086 | 25 #endif |
26 | |
27 | |
28 #include <netdb.h> | |
29 #include <unistd.h> | |
30 #include <errno.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stdio.h> | |
36 #include <time.h> | |
37 #include <sys/socket.h> | |
38 #include <sys/stat.h> | |
39 #include "multi.h" | |
40 #include "prpl.h" | |
41 #include "gaim.h" | |
42 #include "aim.h" | |
43 #include "proxy.h" | |
44 | |
45 /*#include "pixmaps/cancel.xpm"*/ | |
46 #include "pixmaps/admin_icon.xpm" | |
47 #include "pixmaps/aol_icon.xpm" | |
48 #include "pixmaps/away_icon.xpm" | |
49 #include "pixmaps/dt_icon.xpm" | |
50 #include "pixmaps/free_icon.xpm" | |
51 | |
52 /* constants to identify proto_opts */ | |
53 #define USEROPT_AUTH 0 | |
54 #define USEROPT_AUTHPORT 1 | |
55 | |
56 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" | |
57 | |
58 static int gaim_caps = AIM_CAPS_CHAT | | |
59 #if USE_PIXBUF | |
60 AIM_CAPS_BUDDYICON | | |
61 #endif | |
62 AIM_CAPS_IMIMAGE; | |
63 | |
64 static GtkWidget *join_chat_spin = NULL; | |
65 static GtkWidget *join_chat_entry = NULL; | |
66 | |
67 struct oscar_data { | |
68 struct aim_session_t *sess; | |
69 struct aim_conn_t *conn; | |
70 | |
71 guint cnpa; | |
72 guint paspa; | |
73 | |
74 int create_exchange; | |
75 char *create_name; | |
76 | |
77 gboolean conf; | |
78 gboolean reqemail; | |
79 gboolean chpass; | |
80 char *oldp; | |
81 char *newp; | |
82 | |
83 GSList *oscar_chats; | |
84 GSList *direct_ims; | |
85 GSList *hasicons; | |
86 | |
87 gboolean killme; | |
88 }; | |
89 | |
90 struct chat_connection { | |
91 char *name; | |
92 char *show; /* AOL did something funny to us */ | |
93 int exchange; | |
94 int fd; /* this is redundant since we have the conn below */ | |
95 struct aim_conn_t *conn; | |
96 int inpa; | |
97 int id; | |
98 struct gaim_connection *gc; /* i hate this. */ | |
99 struct conversation *cnv; /* bah. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
100 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
101 int maxvis; |
2086 | 102 }; |
103 | |
104 struct direct_im { | |
105 struct gaim_connection *gc; | |
106 char name[80]; | |
107 struct conversation *cnv; | |
108 int watcher; | |
109 struct aim_conn_t *conn; | |
110 }; | |
111 | |
112 struct ask_direct { | |
113 struct gaim_connection *gc; | |
114 char *sn; | |
115 struct aim_directim_priv *priv; | |
116 }; | |
117 | |
118 struct icon_req { | |
119 char *user; | |
120 time_t timestamp; | |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
121 unsigned long checksum; |
2086 | 122 gboolean request; |
123 }; | |
124 | |
125 static struct direct_im *find_direct_im(struct oscar_data *od, char *who) { | |
126 GSList *d = od->direct_ims; | |
127 char *n = g_strdup(normalize(who)); | |
128 struct direct_im *m = NULL; | |
129 | |
130 while (d) { | |
131 m = (struct direct_im *)d->data; | |
132 if (!strcmp(n, normalize(m->name))) | |
133 break; | |
134 m = NULL; | |
135 d = d->next; | |
136 } | |
137 | |
138 g_free(n); | |
139 return m; | |
140 } | |
141 | |
142 static char *extract_name(char *name) { | |
143 char *tmp; | |
144 int i, j; | |
145 char *x = strchr(name, '-'); | |
146 if (!x) return NULL; | |
147 x = strchr(++x, '-'); | |
148 if (!x) return NULL; | |
149 tmp = g_strdup(++x); | |
150 | |
151 for (i = 0, j = 0; x[i]; i++) { | |
152 if (x[i] != '%') | |
153 tmp[j++] = x[i]; | |
154 else { | |
155 char hex[3]; | |
156 hex[0] = x[++i]; | |
157 hex[1] = x[++i]; | |
158 hex[2] = 0; | |
159 sscanf(hex, "%x", (int *)&tmp[j++]); | |
160 } | |
161 } | |
162 | |
163 tmp[j] = 0; | |
164 return tmp; | |
165 } | |
166 | |
167 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | |
168 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | |
169 struct chat_connection *c = NULL; | |
170 if (gc->protocol != PROTO_OSCAR) return NULL; | |
171 | |
172 while (g) { | |
173 c = (struct chat_connection *)g->data; | |
174 if (c->id == id) | |
175 break; | |
176 g = g->next; | |
177 c = NULL; | |
178 } | |
179 | |
180 return c; | |
181 } | |
182 | |
183 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, | |
184 struct aim_conn_t *conn) { | |
185 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | |
186 struct chat_connection *c = NULL; | |
187 | |
188 while (g) { | |
189 c = (struct chat_connection *)g->data; | |
190 if (c->conn == conn) | |
191 break; | |
192 g = g->next; | |
193 c = NULL; | |
194 } | |
195 | |
196 return c; | |
197 } | |
198 | |
199 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); | |
200 static int gaim_parse_login (struct aim_session_t *, struct command_rx_struct *, ...); | |
201 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); | |
202 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); | |
203 static int gaim_info_change (struct aim_session_t *, struct command_rx_struct *, ...); | |
204 static int gaim_account_confirm (struct aim_session_t *, struct command_rx_struct *, ...); | |
205 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...); | |
206 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...); | |
207 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); | |
208 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); | |
209 static int gaim_parse_user_info (struct aim_session_t *, struct command_rx_struct *, ...); | |
210 static int gaim_parse_motd (struct aim_session_t *, struct command_rx_struct *, ...); | |
211 static int gaim_chatnav_info (struct aim_session_t *, struct command_rx_struct *, ...); | |
212 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); | |
213 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); | |
214 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); | |
215 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); | |
216 static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); | |
217 static int gaim_parse_ratechange (struct aim_session_t *, struct command_rx_struct *, ...); | |
218 static int gaim_parse_evilnotify (struct aim_session_t *, struct command_rx_struct *, ...); | |
219 static int gaim_parse_searcherror(struct aim_session_t *, struct command_rx_struct *, ...); | |
220 static int gaim_parse_searchreply(struct aim_session_t *, struct command_rx_struct *, ...); | |
221 static int gaim_bosrights (struct aim_session_t *, struct command_rx_struct *, ...); | |
222 static int gaim_rateresp (struct aim_session_t *, struct command_rx_struct *, ...); | |
223 static int gaim_reportinterval (struct aim_session_t *, struct command_rx_struct *, ...); | |
224 static int gaim_parse_msgerr (struct aim_session_t *, struct command_rx_struct *, ...); | |
225 static int gaim_parse_buddyrights(struct aim_session_t *, struct command_rx_struct *, ...); | |
226 static int gaim_parse_locerr (struct aim_session_t *, struct command_rx_struct *, ...); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
227 static int gaim_icbm_param_info (struct aim_session_t *, struct command_rx_struct *, ...); |
2086 | 228 static int gaim_parse_genericerr (struct aim_session_t *, struct command_rx_struct *, ...); |
229 static int gaim_memrequest (struct aim_session_t *, struct command_rx_struct *, ...); | |
230 | |
231 static int gaim_directim_initiate (struct aim_session_t *, struct command_rx_struct *, ...); | |
232 static int gaim_directim_incoming (struct aim_session_t *, struct command_rx_struct *, ...); | |
233 static int gaim_directim_disconnect(struct aim_session_t *, struct command_rx_struct *, ...); | |
234 static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...); | |
235 | |
236 static char *msgerrreason[] = { | |
237 "Invalid error", | |
238 "Invalid SNAC", | |
239 "Rate to host", | |
240 "Rate to client", | |
241 "Not logged in", | |
242 "Service unavailable", | |
243 "Service not defined", | |
244 "Obsolete SNAC", | |
245 "Not supported by host", | |
246 "Not supported by client", | |
247 "Refused by client", | |
248 "Reply too big", | |
249 "Responses lost", | |
250 "Request denied", | |
251 "Busted SNAC payload", | |
252 "Insufficient rights", | |
253 "In local permit/deny", | |
254 "Too evil (sender)", | |
255 "Too evil (receiver)", | |
256 "User temporarily unavailable", | |
257 "No match", | |
258 "List overflow", | |
259 "Request ambiguous", | |
260 "Queue full", | |
261 "Not while on AOL" | |
262 }; | |
263 static int msgerrreasonlen = 25; | |
264 | |
265 static void oscar_callback(gpointer data, gint source, | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
266 GaimInputCondition condition) { |
2086 | 267 struct aim_conn_t *conn = (struct aim_conn_t *)data; |
268 struct aim_session_t *sess = aim_conn_getsess(conn); | |
269 struct gaim_connection *gc = sess ? sess->aux_data : NULL; | |
270 struct oscar_data *odata; | |
271 | |
272 if (!gc) { | |
273 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
274 debug_printf("oscar callback for closed connection (1).\n"); | |
275 return; | |
276 } | |
277 | |
278 odata = (struct oscar_data *)gc->proto_data; | |
279 | |
280 if (!g_slist_find(connections, gc)) { | |
281 /* oh boy. this is probably bad. i guess the only thing we | |
282 * can really do is return? */ | |
283 debug_printf("oscar callback for closed connection (2).\n"); | |
284 return; | |
285 } | |
286 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
287 if (condition & GAIM_INPUT_READ) { |
2086 | 288 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { |
289 debug_printf("got information on rendezvous\n"); | |
290 if (aim_handlerendconnect(odata->sess, conn) < 0) { | |
291 debug_printf(_("connection error (rend)\n")); | |
292 } | |
293 } else { | |
294 if (aim_get_command(odata->sess, conn) >= 0) { | |
295 aim_rxdispatch(odata->sess); | |
296 if (odata->killme) | |
297 signoff(gc); | |
298 } else { | |
299 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
300 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { | |
301 debug_printf(_("major connection error\n")); | |
302 hide_login_progress(gc, _("Disconnected.")); | |
303 signoff(gc); | |
304 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
305 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
306 char buf[BUF_LONG]; | |
307 debug_printf("disconnected from chat room %s\n", c->name); | |
308 c->conn = NULL; | |
309 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
310 gaim_input_remove(c->inpa); |
2086 | 311 c->inpa = 0; |
312 c->fd = -1; | |
313 aim_conn_kill(odata->sess, &conn); | |
314 sprintf(buf, _("You have been disconnected from chat room %s."), c->name); | |
315 do_error_dialog(buf, _("Chat Error!")); | |
316 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
317 if (odata->cnpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
318 gaim_input_remove(odata->cnpa); |
2086 | 319 odata->cnpa = 0; |
320 debug_printf("removing chatnav input watcher\n"); | |
321 if (odata->create_exchange) { | |
322 odata->create_exchange = 0; | |
323 g_free(odata->create_name); | |
324 odata->create_name = NULL; | |
325 do_error_dialog(_("Chat is currently unavailable"), | |
326 _("Gaim - Chat")); | |
327 } | |
328 aim_conn_kill(odata->sess, &conn); | |
329 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
330 if (odata->paspa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
331 gaim_input_remove(odata->paspa); |
2086 | 332 odata->paspa = 0; |
333 debug_printf("removing authconn input watcher\n"); | |
334 aim_conn_kill(odata->sess, &conn); | |
335 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { | |
336 debug_printf("No handler for rendezvous disconnect (%d).\n", | |
337 source); | |
338 aim_conn_kill(odata->sess, &conn); | |
339 } else { | |
340 debug_printf("holy crap! generic connection error! %d\n", | |
341 conn->type); | |
342 aim_conn_kill(odata->sess, &conn); | |
343 } | |
344 } | |
345 } | |
346 } | |
347 } | |
348 | |
349 static void oscar_debug(struct aim_session_t *sess, int level, const char *format, va_list va) { | |
350 char *s = g_strdup_vprintf(format, va); | |
351 char buf[256]; | |
352 char *t; | |
353 struct gaim_connection *gc = sess->aux_data; | |
354 | |
355 g_snprintf(buf, sizeof(buf), "%s %d: ", gc->username, level); | |
356 t = g_strconcat(buf, s, NULL); | |
357 debug_printf(t); | |
358 if (t[strlen(t)-1] != '\n') | |
359 debug_printf("\n"); | |
360 g_free(t); | |
361 g_free(s); | |
362 } | |
363 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
364 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 365 { |
366 struct gaim_connection *gc = data; | |
367 struct oscar_data *odata; | |
368 struct aim_session_t *sess; | |
369 struct aim_conn_t *conn; | |
370 | |
371 if (!g_slist_find(connections, gc)) { | |
372 close(source); | |
373 return; | |
374 } | |
375 | |
376 odata = gc->proto_data; | |
377 sess = odata->sess; | |
378 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
379 | |
380 if (source < 0) { | |
381 hide_login_progress(gc, _("Couldn't connect to host")); | |
382 signoff(gc); | |
383 return; | |
384 } | |
385 | |
386 aim_conn_completeconnect(sess, conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
387 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, |
2086 | 388 oscar_callback, conn); |
389 debug_printf(_("Password sent, waiting for response\n")); | |
390 } | |
391 | |
392 static void oscar_login(struct aim_user *user) { | |
393 struct aim_session_t *sess; | |
394 struct aim_conn_t *conn; | |
395 char buf[256]; | |
396 struct gaim_connection *gc = new_gaim_conn(user); | |
397 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); | |
398 odata->create_exchange = 0; | |
399 | |
400 debug_printf(_("Logging in %s\n"), user->username); | |
401 | |
402 sess = g_new0(struct aim_session_t, 1); | |
403 | |
404 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
405 aim_setdebuggingcb(sess, oscar_debug); | |
406 | |
407 /* we need an immediate queue because we don't use a while-loop to | |
408 * see if things need to be sent. */ | |
409 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
410 odata->sess = sess; | |
411 sess->aux_data = gc; | |
412 | |
413 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
414 if (conn == NULL) { | |
415 debug_printf(_("internal connection error\n")); | |
416 hide_login_progress(gc, _("Unable to login to AIM")); | |
417 signoff(gc); | |
418 return; | |
419 } | |
420 | |
421 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
422 set_login_progress(gc, 2, buf); | |
423 | |
424 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
425 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
426 | |
427 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
428 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? | |
429 user->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, | |
430 user->proto_opt[USEROPT_AUTHPORT][0] ? | |
431 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
432 oscar_login_connect, gc); | |
433 if (conn->fd < 0) { | |
434 hide_login_progress(gc, _("Couldn't connect to host")); | |
435 signoff(gc); | |
436 return; | |
437 } | |
438 aim_request_login(sess, conn, gc->username); | |
439 } | |
440 | |
441 static void oscar_close(struct gaim_connection *gc) { | |
442 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
443 if (gc->protocol != PROTO_OSCAR) return; | |
444 | |
445 while (odata->oscar_chats) { | |
446 struct chat_connection *n = odata->oscar_chats->data; | |
447 if (n->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
448 gaim_input_remove(n->inpa); |
2086 | 449 g_free(n->name); |
450 g_free(n->show); | |
451 odata->oscar_chats = g_slist_remove(odata->oscar_chats, n); | |
452 g_free(n); | |
453 } | |
454 while (odata->direct_ims) { | |
455 struct direct_im *n = odata->direct_ims->data; | |
456 if (n->watcher > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
457 gaim_input_remove(n->watcher); |
2086 | 458 odata->direct_ims = g_slist_remove(odata->direct_ims, n); |
459 g_free(n); | |
460 } | |
461 #if USE_PIXBUF | |
462 while (odata->hasicons) { | |
463 struct icon_req *n = odata->hasicons->data; | |
464 g_free(n->user); | |
465 odata->hasicons = g_slist_remove(odata->hasicons, n); | |
466 g_free(n); | |
467 } | |
468 #endif | |
469 if (gc->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
470 gaim_input_remove(gc->inpa); |
2086 | 471 if (odata->cnpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
472 gaim_input_remove(odata->cnpa); |
2086 | 473 if (odata->paspa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
474 gaim_input_remove(odata->paspa); |
2086 | 475 aim_session_kill(odata->sess); |
476 g_free(odata->sess); | |
477 odata->sess = NULL; | |
478 g_free(gc->proto_data); | |
479 gc->proto_data = NULL; | |
480 debug_printf(_("Signed off.\n")); | |
481 } | |
482 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
483 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 484 struct gaim_connection *gc = data; |
485 struct oscar_data *odata; | |
486 struct aim_session_t *sess; | |
487 struct aim_conn_t *bosconn; | |
488 | |
489 if (!g_slist_find(connections, gc)) { | |
490 close(source); | |
491 return; | |
492 } | |
493 | |
494 odata = gc->proto_data; | |
495 sess = odata->sess; | |
496 bosconn = odata->conn; | |
497 | |
498 if (source < 0) { | |
499 hide_login_progress(gc, _("Could Not Connect")); | |
500 signoff(gc); | |
501 return; | |
502 } | |
503 | |
504 aim_conn_completeconnect(sess, bosconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
505 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, |
2086 | 506 oscar_callback, bosconn); |
507 set_login_progress(gc, 4, _("Connection established, cookie sent")); | |
508 } | |
509 | |
510 int gaim_parse_auth_resp(struct aim_session_t *sess, | |
511 struct command_rx_struct *command, ...) { | |
512 va_list ap; | |
513 struct aim_conn_t *bosconn = NULL; | |
514 char *sn = NULL, *bosip = NULL, *errurl = NULL, *email = NULL; | |
515 unsigned char *cookie = NULL; | |
516 int errorcode = 0, regstatus = 0; | |
517 int latestbuild = 0, latestbetabuild = 0; | |
518 char *latestrelease = NULL, *latestbeta = NULL; | |
519 char *latestreleaseurl = NULL, *latestbetaurl = NULL; | |
520 char *latestreleaseinfo = NULL, *latestbetainfo = NULL; | |
521 int i; char *host; int port; | |
522 struct aim_user *user; | |
523 | |
524 struct gaim_connection *gc = sess->aux_data; | |
525 struct oscar_data *od = gc->proto_data; | |
526 user = gc->user; | |
527 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
528 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
529 | |
530 va_start(ap, command); | |
531 sn = va_arg(ap, char *); | |
532 errorcode = va_arg(ap, int); | |
533 errurl = va_arg(ap, char *); | |
534 regstatus = va_arg(ap, int); | |
535 email = va_arg(ap, char *); | |
536 bosip = va_arg(ap, char *); | |
537 cookie = va_arg(ap, unsigned char *); | |
538 | |
539 latestrelease = va_arg(ap, char *); | |
540 latestbuild = va_arg(ap, int); | |
541 latestreleaseurl = va_arg(ap, char *); | |
542 latestreleaseinfo = va_arg(ap, char *); | |
543 | |
544 latestbeta = va_arg(ap, char *); | |
545 latestbetabuild = va_arg(ap, int); | |
546 latestbetaurl = va_arg(ap, char *); | |
547 latestbetainfo = va_arg(ap, char *); | |
548 | |
549 va_end(ap); | |
550 | |
551 debug_printf("inside auth_resp (Screen name: %s)\n", sn); | |
552 | |
553 if (errorcode || !bosip || !cookie) { | |
554 switch (errorcode) { | |
555 case 0x05: | |
556 /* Incorrect nick/password */ | |
557 hide_login_progress(gc, _("Incorrect nickname or password.")); | |
558 plugin_event(event_error, (void *)980, 0, 0, 0); | |
559 break; | |
560 case 0x11: | |
561 /* Suspended account */ | |
562 hide_login_progress(gc, _("Your account is currently suspended.")); | |
563 break; | |
564 case 0x18: | |
565 /* connecting too frequently */ | |
566 hide_login_progress(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); | |
567 plugin_event(event_error, (void *)983, 0, 0, 0); | |
568 break; | |
569 case 0x1c: | |
570 /* client too old */ | |
571 hide_login_progress(gc, _("The client version you are using is too old. Please upgrade at " WEBSITE)); | |
572 plugin_event(event_error, (void *)989, 0, 0, 0); | |
573 break; | |
574 default: | |
575 hide_login_progress(gc, _("Authentication Failed")); | |
576 break; | |
577 } | |
578 debug_printf("Login Error Code 0x%04x\n", errorcode); | |
579 debug_printf("Error URL: %s\n", errurl); | |
580 od->killme = TRUE; | |
581 return 1; | |
582 } | |
583 | |
584 | |
585 debug_printf("Reg status: %2d\n", regstatus); | |
586 if (email) { | |
587 debug_printf("Email: %s\n", email); | |
588 } else { | |
589 debug_printf("Email is NULL\n"); | |
590 } | |
591 debug_printf("BOSIP: %s\n", bosip); | |
592 if (latestbeta) | |
593 debug_printf("Latest WinAIM beta version %s, build %d, at %s (%s)\n", | |
594 latestbeta, latestbetabuild, latestbetaurl, latestbetainfo); | |
595 if (latestrelease) | |
596 debug_printf("Latest WinAIM released version %s, build %d, at %s (%s)\n", | |
597 latestrelease, latestbuild, latestreleaseurl, latestreleaseinfo); | |
598 debug_printf("Closing auth connection...\n"); | |
599 aim_conn_kill(sess, &command->conn); | |
600 | |
601 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
602 if (bosconn == NULL) { | |
603 hide_login_progress(gc, _("Internal Error")); | |
604 od->killme = TRUE; | |
605 return 0; | |
606 } | |
607 | |
608 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); | |
609 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, gaim_rateresp, 0); /* rate info */ | |
610 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
611 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, gaim_server_ready, 0); | |
612 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0); | |
613 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
614 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, gaim_reportinterval, 0); | |
615 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); | |
616 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
617 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
618 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
619 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
620 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
621 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); | |
622 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
623 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
624 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
625 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
626 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); | |
627 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
628 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
629 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 630 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
631 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
632 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
633 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
634 | |
635 ((struct oscar_data *)gc->proto_data)->conn = bosconn; | |
636 for (i = 0; i < (int)strlen(bosip); i++) { | |
637 if (bosip[i] == ':') { | |
638 port = atoi(&(bosip[i+1])); | |
639 break; | |
640 } | |
641 } | |
642 host = g_strndup(bosip, i); | |
643 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
644 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc); | |
645 g_free(host); | |
646 if (bosconn->fd < 0) { | |
647 hide_login_progress(gc, _("Could Not Connect")); | |
648 od->killme = TRUE; | |
649 return 0; | |
650 } | |
651 aim_auth_sendcookie(sess, bosconn, cookie); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
652 gaim_input_remove(gc->inpa); |
2086 | 653 return 1; |
654 } | |
655 | |
656 struct pieceofcrap { | |
657 struct gaim_connection *gc; | |
658 unsigned long offset; | |
659 unsigned long len; | |
660 char *modname; | |
661 int fd; | |
662 struct aim_conn_t *conn; | |
663 unsigned int inpa; | |
664 }; | |
665 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
666 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 667 { |
668 struct pieceofcrap *pos = data; | |
669 struct oscar_data *od = pos->gc->proto_data; | |
670 char in = '\0'; | |
671 int x = 0; | |
672 unsigned char m[17]; | |
673 | |
674 while (read(pos->fd, &in, 1) == 1) { | |
675 if (in == '\n') | |
676 x++; | |
677 else if (in != '\r') | |
678 x = 0; | |
679 if (x == 2) | |
680 break; | |
681 in = '\0'; | |
682 } | |
683 if (in != '\n') { | |
684 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
685 " You may be disconnected shortly.", "Login Error"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
686 gaim_input_remove(pos->inpa); |
2086 | 687 close(pos->fd); |
688 g_free(pos); | |
689 return; | |
690 } | |
691 read(pos->fd, m, 16); | |
692 m[16] = '\0'; | |
693 debug_printf("Sending hash: "); | |
694 for (x = 0; x < 16; x++) | |
695 debug_printf("%02x ", (unsigned char)m[x]); | |
696 debug_printf("\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
697 gaim_input_remove(pos->inpa); |
2086 | 698 close(pos->fd); |
699 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
700 g_free(pos); | |
701 } | |
702 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
703 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 704 struct pieceofcrap *pos = data; |
705 char buf[BUF_LONG]; | |
706 | |
707 if (source < 0) { | |
708 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
709 " You may be disconnected shortly.", "Login Error"); | |
710 if (pos->modname) | |
711 g_free(pos->modname); | |
712 g_free(pos); | |
713 return; | |
714 } | |
715 | |
716 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
717 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
718 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
719 write(pos->fd, buf, strlen(buf)); | |
720 if (pos->modname) | |
721 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
722 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 723 return; |
724 } | |
725 | |
726 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
727 #define AIM_MAX_FILE_SIZE 98304 | |
728 | |
729 int gaim_memrequest(struct aim_session_t *sess, | |
730 struct command_rx_struct *command, ...) { | |
731 va_list ap; | |
732 struct pieceofcrap *pos; | |
733 unsigned long offset, len; | |
734 char *modname; | |
735 int fd; | |
736 | |
737 va_start(ap, command); | |
738 offset = va_arg(ap, unsigned long); | |
739 len = va_arg(ap, unsigned long); | |
740 modname = va_arg(ap, char *); | |
741 va_end(ap); | |
742 | |
743 debug_printf("offset: %d, len: %d, file: %s\n", offset, len, modname ? modname : "aim.exe"); | |
744 if (len == 0) { | |
745 debug_printf("len is 0, hashing NULL\n"); | |
746 aim_sendmemblock(sess, command->conn, offset, len, NULL, | |
747 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
748 return 1; | |
749 } | |
750 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
751 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
752 char *buf; | |
753 int i = 8; | |
754 if (modname) | |
755 i += strlen(modname); | |
756 buf = g_malloc(i); | |
757 i = 0; | |
758 if (modname) { | |
759 memcpy(buf, modname, strlen(modname)); | |
760 i += strlen(modname); | |
761 } | |
762 buf[i++] = offset & 0xff; | |
763 buf[i++] = (offset >> 8) & 0xff; | |
764 buf[i++] = (offset >> 16) & 0xff; | |
765 buf[i++] = (offset >> 24) & 0xff; | |
766 buf[i++] = len & 0xff; | |
767 buf[i++] = (len >> 8) & 0xff; | |
768 buf[i++] = (len >> 16) & 0xff; | |
769 buf[i++] = (len >> 24) & 0xff; | |
770 debug_printf("len + offset is invalid, hashing request\n"); | |
771 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
772 g_free(buf); | |
773 return 1; | |
774 } | |
775 */ | |
776 | |
777 pos = g_new0(struct pieceofcrap, 1); | |
778 pos->gc = sess->aux_data; | |
779 pos->conn = command->conn; | |
780 | |
781 pos->offset = offset; | |
782 pos->len = len; | |
783 pos->modname = modname ? g_strdup(modname) : NULL; | |
784 | |
785 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); | |
786 if (fd < 0) { | |
787 if (pos->modname) | |
788 g_free(pos->modname); | |
789 g_free(pos); | |
790 do_error_dialog("Gaim was unable to get a valid hash for logging into AIM." | |
791 " You may be disconnected shortly.", "Login Error"); | |
792 } | |
793 pos->fd = fd; | |
794 | |
795 return 1; | |
796 } | |
797 | |
798 int gaim_parse_login(struct aim_session_t *sess, | |
799 struct command_rx_struct *command, ...) { | |
800 #if 0 | |
801 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
802 #else | |
803 struct client_info_s info = AIM_CLIENTINFO_KNOWNGOOD; | |
804 #endif | |
805 char *key; | |
806 va_list ap; | |
807 struct gaim_connection *gc = sess->aux_data; | |
808 | |
809 va_start(ap, command); | |
810 key = va_arg(ap, char *); | |
811 va_end(ap); | |
812 | |
813 aim_send_login(sess, command->conn, gc->username, gc->password, &info, key); | |
814 return 1; | |
815 } | |
816 | |
817 int gaim_server_ready(struct aim_session_t *sess, | |
818 struct command_rx_struct *command, ...) { | |
819 static int id = 1; | |
820 struct gaim_connection *gc = sess->aux_data; | |
821 struct oscar_data *od = gc->proto_data; | |
822 struct chat_connection *chatcon; | |
823 switch (command->conn->type) { | |
824 case AIM_CONN_TYPE_AUTH: | |
825 aim_auth_setversions(sess, command->conn); | |
826 aim_bos_reqrate(sess, command->conn); | |
827 debug_printf("done with AUTH ServerReady\n"); | |
828 if (od->chpass) { | |
829 debug_printf("changing password\n"); | |
830 aim_auth_changepasswd(sess, command->conn, od->newp, od->oldp); | |
831 g_free(od->oldp); | |
832 g_free(od->newp); | |
833 od->chpass = FALSE; | |
834 } | |
835 if (od->conf) { | |
836 debug_printf("confirming account\n"); | |
837 aim_auth_reqconfirm(sess, command->conn); | |
838 od->conf = FALSE; | |
839 } | |
840 if (od->reqemail) { | |
841 debug_printf("requesting email\n"); | |
842 aim_auth_getinfo(sess, command->conn, 0x0011); | |
843 od->reqemail = FALSE; | |
844 } | |
845 break; | |
846 case AIM_CONN_TYPE_BOS: | |
847 aim_setversions(sess, command->conn); | |
848 aim_bos_reqrate(sess, command->conn); /* request rate info */ | |
849 debug_printf("done with BOS ServerReady\n"); | |
850 break; | |
851 case AIM_CONN_TYPE_CHATNAV: | |
852 debug_printf("chatnav: got server ready\n"); | |
853 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); | |
854 aim_bos_reqrate(sess, command->conn); | |
855 aim_bos_ackrateresp(sess, command->conn); | |
856 aim_chatnav_clientready(sess, command->conn); | |
857 aim_chatnav_reqrights(sess, command->conn); | |
858 break; | |
859 case AIM_CONN_TYPE_CHAT: | |
860 debug_printf("chat: got server ready\n"); | |
861 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | |
862 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
863 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
864 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
865 aim_bos_reqrate(sess, command->conn); | |
866 aim_bos_ackrateresp(sess, command->conn); | |
867 aim_chat_clientready(sess, command->conn); | |
868 chatcon = find_oscar_chat_by_conn(gc, command->conn); | |
869 chatcon->id = id; | |
870 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
871 break; | |
872 case AIM_CONN_TYPE_RENDEZVOUS: | |
873 break; | |
874 default: /* huh? */ | |
875 debug_printf("server ready: got unexpected connection type %04x\n", command->conn->type); | |
876 break; | |
877 } | |
878 return 1; | |
879 } | |
880 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
881 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 882 { |
883 struct gaim_connection *gc = data; | |
884 struct oscar_data *odata; | |
885 struct aim_session_t *sess; | |
886 struct aim_conn_t *tstconn; | |
887 | |
888 if (!g_slist_find(connections, gc)) { | |
889 close(source); | |
890 return; | |
891 } | |
892 | |
893 odata = gc->proto_data; | |
894 sess = odata->sess; | |
895 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); | |
896 | |
897 if (source < 0) { | |
898 aim_conn_kill(sess, &tstconn); | |
899 debug_printf("unable to connect to chatnav server\n"); | |
900 return; | |
901 } | |
902 | |
903 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
904 odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2086 | 905 oscar_callback, tstconn); |
906 debug_printf("chatnav: connected\n"); | |
907 } | |
908 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
909 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 910 { |
911 struct gaim_connection *gc = data; | |
912 struct oscar_data *odata; | |
913 struct aim_session_t *sess; | |
914 struct aim_conn_t *tstconn; | |
915 | |
916 if (!g_slist_find(connections, gc)) { | |
917 close(source); | |
918 return; | |
919 } | |
920 | |
921 odata = gc->proto_data; | |
922 sess = odata->sess; | |
923 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
924 | |
925 if (source < 0) { | |
926 aim_conn_kill(sess, &tstconn); | |
927 debug_printf("unable to connect to authorizer\n"); | |
928 return; | |
929 } | |
930 | |
931 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
932 odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2086 | 933 oscar_callback, tstconn); |
934 debug_printf("chatnav: connected\n"); | |
935 } | |
936 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
937 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 938 { |
939 struct chat_connection *ccon = data; | |
940 struct gaim_connection *gc = ccon->gc; | |
941 struct oscar_data *odata; | |
942 struct aim_session_t *sess; | |
943 struct aim_conn_t *tstconn; | |
944 | |
945 if (!g_slist_find(connections, gc)) { | |
946 close(source); | |
947 g_free(ccon->show); | |
948 g_free(ccon->name); | |
949 g_free(ccon); | |
950 return; | |
951 } | |
952 | |
953 odata = gc->proto_data; | |
954 sess = odata->sess; | |
955 tstconn = ccon->conn; | |
956 | |
957 if (source < 0) { | |
958 aim_conn_kill(sess, &tstconn); | |
959 g_free(ccon->show); | |
960 g_free(ccon->name); | |
961 g_free(ccon); | |
962 return; | |
963 } | |
964 | |
965 aim_conn_completeconnect(sess, ccon->conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
966 ccon->inpa = gaim_input_add(tstconn->fd, |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
967 GAIM_INPUT_READ, |
2086 | 968 oscar_callback, tstconn); |
969 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | |
970 aim_chat_attachname(tstconn, ccon->name); | |
971 } | |
972 | |
973 int gaim_handle_redirect(struct aim_session_t *sess, | |
974 struct command_rx_struct *command, ...) { | |
975 va_list ap; | |
976 int serviceid; | |
977 char *ip; | |
978 unsigned char *cookie; | |
979 struct gaim_connection *gc = sess->aux_data; | |
980 struct aim_user *user = gc->user; | |
981 struct aim_conn_t *tstconn; | |
982 int i; | |
983 char *host; | |
984 int port; | |
985 | |
986 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
987 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
988 | |
989 va_start(ap, command); | |
990 serviceid = va_arg(ap, int); | |
991 ip = va_arg(ap, char *); | |
992 cookie = va_arg(ap, unsigned char *); | |
993 | |
994 for (i = 0; i < (int)strlen(ip); i++) { | |
995 if (ip[i] == ':') { | |
996 port = atoi(&(ip[i+1])); | |
997 break; | |
998 } | |
999 } | |
1000 host = g_strndup(ip, i); | |
1001 | |
1002 switch(serviceid) { | |
1003 case 0x7: /* Authorizer */ | |
1004 debug_printf("Reconnecting with authorizor...\n"); | |
1005 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1006 if (tstconn == NULL) { | |
1007 debug_printf("unable to reconnect with authorizer\n"); | |
1008 g_free(host); | |
1009 return 1; | |
1010 } | |
1011 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
1012 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, gaim_rateresp, 0); | |
1013 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); | |
1014 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
1015 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1016 | |
1017 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1018 tstconn->fd = proxy_connect(host, port, oscar_auth_connect, gc); | |
1019 if (tstconn->fd < 0) { | |
1020 aim_conn_kill(sess, &tstconn); | |
1021 debug_printf("unable to reconnect with authorizer\n"); | |
1022 g_free(host); | |
1023 return 1; | |
1024 } | |
1025 aim_auth_sendcookie(sess, tstconn, cookie); | |
1026 break; | |
1027 case 0xd: /* ChatNav */ | |
1028 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1029 if (tstconn == NULL) { | |
1030 debug_printf("unable to connect to chatnav server\n"); | |
1031 g_free(host); | |
1032 return 1; | |
1033 } | |
1034 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
1035 | |
1036 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1037 tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, gc); | |
1038 if (tstconn->fd < 0) { | |
1039 aim_conn_kill(sess, &tstconn); | |
1040 debug_printf("unable to connect to chatnav server\n"); | |
1041 g_free(host); | |
1042 return 1; | |
1043 } | |
1044 aim_auth_sendcookie(sess, tstconn, cookie); | |
1045 break; | |
1046 case 0xe: /* Chat */ | |
1047 { | |
1048 char *roomname = va_arg(ap, char *); | |
1049 int exchange = va_arg(ap, int); | |
1050 struct chat_connection *ccon; | |
1051 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); | |
1052 if (tstconn == NULL) { | |
1053 debug_printf("unable to connect to chat server\n"); | |
1054 g_free(host); | |
1055 return 1; | |
1056 } | |
1057 | |
1058 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
1059 ccon = g_new0(struct chat_connection, 1); | |
1060 ccon->conn = tstconn; | |
1061 ccon->gc = gc; | |
1062 ccon->fd = -1; | |
1063 ccon->name = g_strdup(roomname); | |
1064 ccon->exchange = exchange; | |
1065 ccon->show = extract_name(roomname); | |
1066 | |
1067 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1068 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); | |
1069 if (ccon->conn->fd < 0) { | |
1070 aim_conn_kill(sess, &tstconn); | |
1071 debug_printf("unable to connect to chat server\n"); | |
1072 g_free(host); | |
1073 g_free(ccon->show); | |
1074 g_free(ccon->name); | |
1075 g_free(ccon); | |
1076 return 1; | |
1077 } | |
1078 aim_auth_sendcookie(sess, tstconn, cookie); | |
1079 debug_printf("Connected to chat room %s exchange %d\n", roomname, exchange); | |
1080 } | |
1081 break; | |
1082 default: /* huh? */ | |
1083 debug_printf("got redirect for unknown service 0x%04x\n", serviceid); | |
1084 break; | |
1085 } | |
1086 | |
1087 va_end(ap); | |
1088 | |
1089 g_free(host); | |
1090 return 1; | |
1091 } | |
1092 | |
1093 int gaim_parse_oncoming(struct aim_session_t *sess, | |
1094 struct command_rx_struct *command, ...) { | |
1095 struct aim_userinfo_s *info; | |
1096 time_t time_idle; | |
1097 int type = 0; | |
1098 struct gaim_connection *gc = sess->aux_data; | |
1099 | |
1100 va_list ap; | |
1101 va_start(ap, command); | |
1102 info = va_arg(ap, struct aim_userinfo_s *); | |
1103 va_end(ap); | |
1104 | |
1105 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1106 type |= UC_UNCONFIRMED; | |
1107 else if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1108 type |= UC_ADMIN; | |
1109 else if (info->flags & AIM_FLAG_AOL) | |
1110 type |= UC_AOL; | |
1111 else if (info->flags & AIM_FLAG_FREE) | |
1112 type |= UC_NORMAL; | |
1113 if (info->flags & AIM_FLAG_AWAY) | |
1114 type |= UC_UNAVAILABLE; | |
1115 | |
1116 if (info->idletime) { | |
1117 time(&time_idle); | |
1118 time_idle -= info->idletime*60; | |
1119 } else | |
1120 time_idle = 0; | |
1121 | |
1122 serv_got_update(gc, info->sn, 1, info->warnlevel/10, info->onlinesince, | |
1123 time_idle, type, info->capabilities); | |
1124 | |
1125 return 1; | |
1126 } | |
1127 | |
1128 int gaim_parse_offgoing(struct aim_session_t *sess, | |
1129 struct command_rx_struct *command, ...) { | |
1130 struct aim_userinfo_s *info; | |
1131 va_list ap; | |
1132 struct gaim_connection *gc = sess->aux_data; | |
1133 | |
1134 va_start(ap, command); | |
1135 info = va_arg(ap, struct aim_userinfo_s *); | |
1136 va_end(ap); | |
1137 | |
1138 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); | |
1139 | |
1140 return 1; | |
1141 } | |
1142 | |
1143 static void cancel_direct_im(gpointer w, struct ask_direct *d) { | |
1144 debug_printf("Freeing DirectIM prompts.\n"); | |
1145 | |
1146 g_free(d->sn); | |
1147 g_free(d); | |
1148 } | |
1149 | |
1150 static void delete_direct_im(gpointer w, struct direct_im *d) { | |
1151 struct oscar_data *od = (struct oscar_data *)d->gc->proto_data; | |
1152 | |
1153 od->direct_ims = g_slist_remove(od->direct_ims, d); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1154 gaim_input_remove(d->watcher); |
2086 | 1155 aim_conn_kill(od->sess, &d->conn); |
1156 g_free(d); | |
1157 } | |
1158 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1159 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1160 struct direct_im *dim = data; |
1161 struct gaim_connection *gc = dim->gc; | |
1162 struct oscar_data *od = gc->proto_data; | |
1163 char buf[256]; | |
1164 | |
1165 if (!g_slist_find(connections, gc)) { | |
1166 g_free(dim); | |
1167 return; | |
1168 } | |
1169 | |
1170 if (source < 0) { | |
1171 g_free(dim); | |
1172 return; | |
1173 } | |
1174 | |
1175 aim_conn_completeconnect(od->sess, dim->conn); | |
1176 if (!(dim->cnv = find_conversation(dim->name))) dim->cnv = new_conversation(dim->name); | |
1177 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1178 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | |
1179 | |
1180 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1181 | |
1182 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", | |
1183 GTK_SIGNAL_FUNC(delete_direct_im), dim); | |
1184 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1185 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 1186 oscar_callback, dim->conn); |
1187 } | |
1188 | |
1189 static int accept_direct_im(gpointer w, struct ask_direct *d) { | |
1190 struct gaim_connection *gc = d->gc; | |
1191 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1192 struct direct_im *dim; | |
1193 char *host; int port = FAIM_LOGIN_PORT; | |
1194 int i; | |
1195 | |
1196 debug_printf("Accepted DirectIM.\n"); | |
1197 | |
1198 dim = find_direct_im(od, d->sn); | |
1199 if (dim) { | |
1200 cancel_direct_im(w, d); /* 40 */ | |
1201 return TRUE; | |
1202 } | |
1203 dim = g_new0(struct direct_im, 1); | |
1204 dim->gc = d->gc; | |
1205 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
1206 | |
1207 if ((dim->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL)) == NULL) { | |
1208 g_free(dim); | |
1209 cancel_direct_im(w, d); | |
1210 return TRUE; | |
1211 } | |
1212 dim->conn->subtype = AIM_CONN_SUBTYPE_OFT_DIRECTIM; | |
1213 dim->conn->priv = d->priv; | |
1214 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1215 gaim_directim_incoming, 0); | |
1216 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, | |
1217 gaim_directim_disconnect, 0); | |
1218 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1219 gaim_directim_typing, 0); | |
1220 | |
1221 for (i = 0; i < (int)strlen(d->priv->ip); i++) { | |
1222 if (d->priv->ip[i] == ':') { | |
1223 port = atoi(&(d->priv->ip[i+1])); | |
1224 break; | |
1225 } | |
1226 } | |
1227 host = g_strndup(d->priv->ip, i); | |
1228 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1229 dim->conn->fd = proxy_connect(host, port, oscar_directim_callback, dim); | |
1230 g_free(host); | |
1231 if (dim->conn->fd < 0) { | |
1232 aim_conn_kill(od->sess, &dim->conn); | |
1233 g_free(dim); | |
1234 cancel_direct_im(w, d); | |
1235 return TRUE; | |
1236 } | |
1237 | |
1238 cancel_direct_im(w, d); | |
1239 | |
1240 return TRUE; | |
1241 } | |
1242 | |
1243 int gaim_parse_incoming_im(struct aim_session_t *sess, | |
1244 struct command_rx_struct *command, ...) { | |
1245 int channel; | |
1246 struct aim_userinfo_s *userinfo; | |
1247 va_list ap; | |
1248 struct gaim_connection *gc = sess->aux_data; | |
1249 | |
1250 va_start(ap, command); | |
1251 channel = va_arg(ap, int); | |
1252 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
1253 | |
1254 /* channel 1: standard message */ | |
1255 if (channel == 1) { | |
1256 char *tmp = g_malloc(BUF_LONG); | |
1257 struct aim_incomingim_ch1_args *args; | |
1258 | |
1259 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
1260 va_end(ap); | |
1261 | |
1262 if (args->icbmflags & AIM_IMFLAGS_HASICON) { | |
1263 struct oscar_data *od = gc->proto_data; | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1264 struct icon_req *ir = NULL; |
2086 | 1265 GSList *h = od->hasicons; |
1266 char *who = normalize(userinfo->sn); | |
1267 debug_printf("%s has an icon\n", userinfo->sn); | |
1268 while (h) { | |
1269 ir = h->data; | |
1270 if (!strcmp(ir->user, who)) | |
1271 break; | |
1272 h = h->next; | |
1273 } | |
1274 if (!h) { | |
1275 ir = g_new0(struct icon_req, 1); | |
1276 ir->user = g_strdup(who); | |
1277 od->hasicons = g_slist_append(od->hasicons, ir); | |
1278 } | |
1279 if (args->iconstamp > ir->timestamp) | |
1280 ir->request = TRUE; | |
1281 ir->timestamp = args->iconstamp; | |
1282 } | |
1283 | |
1284 /* | |
1285 * Quickly convert it to eight bit format, replacing | |
1286 * non-ASCII UNICODE characters with their equivelent | |
1287 * HTML entity. | |
1288 */ | |
1289 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { | |
1290 int i; | |
1291 | |
1292 for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { | |
1293 unsigned short uni; | |
1294 | |
1295 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); | |
1296 | |
1297 if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ | |
1298 | |
1299 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "%c", uni); | |
1300 | |
1301 } else { /* something else, do UNICODE entity */ | |
1302 g_snprintf(tmp+strlen(tmp), BUF_LONG-strlen(tmp), "&#%04x;", uni); | |
1303 } | |
1304 } | |
1305 } else | |
1306 g_snprintf(tmp, BUF_LONG, "%s", args->msg); | |
1307 | |
1308 serv_got_im(gc, userinfo->sn, tmp, args->icbmflags & AIM_IMFLAGS_AWAY, time(NULL)); | |
1309 g_free(tmp); | |
1310 } else if (channel == 2) { | |
1311 struct aim_incomingim_ch2_args *args; | |
1312 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
1313 va_end(ap); | |
1314 if (args->reqclass & AIM_CAPS_CHAT) { | |
1315 char *name = extract_name(args->info.chat.roominfo.name); | |
1316 serv_got_chat_invite(gc, | |
1317 name ? name : args->info.chat.roominfo.name, | |
1318 args->info.chat.roominfo.exchange, | |
1319 userinfo->sn, | |
1320 args->info.chat.msg); | |
1321 if (name) | |
1322 g_free(name); | |
1323 } else if (args->reqclass & AIM_CAPS_SENDFILE) { | |
1324 } else if (args->reqclass & AIM_CAPS_GETFILE) { | |
1325 } else if (args->reqclass & AIM_CAPS_VOICE) { | |
1326 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { | |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
1327 set_icon_data(gc, normalize(userinfo->sn), args->info.icon.icon, |
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
1328 args->info.icon.length); |
2086 | 1329 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
1330 struct ask_direct *d = g_new0(struct ask_direct, 1); | |
1331 char buf[256]; | |
1332 | |
1333 debug_printf("%s received direct im request from %s (%s)\n", | |
1334 gc->username, userinfo->sn, args->info.directim->ip); | |
1335 | |
1336 d->gc = gc; | |
1337 d->sn = g_strdup(userinfo->sn); | |
1338 d->priv = args->info.directim; | |
1339 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", | |
1340 userinfo->sn, gc->username); | |
1341 do_ask_dialog(buf, d, accept_direct_im, cancel_direct_im); | |
1342 } else { | |
1343 debug_printf("Unknown reqclass %d\n", args->reqclass); | |
1344 } | |
1345 } | |
1346 | |
1347 return 1; | |
1348 } | |
1349 | |
1350 int gaim_parse_misses(struct aim_session_t *sess, | |
1351 struct command_rx_struct *command, ...) { | |
1352 va_list ap; | |
1353 unsigned short chan, nummissed, reason; | |
1354 struct aim_userinfo_s *userinfo; | |
1355 char buf[1024]; | |
1356 | |
1357 va_start(ap, command); | |
1358 chan = (unsigned short)va_arg(ap, unsigned int); | |
1359 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
1360 nummissed = (unsigned short)va_arg(ap, unsigned int); | |
1361 reason = (unsigned short)va_arg(ap, unsigned int); | |
1362 va_end(ap); | |
1363 | |
1364 switch(reason) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1365 case 0: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1366 /* Invalid (0) */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1367 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1368 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1369 _("You missed %d message%s from %s because %s invalid."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1370 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1371 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1372 nummissed == 1 ? "it was" : "they were", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1373 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1374 break; |
2086 | 1375 case 1: |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1376 /* Message too large */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1377 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1378 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1379 _("You missed %d message%s from %s because %s too large."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1380 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1381 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1382 nummissed == 1 ? "it was" : "they were", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1383 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1384 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1385 case 2: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1386 /* Rate exceeded */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1387 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1388 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1389 _("You missed %d message%s from %s because the rate limit has been exceeded."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1390 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1391 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1392 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1393 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1394 case 3: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1395 /* Evil Sender */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1396 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1397 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1398 _("You missed %d message%s from %s because they are too evil."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1399 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1400 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1401 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1402 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1403 case 4: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1404 /* Evil Receiver */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1405 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1406 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1407 _("You missed %d message%s from %s because you are too evil."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1408 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1409 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1410 userinfo->sn); |
2086 | 1411 break; |
1412 default: | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1413 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1414 sizeof(buf), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1415 _("You missed %d message%s from %s for unknown reasons."), |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1416 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1417 nummissed == 1 ? "" : "s", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1418 userinfo->sn); |
2086 | 1419 break; |
1420 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1421 do_error_dialog(buf, _("Gaim - Error")); |
2086 | 1422 |
1423 return 1; | |
1424 } | |
1425 | |
1426 int gaim_parse_genericerr(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1427 va_list ap; | |
1428 unsigned short reason; | |
1429 | |
1430 va_start(ap, command); | |
1431 reason = va_arg(ap, int); | |
1432 va_end(ap); | |
1433 | |
1434 debug_printf("snac threw error (reason 0x%04x: %s\n", reason, | |
1435 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); | |
1436 | |
1437 return 1; | |
1438 } | |
1439 | |
1440 int gaim_parse_msgerr(struct aim_session_t *sess, | |
1441 struct command_rx_struct *command, ...) { | |
1442 va_list ap; | |
1443 char *destn; | |
1444 unsigned short reason; | |
1445 char buf[1024]; | |
1446 | |
1447 va_start(ap, command); | |
1448 reason = (unsigned short)va_arg(ap, unsigned int); | |
1449 destn = va_arg(ap, char *); | |
1450 va_end(ap); | |
1451 | |
1452 sprintf(buf, _("Your message to %s did not get sent: %s"), destn, | |
1453 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
1454 do_error_dialog(buf, _("Gaim - Error")); | |
1455 | |
1456 return 1; | |
1457 } | |
1458 | |
1459 int gaim_parse_locerr(struct aim_session_t *sess, | |
1460 struct command_rx_struct *command, ...) { | |
1461 va_list ap; | |
1462 char *destn; | |
1463 unsigned short reason; | |
1464 char buf[1024]; | |
1465 | |
1466 va_start(ap, command); | |
1467 reason = (unsigned short)va_arg(ap, unsigned int); | |
1468 destn = va_arg(ap, char *); | |
1469 va_end(ap); | |
1470 | |
1471 sprintf(buf, _("User information for %s unavailable: %s"), destn, | |
1472 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
1473 do_error_dialog(buf, _("Gaim - Error")); | |
1474 | |
1475 return 1; | |
1476 } | |
1477 | |
1478 static char *images(int flags) { | |
1479 static char buf[1024]; | |
1480 g_snprintf(buf, sizeof(buf), "%s%s%s%s", | |
1481 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", | |
1482 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
1483 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", | |
1484 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : ""); | |
1485 return buf; | |
1486 } | |
1487 | |
1488 int gaim_parse_user_info(struct aim_session_t *sess, | |
1489 struct command_rx_struct *command, ...) { | |
1490 struct aim_userinfo_s *info; | |
1491 char *prof_enc = NULL, *prof = NULL; | |
1492 unsigned short infotype; | |
1493 char buf[BUF_LONG]; | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1494 char legend[BUF_LONG]; |
2086 | 1495 struct gaim_connection *gc = sess->aux_data; |
1496 va_list ap; | |
1497 char *asc; | |
1498 | |
1499 va_start(ap, command); | |
1500 info = va_arg(ap, struct aim_userinfo_s *); | |
1501 prof_enc = va_arg(ap, char *); | |
1502 prof = va_arg(ap, char *); | |
1503 infotype = (unsigned short)va_arg(ap, unsigned int); | |
1504 va_end(ap); | |
1505 | |
1506 if (info->membersince) | |
1507 asc = g_strdup_printf("Member Since : <B>%s</B><BR>\n", | |
1508 asctime(localtime(&info->membersince))); | |
1509 else | |
1510 asc = g_strdup(""); | |
1511 | |
1512 g_snprintf(buf, sizeof buf, | |
1513 _("Username : <B>%s</B> %s <BR>\n" | |
1514 "%s" | |
1515 "Warning Level : <B>%d %%</B><BR>\n" | |
1516 "Online Since : <B>%s</B><BR>\n" | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1517 "Idle Minutes : <B>%d</B>\n<BR>\n<HR><BR>\n"), |
2086 | 1518 info->sn, images(info->flags), |
1519 asc, | |
1520 info->warnlevel/10, | |
1521 asctime(localtime(&info->onlinesince)), | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1522 info->idletime); |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1523 g_snprintf(legend, sizeof legend, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1524 _("<br><BODY BGCOLOR=WHITE><hr><I>Legend:</I><br><br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1525 "<IMG SRC=\"free_icon.gif\"> : Normal AIM User<br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1526 "<IMG SRC=\"aol_icon.gif\"> : AOL User <br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1527 "<IMG SRC=\"dt_icon.gif\"> : Trial AIM User <br>" |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1528 "<IMG SRC=\"admin_icon.gif\"> : Administrator")); |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1529 g_show_info_text(buf, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1530 (prof && strlen(prof)) ? |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1531 away_subs(prof, gc->username) |
2086 | 1532 : |
1533 (infotype == AIM_GETINFO_GENERALINFO ? | |
1534 _("<i>No Information Provided</i>") : | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1535 _("<i>User has no away message</i>")), |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1536 legend, |
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1537 NULL); |
2086 | 1538 |
1539 g_free(asc); | |
1540 | |
1541 return 1; | |
1542 } | |
1543 | |
1544 int gaim_parse_motd(struct aim_session_t *sess, | |
1545 struct command_rx_struct *command, ...) { | |
1546 char *msg; | |
1547 unsigned short id; | |
1548 va_list ap; | |
1549 char buildbuf[150]; | |
1550 | |
1551 va_start(ap, command); | |
1552 id = (unsigned short)va_arg(ap, unsigned int); | |
1553 msg = va_arg(ap, char *); | |
1554 va_end(ap); | |
1555 | |
1556 aim_getbuildstring(buildbuf, sizeof(buildbuf)); | |
1557 | |
1558 debug_printf("MOTD: %s (%d)\n", msg ? msg : "Unknown", id); | |
1559 debug_printf("Gaim %s / Libfaim %s\n", VERSION, buildbuf); | |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1560 if (id < 4) |
2086 | 1561 do_error_dialog(_("Your connection may be lost."), |
1562 _("AOL error")); | |
1563 | |
1564 return 1; | |
1565 } | |
1566 | |
1567 int gaim_chatnav_info(struct aim_session_t *sess, | |
1568 struct command_rx_struct *command, ...) { | |
1569 va_list ap; | |
1570 unsigned short type; | |
1571 struct gaim_connection *gc = sess->aux_data; | |
1572 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
1573 | |
1574 va_start(ap, command); | |
1575 type = (unsigned short)va_arg(ap, unsigned int); | |
1576 | |
1577 switch(type) { | |
1578 case 0x0002: { | |
1579 int maxrooms; | |
1580 struct aim_chat_exchangeinfo *exchanges; | |
1581 int exchangecount, i = 0; | |
1582 | |
1583 maxrooms = (unsigned char)va_arg(ap, unsigned int); | |
1584 exchangecount = va_arg(ap, int); | |
1585 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
1586 va_end(ap); | |
1587 | |
1588 debug_printf("chat info: Chat Rights:\n"); | |
1589 debug_printf("chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
1590 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); | |
1591 while (i < exchangecount) | |
1592 debug_printf("chat info: \t\t%d\n", exchanges[i++].number); | |
1593 if (odata->create_exchange) { | |
1594 debug_printf("creating room %s\n", odata->create_name); | |
1595 aim_chatnav_createroom(sess, command->conn, odata->create_name, | |
1596 odata->create_exchange); | |
1597 odata->create_exchange = 0; | |
1598 g_free(odata->create_name); | |
1599 odata->create_name = NULL; | |
1600 } | |
1601 } | |
1602 break; | |
1603 case 0x0008: { | |
1604 char *fqcn, *name, *ck; | |
1605 unsigned short instance, flags, maxmsglen, maxoccupancy, unknown, exchange; | |
1606 unsigned char createperms; | |
1607 unsigned long createtime; | |
1608 | |
1609 fqcn = va_arg(ap, char *); | |
1610 instance = (unsigned short)va_arg(ap, unsigned int); | |
1611 exchange = (unsigned short)va_arg(ap, unsigned int); | |
1612 flags = (unsigned short)va_arg(ap, unsigned int); | |
1613 createtime = va_arg(ap, unsigned long); | |
1614 maxmsglen = (unsigned short)va_arg(ap, unsigned int); | |
1615 maxoccupancy = (unsigned short)va_arg(ap, unsigned int); | |
1616 createperms = (unsigned char)va_arg(ap, int); | |
1617 unknown = (unsigned short)va_arg(ap, unsigned int); | |
1618 name = va_arg(ap, char *); | |
1619 ck = va_arg(ap, char *); | |
1620 va_end(ap); | |
1621 | |
1622 debug_printf("created room: %s %d %d %d %lu %d %d %d %d %s %s\n", | |
1623 fqcn, | |
1624 exchange, instance, flags, | |
1625 createtime, | |
1626 maxmsglen, maxoccupancy, createperms, unknown, | |
1627 name, ck); | |
1628 aim_chat_join(odata->sess, odata->conn, exchange, ck); | |
1629 } | |
1630 break; | |
1631 default: | |
1632 va_end(ap); | |
1633 debug_printf("chatnav info: unknown type (%04x)\n", type); | |
1634 break; | |
1635 } | |
1636 return 1; | |
1637 } | |
1638 | |
1639 int gaim_chat_join(struct aim_session_t *sess, | |
1640 struct command_rx_struct *command, ...) { | |
1641 va_list ap; | |
1642 int count, i = 0; | |
1643 struct aim_userinfo_s *info; | |
1644 struct gaim_connection *g = sess->aux_data; | |
1645 | |
1646 struct chat_connection *c = NULL; | |
1647 | |
1648 va_start(ap, command); | |
1649 count = va_arg(ap, int); | |
1650 info = va_arg(ap, struct aim_userinfo_s *); | |
1651 va_end(ap); | |
1652 | |
1653 c = find_oscar_chat_by_conn(g, command->conn); | |
1654 if (!c) | |
1655 return 1; | |
1656 | |
1657 while (i < count) | |
1658 add_chat_buddy(c->cnv, info[i++].sn); | |
1659 | |
1660 return 1; | |
1661 } | |
1662 | |
1663 int gaim_chat_leave(struct aim_session_t *sess, | |
1664 struct command_rx_struct *command, ...) { | |
1665 va_list ap; | |
1666 int count, i = 0; | |
1667 struct aim_userinfo_s *info; | |
1668 struct gaim_connection *g = sess->aux_data; | |
1669 | |
1670 struct chat_connection *c = NULL; | |
1671 | |
1672 va_start(ap, command); | |
1673 count = va_arg(ap, int); | |
1674 info = va_arg(ap, struct aim_userinfo_s *); | |
1675 va_end(ap); | |
1676 | |
1677 c = find_oscar_chat_by_conn(g, command->conn); | |
1678 if (!c) | |
1679 return 1; | |
1680 | |
1681 while (i < count) | |
1682 remove_chat_buddy(c->cnv, info[i++].sn); | |
1683 | |
1684 return 1; | |
1685 } | |
1686 | |
1687 int gaim_chat_info_update(struct aim_session_t *sess, | |
1688 struct command_rx_struct *command, ...) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1689 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1690 struct aim_userinfo_s *userinfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1691 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1692 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1693 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1694 char *roomdesc; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1695 unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1696 unsigned long creationtime; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1697 struct gaim_connection *gc = sess->aux_data; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1698 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, command->conn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1699 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1700 va_start(ap, command); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1701 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1702 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1703 usercount= va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1704 userinfo = va_arg(ap, struct aim_userinfo_s *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1705 roomdesc = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1706 unknown_c9 = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1707 creationtime = va_arg(ap, unsigned long); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1708 maxmsglen = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1709 unknown_d2 = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1710 unknown_d5 = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1711 maxvisiblemsglen = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1712 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1713 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1714 debug_printf("inside chat_info_update (maxmsglen = %d, maxvislen = %d)\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1715 maxmsglen, maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1716 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1717 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1718 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1719 |
2086 | 1720 return 1; |
1721 } | |
1722 | |
1723 int gaim_chat_incoming_msg(struct aim_session_t *sess, | |
1724 struct command_rx_struct *command, ...) { | |
1725 va_list ap; | |
1726 struct aim_userinfo_s *info; | |
1727 char *msg; | |
1728 struct gaim_connection *gc = sess->aux_data; | |
1729 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, command->conn); | |
1730 char *tmp; | |
1731 | |
1732 va_start(ap, command); | |
1733 info = va_arg(ap, struct aim_userinfo_s *); | |
1734 msg = va_arg(ap, char *); | |
1735 | |
1736 tmp = g_malloc(BUF_LONG); | |
1737 g_snprintf(tmp, BUF_LONG, "%s", msg); | |
1738 serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL)); | |
1739 g_free(tmp); | |
1740 | |
1741 return 1; | |
1742 } | |
1743 | |
1744 /* | |
1745 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. | |
1746 */ | |
1747 int gaim_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1748 va_list ap; | |
1749 unsigned short type; | |
1750 char *sn = NULL; | |
1751 | |
1752 va_start(ap, command); | |
1753 type = (unsigned short)va_arg(ap, unsigned int); | |
1754 sn = va_arg(ap, char *); | |
1755 va_end(ap); | |
1756 | |
1757 debug_printf("Sent message to %s.\n", sn); | |
1758 | |
1759 return 1; | |
1760 } | |
1761 | |
1762 int gaim_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1763 static char *codes[5] = {"invalid", | |
1764 "change", | |
1765 "warning", | |
1766 "limit", | |
1767 "limit cleared"}; | |
1768 va_list ap; | |
1769 int code; | |
1770 unsigned long rateclass, windowsize, clear, alert, limit, disconnect; | |
1771 unsigned long currentavg, maxavg; | |
1772 | |
1773 va_start(ap, command); | |
1774 code = va_arg(ap, int); | |
1775 rateclass= va_arg(ap, int); | |
1776 windowsize = va_arg(ap, unsigned long); | |
1777 clear = va_arg(ap, unsigned long); | |
1778 alert = va_arg(ap, unsigned long); | |
1779 limit = va_arg(ap, unsigned long); | |
1780 disconnect = va_arg(ap, unsigned long); | |
1781 currentavg = va_arg(ap, unsigned long); | |
1782 maxavg = va_arg(ap, unsigned long); | |
1783 va_end(ap); | |
1784 | |
1785 debug_printf("rate %s (paramid 0x%04lx): curavg = %ld, maxavg = %ld, alert at %ld, " | |
1786 "clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n", | |
1787 (code < 5) ? codes[code] : codes[0], | |
1788 rateclass, | |
1789 currentavg, maxavg, | |
1790 alert, clear, | |
1791 limit, disconnect, | |
1792 windowsize); | |
1793 | |
1794 if (code == AIM_RATE_CODE_CHANGE) { | |
1795 if (currentavg >= clear) | |
1796 aim_conn_setlatency(command->conn, 0); | |
1797 } else if (code == AIM_RATE_CODE_WARNING) { | |
1798 aim_conn_setlatency(command->conn, windowsize/4); | |
1799 } else if (code == AIM_RATE_CODE_LIMIT) { | |
1800 aim_conn_setlatency(command->conn, windowsize/2); | |
1801 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { | |
1802 aim_conn_setlatency(command->conn, 0); | |
1803 } | |
1804 | |
1805 return 1; | |
1806 } | |
1807 | |
1808 int gaim_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1809 va_list ap; | |
1810 int newevil; | |
1811 struct aim_userinfo_s *userinfo; | |
1812 struct gaim_connection *gc = sess->aux_data; | |
1813 | |
1814 va_start(ap, command); | |
1815 newevil = va_arg(ap, int); | |
1816 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
1817 va_end(ap); | |
1818 | |
1819 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
1820 | |
1821 return 1; | |
1822 } | |
1823 | |
1824 int gaim_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1825 struct gaim_connection *gc = sess->aux_data; | |
1826 switch (command->conn->type) { | |
1827 case AIM_CONN_TYPE_BOS: | |
1828 aim_bos_ackrateresp(sess, command->conn); | |
1829 aim_bos_reqpersonalinfo(sess, command->conn); | |
1830 aim_bos_reqlocaterights(sess, command->conn); | |
1831 aim_bos_setprofile(sess, command->conn, gc->user->user_info, NULL, gaim_caps); | |
1832 aim_bos_reqbuddyrights(sess, command->conn); | |
1833 | |
1834 account_online(gc); | |
1835 serv_finish_login(gc); | |
1836 | |
1837 if (bud_list_cache_exists(gc)) | |
1838 do_import(NULL, gc); | |
1839 | |
1840 debug_printf("buddy list loaded\n"); | |
1841 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1842 aim_reqicbmparams(sess, command->conn); |
2086 | 1843 |
1844 aim_bos_reqrights(sess, command->conn); | |
1845 aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS); | |
1846 aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE | | |
1847 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
1848 | |
1849 break; | |
1850 case AIM_CONN_TYPE_AUTH: | |
1851 aim_bos_ackrateresp(sess, command->conn); | |
1852 aim_auth_clientready(sess, command->conn); | |
1853 debug_printf("connected to auth (admin)\n"); | |
1854 break; | |
1855 default: | |
1856 debug_printf("got rate response for unhandled connection type %04x\n", | |
1857 command->conn->type); | |
1858 break; | |
1859 } | |
1860 | |
1861 return 1; | |
1862 } | |
1863 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1864 int gaim_icbm_param_info(struct aim_session_t *sess, struct command_rx_struct *command, ...) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1865 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1866 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1867 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1868 va_start(ap, command); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1869 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1870 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1871 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1872 debug_printf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, " |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1873 "max sender evil = %f, max receiver evil = %f, min msg interval = %ld\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1874 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1875 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1876 params->minmsginterval); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1877 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1878 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1879 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1880 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1881 aim_seticbmparam(sess, command->conn, params); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1882 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1883 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1884 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1885 |
2086 | 1886 int gaim_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1887 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1888 unsigned short interval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1889 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1890 va_start(ap, command); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1891 interval = va_arg(ap, int); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1892 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1893 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1894 debug_printf("minimum report interval: %d (seconds?)\n", interval); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1895 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1896 aim_reqicbmparams(sess, command->conn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1897 |
2086 | 1898 return 1; |
1899 } | |
1900 | |
1901 int gaim_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1902 va_list ap; | |
1903 unsigned short maxbuddies, maxwatchers; | |
1904 | |
1905 va_start(ap, command); | |
1906 maxbuddies = (unsigned short)va_arg(ap, unsigned int); | |
1907 maxwatchers = (unsigned short)va_arg(ap, unsigned int); | |
1908 va_end(ap); | |
1909 | |
1910 debug_printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); | |
1911 | |
1912 return 1; | |
1913 } | |
1914 | |
1915 int gaim_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1916 unsigned short maxpermits, maxdenies; | |
1917 va_list ap; | |
1918 | |
1919 va_start(ap, command); | |
1920 maxpermits = (unsigned short)va_arg(ap, unsigned int); | |
1921 maxdenies = (unsigned short)va_arg(ap, unsigned int); | |
1922 va_end(ap); | |
1923 | |
1924 debug_printf("BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); | |
1925 | |
1926 aim_bos_clientready(sess, command->conn); | |
1927 | |
1928 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
1929 | |
1930 return 1; | |
1931 } | |
1932 | |
1933 int gaim_parse_searchreply(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1934 va_list ap; | |
1935 char *address, *SNs; | |
1936 int i, num; | |
1937 char *buf; | |
1938 int at = 0, len; | |
1939 | |
1940 va_start(ap, command); | |
1941 address = va_arg(ap, char *); | |
1942 num = va_arg(ap, int); | |
1943 SNs = va_arg(ap, char *); | |
1944 va_end(ap); | |
1945 | |
1946 len = num * (MAXSNLEN + 1) + 1024; | |
1947 buf = g_malloc(len); | |
1948 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
1949 for (i = 0; i < num; i++) | |
1950 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
1951 g_show_info_text(buf, NULL); |
2086 | 1952 g_free(buf); |
1953 | |
1954 return 1; | |
1955 } | |
1956 | |
1957 int gaim_parse_searcherror(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1958 va_list ap; | |
1959 char *address; | |
1960 char buf[BUF_LONG]; | |
1961 | |
1962 va_start(ap, command); | |
1963 address = va_arg(ap, char *); | |
1964 va_end(ap); | |
1965 | |
1966 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
1967 do_error_dialog(buf, _("Error")); | |
1968 | |
1969 return 1; | |
1970 } | |
1971 | |
1972 int gaim_account_confirm(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1973 int status; | |
1974 va_list ap; | |
1975 char msg[256]; | |
1976 struct gaim_connection *gc = sess->aux_data; | |
1977 | |
1978 va_start(ap, command); | |
1979 status = va_arg(ap, int); /* status code of confirmation request */ | |
1980 va_end(ap); | |
1981 | |
1982 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
1983 status ? "email sent" : "unknown"); | |
1984 if (status) { | |
1985 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", | |
1986 gc->username); | |
1987 do_error_dialog(msg, "Confirm"); | |
1988 } | |
1989 | |
1990 return 1; | |
1991 } | |
1992 | |
1993 int gaim_info_change(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
1994 unsigned short change = 0; | |
1995 int perms, type, length, str; | |
1996 char *val; | |
1997 va_list ap; | |
1998 char buf[BUF_LONG]; | |
1999 struct gaim_connection *gc = sess->aux_data; | |
2000 | |
2001 va_start(ap, command); | |
2002 perms = va_arg(ap, int); | |
2003 type = va_arg(ap, int); | |
2004 length = va_arg(ap, int); | |
2005 val = va_arg(ap, char *); | |
2006 str = va_arg(ap, int); | |
2007 va_end(ap); | |
2008 | |
2009 if (aimutil_get16(command->data+2) == 0x0005) | |
2010 change = 1; | |
2011 | |
2012 debug_printf("info%s: perms = %d, type = %x, length = %d, val = %s\n", | |
2013 change ? " change" : "", perms, type, length, str ? val : "(not string)"); | |
2014 | |
2015 if ((type == 0x0011) && str) { | |
2016 g_snprintf(buf, sizeof(buf), "The email address for %s is %s", gc->username, val); | |
2017 do_error_dialog(buf, "Email"); | |
2018 } | |
2019 | |
2020 return 1; | |
2021 } | |
2022 | |
2023 static void oscar_keepalive(struct gaim_connection *gc) { | |
2024 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
2025 aim_flap_nop(odata->sess, odata->conn); | |
2026 } | |
2027 | |
2028 static char *oscar_name() { | |
2029 return "Oscar"; | |
2030 } | |
2031 | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2113
diff
changeset
|
2032 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int away) { |
2086 | 2033 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
2034 struct direct_im *dim = find_direct_im(odata, name); | |
2035 if (dim) { | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2113
diff
changeset
|
2036 return aim_send_im_direct(odata->sess, dim->conn, message); |
2086 | 2037 } else { |
2038 if (away) | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2113
diff
changeset
|
2039 return aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message); |
2086 | 2040 else { |
2041 int flags = AIM_IMFLAGS_ACK; | |
2042 #if USE_PIXBUF | |
2043 GSList *h = odata->hasicons; | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
2044 struct icon_req *ir = NULL; |
2086 | 2045 char *who = normalize(name); |
2046 while (h) { | |
2047 ir = h->data; | |
2048 if (ir->request && !strcmp(who, ir->user)) | |
2049 break; | |
2050 h = h->next; | |
2051 } | |
2052 if (h) { | |
2053 ir->request = FALSE; | |
2054 flags |= AIM_IMFLAGS_BUDDYREQ; | |
2055 debug_printf("sending buddy icon request with message\n"); | |
2056 } | |
2057 #endif | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2113
diff
changeset
|
2058 return aim_send_im(odata->sess, odata->conn, name, flags, message); |
2086 | 2059 } |
2060 } | |
2061 } | |
2062 | |
2063 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
2064 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2065 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); | |
2066 } | |
2067 | |
2068 static void oscar_get_away_msg(struct gaim_connection *g, char *name) { | |
2069 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2070 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); | |
2071 } | |
2072 | |
2073 static void oscar_set_dir(struct gaim_connection *g, char *first, char *middle, char *last, | |
2074 char *maiden, char *city, char *state, char *country, int web) { | |
2075 /* FIXME : some of these things are wrong, but i'm lazy */ | |
2076 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2077 aim_setdirectoryinfo(odata->sess, odata->conn, first, middle, last, | |
2078 maiden, NULL, NULL, city, state, NULL, 0, web); | |
2079 } | |
2080 | |
2081 | |
2082 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
2083 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2084 aim_bos_setidle(odata->sess, odata->conn, time); | |
2085 } | |
2086 | |
2087 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
2088 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2089 char inforeal[1025], away[1025]; | |
2090 g_snprintf(inforeal, sizeof(inforeal), "%s", info); | |
2091 if (g->away) | |
2092 g_snprintf(away, sizeof(away), "%s", g->away); | |
2093 if (strlen(info) > 1024) | |
2094 do_error_dialog("Maximum info length (1024) exceeded, truncating", "Info Too Long"); | |
2095 aim_bos_setprofile(odata->sess, odata->conn, inforeal, g->away ? NULL : "", gaim_caps); | |
2096 } | |
2097 | |
2098 static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { | |
2099 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2100 char info[1025], away[1025]; | |
2101 g_snprintf(info, sizeof(info), "%s", g->user->user_info); | |
2102 if (message) | |
2103 g_snprintf(away, sizeof(away), "%s", message); | |
2104 aim_bos_setprofile(odata->sess, odata->conn, NULL, message ? away : "", gaim_caps); | |
2105 if (g->away) | |
2106 g_free (g->away); | |
2107 g->away = NULL; | |
2108 if (message) { | |
2109 if (strlen(message) > 1024) | |
2110 do_error_dialog("Maximum away length (1024) exceeded, truncating", | |
2111 "Info Too Long"); | |
2112 g->away = g_strdup (message); | |
2113 } | |
2114 } | |
2115 | |
2116 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { | |
2117 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2113 | 2118 aim_send_warning(odata->sess, odata->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 2119 } |
2120 | |
2121 static void oscar_dir_search(struct gaim_connection *g, char *first, char *middle, char *last, | |
2122 char *maiden, char *city, char *state, char *country, char *email) { | |
2123 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2124 if (strlen(email)) | |
2125 aim_usersearch_address(odata->sess, odata->conn, email); | |
2126 } | |
2127 | |
2128 static void oscar_add_buddy(struct gaim_connection *g, char *name) { | |
2129 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2130 aim_add_buddy(odata->sess, odata->conn, name); | |
2131 } | |
2132 | |
2133 static void oscar_add_buddies(struct gaim_connection *g, GList *buddies) { | |
2134 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2135 char buf[MSG_LEN]; | |
2136 int n = 0; | |
2137 while (buddies) { | |
2138 if (n > MSG_LEN - 18) { | |
2139 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
2140 n = 0; | |
2141 } | |
2142 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); | |
2143 buddies = buddies->next; | |
2144 } | |
2145 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
2146 } | |
2147 | |
2148 static void oscar_remove_buddy(struct gaim_connection *g, char *name) { | |
2149 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2150 aim_remove_buddy(odata->sess, odata->conn, name); | |
2151 } | |
2152 | |
2153 static void oscar_join_chat(struct gaim_connection *g, int exchange, char *name) { | |
2154 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2155 struct aim_conn_t *cur = NULL; | |
2156 if (!name) { | |
2157 if (!join_chat_entry || !join_chat_spin) | |
2158 return; | |
2159 name = gtk_entry_get_text(GTK_ENTRY(join_chat_entry)); | |
2160 exchange = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(join_chat_spin)); | |
2161 if (!name || !strlen(name)) | |
2162 return; | |
2163 } | |
2164 debug_printf("Attempting to join chat room %s.\n", name); | |
2165 if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { | |
2166 debug_printf("chatnav exists, creating room\n"); | |
2167 aim_chatnav_createroom(odata->sess, cur, name, exchange); | |
2168 } else { | |
2169 /* this gets tricky */ | |
2170 debug_printf("chatnav does not exist, opening chatnav\n"); | |
2171 odata->create_exchange = exchange; | |
2172 odata->create_name = g_strdup(name); | |
2173 aim_bos_reqservice(odata->sess, odata->conn, AIM_CONN_TYPE_CHATNAV); | |
2174 } | |
2175 } | |
2176 | |
2177 static void des_jc() | |
2178 { | |
2179 join_chat_entry = NULL; | |
2180 join_chat_spin = NULL; | |
2181 } | |
2182 | |
2183 static void oscar_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) { | |
2184 GtkWidget *label; | |
2185 GtkWidget *rowbox; | |
2186 GtkObject *adjust; | |
2187 | |
2188 rowbox = gtk_hbox_new(FALSE, 5); | |
2189 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); | |
2190 gtk_widget_show(rowbox); | |
2191 | |
2192 label = gtk_label_new(_("Join what group:")); | |
2193 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
2194 gtk_signal_connect(GTK_OBJECT(label), "destroy", GTK_SIGNAL_FUNC(des_jc), NULL); | |
2195 gtk_widget_show(label); | |
2196 | |
2197 join_chat_entry = gtk_entry_new(); | |
2198 gtk_box_pack_start(GTK_BOX(rowbox), join_chat_entry, TRUE, TRUE, 0); | |
2199 gtk_widget_grab_focus(join_chat_entry); | |
2200 gtk_signal_connect(GTK_OBJECT(join_chat_entry), "activate", GTK_SIGNAL_FUNC(do_join_chat), NULL); | |
2201 gtk_widget_show(join_chat_entry); | |
2202 | |
2203 rowbox = gtk_hbox_new(FALSE, 5); | |
2204 gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0); | |
2205 gtk_widget_show(rowbox); | |
2206 | |
2207 label = gtk_label_new(_("Exchange:")); | |
2208 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
2209 gtk_widget_show(label); | |
2210 | |
2211 adjust = gtk_adjustment_new(4, 4, 20, 1, 10, 10); | |
2212 join_chat_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); | |
2213 gtk_widget_set_usize(join_chat_spin, 50, -1); | |
2214 gtk_box_pack_start(GTK_BOX(rowbox), join_chat_spin, FALSE, FALSE, 0); | |
2215 gtk_widget_show(join_chat_spin); | |
2216 } | |
2217 | |
2218 static void oscar_chat_invite(struct gaim_connection *g, int id, char *message, char *name) { | |
2219 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2220 struct chat_connection *ccon = find_oscar_chat(g, id); | |
2221 | |
2222 if (!ccon) | |
2223 return; | |
2224 | |
2225 aim_chat_invite(odata->sess, odata->conn, name, message ? message : "", | |
2226 ccon->exchange, ccon->name, 0x0); | |
2227 } | |
2228 | |
2229 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
2230 struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL; | |
2231 GSList *bcs = g->buddy_chats; | |
2232 struct conversation *b = NULL; | |
2233 struct chat_connection *c = NULL; | |
2234 int count = 0; | |
2235 | |
2236 while (bcs) { | |
2237 count++; | |
2238 b = (struct conversation *)bcs->data; | |
2239 if (id == b->id) | |
2240 break; | |
2241 bcs = bcs->next; | |
2242 b = NULL; | |
2243 } | |
2244 | |
2245 if (!b) | |
2246 return; | |
2247 | |
2248 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
2249 | |
2250 c = find_oscar_chat(g, b->id); | |
2251 if (c != NULL) { | |
2252 if (odata) | |
2253 odata->oscar_chats = g_slist_remove(odata->oscar_chats, c); | |
2254 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2255 gaim_input_remove(c->inpa); |
2086 | 2256 if (g && odata->sess) |
2257 aim_conn_kill(odata->sess, &c->conn); | |
2258 g_free(c->name); | |
2259 g_free(c->show); | |
2260 g_free(c); | |
2261 } | |
2262 /* we do this because with Oscar it doesn't tell us we left */ | |
2263 serv_got_chat_left(g, b->id); | |
2264 } | |
2265 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2266 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
2086 | 2267 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2268 GSList *bcs = g->buddy_chats; | |
2269 struct conversation *b = NULL; | |
2270 struct chat_connection *c = NULL; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2271 char *buf, *buf2; |
2086 | 2272 int i, j; |
2273 | |
2274 while (bcs) { | |
2275 b = (struct conversation *)bcs->data; | |
2276 if (id == b->id) | |
2277 break; | |
2278 bcs = bcs->next; | |
2279 b = NULL; | |
2280 } | |
2281 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2282 return -EINVAL; |
2086 | 2283 |
2284 bcs = odata->oscar_chats; | |
2285 while (bcs) { | |
2286 c = (struct chat_connection *)bcs->data; | |
2287 if (b == c->cnv) | |
2288 break; | |
2289 bcs = bcs->next; | |
2290 c = NULL; | |
2291 } | |
2292 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2293 return -EINVAL; |
2086 | 2294 |
2295 buf = g_malloc(strlen(message) * 4 + 1); | |
2296 for (i = 0, j = 0; i < strlen(message); i++) { | |
2297 if (message[i] == '\n') { | |
2298 buf[j++] = '<'; | |
2299 buf[j++] = 'B'; | |
2300 buf[j++] = 'R'; | |
2301 buf[j++] = '>'; | |
2302 } else { | |
2303 buf[j++] = message[i]; | |
2304 } | |
2305 } | |
2306 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2307 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2308 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2309 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2310 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2311 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2312 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2313 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2314 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2315 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2316 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2317 |
2086 | 2318 aim_chat_send_im(odata->sess, c->conn, 0, buf, strlen(buf)); |
2319 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2320 return 0; |
2086 | 2321 } |
2322 | |
2323 static char **oscar_list_icon(int uc) { | |
2324 if (uc & UC_UNAVAILABLE) | |
2325 return (char **)away_icon_xpm; | |
2326 if (uc & UC_AOL) | |
2327 return (char **)aol_icon_xpm; | |
2328 if (uc & UC_NORMAL) | |
2329 return (char **)free_icon_xpm; | |
2330 if (uc & UC_ADMIN) | |
2331 return (char **)admin_icon_xpm; | |
2332 if (uc & UC_UNCONFIRMED) | |
2333 return (char **)dt_icon_xpm; | |
2334 return NULL; | |
2335 } | |
2336 | |
2337 static int gaim_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
2338 va_list ap; | |
2339 struct gaim_connection *gc = sess->aux_data; | |
2340 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2341 struct aim_directim_priv *priv; | |
2342 struct aim_conn_t *newconn; | |
2343 struct direct_im *dim; | |
2344 char buf[256]; | |
2345 | |
2346 va_start(ap, command); | |
2347 newconn = va_arg(ap, struct aim_conn_t *); | |
2348 va_end(ap); | |
2349 | |
2350 priv = (struct aim_directim_priv *)newconn->priv; | |
2351 | |
2352 debug_printf("DirectIM: initiate success to %s\n", priv->sn); | |
2353 dim = find_direct_im(od, priv->sn); | |
2354 | |
2355 dim->cnv = find_conversation(priv->sn); | |
2356 if (!dim->cnv) dim->cnv = new_conversation(priv->sn); | |
2357 gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy", | |
2358 GTK_SIGNAL_FUNC(delete_direct_im), dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2359 gaim_input_remove(dim->watcher); |
2086 | 2360 dim->conn = newconn; |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2361 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 2362 oscar_callback, dim->conn); |
2363 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), priv->sn); | |
2364 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | |
2365 | |
2366 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
2367 gaim_directim_incoming, 0); | |
2368 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, | |
2369 gaim_directim_disconnect, 0); | |
2370 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
2371 gaim_directim_typing, 0); | |
2372 | |
2373 return 1; | |
2374 } | |
2375 | |
2376 static int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
2377 va_list ap; | |
2378 char *msg = NULL; | |
2379 struct aim_conn_t *conn; | |
2380 struct aim_directim_priv *priv; | |
2381 struct gaim_connection *gc = sess->aux_data; | |
2382 | |
2383 va_start(ap, command); | |
2384 conn = va_arg(ap, struct aim_conn_t *); | |
2385 msg = va_arg(ap, char *); | |
2386 va_end(ap); | |
2387 | |
2388 if (!(priv = conn->priv)) { | |
2389 return -1; | |
2390 } | |
2391 | |
2392 debug_printf("Got DirectIM message from %s\n", priv->sn); | |
2393 | |
2394 serv_got_im(gc, priv->sn, msg, 0, time((time_t)NULL)); | |
2395 | |
2396 return 1; | |
2397 } | |
2398 | |
2399 static int gaim_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
2400 va_list ap; | |
2401 struct aim_conn_t *conn; | |
2402 char *sn; | |
2403 struct gaim_connection *gc = sess->aux_data; | |
2404 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2405 struct direct_im *dim; | |
2406 char buf[256]; | |
2407 | |
2408 va_start(ap, command); | |
2409 conn = va_arg(ap, struct aim_conn_t *); | |
2410 sn = va_arg(ap, char *); | |
2411 va_end(ap); | |
2412 | |
2413 debug_printf("%s disconnected Direct IM.\n", sn); | |
2414 | |
2415 dim = find_direct_im(od, sn); | |
2416 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2417 gaim_input_remove(dim->watcher); |
2086 | 2418 gtk_signal_disconnect_by_data(GTK_OBJECT(dim->cnv->window), dim); |
2419 | |
2420 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
2421 if (dim->cnv) | |
2422 write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL)); | |
2423 | |
2424 aim_conn_kill(sess, &conn); | |
2425 | |
2426 return 1; | |
2427 } | |
2428 | |
2429 static int gaim_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
2430 va_list ap; | |
2431 struct aim_conn_t *conn; | |
2432 struct aim_directim_priv *priv; | |
2433 | |
2434 va_start(ap, command); | |
2435 conn = va_arg(ap, struct aim_conn_t *); | |
2436 va_end(ap); | |
2437 | |
2438 if (!(priv = conn->priv)) { | |
2439 return -1; | |
2440 } | |
2441 | |
2442 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
2443 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", priv->sn); | |
2444 | |
2445 return 1; | |
2446 } | |
2447 | |
2448 struct ask_do_dir_im { | |
2449 char *who; | |
2450 struct gaim_connection *gc; | |
2451 }; | |
2452 | |
2453 static void oscar_cancel_direct_im(GtkObject *obj, struct ask_do_dir_im *data) { | |
2454 g_free(data); | |
2455 } | |
2456 | |
2457 static void oscar_direct_im(GtkObject *obj, struct ask_do_dir_im *data) { | |
2458 struct gaim_connection *gc = data->gc; | |
2459 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2460 struct direct_im *dim; | |
2461 | |
2462 dim = find_direct_im(od, data->who); | |
2463 if (dim) { | |
2464 do_error_dialog("Direct IM request already pending.", "Unable"); | |
2465 return; | |
2466 } | |
2467 dim = g_new0(struct direct_im, 1); | |
2468 dim->gc = gc; | |
2469 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
2470 | |
2471 dim->conn = aim_directim_initiate(od->sess, od->conn, NULL, data->who); | |
2472 if (dim->conn != NULL) { | |
2473 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2474 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 2475 oscar_callback, dim->conn); |
2476 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, | |
2477 gaim_directim_initiate, 0); | |
2478 } else { | |
2479 do_error_dialog(_("Unable to open Direct IM"), _("Error")); | |
2480 g_free(dim); | |
2481 } | |
2482 } | |
2483 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2484 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
2086 | 2485 char buf[BUF_LONG]; |
2486 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
2487 data->who = who; | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2488 data->gc = gc; |
2086 | 2489 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s." |
2490 " Doing this will let them see your IP address, and may be" | |
2491 " a security risk. Do you wish to continue?"), who); | |
2492 do_ask_dialog(buf, data, oscar_direct_im, oscar_cancel_direct_im); | |
2493 } | |
2494 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2495 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2496 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2497 struct proto_buddy_menu *pbm; |
2086 | 2498 char *n = g_strdup(normalize(gc->username)); |
2499 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2500 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2501 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2502 pbm->callback = oscar_get_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2503 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2504 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2505 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2506 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2507 pbm->label = _("Get Away Msg"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2508 pbm->callback = oscar_get_away_msg; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2509 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2510 m = g_list_append(m, pbm); |
2086 | 2511 |
2512 if (strcmp(n, normalize(who))) { | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2513 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2514 pbm->label = _("Direct IM"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2515 pbm->callback = oscar_ask_direct_im; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2516 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2517 m = g_list_append(m, pbm); |
2086 | 2518 } |
2519 g_free(n); | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2520 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
2521 return m; |
2086 | 2522 } |
2523 | |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2524 static GList *oscar_user_opts() |
2086 | 2525 { |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2526 GList *m = NULL; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2527 struct proto_user_opt *puo; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2528 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2529 puo = g_new0(struct proto_user_opt, 1); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2530 puo->label = "Auth Host:"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2531 puo->def = "login.oscar.aol.com"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2532 puo->pos = USEROPT_AUTH; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2533 m = g_list_append(m, puo); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2534 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2535 puo = g_new0(struct proto_user_opt, 1); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2536 puo->label = "Auth Port:"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2537 puo->def = "5190"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2538 puo->pos = USEROPT_AUTHPORT; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2539 m = g_list_append(m, puo); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2540 |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2141
diff
changeset
|
2541 return m; |
2086 | 2542 } |
2543 | |
2544 static void oscar_set_permit_deny(struct gaim_connection *gc) { | |
2545 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2546 GSList *list; | |
2547 char buf[MAXMSGLEN]; | |
2548 int at; | |
2549 | |
2550 switch(gc->permdeny) { | |
2551 case 1: | |
2552 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); | |
2553 break; | |
2554 case 2: | |
2555 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
2556 break; | |
2557 case 3: | |
2558 list = gc->permit; | |
2559 at = 0; | |
2560 while (list) { | |
2561 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
2562 list = list->next; | |
2563 } | |
2564 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
2565 break; | |
2566 case 4: | |
2567 list = gc->deny; | |
2568 at = 0; | |
2569 while (list) { | |
2570 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
2571 list = list->next; | |
2572 } | |
2573 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
2574 break; | |
2575 default: | |
2576 break; | |
2577 } | |
2578 } | |
2579 | |
2580 static void oscar_add_permit(struct gaim_connection *gc, char *who) { | |
2581 if (gc->permdeny != 3) return; | |
2582 oscar_set_permit_deny(gc); | |
2583 } | |
2584 | |
2585 static void oscar_add_deny(struct gaim_connection *gc, char *who) { | |
2586 if (gc->permdeny != 4) return; | |
2587 oscar_set_permit_deny(gc); | |
2588 } | |
2589 | |
2590 static void oscar_rem_permit(struct gaim_connection *gc, char *who) { | |
2591 if (gc->permdeny != 3) return; | |
2592 oscar_set_permit_deny(gc); | |
2593 } | |
2594 | |
2595 static void oscar_rem_deny(struct gaim_connection *gc, char *who) { | |
2596 if (gc->permdeny != 4) return; | |
2597 oscar_set_permit_deny(gc); | |
2598 } | |
2599 | |
2600 static void oscar_draw_new_user(GtkWidget *box) | |
2601 { | |
2602 GtkWidget *label; | |
2603 | |
2604 label = gtk_label_new(_("Unfortunately, currently Oscar only allows new user registration by " | |
2605 "going to http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no" | |
2606 ". Clicking the Register button will open the URL for you.")); | |
2607 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
2608 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5); | |
2609 gtk_widget_show(label); | |
2610 } | |
2611 | |
2612 static void oscar_do_new_user() | |
2613 { | |
2614 open_url(NULL, "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); | |
2615 } | |
2616 | |
2617 static GList *oscar_away_states() | |
2618 { | |
2619 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | |
2620 } | |
2621 | |
2622 static void oscar_do_action(struct gaim_connection *gc, char *act) | |
2623 { | |
2624 struct oscar_data *od = gc->proto_data; | |
2625 struct aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
2626 | |
2627 if (!strcmp(act, "Set User Info")) { | |
2628 show_set_info(gc); | |
2629 } else if (!strcmp(act, "Change Password")) { | |
2630 show_change_passwd(gc); | |
2631 } else if (!strcmp(act, "Confirm Account")) { | |
2632 if (!conn) { | |
2633 od->conf = TRUE; | |
2634 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2635 } else | |
2636 aim_auth_reqconfirm(od->sess, conn); | |
2637 } else if (!strcmp(act, "Change Email")) { | |
2638 } else if (!strcmp(act, "Display Current Registered Address")) { | |
2639 if (!conn) { | |
2640 od->reqemail = TRUE; | |
2641 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2642 } else | |
2643 aim_auth_getinfo(od->sess, conn, 0x11); | |
2644 } else if (!strcmp(act, "Search for Buddy by Email")) { | |
2645 show_find_email(gc); | |
2646 } | |
2647 } | |
2648 | |
2649 static GList *oscar_actions() | |
2650 { | |
2651 GList *m = NULL; | |
2652 | |
2653 m = g_list_append(m, "Set User Info"); | |
2654 m = g_list_append(m, NULL); | |
2655 m = g_list_append(m, "Change Password"); | |
2656 m = g_list_append(m, "Confirm Account"); | |
2657 /* | |
2658 m = g_list_append(m, "Change Email"); | |
2659 */ | |
2660 m = g_list_append(m, "Display Current Registered Address"); | |
2661 m = g_list_append(m, NULL); | |
2662 m = g_list_append(m, "Search for Buddy by Email"); | |
2663 | |
2664 return m; | |
2665 } | |
2666 | |
2667 static void oscar_change_passwd(struct gaim_connection *gc, char *old, char *new) | |
2668 { | |
2669 struct oscar_data *od = gc->proto_data; | |
2670 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
2671 od->chpass = TRUE; | |
2672 od->oldp = g_strdup(old); | |
2673 od->newp = g_strdup(new); | |
2674 aim_bos_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
2675 } else { | |
2676 aim_auth_changepasswd(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), | |
2677 new, old); | |
2678 } | |
2679 } | |
2680 | |
2681 static struct prpl *my_protocol = NULL; | |
2682 | |
2683 void oscar_init(struct prpl *ret) { | |
2684 ret->protocol = PROTO_OSCAR; | |
2685 ret->options = OPT_PROTO_HTML | OPT_PROTO_CORRECT_TIME; | |
2686 ret->name = oscar_name; | |
2687 ret->list_icon = oscar_list_icon; | |
2688 ret->away_states = oscar_away_states; | |
2689 ret->actions = oscar_actions; | |
2690 ret->do_action = oscar_do_action; | |
2691 ret->buddy_menu = oscar_buddy_menu; | |
2692 ret->user_opts = oscar_user_opts; | |
2693 ret->draw_new_user = oscar_draw_new_user; | |
2694 ret->do_new_user = oscar_do_new_user; | |
2695 ret->login = oscar_login; | |
2696 ret->close = oscar_close; | |
2697 ret->send_im = oscar_send_im; | |
2698 ret->set_info = oscar_set_info; | |
2699 ret->get_info = oscar_get_info; | |
2700 ret->set_away = oscar_set_away; | |
2701 ret->get_away_msg = oscar_get_away_msg; | |
2702 ret->set_dir = oscar_set_dir; | |
2703 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
2704 ret->dir_search = oscar_dir_search; | |
2705 ret->set_idle = oscar_set_idle; | |
2706 ret->change_passwd = oscar_change_passwd; | |
2707 ret->add_buddy = oscar_add_buddy; | |
2708 ret->add_buddies = oscar_add_buddies; | |
2709 ret->remove_buddy = oscar_remove_buddy; | |
2710 ret->add_permit = oscar_add_permit; | |
2711 ret->add_deny = oscar_add_deny; | |
2712 ret->rem_permit = oscar_rem_permit; | |
2713 ret->rem_deny = oscar_rem_deny; | |
2714 ret->set_permit_deny = oscar_set_permit_deny; | |
2715 ret->warn = oscar_warn; | |
2716 ret->accept_chat = NULL; /* oscar doesn't have accept, it just joins */ | |
2717 ret->join_chat = oscar_join_chat; | |
2718 ret->draw_join_chat = oscar_draw_join_chat; | |
2719 ret->chat_invite = oscar_chat_invite; | |
2720 ret->chat_leave = oscar_chat_leave; | |
2721 ret->chat_whisper = NULL; | |
2722 ret->chat_send = oscar_chat_send; | |
2723 ret->keepalive = oscar_keepalive; | |
2724 | |
2725 my_protocol = ret; | |
2726 } | |
2727 | |
2728 #ifndef STATIC | |
2729 | |
2730 char *gaim_plugin_init(GModule *handle) | |
2731 { | |
2732 load_protocol(oscar_init, sizeof(struct prpl)); | |
2733 return NULL; | |
2734 } | |
2735 | |
2736 void gaim_plugin_remove() | |
2737 { | |
2738 struct prpl *p = find_prpl(PROTO_OSCAR); | |
2739 if (p == my_protocol) | |
2740 unload_protocol(p); | |
2741 } | |
2742 | |
2743 char *name() | |
2744 { | |
2745 return "Oscar"; | |
2746 } | |
2747 | |
2748 char *description() | |
2749 { | |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2154
diff
changeset
|
2750 return PRPL_DESC("Oscar"); |
2086 | 2751 } |
2752 | |
2753 #endif |