~prateek.karandikar/ubuntu/precise/pidgin/add_quicklist

« back to all changes in this revision

Viewing changes to libpurple/protocols/oscar/family_locate.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-11-05 19:44:21 UTC
  • mfrom: (62.1.1 maverick-security) (2.3.12 sid)
  • Revision ID: james.westby@ubuntu.com-20101105194421-8r8o4pzw2m5j4hiy
Tags: 1:2.7.5-1ubuntu1
Resync on Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
246
246
          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
247
247
 
 
248
        {OSCAR_CAPABILITY_HTML_MSGS,
 
249
         {0x01, 0x38, 0xca, 0x7b, 0x76, 0x9a, 0x49, 0x15,
 
250
          0x88, 0xf2, 0x13, 0xfc, 0x00, 0x97, 0x9e, 0xa8}},
 
251
 
248
252
        {OSCAR_CAPABILITY_LAST,
249
253
         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250
254
          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
583
587
        guint64 flags = 0;
584
588
        int offset;
585
589
 
586
 
        for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x10) {
 
590
        for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x10) {
587
591
                guint8 *cap;
588
592
                int i, identified;
589
593
 
617
621
        int offset;
618
622
        const char *result = NULL;
619
623
 
620
 
        for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x10) {
 
624
        for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x10) {
621
625
                /* check wheather this capability is a custom user icon */
622
626
                guint8 *cap;
623
627
                int i;
643
647
        guint64 flags = 0;
644
648
        int offset;
645
649
 
646
 
        for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x02) {
 
650
        for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x02) {
647
651
                guint8 *cap;
648
652
                int i, identified;
649
653
 
674
678
        if (!bs)
675
679
                return -EINVAL;
676
680
 
677
 
        for (i = 0; byte_stream_empty(bs); i++) {
678
 
 
 
681
        for (i = 0; byte_stream_bytes_left(bs); i++) {
679
682
                if (aim_caps[i].flag == OSCAR_CAPABILITY_LAST)
680
683
                        break;
681
684
 
682
685
                if (caps & aim_caps[i].flag)
683
686
                        byte_stream_putraw(bs, aim_caps[i].data, 0x10);
684
 
 
685
687
        }
686
 
 
687
688
        return 0;
688
689
}
689
690
 
804
805
                type = byte_stream_get16(bs);
805
806
                length = byte_stream_get16(bs);
806
807
                curpos = byte_stream_curpos(bs);
807
 
                endpos = curpos + MIN(length, byte_stream_empty(bs));
 
808
                endpos = curpos + MIN(length, byte_stream_bytes_left(bs));
808
809
 
809
810
                if (type == 0x0001) {
810
811
                        /*
1010
1011
                                number2 = byte_stream_get8(bs);
1011
1012
                                length2 = byte_stream_get8(bs);
1012
1013
 
1013
 
                                endpos2 = byte_stream_curpos(bs) + MIN(length2, byte_stream_empty(bs));
 
1014
                                endpos2 = byte_stream_curpos(bs) + MIN(length2, byte_stream_bytes_left(bs));
1014
1015
 
1015
1016
                                switch (type2) {
1016
1017
                                        case 0x0000: { /* This is an official buddy icon? */
1165
1166
        return 0;
1166
1167
}
1167
1168
 
1168
 
/* Apparently, this is never called.
1169
 
 * If you activate it, figure out a way to know what mood to pass to
1170
 
 * aim_tlvlist_add_caps() below. --rlaager */
1171
 
#if 0
1172
 
/*
1173
 
 * Inverse of aim_info_extract()
1174
 
 */
1175
 
int
1176
 
aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info)
1177
 
{
1178
 
        GSList *tlvlist = NULL;
1179
 
 
1180
 
        if (!bs || !info)
1181
 
                return -EINVAL;
1182
 
 
1183
 
        byte_stream_put8(bs, strlen(info->bn));
1184
 
        byte_stream_putstr(bs, info->bn);
1185
 
 
1186
 
        byte_stream_put16(bs, info->warnlevel);
1187
 
 
1188
 
        if (info->present & AIM_USERINFO_PRESENT_FLAGS)
1189
 
                aim_tlvlist_add_16(&tlvlist, 0x0001, info->flags);
1190
 
        if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE)
