Mercurial > pidgin.yaz
comparison libfaim/aim_im.c @ 503:6e318907bcce
[gaim-migrate @ 513]
bringing gaim up to latest libfaim
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 18 Jul 2000 05:37:39 +0000 |
parents | e4c34ca88d9b |
children | 88f8f98de02d |
comparison
equal
deleted
inserted
replaced
502:4d1e39112cbd | 503:6e318907bcce |
---|---|
135 | 135 |
136 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */ | 136 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */ |
137 #endif | 137 #endif |
138 | 138 |
139 return (sess->snac_nextid++); | 139 return (sess->snac_nextid++); |
140 } | |
141 | |
142 struct aim_directim_priv { | |
143 unsigned char cookie[8]; | |
144 char sn[MAXSNLEN+1]; | |
145 }; | |
146 | |
147 int aim_send_im_direct(struct aim_session_t *sess, | |
148 struct aim_conn_t *conn, | |
149 char *msg) | |
150 { | |
151 struct command_tx_struct *newpacket; | |
152 struct aim_directim_priv *priv = NULL; | |
153 int i; | |
154 | |
155 if (strlen(msg) >= MAXMSGLEN) | |
156 return -1; | |
157 | |
158 if (!sess || !conn || (conn->type != AIM_CONN_TYPE_RENDEZVOUS) || !conn->priv) { | |
159 printf("faim: directim: invalid arguments\n"); | |
160 return -1; | |
161 } | |
162 | |
163 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OFT, 0x0001, conn, strlen(msg)))) { | |
164 printf("faim: directim: tx_new failed\n"); | |
165 return -1; | |
166 } | |
167 | |
168 newpacket->lock = 1; /* lock struct */ | |
169 | |
170 priv = (struct aim_directim_priv *)conn->priv; | |
171 | |
172 newpacket->hdr.oft.hdr2len = 0x44; | |
173 | |
174 if (!(newpacket->hdr.oft.hdr2 = malloc(newpacket->hdr.oft.hdr2len))) { | |
175 free(newpacket); | |
176 return -1; | |
177 } | |
178 | |
179 i = 0; | |
180 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0006); | |
181 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
182 | |
183 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, priv->cookie, 8); | |
184 | |
185 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
186 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
187 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
188 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
189 | |
190 i += aimutil_put32(newpacket->hdr.oft.hdr2+i, strlen(msg)); | |
191 | |
192 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
193 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
194 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
195 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
196 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
197 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
198 | |
199 i += aimutil_putstr(newpacket->hdr.oft.hdr2+i, sess->logininfo.screen_name, strlen(sess->logininfo.screen_name)); | |
200 | |
201 i = 52; | |
202 i += aimutil_put8(newpacket->hdr.oft.hdr2+i, 0x00); | |
203 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
204 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
205 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
206 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
207 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
208 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
209 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
210 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
211 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
212 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
213 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0000); | |
214 | |
215 memcpy(newpacket->data, msg, strlen(msg)); | |
216 | |
217 newpacket->lock = 0; | |
218 | |
219 aim_tx_enqueue(sess, newpacket); | |
220 | |
221 return 0; | |
222 } | 140 } |
223 | 141 |
224 int aim_parse_outgoing_im_middle(struct aim_session_t *sess, | 142 int aim_parse_outgoing_im_middle(struct aim_session_t *sess, |
225 struct command_rx_struct *command) | 143 struct command_rx_struct *command) |
226 { | 144 { |
380 if (channel == 1) | 298 if (channel == 1) |
381 { | 299 { |
382 u_int j = 0, y = 0, z = 0; | 300 u_int j = 0, y = 0, z = 0; |
383 char *msg = NULL; | 301 char *msg = NULL; |
384 u_int icbmflags = 0; | 302 u_int icbmflags = 0; |
385 struct aim_tlv_t *msgblocktlv, *tmptlv; | 303 struct aim_tlv_t *msgblocktlv; |
386 u_char *msgblock; | 304 u_char *msgblock; |
387 u_short flag1,flag2; | 305 u_short flag1,flag2; |
388 | 306 |
389 /* | 307 /* |
390 * Check Autoresponse status. If it is an autoresponse, | 308 * Check Autoresponse status. If it is an autoresponse, |
533 */ | 451 */ |
534 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16); | 452 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16); |
535 | 453 |
536 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) { | 454 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) { |
537 struct aim_msgcookie_t *cook; | 455 struct aim_msgcookie_t *cook; |
538 | 456 int type; |
539 if ((cook = aim_uncachecookie(sess, cookie)) == NULL) { | 457 |
458 type = aim_msgcookie_gettype(reqclass); /* XXX: fix this shitty code */ | |
459 | |
460 if ((cook = aim_uncachecookie(sess, cookie, type)) == NULL) { | |
540 printf("faim: non-data rendezvous thats not in cache!\n"); | 461 printf("faim: non-data rendezvous thats not in cache!\n"); |
541 aim_freetlvchain(&list2); | 462 aim_freetlvchain(&list2); |
542 aim_freetlvchain(&tlvlist); | 463 aim_freetlvchain(&tlvlist); |
543 return 1; | 464 return 1; |
544 } | 465 } |
545 | 466 |
546 if (cook->type == AIM_CAPS_SENDFILE) { | 467 if (cook->type == AIM_CAPS_SENDFILE) { |
547 struct aim_filetransfer_t *ft; | 468 struct aim_filetransfer_priv *ft; |
548 | 469 |
549 if (cook->data) { | 470 if (cook->data) { |
550 struct aim_tlv_t *errortlv; | 471 struct aim_tlv_t *errortlv; |
551 int errorcode = -1; | 472 int errorcode = -1; |
552 | 473 |
553 ft = (struct aim_filetransfer_t *)cook->data; | 474 ft = (struct aim_filetransfer_priv *)cook->data; |
554 | 475 |
555 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) { | 476 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) { |
556 errorcode = aimutil_get16(errortlv->value); | 477 errorcode = aimutil_get16(errortlv->value); |
557 } | 478 } |
558 if (errorcode) { | 479 if (errorcode) { |
559 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sender, ft->ip, ft->filename, errorcode); | 480 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sn, ft->ip, ft->fh.name, errorcode); |
560 } else if (status == 0x0002) { /* connection accepted */ | 481 } else if (status == 0x0002) { /* connection accepted */ |
561 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sender, ft->ip, ft->filename); | 482 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sn, ft->ip, ft->fh.name); |
562 } | 483 } |
563 free(cook->data); | 484 free(cook->data); |
564 } else { | 485 } else { |
565 printf("faim: not data attached to file transfer\n"); | 486 printf("faim: not data attached to file transfer\n"); |
566 } | 487 } |
592 channel, | 513 channel, |
593 reqclass, | 514 reqclass, |
594 &userinfo); | 515 &userinfo); |
595 | 516 |
596 } else if (reqclass & AIM_CAPS_VOICE) { | 517 } else if (reqclass & AIM_CAPS_VOICE) { |
597 struct aim_msgcookie_t cachedcook; | 518 struct aim_msgcookie_t *cachedcook; |
598 | 519 |
599 printf("faim: rend: voice!\n"); | 520 printf("faim: rend: voice!\n"); |
600 | 521 |
601 memcpy(cachedcook.cookie, cookie, 8); | 522 if(!(cachedcook = (struct aim_msgcookie_t*)calloc(1, sizeof(struct aim_msgcookie_t)))) |
602 cachedcook.type = AIM_CAPS_VOICE; | 523 return 1; |
603 cachedcook.data = NULL; | 524 |
604 if (aim_cachecookie(sess, &cachedcook) != 0) | 525 memcpy(cachedcook->cookie, cookie, 8); |
526 cachedcook->type = AIM_COOKIETYPE_OFTVOICE; | |
527 cachedcook->data = NULL; | |
528 | |
529 if (aim_cachecookie(sess, cachedcook) != 0) | |
605 printf("faim: ERROR caching message cookie\n"); | 530 printf("faim: ERROR caching message cookie\n"); |
606 | 531 |
607 /* XXX: implement all this */ | 532 /* XXX: implement all this */ |
608 | 533 |
609 /* | 534 /* |
610 * Call client. | 535 * Call client. |
611 */ | 536 */ |
612 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | 537 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
613 if (userfunc || (i = 0)) { | 538 if (userfunc || (i = 0)) { |
614 i = userfunc(sess, | 539 i = userfunc(sess, command, channel, reqclass, &userinfo); |
615 command, | |
616 channel, | |
617 reqclass, | |
618 &userinfo); | |
619 } | 540 } |
620 } else if (reqclass & AIM_CAPS_IMIMAGE) { | 541 } else if ((reqclass & AIM_CAPS_IMIMAGE) || (reqclass & AIM_CAPS_BUDDYICON)) { |
621 char ip[30]; | 542 char ip[30]; |
622 struct aim_msgcookie_t cachedcook; | 543 struct aim_directim_priv *priv; |
623 | 544 |
624 memset(ip, 0, sizeof(ip)); | 545 memset(ip, 0, sizeof(ip)); |
625 | 546 |
626 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) { | 547 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) { |
627 struct aim_tlv_t *iptlv, *porttlv; | 548 struct aim_tlv_t *iptlv, *porttlv; |
628 | 549 |
629 iptlv = aim_gettlv(list2, 0x0003, 1); | 550 iptlv = aim_gettlv(list2, 0x0003, 1); |
630 porttlv = aim_gettlv(list2, 0x0005, 1); | 551 porttlv = aim_gettlv(list2, 0x0005, 1); |
631 | 552 |
639 | 560 |
640 printf("faim: rend: directIM request from %s (%s)\n", | 561 printf("faim: rend: directIM request from %s (%s)\n", |
641 userinfo.sn, | 562 userinfo.sn, |
642 ip); | 563 ip); |
643 | 564 |
644 #if 0 | 565 /* XXX: there are a couple of different request packets for |
645 { | 566 * different things */ |
646 struct aim_conn_t *newconn; | |
647 | |
648 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip); | |
649 if (!newconn || (newconn->fd == -1)) { | |
650 printf("could not connect to %s\n", ip); | |
651 perror("aim_newconn"); | |
652 aim_conn_kill(sess, &newconn); | |
653 } else { | |
654 struct aim_directim_priv *priv; | |
655 priv = (struct aim_directim_priv *)malloc(sizeof(struct aim_directim_priv)); | |
656 memcpy(priv->cookie, cookie, 8); | |
657 strncpy(priv->sn, userinfo.sn, MAXSNLEN); | |
658 newconn->priv = priv; | |
659 printf("faim: connected to peer (fd = %d)\n", newconn->fd); | |
660 } | |
661 } | |
662 #endif | |
663 | 567 |
664 #if 0 | 568 priv = (struct aim_directim_priv *)calloc(1, sizeof(struct aim_directim_priv)); |
665 memcpy(cachedcook.cookie, cookie, 8); | 569 memcpy(priv->ip, ip, sizeof(priv->ip)); |
666 | 570 memcpy(priv->sn, userinfo.sn, sizeof(priv->sn)); |
667 ft = malloc(sizeof(struct aim_filetransfer_t)); | 571 memcpy(priv->cookie, cookie, sizeof(priv->cookie)); |
668 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender)); | |
669 strncpy(ft->ip, ip, sizeof(ft->ip)); | |
670 ft->filename = strdup(miscinfo->value+8); | |
671 cachedcook.type = AIM_CAPS_SENDFILE; | |
672 cachedcook.data = ft; | |
673 | |
674 if (aim_cachecookie(sess, &cachedcook) != 0) | |
675 printf("faim: ERROR caching message cookie\n"); | |
676 #endif | |
677 | 572 |
678 /* | 573 /* |
679 * Call client. | 574 * Call client. |
680 */ | 575 */ |
681 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | 576 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
682 if (userfunc || (i = 0)) | 577 if (userfunc || (i = 0)) |
683 i = userfunc(sess, | 578 i = userfunc(sess, |
684 command, | 579 command, |
685 channel, | 580 channel, |
686 reqclass, | 581 reqclass, |
687 &userinfo); | 582 &userinfo, priv); |
688 | 583 |
689 } else if (reqclass & AIM_CAPS_CHAT) { | 584 } else if (reqclass & AIM_CAPS_CHAT) { |
690 struct aim_tlv_t *miscinfo; | 585 struct aim_tlv_t *miscinfo; |
691 struct aim_chat_roominfo roominfo; | 586 struct aim_chat_roominfo roominfo; |
692 char *msg=NULL,*encoding=NULL,*lang=NULL; | 587 char *msg=NULL,*encoding=NULL,*lang=NULL; |
720 free(roominfo.name); | 615 free(roominfo.name); |
721 free(msg); | 616 free(msg); |
722 free(encoding); | 617 free(encoding); |
723 free(lang); | 618 free(lang); |
724 } else if (reqclass & AIM_CAPS_GETFILE) { | 619 } else if (reqclass & AIM_CAPS_GETFILE) { |
725 | 620 char ip[30]; |
621 char *desc = NULL; | |
622 struct aim_msgcookie_t *cachedcook; | |
623 struct aim_filetransfer_priv *ft; | |
624 struct aim_tlv_t *miscinfo; | |
625 struct aim_conn_t *newconn; | |
626 | |
627 if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t)))) | |
628 return 0; | |
629 | |
630 memset(ip, 0, sizeof(ip)); | |
631 | |
632 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) { | |
633 free(cachedcook); | |
634 return 0; | |
635 } | |
636 | |
637 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) { | |
638 struct aim_tlv_t *iptlv, *porttlv; | |
639 | |
640 if (!(iptlv = aim_gettlv(list2, 0x0003, 1)) || !(porttlv = aim_gettlv(list2, 0x0005, 1))) { | |
641 free(cachedcook); | |
642 return 0; | |
643 } | |
644 | |
645 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", | |
646 aimutil_get8(iptlv->value+0), | |
647 aimutil_get8(iptlv->value+1), | |
648 aimutil_get8(iptlv->value+2), | |
649 aimutil_get8(iptlv->value+3), | |
650 aimutil_get16(porttlv->value)); | |
651 } | |
652 | |
653 printf("faim: rend: file get request from %s (%s)\n", userinfo.sn, ip); | |
654 | |
655 #if 0 /* XXX finish this */ | |
656 newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS, ip); | |
657 if (!newconn || (newconn->fd == -1)) { | |
658 printf("could not connect to %s\n", ip); | |
659 perror("aim_newconn"); | |
660 aim_conn_kill(sess, &newconn); | |
661 } else { | |
662 struct aim_filetransfer_priv *priv; | |
663 priv = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); | |
664 memcpy(priv->cookie, cookie, 8); | |
665 strncpy(priv->sn, userinfo.sn, MAXSNLEN); | |
666 newconn->priv = priv; | |
667 printf("faim: connected to peer (fd = %d)\n", newconn->fd); | |
668 } | |
669 | |
670 memcpy(cachedcook->cookie, cookie, 8); | |
671 | |
672 ft = malloc(sizeof(struct aim_filetransfer_priv)); | |
673 ft->state = 1; | |
674 strncpy(ft->sn, userinfo.sn, sizeof(ft->sn)); | |
675 strncpy(ft->ip, ip, sizeof(ft->ip)); | |
676 #if 0 | |
677 strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name)); | |
678 #endif | |
679 cachedcook->type = AIM_COOKIETYPE_OFTGET; | |
680 cachedcook->data = ft; | |
681 | |
682 if (aim_cachecookie(sess, cachedcook) != 0) | |
683 printf("faim: ERROR caching message cookie\n"); | |
684 | |
685 aim_accepttransfer(sess, command->conn, newconn, ft->sn, cookie, AIM_CAPS_GETFILE); | |
686 | |
687 free(desc); | |
688 #endif | |
726 /* | 689 /* |
727 * Call client. | 690 * Call client. |
728 */ | 691 */ |
729 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | 692 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
730 if (userfunc || (i = 0)) | 693 if (userfunc || (i = 0)) |
733 channel, | 696 channel, |
734 reqclass, | 697 reqclass, |
735 &userinfo); | 698 &userinfo); |
736 | 699 |
737 } else if (reqclass & AIM_CAPS_SENDFILE) { | 700 } else if (reqclass & AIM_CAPS_SENDFILE) { |
701 #if 0 | |
702 char ip[30]; | |
703 char *desc = NULL; | |
704 struct aim_msgcookie_t *cachedcook; | |
705 struct aim_filetransfer_priv *ft; | |
706 struct aim_tlv_t *miscinfo; | |
707 | |
708 memset(ip, 0, sizeof(ip)); | |
709 | |
710 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) | |
711 return 0; | |
712 | |
713 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) { | |
714 struct aim_tlv_t *iptlv, *porttlv; | |
715 | |
716 iptlv = aim_gettlv(list2, 0x0003, 1); | |
717 porttlv = aim_gettlv(list2, 0x0005, 1); | |
718 | |
719 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", | |
720 aimutil_get8(iptlv->value+0), | |
721 aimutil_get8(iptlv->value+1), | |
722 aimutil_get8(iptlv->value+2), | |
723 aimutil_get8(iptlv->value+3), | |
724 aimutil_get16(porttlv->value)); | |
725 } | |
726 | |
727 if (aim_gettlv(list2, 0x000c, 1)) { | |
728 desc = aim_gettlv_str(list2, 0x000c, 1); | |
729 } | |
730 | |
731 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n", | |
732 userinfo.sn, | |
733 miscinfo->value+8, | |
734 desc, | |
735 ip); | |
736 | |
737 memcpy(cachedcook->cookie, cookie, 8); | |
738 | |
739 ft = malloc(sizeof(struct aim_filetransfer_priv)); | |
740 strncpy(ft->sn, userinfo.sn, sizeof(ft->sn)); | |
741 strncpy(ft->ip, ip, sizeof(ft->ip)); | |
742 strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name)); | |
743 cachedcook->type = AIM_COOKIETYPE_OFTSEND; | |
744 cachedcook->data = ft; | |
745 | |
746 if (aim_cachecookie(sess, cachedcook) != 0) | |
747 printf("faim: ERROR caching message cookie\n"); | |
748 | |
749 | |
750 aim_accepttransfer(sess, command->conn, ft->sn, cookie, AIM_CAPS_SENDFILE); | |
751 | |
752 if (desc) | |
753 free(desc); | |
754 #endif | |
738 /* | 755 /* |
739 * Call client. | 756 * Call client. |
740 */ | 757 */ |
741 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | 758 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
742 if (userfunc || (i = 0)) | 759 if (userfunc || (i = 0)) |
743 i = userfunc(sess, | 760 i = userfunc(sess, |
744 command, | 761 command, |
745 channel, | 762 channel, |
746 reqclass, | 763 reqclass, |
747 &userinfo); | 764 &userinfo); |
748 #if 0 | |
749 char ip[30]; | |
750 char *desc = NULL; | |
751 struct aim_msgcookie_t cachedcook; | |
752 struct aim_filetransfer_t *ft; | |
753 struct aim_tlv_t *miscinfo; | |
754 | |
755 memset(ip, 0, sizeof(ip)); | |
756 | |
757 miscinfo = aim_gettlv(list2, 0x2711, 1); | |
758 | |
759 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) { | |
760 struct aim_tlv_t *iptlv, *porttlv; | |
761 | |
762 iptlv = aim_gettlv(list2, 0x0003, 1); | |
763 porttlv = aim_gettlv(list2, 0x0005, 1); | |
764 | |
765 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", | |
766 aimutil_get8(iptlv->value+0), | |
767 aimutil_get8(iptlv->value+1), | |
768 aimutil_get8(iptlv->value+2), | |
769 aimutil_get8(iptlv->value+3), | |
770 aimutil_get16(porttlv->value)); | |
771 } | |
772 | |
773 if (aim_gettlv(list2, 0x000c, 1)) { | |
774 desc = aim_gettlv_str(list2, 0x000c, 1); | |
775 } | |
776 | |
777 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n", | |
778 userinfo.sn, | |
779 miscinfo->value+8, | |
780 desc, | |
781 ip); | |
782 | |
783 memcpy(cachedcook.cookie, cookie, 8); | |
784 | |
785 ft = malloc(sizeof(struct aim_filetransfer_t)); | |
786 strncpy(ft->sender, userinfo.sn, sizeof(ft->sender)); | |
787 strncpy(ft->ip, ip, sizeof(ft->ip)); | |
788 ft->filename = strdup(miscinfo->value+8); | |
789 cachedcook.type = AIM_CAPS_SENDFILE; | |
790 cachedcook.data = ft; | |
791 | |
792 if (aim_cachecookie(sess, &cachedcook) != 0) | |
793 printf("faim: ERROR caching message cookie\n"); | |
794 | |
795 | |
796 aim_accepttransfer(sess, command->conn, ft->sender, cookie, AIM_CAPS_SENDFILE); | |
797 | |
798 free(desc); | |
799 #endif | |
800 i = 1; | |
801 } else { | 765 } else { |
802 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass); | 766 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass); |
803 } | 767 } |
804 | 768 |
805 aim_freetlvchain(&list2); | 769 aim_freetlvchain(&list2); |
810 */ | 774 */ |
811 aim_freetlvchain(&tlvlist); | 775 aim_freetlvchain(&tlvlist); |
812 | 776 |
813 | 777 |
814 return i; | 778 return i; |
815 } | |
816 | |
817 u_long aim_accepttransfer(struct aim_session_t *sess, | |
818 struct aim_conn_t *conn, | |
819 char *sender, | |
820 char *cookie, | |
821 unsigned short rendid) | |
822 { | |
823 struct command_tx_struct *newpacket; | |
824 int curbyte, i; | |
825 | |
826 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+4+2+8+16))) | |
827 return -1; | |
828 | |
829 newpacket->lock = 1; | |
830 | |
831 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid); | |
832 for (i = 0; i < 8; i++) | |
833 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]); | |
834 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); | |
835 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender)); | |
836 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender)); | |
837 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0005); | |
838 curbyte += aimutil_put16(newpacket->data+curbyte, 0x001a); | |
839 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002 /* accept */); | |
840 for (i = 0; i < 8; i++) | |
841 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]); | |
842 curbyte += aim_putcap(newpacket->data+curbyte, 0x10, rendid); | |
843 | |
844 newpacket->lock = 0; | |
845 aim_tx_enqueue(sess, newpacket); | |
846 | |
847 return (sess->snac_nextid++); | |
848 } | 779 } |
849 | 780 |
850 /* | 781 /* |
851 * Possible codes: | 782 * Possible codes: |
852 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" | 783 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" |