Changeset cf02dd6 for libfaim/icq.c


Ignore:
Timestamp:
Dec 10, 2003, 3:20:45 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:
b1fe407
Parents:
8c46404
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/icq.c

    re374dee rcf02dd6  
    317317
    318318        aim_tx_enqueue(sess, fr);
     319
     320        return 0;
     321}
     322
     323/*
     324 * Send an SMS message.  This is the non-US way.  The US-way is to IM
     325 * their cell phone number (+19195551234).
     326 *
     327 * We basically construct and send an XML message.  The format is:
     328 * <icq_sms_message>
     329 *   <destination>full_phone_without_leading_+</destination>
     330 *   <text>message</text>
     331 *   <codepage>1252</codepage>
     332 *   <senders_UIN>self_uin</senders_UIN>
     333 *   <senders_name>self_name</senders_name>
     334 *   <delivery_receipt>Yes|No</delivery_receipt>
     335 *   <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time>
     336 * </icq_sms_message>
     337 *
     338 * Yeah hi Peter, whaaaat's happening.  If there's any way to use
     339 * a codepage other than 1252 that would be great.  Thaaaanks.
     340 */
     341faim_export int aim_icq_sendsms(aim_session_t *sess, const char *name, const char *msg, const char *alias)
     342{
     343        aim_conn_t *conn;
     344        aim_frame_t *fr;
     345        aim_snacid_t snacid;
     346        int bslen, xmllen;
     347        char *xml, timestr[30];
     348        time_t t;
     349        struct tm *tm;
     350
     351        if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015)))
     352                return -EINVAL;
     353
     354        if (!name || !msg || !alias)
     355                return -EINVAL;
     356
     357        time(&t);
     358        tm = gmtime(&t);
     359        strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm);
     360
     361        /* The length of xml included the null terminating character */
     362        xmllen = 225 + strlen(name) + strlen(msg) + strlen(sess->sn) + strlen(alias) + strlen(timestr) + 1;
     363
     364        if (!(xml = (char *)malloc(xmllen*sizeof(char))))
     365                return -ENOMEM;
     366        snprintf(xml, xmllen, "<icq_sms_message>\n"
     367                "\t<destination>%s</destination>\n"
     368                "\t<text>%s</text>\n"
     369                "\t<codepage>1252</codepage>\n"
     370                "\t<senders_UIN>%s</senders_UIN>\n"
     371                "\t<senders_name>%s</senders_name>\n"
     372                "\t<delivery_receipt>Yes</delivery_receipt>\n"
     373                "\t<time>%s</time>\n"
     374                "</icq_sms_message>\n",
     375                name, msg, sess->sn, alias, timestr);
     376
     377        bslen = 37 + xmllen;
     378
     379        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) {
     380                free(xml);
     381                return -ENOMEM;
     382        }
     383
     384        snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0);
     385        aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid);
     386
     387        /* For simplicity, don't bother using a tlvlist */
     388        aimbs_put16(&fr->data, 0x0001);
     389        aimbs_put16(&fr->data, bslen);
     390
     391        aimbs_putle16(&fr->data, bslen - 2);
     392        aimbs_putle32(&fr->data, atoi(sess->sn));
     393        aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */
     394        aimbs_putle16(&fr->data, snacid); /* eh. */
     395
     396        /* From libicq200-0.3.2/src/SNAC-SRV.cpp */
     397        aimbs_putle16(&fr->data, 0x8214);
     398        aimbs_put16(&fr->data, 0x0001);
     399        aimbs_put16(&fr->data, 0x0016);
     400        aimbs_put32(&fr->data, 0x00000000);
     401        aimbs_put32(&fr->data, 0x00000000);
     402        aimbs_put32(&fr->data, 0x00000000);
     403        aimbs_put32(&fr->data, 0x00000000);
     404
     405        aimbs_put16(&fr->data, 0x0000);
     406        aimbs_put16(&fr->data, xmllen);
     407        aimbs_putraw(&fr->data, xml, xmllen);
     408
     409        aim_tx_enqueue(sess, fr);
     410
     411        free(xml);
    319412
    320413        return 0;
     
    368461        fu16_t cmdlen, cmd, reqid;
    369462
    370         if (!(tl = aim_readtlvchain(bs)) || !(datatlv = aim_gettlv(tl, 0x0001, 1))) {
    371                 aim_freetlvchain(&tl);
     463        if (!(tl = aim_tlvlist_read(bs)) || !(datatlv = aim_tlv_gettlv(tl, 0x0001, 1))) {
     464                aim_tlvlist_free(&tl);
    372465                faimdprintf(sess, 0, "corrupt ICQ response\n");
    373466                return 0;
     
    549642        }
    550643
    551         aim_freetlvchain(&tl);
     644        aim_tlvlist_free(&tl);
    552645
    553646        return ret;
Note: See TracChangeset for help on using the changeset viewer.