1191
 
                aim_tlvlist_add_32(&tlvlist, 0x0002, info->membersince);
1192
 
        if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE)
1193
 
                aim_tlvlist_add_32(&tlvlist, 0x0003, info->onlinesince);
1194
 
        if (info->present & AIM_USERINFO_PRESENT_IDLE)
1195
 
                aim_tlvlist_add_16(&tlvlist, 0x0004, info->idletime);
1196
 
 
1197
 
/* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */
1198
 
#ifdef ICQ_OSCAR_SUPPORT
1199
 
        if (atoi(info->bn) != 0) {
1200
 
                if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS)
1201
 
                        aim_tlvlist_add_16(&tlvlist, 0x0006, info->icqinfo.status);
1202
 
                if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR)
1203
 
                        aim_tlvlist_add_32(&tlvlist, 0x000a, info->icqinfo.ipaddr);
1204
 
        }
1205
 
#endif
1206
 
 
1207
 
        if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) {
1208
 
                aim_tlvlist_add_caps(&tlvlist, 0x000d, info->capabilities, NULL);
1209
 
        }
1210
 
 
1211
 
        if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
1212
 
                aim_tlvlist_add_32(&tlvlist, (guint16)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen);
1213
 
 
1214
 
        byte_stream_put16(bs, aim_tlvlist_count(tlvlist));
1215
 
        aim_tlvlist_write(bs, &tlvlist);
1216
 
        aim_tlvlist_free(tlvlist);
1217
 
 
1218
 
        return 0;
1219
 
}
1220
 
#endif
1221
 
 
1222
1169
/*
1223
1170
 * Subtype 0x0001
1224
1171
 */
1225
1172
static int
1226
1173
error(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
1227
1174
{
1228
 
        int ret = 0;
1229
 
        aim_rxcallback_t userfunc;
1230
1175
        aim_snac_t *snac2;
1231
1176
        guint16 reason;
1232
1177
        char *bn;
1253
1198
 
1254
1199
        reason = byte_stream_get16(bs);
1255
1200
 
1256
 
        /* Notify the user that we do not have info for this buddy */
1257
 
        if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
1258
 
                ret = userfunc(od, conn, frame, reason, bn);
 
1201
        oscar_user_info_display_error(od, reason, bn);
1259
1202
 
1260
1203
        g_free(snac2->data);
1261
1204
        g_free(snac2);
1262
1205
 
1263
 
        return ret;
 
1206
        return 1;
1264
1207
}
1265
1208
 
1266
1209
/*
1390
1333
        aim_tlvlist_write(&bs, &tlvlist);
1391
1334
        aim_tlvlist_free(tlvlist);
1392
1335
 
1393
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0004, 0x0000, snacid, &bs);
 
1336
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0004, snacid, &bs);
1394
1337
 
1395
1338
        byte_stream_destroy(&bs);
1396
1339
 
1424
1367
        aim_tlvlist_write(&bs, &tlvlist);
1425
1368
        aim_tlvlist_free(tlvlist);
1426
1369
 
1427
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0004, 0x0000, snacid, &bs);
1428
 
 
1429
 
        byte_stream_destroy(&bs);
1430
 
 
1431
 
        return 0;
1432
 
}
1433
 
 
1434
 
/*
1435
 
 * Subtype 0x0005 - Request info of another AIM user.
1436
 
 *
1437
 
 * @param bn The buddy name whose info you wish to request.
1438
 
 * @param infotype The type of info you wish to request.
1439
 
 *        0x0001 - Info/profile
1440
 
 *        0x0003 - Away message
1441
 
 *        0x0004 - Capabilities
1442
 
 */
1443
 
int
1444
 
aim_locate_getinfo(OscarData *od, const char *bn, guint16 infotype)
1445
 
{
1446
 
        FlapConnection *conn;
1447
 
        ByteStream bs;
1448
 
        aim_snacid_t snacid;
1449
 
 
1450
 
        if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !bn)
1451
 
                return -EINVAL;
1452
 
 
1453
 
        byte_stream_new(&bs, 2+1+strlen(bn));
1454
 
 
1455
 
        snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0005, 0x0000, NULL, 0);
