Changeset e374dee for libfaim/chat.c


Ignore:
Timestamp:
Oct 10, 2003, 5:12:30 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fe6f1d3
Parents:
f4d0975
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/chat.c

    r862371b re374dee  
    66#define FAIM_INTERNAL
    77#include <aim.h>
     8
     9#include <string.h>
    810
    911/* Stored in the ->priv of chat connections */
     
    205207        aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
    206208
    207 
    208209        /*
    209210         * Cookie
    210211         */
    211         for (i = 0; i < sizeof(ckstr); i++)
    212                 aimutil_put8(ckstr, (fu8_t) rand());
     212        for (i = 0; i < 8; i++)
     213                ckstr[i] = (fu8_t)rand();
    213214
    214215        /* XXX should be uncached by an unwritten 'invite accept' handler */
     
    225226                free(priv);
    226227
    227         for (i = 0; i < sizeof(ckstr); i++)
    228                 aimbs_put8(&fr->data, ckstr[i]);
    229 
    230 
    231         /*
    232          * Channel (2)
    233          */
    234         aimbs_put16(&fr->data, 0x0002);
    235 
    236         /*
    237          * Dest sn
    238          */
    239         aimbs_put8(&fr->data, strlen(sn));
    240         aimbs_putraw(&fr->data, sn, strlen(sn));
     228        /* ICBM Header */
     229        aimbs_putraw(&fr->data, ckstr, 8); /* Cookie */
     230        aimbs_put16(&fr->data, 0x0002); /* Channel */
     231        aimbs_put8(&fr->data, strlen(sn)); /* Screename length */
     232        aimbs_putraw(&fr->data, sn, strlen(sn)); /* Screenname */
    241233
    242234        /*
     
    346338
    347339                while (curoccupant < usercount)
    348                         aim_extractuserinfo(sess, &occbs, &userinfo[curoccupant++]);
     340                        aim_info_extract(sess, &occbs, &userinfo[curoccupant++]);
    349341        }
    350342
     
    424416        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    425417                ret = userfunc(sess,
    426                                 rx, 
     418                                rx,
    427419                                &roominfo,
    428420                                roomname,
    429421                                usercount,
    430                                 userinfo,       
     422                                userinfo,
    431423                                roomdesc,
    432424                                flags,
     
    439431
    440432        free(roominfo.name);
     433
     434        while (usercount > 0)
     435                aim_info_free(&userinfo[--usercount]);
     436
    441437        free(userinfo);
    442438        free(roomname);
     
    457453                curcount++;
    458454                userinfo = realloc(userinfo, curcount * sizeof(aim_userinfo_t));
    459                 aim_extractuserinfo(sess, bs, &userinfo[curcount-1]);
     455                aim_info_extract(sess, bs, &userinfo[curcount-1]);
    460456        }
    461457
     
    463459                ret = userfunc(sess, rx, curcount, userinfo);
    464460
     461        aim_info_free(userinfo);
    465462        free(userinfo);
    466463
     
    498495        aim_putsnac(&fr->data, 0x000e, 0x0005, 0x0000, snacid);
    499496
    500 
    501         /*
    502          * Generate a random message cookie.
     497        /*
     498         * Cookie
    503499         *
    504500         * XXX mkcookie should generate the cookie and cache it in one
    505501         * operation to preserve uniqueness.
    506          *
    507          */
    508         for (i = 0; i < sizeof(ckstr); i++)
    509                 aimutil_put8(ckstr+i, (fu8_t) rand());
     502         */
     503        for (i = 0; i < 8; i++)
     504                ckstr[i] = (fu8_t)rand();
    510505
    511506        cookie = aim_mkcookie(ckstr, AIM_COOKIETYPE_CHAT, NULL);
     
    514509        aim_cachecookie(sess, cookie);
    515510
    516         for (i = 0; i < sizeof(ckstr); i++)
    517                 aimbs_put8(&fr->data, ckstr[i]);
    518 
    519 
    520         /*
    521          * Channel ID.
    522          */
    523         aimbs_put16(&fr->data, 0x0003);
    524 
     511        /* ICBM Header */
     512        aimbs_putraw(&fr->data, ckstr, 8); /* Cookie */
     513        aimbs_put16(&fr->data, 0x0003); /* Channel */
    525514
    526515        /*
     
    544533         * SubTLV: Type 1: Message
    545534         */
    546         aim_addtlvtochain_raw(&itl, 0x0001, strlen(msg), msg);
     535        aim_addtlvtochain_raw(&itl, 0x0001, msglen, msg);
    547536
    548537        /*
     
    644633
    645634                aim_bstream_init(&tbs, userinfotlv->value, userinfotlv->length);
    646                 aim_extractuserinfo(sess, &tbs, &userinfo);
     635                aim_info_extract(sess, &tbs, &userinfo);
    647636        }
    648637
     
    678667                ret = userfunc(sess, rx, &userinfo, msg);
    679668
     669        aim_info_free(&userinfo);
    680670        free(cookie);
    681671        free(msg);
     
    703693        mod->family = 0x000e;
    704694        mod->version = 0x0001;
    705         mod->toolid = 0x0004; /* XXX this doesn't look right */
    706         mod->toolversion = 0x0001; /* nor does this */
     695        mod->toolid = 0x0010;
     696        mod->toolversion = 0x0629;
    707697        mod->flags = 0;
    708698        strncpy(mod->name, "chat", sizeof(mod->name));
Note: See TracChangeset for help on using the changeset viewer.