Mercurial > pidgin
comparison src/oscar.c @ 511:3133ab511d92
[gaim-migrate @ 521]
beginnings of directim, some improvements to oscar chat stuff
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 20 Jul 2000 18:34:25 +0000 |
parents | 3bd51b3f07c3 |
children | 7922abb3262d |
comparison
equal
deleted
inserted
replaced
510:dab0c611029e | 511:3133ab511d92 |
---|---|
41 #include <aim.h> | 41 #include <aim.h> |
42 #include "gnome_applet_mgr.h" | 42 #include "gnome_applet_mgr.h" |
43 | 43 |
44 static int inpa = -1; | 44 static int inpa = -1; |
45 static int paspa = -1; | 45 static int paspa = -1; |
46 static int cnpa = -1; | |
46 struct aim_session_t *gaim_sess; | 47 struct aim_session_t *gaim_sess; |
47 struct aim_conn_t *gaim_conn; | 48 struct aim_conn_t *gaim_conn; |
48 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | | 49 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | |
49 AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; | 50 AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; |
50 int USE_OSCAR = 0; | 51 int USE_OSCAR = 0; |
67 } | 68 } |
68 | 69 |
69 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); | 70 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); |
70 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...); | 71 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...); |
71 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); | 72 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); |
72 static int gaim_chat_server_ready(struct aim_session_t *, struct command_rx_struct *, ...); | |
73 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); | 73 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); |
74 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...); | 74 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...); |
75 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...); | 75 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...); |
76 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); | 76 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); |
77 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); | 77 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); |
82 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); | 82 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); |
83 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); | 83 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); |
84 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); | 84 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); |
85 static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); | 85 static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); |
86 static int gaim_parse_ratechange (struct aim_session_t *, struct command_rx_struct *, ...); | 86 static int gaim_parse_ratechange (struct aim_session_t *, struct command_rx_struct *, ...); |
87 | |
88 static int gaim_directim_incoming (struct aim_session_t *, struct command_rx_struct *, ...); | |
89 static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...); | |
87 | 90 |
88 extern void auth_failed(); | 91 extern void auth_failed(); |
89 | 92 |
90 static void oscar_callback(gpointer data, gint source, | 93 static void oscar_callback(gpointer data, gint source, |
91 GdkInputCondition condition) { | 94 GdkInputCondition condition) { |
324 return 1; | 327 return 1; |
325 } | 328 } |
326 | 329 |
327 int gaim_server_ready(struct aim_session_t *sess, | 330 int gaim_server_ready(struct aim_session_t *sess, |
328 struct command_rx_struct *command, ...) { | 331 struct command_rx_struct *command, ...) { |
332 static int id = 1; | |
329 switch (command->conn->type) { | 333 switch (command->conn->type) { |
330 case AIM_CONN_TYPE_BOS: | 334 case AIM_CONN_TYPE_BOS: |
331 aim_bos_reqrate(sess, command->conn); | 335 aim_bos_reqrate(sess, command->conn); |
332 aim_bos_ackrateresp(sess, command->conn); | 336 aim_bos_ackrateresp(sess, command->conn); |
333 aim_bos_setprivacyflags(sess, command->conn, 0x00000003); | 337 aim_bos_setprivacyflags(sess, command->conn, 0x00000003); |
341 aim_bos_reqrate(sess, command->conn); | 345 aim_bos_reqrate(sess, command->conn); |
342 aim_bos_ackrateresp(sess, command->conn); | 346 aim_bos_ackrateresp(sess, command->conn); |
343 aim_chatnav_clientready(sess, command->conn); | 347 aim_chatnav_clientready(sess, command->conn); |
344 aim_chatnav_reqrights(sess, command->conn); | 348 aim_chatnav_reqrights(sess, command->conn); |
345 break; | 349 break; |
350 case AIM_CONN_TYPE_CHAT: | |
351 debug_print("chat: got server ready\n"); | |
352 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | |
353 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
354 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
355 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
356 aim_bos_reqrate(sess, command->conn); | |
357 aim_bos_ackrateresp(sess, command->conn); | |
358 aim_chat_clientready(sess, command->conn); | |
359 serv_got_joined_chat(id++, aim_chat_getname(command->conn)); | |
360 break; | |
361 case AIM_CONN_TYPE_RENDEZVOUS: | |
362 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); | |
363 break; | |
346 default: /* huh? */ | 364 default: /* huh? */ |
347 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); | 365 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); |
348 debug_print(debug_buff); | 366 debug_print(debug_buff); |
349 break; | 367 break; |
350 } | 368 } |
351 return 1; | |
352 } | |
353 | |
354 int gaim_chat_server_ready(struct aim_session_t *sess, | |
355 struct command_rx_struct *command, ...) { | |
356 static int id = 1; | |
357 debug_print("chat: got server ready\n"); | |
358 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | |
359 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
360 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
361 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
362 aim_bos_reqrate(sess, command->conn); | |
363 aim_bos_ackrateresp(sess, command->conn); | |
364 aim_chat_clientready(sess, command->conn); | |
365 serv_got_joined_chat(id++, aim_chat_getname(command->conn)); | |
366 return 1; | 369 return 1; |
367 } | 370 } |
368 | 371 |
369 int gaim_handle_redirect(struct aim_session_t *sess, | 372 int gaim_handle_redirect(struct aim_session_t *sess, |
370 struct command_rx_struct *command, ...) { | 373 struct command_rx_struct *command, ...) { |
438 debug_print("unable to connect to chatnav server\n"); | 441 debug_print("unable to connect to chatnav server\n"); |
439 return 1; | 442 return 1; |
440 } | 443 } |
441 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | 444 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
442 aim_auth_sendcookie(sess, tstconn, cookie); | 445 aim_auth_sendcookie(sess, tstconn, cookie); |
446 cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
447 oscar_callback, tstconn); | |
443 } | 448 } |
444 debug_print("chatnav: connected\n"); | 449 debug_print("chatnav: connected\n"); |
445 break; | 450 break; |
446 case 0xe: /* Chat */ | 451 case 0xe: /* Chat */ |
447 { | 452 { |
465 oscar_callback, tstconn); | 470 oscar_callback, tstconn); |
466 | 471 |
467 oscar_chats = g_list_append(oscar_chats, ccon); | 472 oscar_chats = g_list_append(oscar_chats, ccon); |
468 | 473 |
469 aim_chat_attachname(tstconn, roomname); | 474 aim_chat_attachname(tstconn, roomname); |
470 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_chat_server_ready, 0); | 475 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
471 aim_auth_sendcookie(sess, tstconn, cookie); | 476 aim_auth_sendcookie(sess, tstconn, cookie); |
472 } | 477 } |
473 break; | 478 break; |
474 default: /* huh? */ | 479 default: /* huh? */ |
475 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n", | 480 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n", |
577 } else if (rendtype & AIM_CAPS_VOICE) { | 582 } else if (rendtype & AIM_CAPS_VOICE) { |
578 /* this one libfaim tells us unuseful info about */ | 583 /* this one libfaim tells us unuseful info about */ |
579 } else if (rendtype & AIM_CAPS_BUDDYICON) { | 584 } else if (rendtype & AIM_CAPS_BUDDYICON) { |
580 /* bah */ | 585 /* bah */ |
581 } else if (rendtype & AIM_CAPS_IMIMAGE) { | 586 } else if (rendtype & AIM_CAPS_IMIMAGE) { |
587 /* DirectIM stuff */ | |
588 struct aim_directim_priv *priv; | |
589 struct aim_conn_t *newconn; | |
590 | |
591 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
592 priv = va_arg(ap, struct aim_directim_priv *); | |
593 va_end(ap); | |
594 | |
595 sprintf(debug_buff, "DirectIM request from %s (%s)\n", userinfo->sn, priv->ip); | |
596 debug_print(debug_buff); | |
597 | |
598 if (!(newconn = aim_directim_connect(sess, command->conn, priv))) { | |
599 debug_print("imimage: could not connect\n"); | |
600 return 1; | |
601 } | |
602 | |
603 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); | |
604 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0); | |
605 | |
606 gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
607 oscar_callback, newconn); | |
608 | |
609 sprintf(debug_buff, "DirectIM: connected to %s\n", userinfo->sn); | |
610 debug_print(debug_buff); | |
611 | |
612 serv_got_imimage(priv->sn, priv->cookie, priv->ip, newconn); | |
582 } else { | 613 } else { |
583 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); | 614 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); |
584 debug_print(debug_buff); | 615 debug_print(debug_buff); |
585 } | 616 } |
586 } | 617 } |
713 exchanges[i].lang1); | 744 exchanges[i].lang1); |
714 debug_print(debug_buff); | 745 debug_print(debug_buff); |
715 i++; | 746 i++; |
716 } | 747 } |
717 } | 748 } |
749 gdk_input_remove(cnpa); | |
750 cnpa = -1; | |
718 aim_conn_kill(sess, &command->conn); | 751 aim_conn_kill(sess, &command->conn); |
719 break; | 752 break; |
720 default: | 753 default: |
721 va_end(ap); | 754 va_end(ap); |
722 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type); | 755 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type); |
850 sprintf(debug_buff, "ratechange: %lu\n", newrate); | 883 sprintf(debug_buff, "ratechange: %lu\n", newrate); |
851 debug_print(debug_buff); | 884 debug_print(debug_buff); |
852 | 885 |
853 return 1; | 886 return 1; |
854 }; | 887 }; |
888 | |
889 int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
890 va_list ap; | |
891 char *sn = NULL, *msg = NULL; | |
892 struct aim_conn_t *conn; | |
893 | |
894 va_start(ap, command); | |
895 conn = va_arg(ap, struct aim_conn_t *); | |
896 sn = va_arg(ap, char *); | |
897 msg = va_arg(ap, char *); | |
898 va_end(ap); | |
899 | |
900 sprintf(debug_buff, "Got DirectIM message from %s\n", sn); | |
901 debug_print(debug_buff); | |
902 | |
903 serv_got_im(sn, msg, 0); | |
904 | |
905 return 1; | |
906 } | |
907 | |
908 int gaim_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
909 va_list ap; | |
910 char *sn; | |
911 | |
912 ap = va_start(ap, command); | |
913 sn = va_arg(ap, char *); | |
914 va_end(ap); | |
915 | |
916 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
917 sprintf(debug_buff, "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
918 debug_print(debug_buff); | |
919 | |
920 return 1; | |
921 } | |
922 | |
923 void oscar_do_directim(char *name) { | |
924 struct aim_conn_t *newconn = aim_directim_initiate(gaim_sess, gaim_conn, NULL, name); | |
925 gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn); | |
926 } |