Changes in protocols/oscar/oscar.c [5a673f3:7ee07c3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
r5a673f3 r7ee07c3 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 *, ...);208 207 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); 209 208 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); … … 255 254 256 255 u = t = g_strdup(s); 256 257 strcpy(t, s); 257 258 g_strdown(t); 258 259 … … 568 569 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); 569 570 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 " AIMHASHDATA664 "?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 673 604 /* size of icbmui.ocm, the largest module in AIM 3.5 */ 674 605 #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 }740 606 741 607 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { … … 785 651 struct im_connection *ic = sess->aux_data; 786 652 struct chat_connection *chatcon; 787 struct groupchat *c = NULL;788 653 static int id = 1; 789 654 … … 798 663 chatcon = find_oscar_chat_by_conn(ic, fr->conn); 799 664 chatcon->id = id; 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); 665 chatcon->cnv = imcb_chat_new(ic, chatcon->show); 806 666 chatcon->cnv->data = chatcon; 807 667 … … 1194 1054 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); 1195 1055 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1196 imcb_ask_add(data->ic, uin, NULL); 1056 if(imcb_find_buddy(data->ic, uin) == NULL) 1057 imcb_ask_add(data->ic, uin, NULL); 1197 1058 1198 1059 g_free(uin); … … 1955 1816 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1956 1817 if (odata->icq) { 1957 /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?1958 1818 struct buddy *budlight = imcb_find_buddy(g, who); 1959 1819 if (budlight) … … 1961 1821 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) 1962 1822 aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7); 1963 */1964 1823 } else 1965 1824 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE); … … 2088 1947 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { 2089 1948 struct im_connection *ic = sess->aux_data; 2090 struct aim_ssi_item *curitem , *curgroup;1949 struct aim_ssi_item *curitem; 2091 1950 int tmp; 2092 1951 char *nrm; … … 2099 1958 switch (curitem->type) { 2100 1959 case 0x0000: /* Buddy */ 2101 if ((curitem->name) && (!imcb_ buddy_by_handle(ic, nrm))) {1960 if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) { 2102 1961 char *realname = NULL; 2103 1962 2104 1963 if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1)) 2105 1964 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 2106 2107 imcb_add_buddy(ic, nrm, curgroup->gid == curitem->gid ? curgroup->name :NULL);1965 1966 imcb_add_buddy(ic, nrm, NULL); 2108 1967 2109 1968 if (realname) { … … 2113 1972 } 2114 1973 } 2115 break;2116 2117 case 0x0001: /* Group */2118 curgroup = curitem;2119 1974 break; 2120 1975 … … 2659 2514 static int chat_id = 0; 2660 2515 char * chatname; 2661 struct groupchat *c;2662 2516 2663 2517 chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "", 2664 2518 ic->acc->user, chat_id++); 2665 2666 c = imcb_chat_new(ic, chatname); 2519 2667 2520 ret = oscar_chat_join(ic, chatname, NULL, NULL); 2521 2668 2522 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); 2669 2523
Note: See TracChangeset
for help on using the changeset viewer.