Changeset 7ee07c3
- Timestamp:
- 2010-05-09T16:06:19Z (15 years ago)
- Branches:
- master
- Children:
- e73a501
- Parents:
- 5a599a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/oscar.c
r5a599a1 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 *, ...); … … 570 569 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0); 571 570 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0); 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);573 571 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0); 574 572 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); … … 604 602 } 605 603 606 struct pieceofcrap {607 struct im_connection *ic;608 unsigned long offset;609 unsigned long len;610 char *modname;611 int fd;612 aim_conn_t *conn;613 unsigned int inpa;614 };615 616 static gboolean damn_you(gpointer data, gint source, b_input_condition c)617 {618 struct pieceofcrap *pos = data;619 struct oscar_data *od = pos->ic->proto_data;620 char in = '\0';621 int x = 0;622 unsigned char m[17];623 624 while (read(pos->fd, &in, 1) == 1) {625 if (in == '\n')626 x++;627 else if (in != '\r')628 x = 0;629 if (x == 2)630 break;631 in = '\0';632 }633 if (in != '\n') {634 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."635 " You may be disconnected shortly.");636 b_event_remove(pos->inpa);637 closesocket(pos->fd);638 g_free(pos);639 return FALSE;640 }641 /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */642 read(pos->fd, m, 16);643 m[16] = '\0';644 b_event_remove(pos->inpa);645 closesocket(pos->fd);646 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);647 g_free(pos);648 649 return FALSE;650 }651 652 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {653 struct pieceofcrap *pos = data;654 char buf[BUF_LONG];655 656 if (source < 0) {657 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."658 " You may be disconnected shortly.");659 if (pos->modname)660 g_free(pos->modname);661 g_free(pos);662 return FALSE;663 }664 665 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA666 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",667 pos->offset, pos->len, pos->modname ? pos->modname : "");668 write(pos->fd, buf, strlen(buf));669 if (pos->modname)670 g_free(pos->modname);671 pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);672 return FALSE;673 }674 675 604 /* size of icbmui.ocm, the largest module in AIM 3.5 */ 676 605 #define AIM_MAX_FILE_SIZE 98304 677 678 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {679 va_list ap;680 struct pieceofcrap *pos;681 guint32 offset, len;682 char *modname;683 int fd;684 685 va_start(ap, fr);686 offset = (guint32)va_arg(ap, unsigned long);687 len = (guint32)va_arg(ap, unsigned long);688 modname = va_arg(ap, char *);689 va_end(ap);690 691 if (len == 0) {692 aim_sendmemblock(sess, fr->conn, offset, len, NULL,693 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);694 return 1;695 }696 /* uncomment this when you're convinced it's right. remember, it's been wrong before.697 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {698 char *buf;699 int i = 8;700 if (modname)701 i += strlen(modname);702 buf = g_malloc(i);703 i = 0;704 if (modname) {705 memcpy(buf, modname, strlen(modname));706 i += strlen(modname);707 }708 buf[i++] = offset & 0xff;709 buf[i++] = (offset >> 8) & 0xff;710 buf[i++] = (offset >> 16) & 0xff;711 buf[i++] = (offset >> 24) & 0xff;712 buf[i++] = len & 0xff;713 buf[i++] = (len >> 8) & 0xff;714 buf[i++] = (len >> 16) & 0xff;715 buf[i++] = (len >> 24) & 0xff;716 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);717 g_free(buf);718 return 1;719 }720 */721 722 pos = g_new0(struct pieceofcrap, 1);723 pos->ic = sess->aux_data;724 pos->conn = fr->conn;725 726 pos->offset = offset;727 pos->len = len;728 pos->modname = modname ? g_strdup(modname) : NULL;729 730 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);731 if (fd < 0) {732 if (pos->modname)733 g_free(pos->modname);734 g_free(pos);735 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."736 " You may be disconnected shortly.");737 }738 pos->fd = fd;739 740 return 1;741 }742 606 743 607 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
Note: See TracChangeset
for help on using the changeset viewer.