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