1456
 
 
1457
 
        byte_stream_put16(&bs, infotype);
1458
 
        byte_stream_put8(&bs, strlen(bn));
1459
 
        byte_stream_putstr(&bs, bn);
1460
 
 
1461
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0005, 0x0000, snacid, &bs);
 
1370
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0004, snacid, &bs);
1462
1371
 
1463
1372
        byte_stream_destroy(&bs);
1464
1373
 
1470
1379
userinfo(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
1471
1380
{
1472
1381
        int ret = 0;
1473
 
        aim_rxcallback_t userfunc;
1474
1382
        aim_userinfo_t *userinfo, *userinfo2;
1475
1383
        GSList *tlvlist;
1476
1384
        aim_tlv_t *tlv = NULL;
1522
1430
        g_free(userinfo);
1523
1431
 
1524
1432
        /* Show the info to the user */
1525
 
        if (userinfo2 != NULL && ((userfunc = aim_callhandler(od, snac->family, snac->subtype))))
1526
 
                ret = userfunc(od, conn, frame, userinfo2);
 
1433
        oscar_user_info_display_aim(od, userinfo2);
1527
1434
 
1528
1435
        return ret;
1529
1436
}
1530
1437
 
1531
1438
/*
1532
 
 * Subtype 0x0009 - Set directory profile data.
1533
 
 *
1534
 
 * This is not the same as aim_location_setprofile!
1535
 
 * privacy: 1 to allow searching, 0 to disallow.
1536
 
 *
1537
 
 */
1538
 
int aim_locate_setdirinfo(OscarData *od, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy)
1539
 
{
1540
 
        FlapConnection *conn;
1541
 
        ByteStream bs;
1542
 
        aim_snacid_t snacid;
1543
 
        GSList *tlvlist = NULL;
1544
 
 
1545
 
        if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)))
1546
 
                return -EINVAL;
1547
 
 
1548
 
        aim_tlvlist_add_16(&tlvlist, 0x000a, privacy);
1549
 
 
1550
 
        if (first)
1551
 
                aim_tlvlist_add_str(&tlvlist, 0x0001, first);
1552
 
        if (last)
1553
 
                aim_tlvlist_add_str(&tlvlist, 0x0002, last);
1554
 
        if (middle)
1555
 
                aim_tlvlist_add_str(&tlvlist, 0x0003, middle);
1556
 
        if (maiden)
1557
 
                aim_tlvlist_add_str(&tlvlist, 0x0004, maiden);
1558
 
 
1559
 
        if (state)
1560
 
                aim_tlvlist_add_str(&tlvlist, 0x0007, state);
1561
 
        if (city)
1562
 
                aim_tlvlist_add_str(&tlvlist, 0x0008, city);
1563
 
 
1564
 
        if (nickname)
1565
 
                aim_tlvlist_add_str(&tlvlist, 0x000c, nickname);
1566
 
        if (zip)
1567
 
                aim_tlvlist_add_str(&tlvlist, 0x000d, zip);
1568
 
 
1569
 
        if (street)
1570
 
                aim_tlvlist_add_str(&tlvlist, 0x0021, street);
1571
 
 
1572
 
        byte_stream_new(&bs, aim_tlvlist_size(tlvlist));
1573
 
 
1574
 
        snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0009, 0x0000, NULL, 0);
1575
 
 
1576
 
        aim_tlvlist_write(&bs, &tlvlist);
1577
 
        aim_tlvlist_free(tlvlist);
1578
 
 
1579
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x0009, 0x0000, snacid, &bs);
1580
 
 
1581
 
        byte_stream_destroy(&bs);
1582
 
 
1583
 
        return 0;
1584
 
}
1585
 
 
1586
 
/*
1587
 
 * Subtype 0x000b - Huh? What is this?
1588
 
 */
1589
 
int aim_locate_000b(OscarData *od, const char *bn)
1590
 
{
1591
 
        FlapConnection *conn;
1592
 
        ByteStream bs;
1593
 
        aim_snacid_t snacid;
1594
 
 
1595
 
                return -EINVAL;
1596
 
 
1597
 
        if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !bn)
