Changeset 7869e48 for libfaim/im.c


Ignore:
Timestamp:
Jan 12, 2013, 1:43:13 PM (11 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
e3a0d71, 4485285
Parents:
4626016
git-author:
Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
git-committer:
Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
Message:
Remove trailing whitespace

This commit was made with the command sequence

    for i in $(git ls-files | tr '\n' ' ');
    do
      echo $i; sed -i s'/\s\+$//g' "$(readlink -f $i)";
    done
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/im.c

    rcf02dd6 r7869e48  
    99 * is used for negotiating "rendezvous".  These transactions end in
    1010 * something more complex happening, such as a chat invitation, or
    11  * a file transfer.  Channel 3 is used for chat messages (not in 
    12  * the same family as these channels).  Channel 4 is used for 
    13  * various ICQ messages.  Examples are normal messages, URLs, and 
     11 * a file transfer.  Channel 3 is used for chat messages (not in
     12 * the same family as these channels).  Channel 4 is used for
     13 * various ICQ messages.  Examples are normal messages, URLs, and
    1414 * old-style authorization.
    1515 *
     
    1919 * use of this field.
    2020 *
    21  * TODO: Split this up into an im.c file an an icbm.c file.  It 
     21 * TODO: Split this up into an im.c file an an icbm.c file.  It
    2222 *       will be beautiful, you'll see.
    2323 *
     
    3535
    3636/**
    37  * Add a standard ICBM header to the given bstream with the given 
     37 * Add a standard ICBM header to the given bstream with the given
    3838 * information.
    3939 *
     
    6464 * Heres the current collection:
    6565 *  0501 0003 0101 0101 01              AOL Mobile Communicator, WinAIM 1.0.414
    66  *  0501 0003 0101 0201 01              WinAIM 2.0.847, 2.1.1187, 3.0.1464, 
     66 *  0501 0003 0101 0201 01              WinAIM 2.0.847, 2.1.1187, 3.0.1464,
    6767 *                                      4.3.2229, 4.4.2286
    6868 *  0501 0004 0101 0102 0101            WinAIM 4.1.2010, libfaim (right here)
     
    8484        } fingerprints[] = {
    8585                /* AOL Mobile Communicator, WinAIM 1.0.414 */
    86                 { AIM_CLIENTTYPE_MC, 
     86                { AIM_CLIENTTYPE_MC,
    8787                  3, {0x01, 0x01, 0x01}},
    8888
    8989                /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */
    90                 { AIM_CLIENTTYPE_WINAIM, 
     90                { AIM_CLIENTTYPE_WINAIM,
    9191                  3, {0x01, 0x01, 0x02}},
    9292
     
    116116}
    117117
    118 /** 
     118/**
    119119 * Subtype 0x0002 - Set ICBM parameters.
    120120 *
    121121 * I definitly recommend sending this.  If you don't, you'll be stuck
    122122 * with the rather unreasonable defaults.
    123  * 
     123 *
    124124 */
    125125faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params)
     
    145145
    146146        /* These are all read-write */
    147         aimbs_put32(&fr->data, params->flags); 
     147        aimbs_put32(&fr->data, params->flags);
    148148        aimbs_put16(&fr->data, params->maxmsglen);
    149         aimbs_put16(&fr->data, params->maxsenderwarn); 
    150         aimbs_put16(&fr->data, params->maxrecverwarn); 
     149        aimbs_put16(&fr->data, params->maxsenderwarn);
     150        aimbs_put16(&fr->data, params->maxrecverwarn);
    151151        aimbs_put32(&fr->data, params->minmsginterval);
    152152
     
    185185        params.maxrecverwarn = aimbs_get16(bs);
    186186        params.minmsginterval = aimbs_get32(bs);
    187        
     187
    188188        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
    189189                return userfunc(sess, rx, &params);
     
    193193
    194194/**
    195  * Subtype 0x0006 - Send an ICBM (instant message). 
     195 * Subtype 0x0006 - Send an ICBM (instant message).
    196196 *
    197197 *
     
    207207 *                        what you're doing.
    208208 *   AIM_IMFLAGS_ISO_8859_1 -- The message contains the ASCII8 subset
    209  *                        known as ISO-8859-1. 
     209 *                        known as ISO-8859-1.
    210210 *
    211211 * Generally, you should use the lowest encoding possible to send
    212212 * your message.  If you only use basic punctuation and the generic
    213213 * Latin alphabet, use ASCII7 (no flags).  If you happen to use non-ASCII7
    214  * characters, but they are all clearly defined in ISO-8859-1, then 
     214 * characters, but they are all clearly defined in ISO-8859-1, then
    215215 * use that.  Keep in mind that not all characters in the PC ASCII8
    216216 * character set are defined in the ISO standard. For those cases (most
     
    224224 * of the clients I use can parse those messages (and besides that,
    225225 * wchars are difficult and non-portable to handle in most UNIX environments).
    226  * If you really need to include special characters, use the HTML UNICODE 
    227  * entities.  These are of the form &#2026; where 2026 is the hex 
    228  * representation of the UNICODE index (in this case, UNICODE 
     226 * If you really need to include special characters, use the HTML UNICODE
     227 * entities.  These are of the form &#2026; where 2026 is the hex
     228 * representation of the UNICODE index (in this case, UNICODE
    229229 * "Horizontal Ellipsis", or 133 in in ASCII8).
    230230 *
     
    232232 * in all of libfaim, it is written with performance in mind.  As such,
    233233 * it is not as clear as it could be in respect to how this message is
    234  * supposed to be layed out. Most obviously, tlvlists should be used 
    235  * instead of writing out the bytes manually. 
     234 * supposed to be layed out. Most obviously, tlvlists should be used
     235 * instead of writing out the bytes manually.
    236236 *
    237237 * XXX - more precise verification that we never send SNACs larger than 8192
     
    289289                return -ENOMEM;
    290290
    291         /* XXX - should be optional */ 
     291        /* XXX - should be optional */
    292292        snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1);
    293293        aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
    294294
    295         /* 
     295        /*
    296296         * Generate a random message cookie
    297297         *
    298          * We could cache these like we do SNAC IDs.  (In fact, it 
    299          * might be a good idea.)  In the message error functions, 
    300          * the 8byte message cookie is returned as well as the 
     298         * We could cache these like we do SNAC IDs.  (In fact, it
     299         * might be a good idea.)  In the message error functions,
     300         * the 8byte message cookie is returned as well as the
    301301         * SNAC ID.
    302302         *
     
    367367        /*
    368368         * Set the I HAVE A REALLY PURTY ICON flag.
    369          * XXX - This should really only be sent on initial 
     369         * XXX - This should really only be sent on initial
    370370         * IMs and when you change your icon.
    371371         */
     
    397397
    398398/*
    399  * Simple wrapper for aim_im_sendch1_ext() 
     399 * Simple wrapper for aim_im_sendch1_ext()
    400400 *
    401401 * You cannot use aim_send_im if you need the HASICON flag.  You must
     
    505505 * You'd think this would be in icq.c, but, well, I'm trying to stick with
    506506 * the one-group-per-file scheme as much as possible.  This could easily
    507  * be an exception, since Rendezvous IMs are external of the Oscar core, 
     507 * be an exception, since Rendezvous IMs are external of the Oscar core,
    508508 * and therefore are undefined.  Really I just need to think of a good way to
    509509 * make an interface similar to what AOL actually uses.  But I'm not using COM.
     
    613613        aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid);
    614614
    615         /* 
    616          * Generate a random message cookie 
    617          *
    618          * This cookie needs to be alphanumeric and NULL-terminated to be 
     615        /*
     616         * Generate a random message cookie
     617         *
     618         * This cookie needs to be alphanumeric and NULL-terminated to be
    619619         * TOC-compatible.
    620620         *
     
    646646        aim_tlvlist_add_16(&itl, 0x0005, port);
    647647        aim_tlvlist_add_noval(&itl, 0x000f);
    648        
     648
    649649        aim_tlvlist_write(&hdrbs, &itl);
    650650
     
    833833 * @param sess The oscar session.
    834834 * @param sn The UIN of the user of whom you wish to request info.
    835  * @param type The type of info you wish to request.  This should be the current 
     835 * @param type The type of info you wish to request.  This should be the current
    836836 *        state of the user, as one of the AIM_ICQ_STATE_* defines.
    837837 * @return Return 0 if no errors, otherwise return the error number.
     
    931931 * Subtype 0x0006 - Send an ICQ-esque ICBM.
    932932 *
    933  * This can be used to send an ICQ authorization reply (deny or grant).  It is the "old way." 
    934  * The new way is to use SSI.  I like the new way a lot better.  This seems like such a hack, 
    935  * mostly because it's in network byte order.  Figuring this stuff out sometimes takes a while, 
    936  * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people 
     933 * This can be used to send an ICQ authorization reply (deny or grant).  It is the "old way."
     934 * The new way is to use SSI.  I like the new way a lot better.  This seems like such a hack,
     935 * mostly because it's in network byte order.  Figuring this stuff out sometimes takes a while,
     936 * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people
    937937 * were taking when they merged the two protocols.
    938938 *
     
    10731073 *
    10741074 * Not only do AIM ICBM's support multiple channels.  Not only do they
    1075  * support multiple character sets.  But they support multiple character 
     1075 * support multiple character sets.  But they support multiple character
    10761076 * sets / encodings within the same ICBM.
    10771077 *
     
    10791079 * seem utterly unnecessary by today's standards.  In fact, there is only
    10801080 * one client still in popular use that still uses this method: AOL for the
    1081  * Macintosh, Version 5.0.  Obscure, yes, I know. 
     1081 * Macintosh, Version 5.0.  Obscure, yes, I know.
    10821082 *
    10831083 * In modern (non-"legacy") clients, if the user tries to send a character
     
    10871087 * Multipart messages prevent this wasted space by allowing the client to
    10881088 * only send the characters in UNICODE that need to be sent that way, and
    1089  * the rest of the message can be sent in whatever the native character 
     1089 * the rest of the message can be sent in whatever the native character
    10901090 * set is (probably ASCII).
    10911091 *
     
    11161116static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen)
    11171117{
    1118         aim_mpmsg_section_t *sec; 
    1119        
     1118        aim_mpmsg_section_t *sec;
     1119
    11201120        if (!(sec = malloc(sizeof(aim_mpmsg_section_t))))
    11211121                return -1;
     
    11631163        fu8_t *dup;
    11641164
    1165         if (!(dup = strdup(ascii))) 
     1165        if (!(dup = strdup(ascii)))
    11661166                return -1;
    11671167
     
    11931193                return -1;
    11941194        }
    1195        
     1195
    11961196        return 0;
    11971197}
     
    12031203        for (cur = mpm->parts; cur; ) {
    12041204                aim_mpmsg_section_t *tmp;
    1205                
     1205
    12061206                tmp = cur->next;
    12071207                free(cur->data);
     
    12091209                cur = tmp;
    12101210        }
    1211        
     1211
    12121212        mpm->numparts = 0;
    12131213        mpm->parts = NULL;
     
    12171217
    12181218/*
    1219  * Start by building the multipart structures, then pick the first 
     1219 * Start by building the multipart structures, then pick the first
    12201220 * human-readable section and stuff it into args->msg so no one gets
    12211221 * suspicious.
     
    14051405                         * You really shouldn't advertise a zero-length icon
    14061406                         * anyway.
    1407                          * 
     1407                         *
    14081408                         */
    14091409                        if (args.iconlen)
     
    15521552
    15531553/*
    1554  * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is 
     1554 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is
    15551555 * kind of odd. This sends the client ICQRTF since that is all that I've seen
    15561556 * SERVERRELAY used for.
     
    15711571
    15721572        msgtype = aimbs_getle16(servdata);
    1573        
     1573
    15741574        anslen = aimbs_getle32(servdata);
    15751575        aim_bstream_advance(servdata, anslen);
     
    16021602        args->destructor = (void *)incomingim_ch2_sendfile_free;
    16031603
    1604         /* Maybe there is a better way to tell what kind of sendfile 
     1604        /* Maybe there is a better way to tell what kind of sendfile
    16051605         * this is?  Maybe TLV t(000a)? */
    16061606        if (servdata) { /* Someone is sending us a file */
     
    16131613
    16141614                /*
    1615                  * I hope to God I'm right when I guess that there is a 
    1616                  * 32 char max filename length for single files.  I think 
    1617                  * OFT tends to do that.  Gotta love inconsistency.  I saw 
     1615                 * I hope to God I'm right when I guess that there is a
     1616                 * 32 char max filename length for single files.  I think
     1617                 * OFT tends to do that.  Gotta love inconsistency.  I saw
    16181618                 * a 26 byte filename?
    16191619                 */
    16201620                /* AAA - create an aimbs_getnullstr function (don't anymore)(maybe) */
    1621                 /* Use an inelegant way of getting the null-terminated filename, 
     1621                /* Use an inelegant way of getting the null-terminated filename,
    16221622                 * since there's no easy bstream routine. */
    16231623                for (flen = 0; aimbs_get8(servdata); flen++);
     
    16251625                args->info.sendfile.filename = aimbs_getstr(servdata, flen);
    16261626
    1627                 /* There is sometimes more after the null-terminated filename, 
     1627                /* There is sometimes more after the null-terminated filename,
    16281628                 * but I'm unsure of its format. */
    16291629                /* I don't believe him. */
     
    16521652
    16531653        /*
    1654          * There's another block of TLVs embedded in the type 5 here. 
     1654         * There's another block of TLVs embedded in the type 5 here.
    16551655         */
    16561656        block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1);
     
    16611661         *
    16621662         * 0 is a request, 1 is a cancel, 2 is an accept
    1663          */ 
     1663         */
    16641664        args.status = aimbs_get16(&bbs);
    16651665
     
    16681668         */
    16691669        cookie2 = aimbs_getraw(&bbs, 8);
    1670         if (memcmp(cookie, cookie2, 8) != 0) 
     1670        if (memcmp(cookie, cookie2, 8) != 0)
    16711671                faimdprintf(sess, 0, "rend: warning cookies don't match!\n");
    16721672        memcpy(args.cookie, cookie2, 8);
     
    16791679        args.reqclass = aim_locate_getcaps(sess, &bbs, 0x10);
    16801680
    1681         /* 
     1681        /*
    16821682         * What follows may be TLVs or nothing, depending on the
    16831683         * purpose of the message.
     
    17611761        if (aim_tlv_gettlv(list2, 0x000d, 1))
    17621762                args.encoding = aim_tlv_getstr(list2, 0x000d, 1);
    1763        
     1763
    17641764        /*
    17651765         * Language.
     
    18961896         * Channel ID.
    18971897         *
    1898          * Channel 0x0001 is the message channel.  It is 
     1898         * Channel 0x0001 is the message channel.  It is
    18991899         * used to send basic ICBMs.
    19001900         *
     
    19051905         * Channel 0x0003 is used for chat messages.
    19061906         *
    1907          * Channel 0x0004 is used for ICQ authorization, or 
     1907         * Channel 0x0004 is used for ICQ authorization, or
    19081908         * possibly any system notice.
    19091909         *
     
    19181918         * userinfo block contains the number of TLVs that contain user
    19191919         * information, the rest are not even though there is no seperation.
    1920          * You can start reading the message TLVs after aim_info_extract() 
     1920         * You can start reading the message TLVs after aim_info_extract()
    19211921         * parses out the standard userinfo block.
    19221922         *
     
    19241924         * userinfo block and the rest of the message, however there should
    19251925         * never be two TLVs of the same type in one block.
    1926          * 
     1926         *
    19271927         */
    19281928        aim_info_extract(sess, bs, &userinfo);
     
    19431943
    19441944                /*
    1945                  * Read block of TLVs (not including the userinfo data).  All 
     1945                 * Read block of TLVs (not including the userinfo data).  All
    19461946                 * further data is derived from what is parsed here.
    19471947                 */
     
    19701970/*
    19711971 * Subtype 0x0008 - Send a warning to sn.
    1972  * 
     1972 *
    19731973 * Flags:
    19741974 *  AIM_WARN_ANON  Send as an anonymous (doesn't count as much)
    19751975 *
    1976  * returns -1 on error (couldn't alloc packet), 0 on success. 
     1976 * returns -1 on error (couldn't alloc packet), 0 on success.
    19771977 *
    19781978 */
     
    19911991        aim_putsnac(&fr->data, 0x0004, 0x0008, 0x0000, snacid);
    19921992
    1993         aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000); 
     1993        aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000);
    19941994        aimbs_put8(&fr->data, strlen(sn));
    19951995        aimbs_putraw(&fr->data, sn, strlen(sn));
     
    20082008        aim_userinfo_t userinfo;
    20092009
    2010         while (aim_bstream_empty(bs)) { 
     2010        while (aim_bstream_empty(bs)) {
    20112011
    20122012                channel = aimbs_get16(bs);
     
    20312031 *    AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer"
    20322032 *    AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers"
    2033  * 
     2033 *
    20342034 */
    20352035faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code)
     
    20392039        aim_snacid_t snacid;
    20402040        aim_tlvlist_t *tl = NULL;
    2041        
     2041
    20422042        if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)))
    20432043                return -EINVAL;
     
    20482048        snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0);
    20492049        aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid);
    2050        
     2050
    20512051        aimbs_putraw(&fr->data, cookie, 8);
    20522052
     
    21532153 * Subtype 0x000c - Receive an ack after sending an ICBM.
    21542154 *
    2155  * You have to have send the message with the AIM_IMFLAGS_ACK flag set 
    2156  * (TLV t(0003)).  The ack contains the ICBM header of the message you 
     2155 * You have to have send the message with the AIM_IMFLAGS_ACK flag set
     2156 * (TLV t(0003)).  The ack contains the ICBM header of the message you
    21572157 * sent.
    21582158 *
     
    21822182 * Subtype 0x0014 - Send a mini typing notification (mtn) packet.
    21832183 *
    2184  * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 
     2184 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
    21852185 * and Gaim 0.60 and newer.
    21862186 *
     
    22372237 * Subtype 0x0014 - Receive a mini typing notification (mtn) packet.
    22382238 *
    2239  * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, 
     2239 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
    22402240 * and Gaim 0.60 and newer.
    22412241 *
Note: See TracChangeset for help on using the changeset viewer.