Mercurial > pidgin.yaz
comparison plugins/icq/udp.c @ 1309:0a766047b4fd
[gaim-migrate @ 1319]
Yay, new icqlib
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 19 Dec 2000 10:08:29 +0000 |
parents | 201ec77f3a60 |
children | 4c510ca3563f |
comparison
equal
deleted
inserted
replaced
1308:4741b5a75b9f | 1309:0a766047b4fd |
---|---|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* | 2 /* |
3 $Id: udp.c 1162 2000-11-28 02:22:42Z warmenhoven $ | 3 $Id: udp.c 1319 2000-12-19 10:08:29Z warmenhoven $ |
4 $Log$ | 4 $Log$ |
5 Revision 1.1 2000/11/28 02:22:42 warmenhoven | 5 Revision 1.2 2000/12/19 10:08:29 warmenhoven |
6 icq. whoop de doo | 6 Yay, new icqlib |
7 | |
8 Revision 1.26 2000/12/19 06:00:07 bills | |
9 moved members from ICQLINK to ICQLINK_private struct | |
10 | |
11 Revision 1.25 2000/11/02 07:29:07 denis | |
12 Ability to disable TCP protocol has been added. | |
13 | |
14 Revision 1.24 2000/08/13 00:59:52 denis | |
15 Patch #101057 have been applied. | |
7 | 16 |
8 Revision 1.23 2000/07/09 22:19:35 bills | 17 Revision 1.23 2000/07/09 22:19:35 bills |
9 added new *Close functions, use *Close functions instead of *Delete | 18 added new *Close functions, use *Close functions instead of *Delete |
10 where correct, and misc cleanup | 19 where correct, and misc cleanup |
11 | 20 |
295 icq_UDPQueueItem *ptr = 0; | 304 icq_UDPQueueItem *ptr = 0; |
296 icq_Packet *sp = 0, *pack = 0; | 305 icq_Packet *sp = 0, *pack = 0; |
297 int attempt; | 306 int attempt; |
298 while(icq_UDPQueueInterval(link) == 0) | 307 while(icq_UDPQueueInterval(link) == 0) |
299 { | 308 { |
300 ptr = (icq_UDPQueueItem*)list_first(link->icq_UDPQueue); | 309 ptr = (icq_UDPQueueItem*)list_first(link->d->icq_UDPQueue); |
301 attempt = ptr->attempts + 1; | 310 attempt = ptr->attempts + 1; |
302 if(attempt > 6) | 311 if(attempt > 6) |
303 { | 312 { |
304 icq_Disconnect(link); | 313 icq_Disconnect(link); |
305 if(link->icq_Disconnected) | 314 if(link->icq_Disconnected) |
323 JAVA client sends two different commands | 332 JAVA client sends two different commands |
324 so we do also :) | 333 so we do also :) |
325 *****************************************/ | 334 *****************************************/ |
326 WORD icq_KeepAlive(ICQLINK *link) /* V5 */ | 335 WORD icq_KeepAlive(ICQLINK *link) /* V5 */ |
327 { | 336 { |
328 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_KEEP_ALIVE, link->icq_UDPSeqNum1++); | 337 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_KEEP_ALIVE, link->d->icq_UDPSeqNum1++); |
329 icq_PacketAppend32(p, rand()); | 338 icq_PacketAppend32(p, rand()); |
330 icq_UDPSockWrite(link, p); | 339 icq_UDPSockWrite(link, p); |
331 icq_PacketDelete(p); | 340 icq_PacketDelete(p); |
332 | 341 |
333 /* icq_Packet *p = icq_UDPCreateStdPacket(UDP_CMD_KEEP_ALIVE); | 342 /* icq_Packet *p = icq_UDPCreateStdPacket(UDP_CMD_KEEP_ALIVE); |
337 icq_UDPSockWrite(icq_Sok, p); | 346 icq_UDPSockWrite(icq_Sok, p); |
338 icq_PacketDelete(p);*/ | 347 icq_PacketDelete(p);*/ |
339 | 348 |
340 icq_FmtLog(link, ICQ_LOG_MESSAGE, "Send Keep Alive packet to the server\n"); | 349 icq_FmtLog(link, ICQ_LOG_MESSAGE, "Send Keep Alive packet to the server\n"); |
341 | 350 |
342 return link->icq_UDPSeqNum1-1; | 351 return link->d->icq_UDPSeqNum1-1; |
343 } | 352 } |
344 | 353 |
345 /********************************** | 354 /********************************** |
346 This must be called to remove | 355 This must be called to remove |
347 messages from the server | 356 messages from the server |
465 *************************************/ | 474 *************************************/ |
466 void icq_Login(ICQLINK *link, DWORD status) /* V5 */ | 475 void icq_Login(ICQLINK *link, DWORD status) /* V5 */ |
467 { | 476 { |
468 icq_Packet *p; | 477 icq_Packet *p; |
469 | 478 |
470 memset(link->icq_UDPServMess, FALSE, sizeof(link->icq_UDPServMess)); | 479 memset(link->d->icq_UDPServMess, FALSE, sizeof(link->d->icq_UDPServMess)); |
471 link->icq_UDPSession = rand() & 0x3FFFFFFF; | 480 link->d->icq_UDPSession = rand() & 0x3FFFFFFF; |
472 link->icq_UDPSeqNum1 = rand() & 0x7FFF; | 481 link->d->icq_UDPSeqNum1 = rand() & 0x7FFF; |
473 link->icq_UDPSeqNum2 = 1; | 482 link->d->icq_UDPSeqNum2 = 1; |
474 | 483 |
475 p = icq_UDPCreateStdPacket(link, UDP_CMD_LOGIN); | 484 p = icq_UDPCreateStdPacket(link, UDP_CMD_LOGIN); |
476 icq_PacketAppend32(p, time(0L)); | 485 icq_PacketAppend32(p, time(0L)); |
477 icq_PacketAppend32n(p, link->icq_TCPSrvPort); | 486 icq_PacketAppend32n(p, link->icq_TCPSrvPort); |
478 /*icq_PacketAppend16(p, 0); | 487 /*icq_PacketAppend16(p, 0); |
479 icq_PacketAppend16n(p, htons(link->icq_OurPort));*/ | 488 icq_PacketAppend16n(p, htons(link->icq_OurPort));*/ |
480 icq_PacketAppendString(p, link->icq_Password); | 489 icq_PacketAppendString(p, link->icq_Password); |
481 icq_PacketAppend32(p, LOGIN_X1_DEF); | 490 icq_PacketAppend32(p, LOGIN_X1_DEF); |
482 icq_PacketAppend32n(p, htonl(link->icq_OurIP)); | 491 if(link->icq_UseTCP) |
483 if(link->icq_UseProxy) | 492 { |
484 icq_PacketAppend8(p, LOGIN_SNDONLY_TCP); | 493 if(link->icq_UseProxy) |
494 { | |
495 icq_PacketAppend32n(p, htonl(link->icq_ProxyIP)); | |
496 icq_PacketAppend8(p, LOGIN_SNDONLY_TCP); | |
497 } | |
498 else | |
499 { | |
500 icq_PacketAppend32n(p, htonl(link->icq_OurIP)); | |
501 icq_PacketAppend8(p, LOGIN_SNDRCV_TCP); | |
502 } | |
503 } | |
485 else | 504 else |
486 icq_PacketAppend8(p, LOGIN_SNDRCV_TCP); | 505 { |
506 icq_PacketAppend32n(p, htonl(link->icq_ProxyIP)); | |
507 icq_PacketAppend8(p, LOGIN_NO_TCP); | |
508 } | |
487 icq_PacketAppend32(p, status); | 509 icq_PacketAppend32(p, status); |
488 icq_PacketAppend32(p, LOGIN_X3_DEF); | 510 icq_PacketAppend32(p, LOGIN_X3_DEF); |
489 icq_PacketAppend32(p, LOGIN_X4_DEF); | 511 icq_PacketAppend32(p, LOGIN_X4_DEF); |
490 icq_PacketAppend32(p, LOGIN_X5_DEF); | 512 icq_PacketAppend32(p, LOGIN_X5_DEF); |
491 | 513 |
496 /********************** | 518 /********************** |
497 Logs off ICQ | 519 Logs off ICQ |
498 ***********************/ | 520 ***********************/ |
499 void icq_Logout(ICQLINK *link) /* V5 */ | 521 void icq_Logout(ICQLINK *link) /* V5 */ |
500 { | 522 { |
501 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_SEND_TEXT_CODE, link->icq_UDPSeqNum1++); | 523 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_SEND_TEXT_CODE, link->d->icq_UDPSeqNum1++); |
502 icq_PacketAppendString(p, "B_USER_DISCONNECTED"); | 524 icq_PacketAppendString(p, "B_USER_DISCONNECTED"); |
503 icq_PacketAppend8(p, 5); | 525 icq_PacketAppend8(p, 5); |
504 icq_PacketAppend8(p, 0); | 526 icq_PacketAppend8(p, 0); |
505 icq_UDPSockWrite(link, p); | 527 icq_UDPSockWrite(link, p); |
506 icq_PacketDelete(p); | 528 icq_PacketDelete(p); |
538 icq_PacketAppend16(p, TYPE_MSG); | 560 icq_PacketAppend16(p, TYPE_MSG); |
539 icq_PacketAppendString(p, buf); | 561 icq_PacketAppendString(p, buf); |
540 | 562 |
541 icq_UDPSockWrite(link, p); | 563 icq_UDPSockWrite(link, p); |
542 icq_PacketDelete(p); | 564 icq_PacketDelete(p); |
543 return link->icq_UDPSeqNum1-1; | 565 return link->d->icq_UDPSeqNum1-1; |
544 } | 566 } |
545 | 567 |
546 WORD icq_UDPSendURL(ICQLINK *link, DWORD uin, const char *url, const char *descr) /* V5 */ | 568 WORD icq_UDPSendURL(ICQLINK *link, DWORD uin, const char *url, const char *descr) /* V5 */ |
547 { | 569 { |
548 char buf1[512], buf2[512]; | 570 char buf1[512], buf2[512]; |
559 icq_PacketAppendStringFE(p, buf1); | 581 icq_PacketAppendStringFE(p, buf1); |
560 icq_PacketAppendString0(p, buf2); | 582 icq_PacketAppendString0(p, buf2); |
561 | 583 |
562 icq_UDPSockWrite(link, p); | 584 icq_UDPSockWrite(link, p); |
563 icq_PacketDelete(p); | 585 icq_PacketDelete(p); |
564 return link->icq_UDPSeqNum1-1; | 586 return link->d->icq_UDPSeqNum1-1; |
565 } | 587 } |
566 | 588 |
567 /************************************************** | 589 /************************************************** |
568 Sends a authorization to the server so the Mirabilis | 590 Sends a authorization to the server so the Mirabilis |
569 client can add the user. | 591 client can add the user. |
575 icq_PacketAppend32(p, TYPE_AUTH); | 597 icq_PacketAppend32(p, TYPE_AUTH); |
576 icq_PacketAppend16(p, 0); | 598 icq_PacketAppend16(p, 0); |
577 icq_UDPSockWrite(link, p); | 599 icq_UDPSockWrite(link, p); |
578 icq_PacketDelete(p); | 600 icq_PacketDelete(p); |
579 | 601 |
580 return link->icq_UDPSeqNum1-1; | 602 return link->d->icq_UDPSeqNum1-1; |
581 } | 603 } |
582 | 604 |
583 /************************************************** | 605 /************************************************** |
584 Changes the users status on the server | 606 Changes the users status on the server |
585 ***************************************************/ | 607 ***************************************************/ |
599 { | 621 { |
600 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_INFO_REQ); | 622 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_INFO_REQ); |
601 icq_PacketAppend32(p, uin); | 623 icq_PacketAppend32(p, uin); |
602 icq_UDPSockWrite(link, p); | 624 icq_UDPSockWrite(link, p); |
603 icq_PacketDelete(p); | 625 icq_PacketDelete(p); |
604 return link->icq_UDPSeqNum1-1; | 626 return link->d->icq_UDPSeqNum1-1; |
605 } | 627 } |
606 | 628 |
607 /******************************************************** | 629 /******************************************************** |
608 Sends a request to the server for info on a specific user | 630 Sends a request to the server for info on a specific user |
609 *********************************************************/ | 631 *********************************************************/ |
611 { | 633 { |
612 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_EXT_INFO_REQ); | 634 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_EXT_INFO_REQ); |
613 icq_PacketAppend32(p, uin); | 635 icq_PacketAppend32(p, uin); |
614 icq_UDPSockWrite(link, p); | 636 icq_UDPSockWrite(link, p); |
615 icq_PacketDelete(p); | 637 icq_PacketDelete(p); |
616 return link->icq_UDPSeqNum1-1; | 638 return link->d->icq_UDPSeqNum1-1; |
617 } | 639 } |
618 | 640 |
619 /************************************************************** | 641 /************************************************************** |
620 Initializes a server search for the information specified | 642 Initializes a server search for the information specified |
621 ***************************************************************/ | 643 ***************************************************************/ |
646 Registers a new uin in the ICQ network | 668 Registers a new uin in the ICQ network |
647 ***************************************************/ | 669 ***************************************************/ |
648 void icq_RegNewUser(ICQLINK *link, const char *pass) /* V5 */ | 670 void icq_RegNewUser(ICQLINK *link, const char *pass) /* V5 */ |
649 { | 671 { |
650 char pass8[9]; | 672 char pass8[9]; |
651 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_REG_NEW_USER, link->icq_UDPSeqNum1++); | 673 icq_Packet *p = icq_UDPCreateStdSeqPacket(link, UDP_CMD_REG_NEW_USER, link->d->icq_UDPSeqNum1++); |
652 strncpy(pass8, pass, 8); | 674 strncpy(pass8, pass, 8); |
653 icq_PacketAppendString(p, pass8); | 675 icq_PacketAppendString(p, pass8); |
654 icq_PacketAppend32(p, 0xA0); | 676 icq_PacketAppend32(p, 0xA0); |
655 icq_PacketAppend32(p, 0x2461); | 677 icq_PacketAppend32(p, 0x2461); |
656 icq_PacketAppend32(p, 0xA00000); | 678 icq_PacketAppend32(p, 0xA00000); |
672 icq_PacketAppendString(p, last); | 694 icq_PacketAppendString(p, last); |
673 icq_PacketAppendString(p, email); | 695 icq_PacketAppendString(p, email); |
674 /* auth (byte)? */ | 696 /* auth (byte)? */ |
675 icq_UDPSockWrite(link, p); | 697 icq_UDPSockWrite(link, p); |
676 icq_PacketDelete(p); | 698 icq_PacketDelete(p); |
677 return link->icq_UDPSeqNum1-1; | 699 return link->d->icq_UDPSeqNum1-1; |
678 } | 700 } |
679 | 701 |
680 WORD icq_UpdateAuthInfo(ICQLINK *link, DWORD auth) /* V5 */ | 702 WORD icq_UpdateAuthInfo(ICQLINK *link, DWORD auth) /* V5 */ |
681 { | 703 { |
682 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_UPDATE_AUTH); | 704 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_UPDATE_AUTH); |
683 icq_PacketAppend32(p, auth); /* NOT auth? */ | 705 icq_PacketAppend32(p, auth); /* NOT auth? */ |
684 icq_UDPSockWrite(link, p); | 706 icq_UDPSockWrite(link, p); |
685 icq_PacketDelete(p); | 707 icq_PacketDelete(p); |
686 return link->icq_UDPSeqNum1-1; | 708 return link->d->icq_UDPSeqNum1-1; |
687 } | 709 } |
688 | 710 |
689 WORD icq_UpdateMetaInfoSet(ICQLINK *link, const char *nick, const char *first, const char *last, | 711 WORD icq_UpdateMetaInfoSet(ICQLINK *link, const char *nick, const char *first, const char *last, |
690 const char *email, const char *email2, const char *email3, | 712 const char *email, const char *email2, const char *email3, |
691 const char *city, const char *state, const char *phone, const char *fax, | 713 const char *city, const char *state, const char *phone, const char *fax, |
710 icq_PacketAppend16(p, cnt_code); | 732 icq_PacketAppend16(p, cnt_code); |
711 icq_PacketAppend8(p, cnt_stat); | 733 icq_PacketAppend8(p, cnt_stat); |
712 icq_PacketAppend8(p, emailhide); | 734 icq_PacketAppend8(p, emailhide); |
713 icq_UDPSockWrite(link, p); | 735 icq_UDPSockWrite(link, p); |
714 icq_PacketDelete(p); | 736 icq_PacketDelete(p); |
715 return link->icq_UDPSeqNum2-1; | 737 return link->d->icq_UDPSeqNum2-1; |
716 } | 738 } |
717 | 739 |
718 WORD icq_UpdateMetaInfoHomepage(ICQLINK *link, unsigned char age, const char *homepage, | 740 WORD icq_UpdateMetaInfoHomepage(ICQLINK *link, unsigned char age, const char *homepage, |
719 unsigned char year, unsigned char month, unsigned char day, | 741 unsigned char year, unsigned char month, unsigned char day, |
720 unsigned char lang1, unsigned char lang2, unsigned char lang3) | 742 unsigned char lang1, unsigned char lang2, unsigned char lang3) |
730 icq_PacketAppend8(p, 0xFF /* lang1 */); | 752 icq_PacketAppend8(p, 0xFF /* lang1 */); |
731 icq_PacketAppend8(p, 0xFF /* lang2 */); | 753 icq_PacketAppend8(p, 0xFF /* lang2 */); |
732 icq_PacketAppend8(p, 0xFF /* lang3 */); | 754 icq_PacketAppend8(p, 0xFF /* lang3 */); |
733 icq_UDPSockWrite(link, p); | 755 icq_UDPSockWrite(link, p); |
734 icq_PacketDelete(p); | 756 icq_PacketDelete(p); |
735 return link->icq_UDPSeqNum2-1; | 757 return link->d->icq_UDPSeqNum2-1; |
736 } | 758 } |
737 | 759 |
738 WORD icq_UpdateMetaInfoAbout(ICQLINK *link, const char *about) | 760 WORD icq_UpdateMetaInfoAbout(ICQLINK *link, const char *about) |
739 { | 761 { |
740 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_META_USER); | 762 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_META_USER); |
741 icq_PacketAppend16(p, META_CMD_SET_ABOUT); | 763 icq_PacketAppend16(p, META_CMD_SET_ABOUT); |
742 icq_PacketAppendString(p, about); | 764 icq_PacketAppendString(p, about); |
743 icq_UDPSockWrite(link, p); | 765 icq_UDPSockWrite(link, p); |
744 icq_PacketDelete(p); | 766 icq_PacketDelete(p); |
745 return link->icq_UDPSeqNum2-1; | 767 return link->d->icq_UDPSeqNum2-1; |
746 } | 768 } |
747 | 769 |
748 WORD icq_UpdateMetaInfoSecurity(ICQLINK *link, unsigned char reqauth, unsigned char webpresence, | 770 WORD icq_UpdateMetaInfoSecurity(ICQLINK *link, unsigned char reqauth, unsigned char webpresence, |
749 unsigned char pubip) | 771 unsigned char pubip) |
750 { | 772 { |
753 icq_PacketAppend8(p, !reqauth); | 775 icq_PacketAppend8(p, !reqauth); |
754 icq_PacketAppend8(p, webpresence); | 776 icq_PacketAppend8(p, webpresence); |
755 icq_PacketAppend8(p, pubip); | 777 icq_PacketAppend8(p, pubip); |
756 icq_UDPSockWrite(link, p); | 778 icq_UDPSockWrite(link, p); |
757 icq_PacketDelete(p); | 779 icq_PacketDelete(p); |
758 return link->icq_UDPSeqNum2-1; | 780 return link->d->icq_UDPSeqNum2-1; |
759 } | 781 } |
760 | 782 |
761 WORD icq_UpdateNewUserInfo(ICQLINK *link, const char *nick, const char *first, const char *last, | 783 WORD icq_UpdateNewUserInfo(ICQLINK *link, const char *nick, const char *first, const char *last, |
762 const char *email) /* V5 */ | 784 const char *email) /* V5 */ |
763 { | 785 { |
769 icq_PacketAppend8(p, 1); | 791 icq_PacketAppend8(p, 1); |
770 icq_PacketAppend8(p, 1); | 792 icq_PacketAppend8(p, 1); |
771 icq_PacketAppend8(p, 1); | 793 icq_PacketAppend8(p, 1); |
772 icq_UDPSockWrite(link, p); | 794 icq_UDPSockWrite(link, p); |
773 icq_PacketDelete(p); | 795 icq_PacketDelete(p); |
774 return link->icq_UDPSeqNum1-1; | 796 return link->d->icq_UDPSeqNum1-1; |
775 } | 797 } |
776 | 798 |
777 WORD icq_SendMetaInfoReq(ICQLINK *link, unsigned long uin) | 799 WORD icq_SendMetaInfoReq(ICQLINK *link, unsigned long uin) |
778 { | 800 { |
779 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_META_USER); | 801 icq_Packet *p = icq_UDPCreateStdPacket(link, UDP_CMD_META_USER); |
780 icq_PacketAppend16(p, META_CMD_REQ_INFO); | 802 icq_PacketAppend16(p, META_CMD_REQ_INFO); |
781 icq_PacketAppend32(p, uin); | 803 icq_PacketAppend32(p, uin); |
782 icq_UDPSockWrite(link, p); | 804 icq_UDPSockWrite(link, p); |
783 icq_PacketDelete(p); | 805 icq_PacketDelete(p); |
784 return link->icq_UDPSeqNum2-1; | 806 return link->d->icq_UDPSeqNum2-1; |
785 } | 807 } |