comparison libpurple/protocols/jabber/si.c @ 29788:259a331e4de7

Actually request the thumbnail when getting one in an offer.
author Marcus Lundblad <ml@update.uu.se>
date Wed, 01 Jul 2009 17:31:47 +0000
parents 7d8b074feda2
children 8781cfb550bb
comparison
equal deleted inserted replaced
29787:7d8b074feda2 29788:259a331e4de7
1621 purple_xfer_request_accepted(xfer, file); 1621 purple_xfer_request_accepted(xfer, file);
1622 else 1622 else
1623 purple_xfer_request(xfer); 1623 purple_xfer_request(xfer);
1624 } 1624 }
1625 1625
1626 static void
1627 jabber_si_thumbnail_cb(JabberStream *js, const char *from, JabberIqType type,
1628 const char *id, xmlnode *packet, gpointer data)
1629 {
1630 PurpleXfer *xfer = (PurpleXfer *) data;
1631 xmlnode *data_element = xmlnode_get_child(packet, "data");
1632 xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found");
1633
1634 if (data_element) {
1635 JabberData *data = jabber_data_create_from_xml(data_element);
1636
1637 if (data) {
1638 purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
1639 jabber_data_get_size(data));
1640 jabber_data_destroy(data);
1641 }
1642 } else if (item_not_found) {
1643 purple_debug_info("jabber",
1644 "Responder didn't recognize requested data\n");
1645 } else {
1646 purple_debug_error("jabber", "Unknown response to data request\n");
1647 }
1648 purple_xfer_request(xfer);
1649 }
1650
1626 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type, 1651 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
1627 const char *id, xmlnode *si) 1652 const char *id, xmlnode *si)
1628 { 1653 {
1629 JabberSIXfer *jsx; 1654 JabberSIXfer *jsx;
1630 PurpleXfer *xfer; 1655 PurpleXfer *xfer;
1631 xmlnode *file, *feature, *x, *field, *option, *value; 1656 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail;
1632 const char *stream_id, *filename, *filesize_c, *profile; 1657 const char *stream_id, *filename, *filesize_c, *profile;
1633 size_t filesize = 0; 1658 size_t filesize = 0;
1634 1659
1635 if(!(profile = xmlnode_get_attrib(si, "profile")) || 1660 if(!(profile = xmlnode_get_attrib(si, "profile")) ||
1636 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer")) 1661 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer"))
1708 1733
1709 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init); 1734 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
1710 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied); 1735 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
1711 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv); 1736 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
1712 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end); 1737 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
1713 1738
1714 js->file_transfers = g_list_append(js->file_transfers, xfer); 1739 js->file_transfers = g_list_append(js->file_transfers, xfer);
1715 1740
1716 purple_xfer_request(xfer); 1741 /* if there is a thumbnail, we should request it... */
1742 if ((thumbnail = xmlnode_get_child(file, "thumbnail"))) {
1743 const char *cid = xmlnode_get_attrib(thumbnail, "cid");
1744 if (cid) {
1745 JabberIq *request =
1746 jabber_iq_new(jsx->js, JABBER_IQ_GET);
1747
1748 purple_debug_info("jabber", "got file thumbnail, request it\n");
1749 xmlnode_insert_child(request->node,
1750 jabber_data_get_xml_request(cid));
1751 xmlnode_set_attrib(request->node, "to",
1752 purple_xfer_get_remote_user(xfer));
1753 jabber_iq_set_callback(request, jabber_si_thumbnail_cb, xfer);
1754 jabber_iq_send(request);
1755 } else {
1756 purple_xfer_request(xfer);
1757 }
1758 } else {
1759 purple_xfer_request(xfer);
1760 }
1717 } 1761 }
1718 1762
1719 void 1763 void
1720 jabber_si_init(void) 1764 jabber_si_init(void)
1721 { 1765 {