comparison src/protocols/jabber/jabber.c @ 5393:ec16a766cdc6

[gaim-migrate @ 5769] remove JEP-0008 avatar support. That JEP has been retracted, in favor of something new, which I probably won't get to implement before 0.63, and I don't want this "support" floating around out there in a release. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 16 May 2003 03:59:46 +0000
parents a6f37a893b49
children 8d8bf0d31a23
comparison
equal deleted inserted replaced
5392:93661ac6224f 5393:ec16a766cdc6
1455 gaim_debug(GAIM_DEBUG_WARNING, "jabber", 1455 gaim_debug(GAIM_DEBUG_WARNING, "jabber",
1456 "unhandled message %s\n", type); 1456 "unhandled message %s\n", type);
1457 } 1457 }
1458 } 1458 }
1459 1459
1460 static void jabber_handleavatar(gjconn gjc, xmlnode querynode, char *from) {
1461 char *buddy;
1462 char *encoded;
1463 char *icon;
1464 int iconlen;
1465 xmlnode data;
1466
1467 if((buddy = get_realwho(gjc, from, FALSE, NULL)) == NULL)
1468 return;
1469
1470 if(!jabber_is_default_resource(GJ_GC(gjc), buddy)) {
1471 g_free(buddy);
1472 return;
1473 }
1474
1475 data = xmlnode_get_tag(querynode, "data");
1476
1477 if(!data) {
1478 g_free(buddy);
1479 return;
1480 }
1481
1482 encoded = xmlnode_get_data(data);
1483
1484 if(!encoded) {
1485 g_free(buddy);
1486 return;
1487 }
1488
1489 frombase64(encoded, &icon, &iconlen);
1490 set_icon_data(GJ_GC(gjc), buddy, icon, iconlen);
1491 g_free(icon);
1492 g_free(buddy);
1493 }
1494
1495 static void jabber_request_buddy_avatar(struct gaim_connection *gc, char *who) {
1496 xmlnode x;
1497 char *id;
1498 char *realwho;
1499 struct jabber_data *jd = gc->proto_data;
1500 gjconn gjc = jd->gjc;
1501
1502 if((realwho = get_realwho(gjc, who, TRUE, NULL)) == NULL)
1503 return;
1504
1505 x = jutil_iqnew(JPACKET__GET, "jabber:iq:avatar");
1506 xmlnode_put_attrib(x, "to", realwho);
1507
1508 g_free(realwho);
1509
1510 id = gjab_getid(gjc);
1511 xmlnode_put_attrib(x, "id", id);
1512
1513 gjab_send(gjc, x);
1514
1515 xmlnode_free(x);
1516 }
1517
1518 static void jabber_handlepresence(gjconn gjc, jpacket p) 1460 static void jabber_handlepresence(gjconn gjc, jpacket p)
1519 { 1461 {
1520 char *to, *from, *type; 1462 char *to, *from, *type;
1521 struct buddy *b = NULL; 1463 struct buddy *b = NULL;
1522 gaim_jid gjid; 1464 gaim_jid gjid;
1601 else { 1543 else {
1602 jabber_track_resource(GJ_GC(gjc), buddy, gjid->resource, priority, state); 1544 jabber_track_resource(GJ_GC(gjc), buddy, gjid->resource, priority, state);
1603 1545
1604 /* keep track of away msg somewhat the same as the yahoo plugin */ 1546 /* keep track of away msg somewhat the same as the yahoo plugin */
1605 jabber_track_away(gjc, p, type); 1547 jabber_track_away(gjc, p, type);
1606 }
1607
1608 for(y = xmlnode_get_firstchild(p->x); y; y = xmlnode_get_nextsibling(y)) {
1609 char *tagname = xmlnode_get_name(y);
1610 if(!tagname) {
1611 continue;
1612 } else if(!strcmp(tagname, "x")) {
1613 if(!strcmp(xmlnode_get_attrib(y, "xmlns"), "jabber:x:avatar")) {
1614 xmlnode hash = xmlnode_get_tag(y, "hash");
1615 if(!jabber_is_default_resource(GJ_GC(gjc), from))
1616 continue;
1617 if(hash) {
1618 char *old_hash = gaim_buddy_get_setting(b, "icon_checksum");
1619 char *new_hash = xmlnode_get_data(hash);
1620 if(!old_hash || strcmp(old_hash, new_hash)) {
1621 jabber_request_buddy_avatar(GJ_GC(gjc), from);
1622 gaim_buddy_set_setting(b, "icon_checksum", new_hash);
1623 gaim_blist_save();
1624 }
1625 } else {
1626 gaim_buddy_set_setting(b, "icon_checksum", NULL);
1627 gaim_blist_save();
1628 }
1629 }
1630 }
1631 } 1548 }
1632 1549
1633 if (!cnv) { 1550 if (!cnv) {
1634 /* this is where we handle presence information for "regular" buddies */ 1551 /* this is where we handle presence information for "regular" buddies */
1635 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), buddy); 1552 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), buddy);
2312 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */ 2229 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */
2313 jabber_handlevcard(gjc, querynode, from); 2230 jabber_handlevcard(gjc, querynode, from);
2314 } else if (vcard) { 2231 } else if (vcard) {
2315 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */ 2232 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */
2316 jabber_handlevcard(gjc, vcard, from); 2233 jabber_handlevcard(gjc, vcard, from);
2317 } else if(NSCHECK(querynode, "jabber:iq:avatar")) {
2318 jabber_handleavatar(gjc, querynode, from);
2319 } else if((xmlns = xmlnode_get_attrib(querynode, "xmlns")) != NULL) { 2234 } else if((xmlns = xmlnode_get_attrib(querynode, "xmlns")) != NULL) {
2320 gaim_debug(GAIM_DEBUG_MISC, "jabber", 2235 gaim_debug(GAIM_DEBUG_MISC, "jabber",
2321 "jabber:iq:query: %s\n", xmlns); 2236 "jabber:iq:query: %s\n", xmlns);
2322 } else { 2237 } else {
2323 char *val; 2238 char *val;