Changes in protocols/oscar/oscar.c [7ee07c3:5a673f3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
r7ee07c3 r5a673f3 205 205 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); 206 206 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); 207 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); 207 208 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); 208 209 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); … … 254 255 255 256 u = t = g_strdup(s); 256 257 strcpy(t, s);258 257 g_strdown(t); 259 258 … … 569 568 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); 570 569 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0); 570 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0); 571 571 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0); 572 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); … … 602 602 } 603 603 604 struct pieceofcrap { 605 struct im_connection *ic; 606 unsigned long offset; 607 unsigned long len; 608 char *modname; 609 int fd; 610 aim_conn_t *conn; 611 unsigned int inpa; 612 }; 613 614 static gboolean damn_you(gpointer data, gint source, b_input_condition c) 615 { 616 struct pieceofcrap *pos = data; 617 struct oscar_data *od = pos->ic->proto_data; 618 char in = '\0'; 619 int x = 0; 620 unsigned char m[17]; 621 622 while (read(pos->fd, &in, 1) == 1) { 623 if (in == '\n') 624 x++; 625 else if (in != '\r') 626 x = 0; 627 if (x == 2) 628 break; 629 in = '\0'; 630 } 631 if (in != '\n') { 632 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 633 " You may be disconnected shortly."); 634 b_event_remove(pos->inpa); 635 closesocket(pos->fd); 636 g_free(pos); 637 return FALSE; 638 } 639 /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */ 640 read(pos->fd, m, 16); 641 m[16] = '\0'; 642 b_event_remove(pos->inpa); 643 closesocket(pos->fd); 644 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); 645 g_free(pos); 646 647 return FALSE; 648 } 649 650 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) { 651 struct pieceofcrap *pos = data; 652 char buf[BUF_LONG]; 653 654 if (source < 0) { 655 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 656 " You may be disconnected shortly."); 657 if (pos->modname) 658 g_free(pos->modname); 659 g_free(pos); 660 return FALSE; 661 } 662 663 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA 664 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", 665 pos->offset, pos->len, pos->modname ? pos->modname : ""); 666 write(pos->fd, buf, strlen(buf)); 667 if (pos->modname) 668 g_free(pos->modname); 669 pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); 670 return FALSE; 671 } 672 604 673 /* size of icbmui.ocm, the largest module in AIM 3.5 */ 605 674 #define AIM_MAX_FILE_SIZE 98304 675 676 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { 677 va_list ap; 678 struct pieceofcrap *pos; 679 guint32 offset, len; 680 char *modname; 681 int fd; 682 683 va_start(ap, fr); 684 offset = (guint32)va_arg(ap, unsigned long); 685 len = (guint32)va_arg(ap, unsigned long); 686 modname = va_arg(ap, char *); 687 va_end(ap); 688 689 if (len == 0) { 690 aim_sendmemblock(sess, fr->conn, offset, len, NULL, 691 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 692 return 1; 693 } 694 /* uncomment this when you're convinced it's right. remember, it's been wrong before. 695 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { 696 char *buf; 697 int i = 8; 698 if (modname) 699 i += strlen(modname); 700 buf = g_malloc(i); 701 i = 0; 702 if (modname) { 703 memcpy(buf, modname, strlen(modname)); 704 i += strlen(modname); 705 } 706 buf[i++] = offset & 0xff; 707 buf[i++] = (offset >> 8) & 0xff; 708 buf[i++] = (offset >> 16) & 0xff; 709 buf[i++] = (offset >> 24) & 0xff; 710 buf[i++] = len & 0xff; 711 buf[i++] = (len >> 8) & 0xff; 712 buf[i++] = (len >> 16) & 0xff; 713 buf[i++] = (len >> 24) & 0xff; 714 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); 715 g_free(buf); 716 return 1; 717 } 718 */ 719 720 pos = g_new0(struct pieceofcrap, 1); 721 pos->ic = sess->aux_data; 722 pos->conn = fr->conn; 723 724 pos->offset = offset; 725 pos->len = len; 726 pos->modname = modname ? g_strdup(modname) : NULL; 727 728 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); 729 if (fd < 0) { 730 if (pos->modname) 731 g_free(pos->modname); 732 g_free(pos); 733 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM." 734 " You may be disconnected shortly."); 735 } 736 pos->fd = fd; 737 738 return 1; 739 } 606 740 607 741 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { … … 651 785 struct im_connection *ic = sess->aux_data; 652 786 struct chat_connection *chatcon; 787 struct groupchat *c = NULL; 653 788 static int id = 1; 654 789 … … 663 798 chatcon = find_oscar_chat_by_conn(ic, fr->conn); 664 799 chatcon->id = id; 665 chatcon->cnv = imcb_chat_new(ic, chatcon->show); 800 801 c = bee_chat_by_title(ic->bee, ic, chatcon->show); 802 if (c && !c->data) 803 chatcon->cnv = c; 804 else 805 chatcon->cnv = imcb_chat_new(ic, chatcon->show); 666 806 chatcon->cnv->data = chatcon; 667 807 … … 1054 1194 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); 1055 1195 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1056 if(imcb_find_buddy(data->ic, uin) == NULL) 1057 imcb_ask_add(data->ic, uin, NULL); 1196 imcb_ask_add(data->ic, uin, NULL); 1058 1197 1059 1198 g_free(uin); … … 1816 1955 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1817 1956 if (odata->icq) { 1957 /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back? 1818 1958 struct buddy *budlight = imcb_find_buddy(g, who); 1819 1959 if (budlight) … … 1821 1961 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) 1822 1962 aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7); 1963 */ 1823 1964 } else 1824 1965 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE); … … 1947 2088 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { 1948 2089 struct im_connection *ic = sess->aux_data; 1949 struct aim_ssi_item *curitem ;2090 struct aim_ssi_item *curitem, *curgroup; 1950 2091 int tmp; 1951 2092 char *nrm; … … 1958 2099 switch (curitem->type) { 1959 2100 case 0x0000: /* Buddy */ 1960 if ((curitem->name) && (!imcb_ find_buddy(ic, nrm))) {2101 if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) { 1961 2102 char *realname = NULL; 1962 2103 1963 2104 if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) 1964 2105 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 1965 1966 imcb_add_buddy(ic, nrm, NULL);2106 2107 imcb_add_buddy(ic, nrm, curgroup->gid == curitem->gid ? curgroup->name : NULL); 1967 2108 1968 2109 if (realname) { … … 1972 2113 } 1973 2114 } 2115 break; 2116 2117 case 0x0001: /* Group */ 2118 curgroup = curitem; 1974 2119 break; 1975 2120 … … 2514 2659 static int chat_id = 0; 2515 2660 char * chatname; 2661 struct groupchat *c; 2516 2662 2517 2663 chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "", 2518 2664 ic->acc->user, chat_id++); 2519 2665 2666 c = imcb_chat_new(ic, chatname); 2520 2667 ret = oscar_chat_join(ic, chatname, NULL, NULL); 2521 2522 2668 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); 2523 2669
Note: See TracChangeset
for help on using the changeset viewer.