Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    r7ee07c3 r5a673f3  
    205205static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
    206206static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
     207static int gaim_memrequest       (aim_session_t *, aim_frame_t *, ...);
    207208static int gaim_selfinfo         (aim_session_t *, aim_frame_t *, ...);
    208209static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
     
    254255
    255256        u = t = g_strdup(s);
    256 
    257         strcpy(t, s);
    258257        g_strdown(t);
    259258
     
    569568        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0);
    570569        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);
    571571        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0);
    572572        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
     
    602602}
    603603
     604struct 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
     614static 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
     650static 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
    604673/* size of icbmui.ocm, the largest module in AIM 3.5 */
    605674#define AIM_MAX_FILE_SIZE 98304
     675
     676int 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}
    606740
    607741static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
     
    651785        struct im_connection *ic = sess->aux_data;
    652786        struct chat_connection *chatcon;
     787        struct groupchat *c = NULL;
    653788        static int id = 1;
    654789
     
    663798        chatcon = find_oscar_chat_by_conn(ic, fr->conn);
    664799        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);
    666806        chatcon->cnv->data = chatcon;
    667807
     
    10541194        aim_ssi_auth_reply(od->sess, od->conn, uin, 1, "");
    10551195        // 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);
    10581197       
    10591198        g_free(uin);
     
    18161955        struct oscar_data *odata = (struct oscar_data *)g->proto_data;
    18171956        if (odata->icq) {
     1957                /** FIXME(wilmer): Hmm, lost the ability to get away msgs here, do we care to get that back?
    18181958                struct buddy *budlight = imcb_find_buddy(g, who);
    18191959                if (budlight)
     
    18211961                                if (budlight->caps & AIM_CAPS_ICQSERVERRELAY)
    18221962                                        aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xff80) >> 7);
     1963                */
    18231964        } else
    18241965                aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_AWAYMESSAGE);
     
    19472088static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) {
    19482089        struct im_connection *ic = sess->aux_data;
    1949         struct aim_ssi_item *curitem;
     2090        struct aim_ssi_item *curitem, *curgroup;
    19502091        int tmp;
    19512092        char *nrm;
     
    19582099                switch (curitem->type) {
    19592100                        case 0x0000: /* Buddy */
    1960                                 if ((curitem->name) && (!imcb_find_buddy(ic, nrm))) {
     2101                                if ((curitem->name) && (!imcb_buddy_by_handle(ic, nrm))) {
    19612102                                        char *realname = NULL;
    19622103
    19632104                                        if (curitem->data && aim_gettlv(curitem->data, 0x0131, 1))
    19642105                                                    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);
    19672108                                       
    19682109                                        if (realname) {
     
    19722113                                        }
    19732114                                }
     2115                                break;
     2116
     2117                        case 0x0001: /* Group */
     2118                                curgroup = curitem;
    19742119                                break;
    19752120
     
    25142659        static int chat_id = 0;
    25152660        char * chatname;
     2661        struct groupchat *c;
    25162662       
    25172663        chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "",
    25182664                                   ic->acc->user, chat_id++);
    2519  
     2665       
     2666        c = imcb_chat_new(ic, chatname);
    25202667        ret = oscar_chat_join(ic, chatname, NULL, NULL);
    2521 
    25222668        aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0);
    25232669
Note: See TracChangeset for help on using the changeset viewer.