Mercurial > pidgin
comparison src/protocols/oscar/login.c @ 2270:d82efea341ef
[gaim-migrate @ 2280]
new libfaim. stupid bugs.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 12 Sep 2001 00:39:51 +0000 |
parents | 933346315b9b |
children | 7ec21662ffc2 |
comparison
equal
deleted
inserted
replaced
2269:7ff6170d84a0 | 2270:d82efea341ef |
---|---|
380 return i; | 380 return i; |
381 } | 381 } |
382 | 382 |
383 /* | 383 /* |
384 * Send Server Ready. (Non-client) | 384 * Send Server Ready. (Non-client) |
385 * | |
386 * XXX If anyone cares, this should be made to use the conn-stored group | |
387 * system. | |
388 * | |
385 */ | 389 */ |
386 faim_export int aim_sendserverready(aim_session_t *sess, aim_conn_t *conn) | 390 faim_export int aim_sendserverready(aim_session_t *sess, aim_conn_t *conn) |
387 { | 391 { |
388 aim_frame_t *fr; | 392 aim_frame_t *fr; |
389 aim_snacid_t snacid; | 393 aim_snacid_t snacid; |
410 aim_tx_enqueue(sess, fr); | 414 aim_tx_enqueue(sess, fr); |
411 | 415 |
412 return 0; | 416 return 0; |
413 } | 417 } |
414 | 418 |
415 | |
416 /* | 419 /* |
417 * Send service redirect. (Non-Client) | 420 * Send service redirect. (Non-Client) |
418 */ | 421 */ |
419 faim_export int aim_sendredirect(aim_session_t *sess, aim_conn_t *conn, fu16_t servid, const char *ip, const char *cookie) | 422 faim_export int aim_sendredirect(aim_session_t *sess, aim_conn_t *conn, fu16_t servid, const char *ip, const char *cookie) |
420 { | 423 { |
438 aim_tx_enqueue(sess, fr); | 441 aim_tx_enqueue(sess, fr); |
439 | 442 |
440 return 0; | 443 return 0; |
441 } | 444 } |
442 | 445 |
443 | 446 /* |
447 * See comments in conn.c about how the group associations are supposed | |
448 * to work, and how they really work. | |
449 * | |
450 * This info probably doesn't even need to make it to the client. | |
451 * | |
452 */ | |
444 static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | 453 static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
445 { | 454 { |
446 aim_rxcallback_t userfunc; | 455 aim_rxcallback_t userfunc; |
447 int ret = 0; | 456 int ret = 0; |
448 fu16_t *families; | 457 fu16_t *families; |
449 int famcount; | 458 int famcount; |
450 | 459 |
451 if (!(families = malloc(aim_bstream_empty(bs)))) | 460 if (!(families = malloc(aim_bstream_empty(bs)))) |
452 return 0; | 461 return 0; |
453 | 462 |
454 for (famcount = 0; aim_bstream_empty(bs); famcount++) | 463 for (famcount = 0; aim_bstream_empty(bs); famcount++) { |
455 families[famcount] = aimbs_get16(bs); | 464 families[famcount] = aimbs_get16(bs); |
465 aim_conn_addgroup(rx->conn, families[famcount]); | |
466 } | |
456 | 467 |
457 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 468 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
458 ret = userfunc(sess, rx, famcount, families); | 469 ret = userfunc(sess, rx, famcount, families); |
459 | 470 |
460 free(families); | 471 free(families); |
618 | 629 |
619 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 630 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
620 return userfunc(sess, rx, newevil, &userinfo); | 631 return userfunc(sess, rx, newevil, &userinfo); |
621 | 632 |
622 return 0; | 633 return 0; |
634 } | |
635 | |
636 /* | |
637 * How Migrations work. | |
638 * | |
639 * The server sends a Server Pause message, which the client should respond to | |
640 * with a Server Pause Ack, which contains the families it needs on this | |
641 * connection. The server will send a Migration Notice with an IP address, and | |
642 * then disconnect. Next the client should open the connection and send the | |
643 * cookie. Repeat the normal login process and pretend this never happened. | |
644 * | |
645 * The Server Pause contains no data. | |
646 * | |
647 */ | |
648 static int serverpause(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
649 { | |
650 aim_rxcallback_t userfunc; | |
651 | |
652 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
653 return userfunc(sess, rx); | |
654 | |
655 return 0; | |
656 } | |
657 | |
658 /* | |
659 * It is rather important that aim_sendpauseack() gets called for the exact | |
660 * same connection that the Server Pause callback was called for, since | |
661 * libfaim extracts the data for the SNAC from the connection structure. | |
662 * | |
663 * Of course, if you don't do that, more bad things happen than just what | |
664 * libfaim can cause. | |
665 * | |
666 */ | |
667 faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn) | |
668 { | |
669 aim_frame_t *fr; | |
670 aim_snacid_t snacid; | |
671 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside; | |
672 struct snacgroup *sg; | |
673 | |
674 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1024))) | |
675 return -ENOMEM; | |
676 | |
677 snacid = aim_cachesnac(sess, 0x0001, 0x000c, 0x0000, NULL, 0); | |
678 aim_putsnac(&fr->data, 0x0001, 0x000c, 0x0000, snacid); | |
679 | |
680 /* | |
681 * This list should have all the groups that the original | |
682 * Host Online / Server Ready said this host supports. And | |
683 * we want them all back after the migration. | |
684 */ | |
685 for (sg = ins->groups; sg; sg = sg->next) | |
686 aimbs_put16(&fr->data, sg->group); | |
687 | |
688 aim_tx_enqueue(sess, fr); | |
689 | |
690 return 0; | |
691 } | |
692 | |
693 /* | |
694 * This is the final SNAC sent on the original connection during a migration. | |
695 * It contains the IP and cookie used to connect to the new server, and | |
696 * optionally a list of the SNAC groups being migrated. | |
697 * | |
698 */ | |
699 static int migrate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
700 { | |
701 aim_rxcallback_t userfunc; | |
702 int ret = 0; | |
703 fu16_t groupcount, i; | |
704 aim_tlvlist_t *tl; | |
705 char *ip = NULL; | |
706 aim_tlv_t *cktlv; | |
707 | |
708 /* | |
709 * Apparently there's some fun stuff that can happen right here. The | |
710 * migration can actually be quite selective about what groups it | |
711 * moves to the new server. When not all the groups for a connection | |
712 * are migrated, or they are all migrated but some groups are moved | |
713 * to a different server than others, it is called a bifurcated | |
714 * migration. | |
715 * | |
716 * Let's play dumb and not support that. | |
717 * | |
718 */ | |
719 groupcount = aimbs_get16(bs); | |
720 for (i = 0; i < groupcount; i++) { | |
721 fu16_t group; | |
722 | |
723 group = aimbs_get16(bs); | |
724 | |
725 faimdprintf(sess, 0, "bifurcated migration unsupported -- group 0x%04x\n", group); | |
726 } | |
727 | |
728 tl = aim_readtlvchain(bs); | |
729 | |
730 if (aim_gettlv(tl, 0x0005, 1)) | |
731 ip = aim_gettlv_str(tl, 0x0005, 1); | |
732 | |
733 cktlv = aim_gettlv(tl, 0x0006, 1); | |
734 | |
735 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
736 ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL); | |
737 | |
738 aim_freetlvchain(&tl); | |
739 free(ip); | |
740 | |
741 return ret; | |
623 } | 742 } |
624 | 743 |
625 static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | 744 static int motd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
626 { | 745 { |
627 aim_rxcallback_t userfunc; | 746 aim_rxcallback_t userfunc; |
855 return redirect(sess, mod, rx, snac, bs); | 974 return redirect(sess, mod, rx, snac, bs); |
856 else if (snac->subtype == 0x0007) | 975 else if (snac->subtype == 0x0007) |
857 return rateresp(sess, mod, rx, snac, bs); | 976 return rateresp(sess, mod, rx, snac, bs); |
858 else if (snac->subtype == 0x000a) | 977 else if (snac->subtype == 0x000a) |
859 return ratechange(sess, mod, rx, snac, bs); | 978 return ratechange(sess, mod, rx, snac, bs); |
979 else if (snac->subtype == 0x000b) | |
980 return serverpause(sess, mod, rx, snac, bs); | |
860 else if (snac->subtype == 0x000f) | 981 else if (snac->subtype == 0x000f) |
861 return selfinfo(sess, mod, rx, snac, bs); | 982 return selfinfo(sess, mod, rx, snac, bs); |
862 else if (snac->subtype == 0x0010) | 983 else if (snac->subtype == 0x0010) |
863 return evilnotify(sess, mod, rx, snac, bs); | 984 return evilnotify(sess, mod, rx, snac, bs); |
985 else if (snac->subtype == 0x0012) | |
986 return migrate(sess, mod, rx, snac, bs); | |
864 else if (snac->subtype == 0x0013) | 987 else if (snac->subtype == 0x0013) |
865 return motd(sess, mod, rx, snac, bs); | 988 return motd(sess, mod, rx, snac, bs); |
866 else if (snac->subtype == 0x0018) | 989 else if (snac->subtype == 0x0018) |
867 return hostversions(sess, mod, rx, snac, bs); | 990 return hostversions(sess, mod, rx, snac, bs); |
868 else if (snac->subtype == 0x001f) | 991 else if (snac->subtype == 0x001f) |