comparison libpurple/protocols/jabber/si.c @ 30242:93f6a5d48a46

Updated to use new BoB request functionallity
author Marcus Lundblad <ml@update.uu.se>
date Sun, 21 Mar 2010 20:57:29 +0000
parents 885ceb384678
children f14cbb6a28a7
comparison
equal deleted inserted replaced
30241:d6af24bcf107 30242:93f6a5d48a46
1661 else 1661 else
1662 purple_xfer_request(xfer); 1662 purple_xfer_request(xfer);
1663 } 1663 }
1664 1664
1665 static void 1665 static void
1666 jabber_si_thumbnail_cb(JabberStream *js, const char *from, JabberIqType type, 1666 jabber_si_thumbnail_cb(JabberData *data, gchar *alt, gpointer userdata)
1667 const char *id, xmlnode *packet, gpointer data) 1667 {
1668 { 1668 PurpleXfer *xfer = (PurpleXfer *) userdata;
1669 PurpleXfer *xfer = (PurpleXfer *) data; 1669
1670 xmlnode *data_element = xmlnode_get_child(packet, "data"); 1670 if (data) {
1671 xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found"); 1671 purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
1672 1672 jabber_data_get_size(data), jabber_data_get_type(data));
1673 if (data_element) { 1673 /* data is ephemeral, get rid of now (the xfer re-owned the thumbnail */
1674 JabberData *data = jabber_data_create_from_xml(data_element); 1674 jabber_data_destroy(data);
1675 1675 }
1676 if (data) { 1676
1677 purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
1678 jabber_data_get_size(data), jabber_data_get_type(data));
1679 jabber_data_destroy(data);
1680 }
1681 } else if (item_not_found) {
1682 purple_debug_info("jabber",
1683 "Responder didn't recognize requested data\n");
1684 } else {
1685 purple_debug_error("jabber", "Unknown response to data request\n");
1686 }
1687 purple_xfer_request(xfer); 1677 purple_xfer_request(xfer);
1688 } 1678 }
1689 1679
1690 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type, 1680 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
1691 const char *id, xmlnode *si) 1681 const char *id, xmlnode *si)
1780 /* if there is a thumbnail, we should request it... */ 1770 /* if there is a thumbnail, we should request it... */
1781 if ((thumbnail = xmlnode_get_child_with_namespace(file, "thumbnail", 1771 if ((thumbnail = xmlnode_get_child_with_namespace(file, "thumbnail",
1782 NS_THUMBS))) { 1772 NS_THUMBS))) {
1783 const char *cid = xmlnode_get_attrib(thumbnail, "cid"); 1773 const char *cid = xmlnode_get_attrib(thumbnail, "cid");
1784 if (cid) { 1774 if (cid) {
1785 JabberIq *request = 1775 jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer),
1786 jabber_iq_new(jsx->js, JABBER_IQ_GET); 1776 NULL, TRUE, jabber_si_thumbnail_cb, xfer);
1787
1788 purple_debug_info("jabber", "got file thumbnail, request it\n");
1789 xmlnode_insert_child(request->node,
1790 jabber_data_get_xml_request(cid));
1791 xmlnode_set_attrib(request->node, "to",
1792 purple_xfer_get_remote_user(xfer));
1793 jabber_iq_set_callback(request, jabber_si_thumbnail_cb, xfer);
1794 jabber_iq_send(request);
1795 } else { 1777 } else {
1796 purple_xfer_request(xfer); 1778 purple_xfer_request(xfer);
1797 } 1779 }
1798 } else { 1780 } else {
1799 purple_xfer_request(xfer); 1781 purple_xfer_request(xfer);