Mercurial > pidgin
comparison libpurple/protocols/jabber/buddy.c @ 26465:ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 13 Mar 2009 02:26:45 +0000 |
parents | 439f07ce4c8a |
children | cde07a2e4531 |
comparison
equal
deleted
inserted
replaced
26464:a4a5825fb1bb | 26465:ae41d8e827e3 |
---|---|
1185 } | 1185 } |
1186 l = l->next; | 1186 l = l->next; |
1187 } | 1187 } |
1188 } | 1188 } |
1189 | 1189 |
1190 static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data) | 1190 static void jabber_vcard_save_mine(JabberStream *js, const char *from, |
1191 JabberIqType type, const char *id, | |
1192 xmlnode *packet, gpointer data) | |
1191 { | 1193 { |
1192 xmlnode *vcard; | 1194 xmlnode *vcard; |
1193 char *txt; | 1195 char *txt; |
1194 PurpleStoredImage *img; | 1196 PurpleStoredImage *img; |
1197 | |
1198 if (type == JABBER_IQ_ERROR) { | |
1199 purple_debug_warning("jabber", "Server returned error while retrieving vCard"); | |
1200 return; | |
1201 } | |
1195 | 1202 |
1196 if((vcard = xmlnode_get_child(packet, "vCard")) || | 1203 if((vcard = xmlnode_get_child(packet, "vCard")) || |
1197 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) | 1204 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) |
1198 { | 1205 { |
1199 txt = xmlnode_to_str(vcard, NULL); | 1206 txt = xmlnode_to_str(vcard, NULL); |
1221 jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL); | 1228 jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL); |
1222 | 1229 |
1223 jabber_iq_send(iq); | 1230 jabber_iq_send(iq); |
1224 } | 1231 } |
1225 | 1232 |
1226 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) | 1233 static void jabber_vcard_parse(JabberStream *js, const char *from, |
1227 { | 1234 JabberIqType type, const char *id, |
1228 const char *id, *from; | 1235 xmlnode *packet, gpointer data) |
1236 { | |
1229 char *bare_jid; | 1237 char *bare_jid; |
1230 char *text; | 1238 char *text; |
1231 char *serverside_alias = NULL; | 1239 char *serverside_alias = NULL; |
1232 xmlnode *vcard; | 1240 xmlnode *vcard; |
1233 PurpleBuddy *b; | 1241 PurpleBuddy *b; |
1234 JabberBuddyInfo *jbi = data; | 1242 JabberBuddyInfo *jbi = data; |
1235 PurpleNotifyUserInfo *user_info; | 1243 PurpleNotifyUserInfo *user_info; |
1236 | |
1237 from = xmlnode_get_attrib(packet, "from"); | |
1238 id = xmlnode_get_attrib(packet, "id"); | |
1239 | 1244 |
1240 if(!jbi) | 1245 if(!jbi) |
1241 return; | 1246 return; |
1242 | 1247 |
1243 jabber_buddy_info_remove_id(jbi, id); | 1248 jabber_buddy_info_remove_id(jbi, id); |
1584 { | 1589 { |
1585 JabberBuddyInfoResource *jbri = data; | 1590 JabberBuddyInfoResource *jbri = data; |
1586 g_free(jbri); | 1591 g_free(jbri); |
1587 } | 1592 } |
1588 | 1593 |
1589 static void jabber_version_parse(JabberStream *js, xmlnode *packet, gpointer data) | 1594 static void jabber_version_parse(JabberStream *js, const char *from, |
1595 JabberIqType type, const char *id, | |
1596 xmlnode *packet, gpointer data) | |
1590 { | 1597 { |
1591 JabberBuddyInfo *jbi = data; | 1598 JabberBuddyInfo *jbi = data; |
1592 const char *type, *id, *from; | |
1593 xmlnode *query; | 1599 xmlnode *query; |
1594 char *resource_name; | 1600 char *resource_name; |
1595 | 1601 |
1596 g_return_if_fail(jbi != NULL); | 1602 g_return_if_fail(jbi != NULL); |
1597 | 1603 |
1598 type = xmlnode_get_attrib(packet, "type"); | |
1599 id = xmlnode_get_attrib(packet, "id"); | |
1600 from = xmlnode_get_attrib(packet, "from"); | |
1601 | |
1602 jabber_buddy_info_remove_id(jbi, id); | 1604 jabber_buddy_info_remove_id(jbi, id); |
1603 | 1605 |
1604 if(!from) | 1606 if(!from) |
1605 return; | 1607 return; |
1606 | 1608 |
1607 resource_name = jabber_get_resource(from); | 1609 resource_name = jabber_get_resource(from); |
1608 | 1610 |
1609 if(resource_name) { | 1611 if(resource_name) { |
1610 if(type && !strcmp(type, "result")) { | 1612 if (type == JABBER_IQ_RESULT) { |
1611 if((query = xmlnode_get_child(packet, "query"))) { | 1613 if((query = xmlnode_get_child(packet, "query"))) { |
1612 JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name); | 1614 JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name); |
1613 if(jbr) { | 1615 if(jbr) { |
1614 xmlnode *node; | 1616 xmlnode *node; |
1615 if((node = xmlnode_get_child(query, "name"))) { | 1617 if((node = xmlnode_get_child(query, "name"))) { |
1628 } | 1630 } |
1629 | 1631 |
1630 jabber_buddy_info_show_if_ready(jbi); | 1632 jabber_buddy_info_show_if_ready(jbi); |
1631 } | 1633 } |
1632 | 1634 |
1633 static void jabber_last_parse(JabberStream *js, xmlnode *packet, gpointer data) | 1635 static void jabber_last_parse(JabberStream *js, const char *from, |
1636 JabberIqType type, const char *id, | |
1637 xmlnode *packet, gpointer data) | |
1634 { | 1638 { |
1635 JabberBuddyInfo *jbi = data; | 1639 JabberBuddyInfo *jbi = data; |
1636 xmlnode *query; | 1640 xmlnode *query; |
1637 char *resource_name; | 1641 char *resource_name; |
1638 const char *type, *id, *from, *seconds; | 1642 const char *seconds; |
1639 | 1643 |
1640 g_return_if_fail(jbi != NULL); | 1644 g_return_if_fail(jbi != NULL); |
1641 | 1645 |
1642 type = xmlnode_get_attrib(packet, "type"); | |
1643 id = xmlnode_get_attrib(packet, "id"); | |
1644 from = xmlnode_get_attrib(packet, "from"); | |
1645 | |
1646 jabber_buddy_info_remove_id(jbi, id); | 1646 jabber_buddy_info_remove_id(jbi, id); |
1647 | 1647 |
1648 if(!from) | 1648 if(!from) |
1649 return; | 1649 return; |
1650 | 1650 |
1651 resource_name = jabber_get_resource(from); | 1651 resource_name = jabber_get_resource(from); |
1652 | 1652 |
1653 if(resource_name) { | 1653 if(resource_name) { |
1654 if(type && !strcmp(type, "result")) { | 1654 if (type == JABBER_IQ_RESULT) { |
1655 if((query = xmlnode_get_child(packet, "query"))) { | 1655 if((query = xmlnode_get_child(packet, "query"))) { |
1656 seconds = xmlnode_get_attrib(query, "seconds"); | 1656 seconds = xmlnode_get_attrib(query, "seconds"); |
1657 if(seconds) { | 1657 if(seconds) { |
1658 char *end = NULL; | 1658 char *end = NULL; |
1659 long sec = strtol(seconds, &end, 10); | 1659 long sec = strtol(seconds, &end, 10); |
1670 } | 1670 } |
1671 | 1671 |
1672 jabber_buddy_info_show_if_ready(jbi); | 1672 jabber_buddy_info_show_if_ready(jbi); |
1673 } | 1673 } |
1674 | 1674 |
1675 static void jabber_time_parse(JabberStream *js, xmlnode *packet, gpointer data) | 1675 static void jabber_time_parse(JabberStream *js, const char *from, |
1676 JabberIqType type, const char *id, | |
1677 xmlnode *packet, gpointer data) | |
1676 { | 1678 { |
1677 JabberBuddyInfo *jbi = data; | 1679 JabberBuddyInfo *jbi = data; |
1678 JabberBuddyResource *jbr; | 1680 JabberBuddyResource *jbr; |
1679 char *resource_name; | 1681 char *resource_name; |
1680 const char *type, *id, *from; | |
1681 | 1682 |
1682 g_return_if_fail(jbi != NULL); | 1683 g_return_if_fail(jbi != NULL); |
1683 | |
1684 id = xmlnode_get_attrib(packet, "id"); | |
1685 type = xmlnode_get_attrib(packet, "type"); | |
1686 from = xmlnode_get_attrib(packet, "from"); | |
1687 | 1684 |
1688 jabber_buddy_info_remove_id(jbi, id); | 1685 jabber_buddy_info_remove_id(jbi, id); |
1689 | 1686 |
1690 if (!from) | 1687 if (!from) |
1691 return; | 1688 return; |
1692 | 1689 |
1693 resource_name = jabber_get_resource(from); | 1690 resource_name = jabber_get_resource(from); |
1694 jbr = resource_name ? jabber_buddy_find_resource(jbi->jb, resource_name) : NULL; | 1691 jbr = resource_name ? jabber_buddy_find_resource(jbi->jb, resource_name) : NULL; |
1695 g_free(resource_name); | 1692 g_free(resource_name); |
1696 if (jbr) { | 1693 if (jbr) { |
1697 if (type && !strcmp(type, "result")) { | 1694 if (type == JABBER_IQ_RESULT) { |
1698 xmlnode *time = xmlnode_get_child(packet, "time"); | 1695 xmlnode *time = xmlnode_get_child(packet, "time"); |
1699 xmlnode *tzo = time ? xmlnode_get_child(time, "tzo") : NULL; | 1696 xmlnode *tzo = time ? xmlnode_get_child(time, "tzo") : NULL; |
1700 char *tzo_data = tzo ? xmlnode_get_data(tzo) : NULL; | 1697 char *tzo_data = tzo ? xmlnode_get_data(tzo) : NULL; |
1701 if (tzo_data) { | 1698 if (tzo_data) { |
1702 char *c = tzo_data; | 1699 char *c = tzo_data; |
2263 /* XXX find out the jid */ | 2260 /* XXX find out the jid */ |
2264 purple_blist_request_add_buddy(purple_connection_get_account(gc), | 2261 purple_blist_request_add_buddy(purple_connection_get_account(gc), |
2265 g_list_nth_data(row, 0), NULL, NULL); | 2262 g_list_nth_data(row, 0), NULL, NULL); |
2266 } | 2263 } |
2267 | 2264 |
2268 static void user_search_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | 2265 static void user_search_result_cb(JabberStream *js, const char *from, |
2266 JabberIqType type, const char *id, | |
2267 xmlnode *packet, gpointer data) | |
2269 { | 2268 { |
2270 PurpleNotifySearchResults *results; | 2269 PurpleNotifySearchResults *results; |
2271 PurpleNotifySearchColumn *column; | 2270 PurpleNotifySearchColumn *column; |
2272 xmlnode *x, *query, *item, *field; | 2271 xmlnode *x, *query, *item, *field; |
2273 | 2272 |
2459 "Note: Each field supports wild card searches (%)"), | 2458 "Note: Each field supports wild card searches (%)"), |
2460 NULL | 2459 NULL |
2461 }; | 2460 }; |
2462 #endif | 2461 #endif |
2463 | 2462 |
2464 static void user_search_fields_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | 2463 static void user_search_fields_result_cb(JabberStream *js, const char *from, |
2464 JabberIqType type, const char *id, | |
2465 xmlnode *packet, gpointer data) | |
2465 { | 2466 { |
2466 xmlnode *query, *x; | 2467 xmlnode *query, *x; |
2467 const char *from, *type; | 2468 |
2468 | 2469 if (!from) |
2469 if(!(from = xmlnode_get_attrib(packet, "from"))) | 2470 return; |
2470 return; | 2471 |
2471 | 2472 if (type == JABBER_IQ_ERROR) { |
2472 if(!(type = xmlnode_get_attrib(packet, "type")) || !strcmp(type, "error")) { | |
2473 char *msg = jabber_parse_error(js, packet, NULL); | 2473 char *msg = jabber_parse_error(js, packet, NULL); |
2474 | 2474 |
2475 if(!msg) | 2475 if(!msg) |
2476 msg = g_strdup(_("Unknown error")); | 2476 msg = g_strdup(_("Unknown error")); |
2477 | 2477 |