Changeset 3e1de87


Ignore:
Timestamp:
2005-11-19T11:12:18Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4d50898
Parents:
0b2e843
Message:

Applied AIM typing notification patch from Hanji.

Location:
protocols/oscar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/im.c

    r0b2e843 r3e1de87  
    19961996}
    19971997
     1998/*
     1999 * Subtype 0x0014 - Send a mini typing notification (mtn) packet.
     2000 *
     2001 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
     2002 * and Gaim 0.60 and newer.
     2003 *
     2004 */
     2005int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 type2)
     2006{
     2007        aim_conn_t *conn;
     2008        aim_frame_t *fr;
     2009        aim_snacid_t snacid;
     2010
     2011        if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002)))
     2012                return -EINVAL;
     2013
     2014        if (!sn)
     2015                return -EINVAL;
     2016
     2017        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+11+strlen(sn)+2)))
     2018                return -ENOMEM;
     2019
     2020        snacid = aim_cachesnac(sess, 0x0004, 0x0014, 0x0000, NULL, 0);
     2021        aim_putsnac(&fr->data, 0x0004, 0x0014, 0x0000, snacid);
     2022
     2023        /*
     2024         * 8 days of light
     2025         * Er, that is to say, 8 bytes of 0's
     2026         */
     2027        aimbs_put16(&fr->data, 0x0000);
     2028        aimbs_put16(&fr->data, 0x0000);
     2029        aimbs_put16(&fr->data, 0x0000);
     2030        aimbs_put16(&fr->data, 0x0000);
     2031
     2032        /*
     2033         * Type 1 (should be 0x0001 for mtn)
     2034         */
     2035        aimbs_put16(&fr->data, type1);
     2036
     2037        /*
     2038         * Dest sn
     2039         */
     2040        aimbs_put8(&fr->data, strlen(sn));
     2041        aimbs_putraw(&fr->data, sn, strlen(sn));
     2042
     2043        /*
     2044         * Type 2 (should be 0x0000, 0x0001, or 0x0002 for mtn)
     2045         */
     2046        aimbs_put16(&fr->data, type2);
     2047
     2048        aim_tx_enqueue(sess, fr);
     2049
     2050        return 0;
     2051}
     2052
     2053/*
     2054 * Subtype 0x0014 - Receive a mini typing notification (mtn) packet.
     2055 *
     2056 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer,
     2057 * and Gaim 0.60 and newer.
     2058 *
     2059 */
     2060static int mtn_receive(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
     2061{
     2062        int ret = 0;
     2063        aim_rxcallback_t userfunc;
     2064        char *sn;
     2065        guint8 snlen;
     2066        guint16 type1, type2;
     2067
     2068        aim_bstream_advance(bs, 8); /* Unknown - All 0's */
     2069        type1 = aimbs_get16(bs);
     2070        snlen = aimbs_get8(bs);
     2071        sn = aimbs_getstr(bs, snlen);
     2072        type2 = aimbs_get16(bs);
     2073
     2074        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     2075                ret = userfunc(sess, rx, type1, sn, type2);
     2076
     2077        g_free(sn);
     2078
     2079        return ret;
     2080}
     2081
    19982082static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
    19992083{
     
    20112095        else if (snac->subtype == 0x000c)
    20122096                return msgack(sess, mod, rx, snac, bs);
     2097        else if (snac->subtype == 0x0014)
     2098                return mtn_receive(sess, mod, rx, snac, bs);
    20132099
    20142100        return 0;
  • protocols/oscar/im.h

    r0b2e843 r3e1de87  
    1414#define AIM_CB_MSG_CLIENTAUTORESP 0x000b
    1515#define AIM_CB_MSG_ACK 0x000c
     16#define AIM_CB_MSG_MTN 0x0014
    1617#define AIM_CB_MSG_DEFAULT 0xffff
    1718
     
    194195
    195196int aim_send_im_ch2_geticqmessage(aim_session_t *sess, const char *sn, int type);
     197int aim_im_sendmtn(aim_session_t *sess, guint16 type1, const char *sn, guint16 type2);
    196198int aim_send_im_ch2_statusmessage(aim_session_t *sess, const char *sender, const guint8 *cookie, const char *message, const guint8 state, const guint16 dc);
    197199
  • protocols/oscar/oscar.c

    r0b2e843 r3e1de87  
    221221static int gaim_ssi_parselist    (aim_session_t *, aim_frame_t *, ...);
    222222static int gaim_ssi_parseack     (aim_session_t *, aim_frame_t *, ...);
    223 
     223static int gaim_parsemtn         (aim_session_t *, aim_frame_t *, ...);
    224224static int gaim_icqinfo          (aim_session_t *, aim_frame_t *, ...);
    225225static int gaim_parseaiminfo     (aim_session_t *, aim_frame_t *, ...);
     
    558558        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0);
    559559        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parseaiminfo, 0);
     560        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0);
    560561
    561562        ((struct oscar_data *)gc->proto_data)->conn = bosconn;
     
    16781679
    16791680        /* Maybe senderwarn and recverwarn should be user preferences... */
     1681        params->flags = 0x0000000b;
    16801682        params->maxmsglen = 8000;
    16811683        params->minmsginterval = 0;
     
    24352437}
    24362438
     2439int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...)
     2440{
     2441        struct gaim_connection * gc = sess->aux_data;
     2442        va_list ap;
     2443        guint16 type1, type2;
     2444        char * sn;
     2445
     2446        va_start(ap, fr);
     2447        type1 = va_arg(ap, int);
     2448        sn = va_arg(ap, char*);
     2449        type2 = va_arg(ap, int);
     2450        va_end(ap);
     2451
     2452        if(type2 == 0x0001 || type2 == 0x0002)
     2453                serv_got_typing(gc, sn, 0);
     2454
     2455        return 1;
     2456}
     2457
    24372458static char *oscar_get_status_string( struct gaim_connection *gc, int number )
    24382459{
     
    24612482                return( "Away" );
    24622483        }
     2484}
     2485
     2486int oscar_send_typing(struct gaim_connection *gc, char * who, int typing)
     2487{
     2488        struct oscar_data *od = gc->proto_data;
     2489        return( aim_im_sendmtn(od->sess, 1, who, typing ? 0x0002 : 0x0000) );
    24632490}
    24642491
     
    24852512        ret->get_status_string = oscar_get_status_string;
    24862513
     2514        ret->send_typing = oscar_send_typing;
     2515
    24872516        my_protocol = ret;
    24882517}
Note: See TracChangeset for help on using the changeset viewer.