Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/chat.c

    rcf02dd6 r7869e48  
    55
    66#define FAIM_INTERNAL
    7 #include <aim.h> 
     7#include <aim.h>
    88
    99#include <string.h>
     
    9393
    9494        buflen = 2 + 1 + strlen(roomname) + 2;
    95        
     95
    9696        if (!(buf = malloc(buflen)))
    9797                return 0;
     
    112112
    113113/*
    114  * Join a room of name roomname.  This is the first step to joining an 
    115  * already created room.  It's basically a Service Request for 
    116  * family 0x000e, with a little added on to specify the exchange and room 
     114 * Join a room of name roomname.  This is the first step to joining an
     115 * already created room.  It's basically a Service Request for
     116 * family 0x000e, with a little added on to specify the exchange and room
    117117 * name.
    118118 */
     
    123123        aim_tlvlist_t *tl = NULL;
    124124        struct chatsnacinfo csi;
    125        
     125
    126126        if (!sess || !conn || !roomname || !strlen(roomname))
    127127                return -EINVAL;
     
    149149        aim_tx_enqueue(sess, fr);
    150150
    151         return 0; 
     151        return 0;
    152152}
    153153
     
    194194        int hdrlen;
    195195        aim_bstream_t hdrbs;
    196        
     196
    197197        if (!sess || !conn || !sn || !msg || !roomname)
    198198                return -EINVAL;
     
    239239         * Sigh.  AOL was rather inconsistent right here.  So we have
    240240         * to play some minor tricks.  Right inside the type 5 is some
    241          * raw data, followed by a series of TLVs. 
     241         * raw data, followed by a series of TLVs.
    242242         *
    243243         */
     
    245245        hdr = malloc(hdrlen);
    246246        aim_bstream_init(&hdrbs, hdr, hdrlen);
    247        
     247
    248248        aimbs_put16(&hdrbs, 0x0000); /* Unknown! */
    249249        aimbs_putraw(&hdrbs, ckstr, sizeof(ckstr)); /* I think... */
     
    255255        aim_addtlvtochain_chatroom(&itl, 0x2711, exchange, roomname, instance);
    256256        aim_tlvlist_write(&hdrbs, &itl);
    257        
     257
    258258        aim_tlvlist_add_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr);
    259259
     
    263263        aim_tlvlist_free(&itl);
    264264        aim_tlvlist_free(&otl);
    265        
     265
    266266        aim_tx_enqueue(sess, fr);
    267267
     
    307307        /*
    308308         * Everything else are TLVs.
    309          */ 
     309         */
    310310        tlvlist = aim_tlvlist_read(bs);
    311311
     
    325325         * Type 0x0073:  Occupant list.
    326326         */
    327         if (aim_tlv_gettlv(tlvlist, 0x0073, 1)) {       
     327        if (aim_tlv_gettlv(tlvlist, 0x0073, 1)) {
    328328                int curoccupant = 0;
    329329                aim_tlv_t *tmptlv;
     
    341341        }
    342342
    343         /* 
     343        /*
    344344         * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG)
    345345         */
     
    347347                flags = aim_tlv_get16(tlvlist, 0x00c9, 1);
    348348
    349         /* 
     349        /*
    350350         * Type 0x00ca: Creation time (4 bytes)
    351351         */
     
    353353                creationtime = aim_tlv_get32(tlvlist, 0x00ca, 1);
    354354
    355         /* 
     355        /*
    356356         * Type 0x00d1: Maximum Message Length
    357357         */
     
    359359                maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1);
    360360
    361         /* 
     361        /*
    362362         * Type 0x00d2: Unknown. (2 bytes)
    363363         */
     
    365365                unknown_d2 = aim_tlv_get16(tlvlist, 0x00d2, 1);
    366366
    367         /* 
     367        /*
    368368         * Type 0x00d3: Room Description
    369369         */
     
    377377                ;
    378378
    379         /* 
     379        /*
    380380         * Type 0x00d5: Unknown. (1 byte)
    381381         */
     
    389389        if (aim_tlv_gettlv(tlvlist, 0x000d6, 1))
    390390                ;
    391        
     391
    392392        /*
    393393         * Type 0x00d7: Language 1 ("en")
     
    401401        if (aim_tlv_gettlv(tlvlist, 0x000d8, 1))
    402402                ;
    403        
     403
    404404        /*
    405405         * Type 0x00d9: Language 2 ("en")
     
    475475 *                                 and displays the message as normal.)
    476476 *
    477  * XXX convert this to use tlvchains 
     477 * XXX convert this to use tlvchains
    478478 */
    479479faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen)
    480 {   
     480{
    481481        int i;
    482482        aim_frame_t *fr;
     
    539539         *
    540540         * This could include other information... We just
    541          * put in a message TLV however. 
    542          * 
     541         * put in a message TLV however.
     542         *
    543543         */
    544544        aim_tlvlist_add_frozentlvlist(&otl, 0x0005, &itl);
    545545
    546546        aim_tlvlist_write(&fr->data, &otl);
    547        
     547
    548548        aim_tlvlist_free(&itl);
    549549        aim_tlvlist_free(&otl);
    550        
     550
    551551        aim_tx_enqueue(sess, fr);
    552552
     
    557557 * Subtype 0x0006
    558558 *
    559  * We could probably include this in the normal ICBM parsing 
     559 * We could probably include this in the normal ICBM parsing
    560560 * code as channel 0x0003, however, since only the start
    561561 * would be the same, we might as well do it here.
     
    577577 *         message string
    578578 *       possibly others
    579  * 
     579 *
    580580 */
    581581static int incomingmsg(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
    582582{
    583583        aim_userinfo_t userinfo;
    584         aim_rxcallback_t userfunc;     
     584        aim_rxcallback_t userfunc;
    585585        int ret = 0;
    586586        fu8_t *cookie;
     
    619619
    620620        /*
    621          * Start parsing TLVs right away. 
     621         * Start parsing TLVs right away.
    622622         */
    623623        otl = aim_tlvlist_read(bs);
     
    637637
    638638        /*
    639          * Type 0x0001: If present, it means it was a message to the 
     639         * Type 0x0001: If present, it means it was a message to the
    640640         * room (as opposed to a whisper).
    641641         */
     
    655655                itl = aim_tlvlist_read(&tbs);
    656656
    657                 /* 
     657                /*
    658658                 * Type 0x0001: Message.
    659                  */     
     659                 */
    660660                if (aim_tlv_gettlv(itl, 0x0001, 1))
    661661                        msg = aim_tlv_getstr(itl, 0x0001, 1);
    662662
    663                 aim_tlvlist_free(&itl); 
     663                aim_tlvlist_free(&itl);
    664664        }
    665665
Note: See TracChangeset for help on using the changeset viewer.