comparison src/oscar.c @ 312:3069be4c291e

[gaim-migrate @ 322] I don't know why I did this. I have homework due in 15 hours that I haven't started yet, and it's in a language I don't know and it's a project I don't understand. If my teacher knew about this, he would be pissed. He looks pissed all the time, even when he's not. When he smiles he looks devilish. Maybe I only think that because literally half the class flunked the midterm. I am not joking about that. More people got F's than A, B, and C combined. It's 2 am and the homework's due at 5 tomorrow so what do I do? Get chat to work. Wow. That's going to look good on my resume. "Why did you flunk this class?" "Because I was getting chat in Instant Messenger to work." Not that that's not something to be proud of, but I wonder which is more important to employers. The big battle, experience versus education. Just because you got good grades in college doesn't mean you're smarter than someone who flunked, it just means you put in the effort necessary to get a better grade and the other person didn't. Maybe the person who flunked was working on real honest-to-god actually *used* software, as opposed to some stupid tree that only gets used for a fringe branch of computer science that doesn't offer much more than a normal heap or binary search tree offers. Maybe the person was out there reverse-engineering protocols and allowing cross- platform communication to occur, creating interoperability and causing a greater demand not only for the product, but for the platform it runs on! Given the choices, who would you pick? Someone who was told how to code a tree and managed to get it to work, or someone who increases your userbase and marketability? Enough of my rant for a while. I've had waaaaay too much sugar (gummy candy is deadly). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 02 Jun 2000 09:11:48 +0000
parents 61894ab8c47e
children cea40691706c
comparison
equal deleted inserted replaced
311:0a8b4edc4732 312:3069be4c291e
41 static int inpa = -1; 41 static int inpa = -1;
42 struct aim_session_t *gaim_sess; 42 struct aim_session_t *gaim_sess;
43 struct aim_conn_t *gaim_conn; 43 struct aim_conn_t *gaim_conn;
44 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE; 44 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE;
45 45
46 GList *oscar_chats = NULL;
47
48 struct chat_connection *find_oscar_chat(char *name) {
49 GList *g = oscar_chats;
50 struct chat_connection *c = NULL;
51
52 while (g) {
53 c = (struct chat_connection *)g->data;
54 if (!strcmp(name, c->name))
55 break;
56 g = g->next;
57 c = NULL;
58 }
59
60 return c;
61 }
62
46 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); 63 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...);
47 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...); 64 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...);
48 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); 65 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...);
66 static int gaim_chat_server_ready(struct aim_session_t *, struct command_rx_struct *, ...);
49 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); 67 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...);
50 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...); 68 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...);
51 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...); 69 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...);
52 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); 70 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...);
53 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); 71 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...);
267 return 1; 285 return 1;
268 } 286 }
269 287
270 int gaim_server_ready(struct aim_session_t *sess, 288 int gaim_server_ready(struct aim_session_t *sess,
271 struct command_rx_struct *command, ...) { 289 struct command_rx_struct *command, ...) {
272 static int id = 1;
273 switch (command->conn->type) { 290 switch (command->conn->type) {
274 case AIM_CONN_TYPE_BOS: 291 case AIM_CONN_TYPE_BOS:
275 aim_bos_reqrate(sess, command->conn); 292 aim_bos_reqrate(sess, command->conn);
276 aim_bos_ackrateresp(sess, command->conn); 293 aim_bos_ackrateresp(sess, command->conn);
277 aim_bos_setprivacyflags(sess, command->conn, 0x00000003); 294 aim_bos_setprivacyflags(sess, command->conn, 0x00000003);
285 aim_bos_reqrate(sess, command->conn); 302 aim_bos_reqrate(sess, command->conn);
286 aim_bos_ackrateresp(sess, command->conn); 303 aim_bos_ackrateresp(sess, command->conn);
287 aim_chatnav_clientready(sess, command->conn); 304 aim_chatnav_clientready(sess, command->conn);
288 aim_chatnav_reqrights(sess, command->conn); 305 aim_chatnav_reqrights(sess, command->conn);
289 break; 306 break;
290 case AIM_CONN_TYPE_CHAT:
291 debug_print("chat: got server ready\n");
292 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
293 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
294 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
295 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
296 aim_bos_reqrate(sess, command->conn);
297 aim_bos_ackrateresp(sess, command->conn);
298 aim_chat_clientready(sess, command->conn);
299 serv_got_joined_chat(id++, aim_chat_getname(command->conn));
300 break;
301 default: /* huh? */ 307 default: /* huh? */
302 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); 308 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type);
303 debug_print(debug_buff); 309 debug_print(debug_buff);
304 break; 310 break;
305 } 311 }
306 return 1; 312 return 1;
313 }
314
315 int gaim_chat_server_ready(struct aim_session_t *sess,
316 struct command_rx_struct *command, ...) {
317 static int id = 1;
318 debug_print("chat: got server ready\n");
319 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
320 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
321 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
322 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
323 aim_bos_reqrate(sess, command->conn);
324 aim_bos_ackrateresp(sess, command->conn);
325 aim_chat_clientready(sess, command->conn);
326 serv_got_joined_chat(id++, aim_chat_getname(command->conn));
307 } 327 }
308 328
309 extern void gaim_setup(); 329 extern void gaim_setup();
310 extern int bud_list_cache_exists(); 330 extern int bud_list_cache_exists();
311 extern void do_import(GtkWidget *w, void *dummy); 331 extern void do_import(GtkWidget *w, void *dummy);
385 break; 405 break;
386 case 0xe: /* Chat */ 406 case 0xe: /* Chat */
387 { 407 {
388 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); 408 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
389 char *roomname = va_arg(ap, char *); 409 char *roomname = va_arg(ap, char *);
410 struct chat_connection *ccon;
390 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) { 411 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) {
391 debug_print("unable to connect to chat server\n"); 412 debug_print("unable to connect to chat server\n");
392 return 1; 413 return 1;
393 } 414 }
394 sprintf(debug_buff, "Connected to chat room %s\n", roomname); 415 sprintf(debug_buff, "Connected to chat room %s\n", roomname);
395 debug_print(debug_buff); 416 debug_print(debug_buff);
396 417
418 ccon = g_new0(struct chat_connection, 1);
419 ccon->conn = tstconn;
420 ccon->fd = tstconn->fd;
421 ccon->name = g_strdup(roomname);
422
423 ccon->inpa = gdk_input_add(tstconn->fd,
424 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
425 oscar_callback, tstconn);
426
427 oscar_chats = g_list_append(oscar_chats, ccon);
428
397 aim_chat_attachname(tstconn, roomname); 429 aim_chat_attachname(tstconn, roomname);
398 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); 430 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_chat_server_ready, 0);
399 aim_auth_sendcookie(sess, tstconn, cookie); 431 aim_auth_sendcookie(sess, tstconn, cookie);
400 } 432 }
401 break; 433 break;
402 default: /* huh? */ 434 default: /* huh? */
403 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n", 435 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n",
630 exchanges[i].lang1); 662 exchanges[i].lang1);
631 debug_print(debug_buff); 663 debug_print(debug_buff);
632 i++; 664 i++;
633 } 665 }
634 } 666 }
667 aim_conn_close(command->conn);
635 break; 668 break;
636 default: 669 default:
637 va_end(ap); 670 va_end(ap);
638 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type); 671 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type);
639 debug_print(debug_buff); 672 debug_print(debug_buff);