1598
 
                return -EINVAL;
1599
 
 
1600
 
        byte_stream_new(&bs, 1+strlen(bn));
1601
 
 
1602
 
        snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x000b, 0x0000, NULL, 0);
1603
 
 
1604
 
        byte_stream_put8(&bs, strlen(bn));
1605
 
        byte_stream_putstr(&bs, bn);
1606
 
 
1607
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x000b, 0x0000, snacid, &bs);
1608
 
 
1609
 
        byte_stream_destroy(&bs);
1610
 
 
1611
 
        return 0;
1612
 
}
1613
 
 
1614
 
/*
1615
 
 * Subtype 0x000f
1616
 
 *
1617
 
 * XXX pass these in better
1618
 
 *
1619
 
 */
1620
 
int
1621
 
aim_locate_setinterests(OscarData *od, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy)
1622
 
{
1623
 
        FlapConnection *conn;
1624
 
        ByteStream bs;
1625
 
        aim_snacid_t snacid;
1626
 
        GSList *tlvlist = NULL;
1627
 
 
1628
 
        if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)))
1629
 
                return -EINVAL;
1630
 
 
1631
 
        /* ?? privacy ?? */
1632
 
        aim_tlvlist_add_16(&tlvlist, 0x000a, privacy);
1633
 
 
1634
 
        if (interest1)
1635
 
                aim_tlvlist_add_str(&tlvlist, 0x0000b, interest1);
1636
 
        if (interest2)
1637
 
                aim_tlvlist_add_str(&tlvlist, 0x0000b, interest2);
1638
 
        if (interest3)
1639
 
                aim_tlvlist_add_str(&tlvlist, 0x0000b, interest3);
1640
 
        if (interest4)
1641
 
                aim_tlvlist_add_str(&tlvlist, 0x0000b, interest4);
1642
 
        if (interest5)
1643
 
                aim_tlvlist_add_str(&tlvlist, 0x0000b, interest5);
1644
 
 
1645
 
        byte_stream_new(&bs, aim_tlvlist_size(tlvlist));
1646
 
 
1647
 
        snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x000f, 0x0000, NULL, 0);
1648
 
 
1649
 
        aim_tlvlist_write(&bs, &tlvlist);
1650
 
        aim_tlvlist_free(tlvlist);
1651
 
 
1652
 
        flap_connection_send_snac(od, conn, SNAC_FAMILY_LOCATE, 0x000f, 0x0000, snacid, &bs);
1653
 
 
1654
 
        byte_stream_destroy(&bs);
1655
 
        return 0;
1656
 
}
1657
 
 
1658
 
/*
1659
1439
 * Subtype 0x0015 - Request the info of a user using the short method.  This is
1660
1440
 * what iChat uses.  It normally is VERY leniently rate limited.
1661
1441
 *
1683
1463
        byte_stream_putstr(&bs, bn);
1684
1464
 
1685
1465
        snacid = aim_cachesnac(od, SNAC_FAMILY_LOCATE, 0x0015, 0x0000, bn, strlen(bn)+1);
1686
 
        flap_connection_send_snac_with_priority(od, conn, SNAC_FAMILY_LOCATE, 0x0015, 0x0000, snacid, &bs, FALSE);
 
1466
        flap_connection_send_snac_with_priority(od, conn, SNAC_FAMILY_LOCATE, 0x0015, snacid, &bs, FALSE);
1687
1467
 
1688
1468
        byte_stream_destroy(&bs);
1689
1469
 
1731
1511
        return 0;
1732
1512
}
1733
1513
 
1734
 
#if 0 //rlaager
1735
 
const char* aim_get_custom_icon_mood(gint32 no)
1736
 
{
1737
 
        if (no >= G_N_ELEMENTS(aim_custom_icons) || no < 1)
1738
 
                return NULL;
1739
 
        return aim_custom_icons[no].mood.mood;
1740
 
}
1741
 
#endif
1742
 
 
1743
1514
const char*
1744
1515
icq_get_custom_icon_description(const char *mood)
1745
1516
{