Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/family_feedbag.c @ 22700:979a81468e19
All SNACs on FLAP channel 2 except in the auth family are now sent through
flap_connection_send_snac() instead of flap_connection_send(). This allows
them to be tallied into the rate limiting calculations and to be throttled
as necessary to prevent rate limiting violations.
This does fix the instantaneous disconnection seen with the addition of ICQ
Status Notes support for people with many ICQ contacts with status notes on
their buddy list. Unfortunately, we still request the ICQ Status Note many
times per contact, so such people now may be rate limited for a
significant period of time as they connect.
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Thu, 24 Apr 2008 11:10:03 +0000 |
parents | 477b020d5945 |
children | 10ab0aed3e80 |
comparison
equal
deleted
inserted
replaced
22698:80c87908ff1d | 22700:979a81468e19 |
---|---|
1239 * | 1239 * |
1240 */ | 1240 */ |
1241 int aim_ssi_reqifchanged(OscarData *od, time_t timestamp, guint16 numitems) | 1241 int aim_ssi_reqifchanged(OscarData *od, time_t timestamp, guint16 numitems) |
1242 { | 1242 { |
1243 FlapConnection *conn; | 1243 FlapConnection *conn; |
1244 FlapFrame *frame; | 1244 ByteStream bs; |
1245 aim_snacid_t snacid; | 1245 aim_snacid_t snacid; |
1246 | 1246 |
1247 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG))) | 1247 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG))) |
1248 return -EINVAL; | 1248 return -EINVAL; |
1249 | 1249 |
1250 frame = flap_frame_new(od, 0x02, 10+4+2); | 1250 byte_stream_new(&bs, 4+2); |
1251 | |
1252 byte_stream_put32(&bs, timestamp); | |
1253 byte_stream_put16(&bs, numitems); | |
1251 | 1254 |
1252 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, NULL, 0); | 1255 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, NULL, 0); |
1253 | 1256 flap_connection_send_snac(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, snacid, &bs); |
1254 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, snacid); | 1257 |
1255 byte_stream_put32(&frame->data, timestamp); | 1258 byte_stream_destroy(&bs); |
1256 byte_stream_put16(&frame->data, numitems); | |
1257 | |
1258 flap_connection_send(conn, frame); | |
1259 | 1259 |
1260 /* Free any current data, just in case */ | 1260 /* Free any current data, just in case */ |
1261 aim_ssi_freelist(od); | 1261 aim_ssi_freelist(od); |
1262 | 1262 |
1263 return 0; | 1263 return 0; |
1341 * | 1341 * |
1342 */ | 1342 */ |
1343 static int aim_ssi_addmoddel(OscarData *od) | 1343 static int aim_ssi_addmoddel(OscarData *od) |
1344 { | 1344 { |
1345 FlapConnection *conn; | 1345 FlapConnection *conn; |
1346 FlapFrame *frame; | 1346 ByteStream bs; |
1347 aim_snacid_t snacid; | 1347 aim_snacid_t snacid; |
1348 int snaclen; | 1348 int bslen; |
1349 struct aim_ssi_tmp *cur; | 1349 struct aim_ssi_tmp *cur; |
1350 | 1350 |
1351 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !od->ssi.pending || !od->ssi.pending->item) | 1351 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !od->ssi.pending || !od->ssi.pending->item) |
1352 return -EINVAL; | 1352 return -EINVAL; |
1353 | 1353 |
1354 /* Calculate total SNAC size */ | 1354 /* Calculate total SNAC size */ |
1355 snaclen = 10; /* For family, subtype, flags, and SNAC ID */ | 1355 bslen = 0; |
1356 for (cur=od->ssi.pending; cur; cur=cur->next) { | 1356 for (cur=od->ssi.pending; cur; cur=cur->next) { |
1357 snaclen += 10; /* For length, GID, BID, type, and length */ | 1357 bslen += 10; /* For length, GID, BID, type, and length */ |
1358 if (cur->item->name) | 1358 if (cur->item->name) |
1359 snaclen += strlen(cur->item->name); | 1359 bslen += strlen(cur->item->name); |
1360 if (cur->item->data) | 1360 if (cur->item->data) |
1361 snaclen += aim_tlvlist_size(cur->item->data); | 1361 bslen += aim_tlvlist_size(cur->item->data); |
1362 } | 1362 } |
1363 | 1363 |
1364 frame = flap_frame_new(od, 0x02, snaclen); | 1364 byte_stream_new(&bs, bslen); |
1365 | |
1366 aim_putsnac(&bs, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, snacid); | |
1367 | |
1368 for (cur=od->ssi.pending; cur; cur=cur->next) { | |
1369 byte_stream_put16(&bs, cur->item->name ? strlen(cur->item->name) : 0); | |
1370 if (cur->item->name) | |
1371 byte_stream_putstr(&bs, cur->item->name); | |
1372 byte_stream_put16(&bs, cur->item->gid); | |
1373 byte_stream_put16(&bs, cur->item->bid); | |
1374 byte_stream_put16(&bs, cur->item->type); | |
1375 byte_stream_put16(&bs, cur->item->data ? aim_tlvlist_size(cur->item->data) : 0); | |
1376 if (cur->item->data) | |
1377 aim_tlvlist_write(&bs, &cur->item->data); | |
1378 } | |
1365 | 1379 |
1366 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, NULL, 0); | 1380 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, NULL, 0); |
1367 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, snacid); | 1381 flap_connection_send_snac(od, conn, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, snacid, &bs); |
1368 | 1382 |
1369 for (cur=od->ssi.pending; cur; cur=cur->next) { | 1383 byte_stream_destroy(&bs); |
1370 byte_stream_put16(&frame->data, cur->item->name ? strlen(cur->item->name) : 0); | |
1371 if (cur->item->name) | |
1372 byte_stream_putstr(&frame->data, cur->item->name); | |
1373 byte_stream_put16(&frame->data, cur->item->gid); | |
1374 byte_stream_put16(&frame->data, cur->item->bid); | |
1375 byte_stream_put16(&frame->data, cur->item->type); | |
1376 byte_stream_put16(&frame->data, cur->item->data ? aim_tlvlist_size(cur->item->data) : 0); | |
1377 if (cur->item->data) | |
1378 aim_tlvlist_write(&frame->data, &cur->item->data); | |
1379 } | |
1380 | |
1381 flap_connection_send(conn, frame); | |
1382 | 1384 |
1383 return 0; | 1385 return 0; |
1384 } | 1386 } |
1385 | 1387 |
1386 /* | 1388 /* |
1682 * | 1684 * |
1683 */ | 1685 */ |
1684 int aim_ssi_sendauth(OscarData *od, char *sn, char *msg) | 1686 int aim_ssi_sendauth(OscarData *od, char *sn, char *msg) |
1685 { | 1687 { |
1686 FlapConnection *conn; | 1688 FlapConnection *conn; |
1687 FlapFrame *frame; | 1689 ByteStream bs; |
1688 aim_snacid_t snacid; | 1690 aim_snacid_t snacid; |
1689 | 1691 |
1690 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) | 1692 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) |
1691 return -EINVAL; | 1693 return -EINVAL; |
1692 | 1694 |
1693 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2); | 1695 byte_stream_new(&bs, 1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2); |
1696 | |
1697 /* Screen name */ | |
1698 byte_stream_put8(&bs, strlen(sn)); | |
1699 byte_stream_putstr(&bs, sn); | |
1700 | |
1701 /* Message (null terminated) */ | |
1702 byte_stream_put16(&bs, msg ? strlen(msg) : 0); | |
1703 if (msg) { | |
1704 byte_stream_putstr(&bs, msg); | |
1705 byte_stream_put8(&bs, 0x00); | |
1706 } | |
1707 | |
1708 /* Unknown */ | |
1709 byte_stream_put16(&bs, 0x0000); | |
1694 | 1710 |
1695 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, NULL, 0); | 1711 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, NULL, 0); |
1696 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, snacid); | 1712 flap_connection_send_snac(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, snacid, &bs); |
1697 | 1713 |
1698 /* Screen name */ | 1714 byte_stream_destroy(&bs); |
1699 byte_stream_put8(&frame->data, strlen(sn)); | |
1700 byte_stream_putstr(&frame->data, sn); | |
1701 | |
1702 /* Message (null terminated) */ | |
1703 byte_stream_put16(&frame->data, msg ? strlen(msg) : 0); | |
1704 if (msg) { | |
1705 byte_stream_putstr(&frame->data, msg); | |
1706 byte_stream_put8(&frame->data, 0x00); | |
1707 } | |
1708 | |
1709 /* Unknown */ | |
1710 byte_stream_put16(&frame->data, 0x0000); | |
1711 | |
1712 flap_connection_send(conn, frame); | |
1713 | 1715 |
1714 return 0; | 1716 return 0; |
1715 } | 1717 } |
1716 | 1718 |
1717 /* | 1719 /* |
1756 * | 1758 * |
1757 */ | 1759 */ |
1758 int aim_ssi_sendauthrequest(OscarData *od, char *sn, const char *msg) | 1760 int aim_ssi_sendauthrequest(OscarData *od, char *sn, const char *msg) |
1759 { | 1761 { |
1760 FlapConnection *conn; | 1762 FlapConnection *conn; |
1761 FlapFrame *frame; | 1763 ByteStream bs; |
1762 aim_snacid_t snacid; | 1764 aim_snacid_t snacid; |
1763 | 1765 |
1764 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) | 1766 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) |
1765 return -EINVAL; | 1767 return -EINVAL; |
1766 | 1768 |
1767 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2); | 1769 byte_stream_new(&bs, 1+strlen(sn) + 2+(msg ? (strlen(msg)+1) : 0) + 2); |
1770 | |
1771 aim_putsnac(&bs, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, snacid); | |
1772 | |
1773 /* Screen name */ | |
1774 byte_stream_put8(&bs, strlen(sn)); | |
1775 byte_stream_putstr(&bs, sn); | |
1776 | |
1777 /* Message (null terminated) */ | |
1778 byte_stream_put16(&bs, msg ? strlen(msg) : 0); | |
1779 if (msg) { | |
1780 byte_stream_putstr(&bs, msg); | |
1781 byte_stream_put8(&bs, 0x00); | |
1782 } | |
1783 | |
1784 /* Unknown */ | |
1785 byte_stream_put16(&bs, 0x0000); | |
1768 | 1786 |
1769 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, NULL, 0); | 1787 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, NULL, 0); |
1770 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, snacid); | 1788 flap_connection_send_snac(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, snacid, &bs); |
1771 | 1789 |
1772 /* Screen name */ | 1790 byte_stream_destroy(&bs); |
1773 byte_stream_put8(&frame->data, strlen(sn)); | |
1774 byte_stream_putstr(&frame->data, sn); | |
1775 | |
1776 /* Message (null terminated) */ | |
1777 byte_stream_put16(&frame->data, msg ? strlen(msg) : 0); | |
1778 if (msg) { | |
1779 byte_stream_putstr(&frame->data, msg); | |
1780 byte_stream_put8(&frame->data, 0x00); | |
1781 } | |
1782 | |
1783 /* Unknown */ | |
1784 byte_stream_put16(&frame->data, 0x0000); | |
1785 | |
1786 flap_connection_send(conn, frame); | |
1787 | 1791 |
1788 return 0; | 1792 return 0; |
1789 } | 1793 } |
1790 | 1794 |
1791 /* | 1795 /* |
1833 * | 1837 * |
1834 */ | 1838 */ |
1835 int aim_ssi_sendauthreply(OscarData *od, char *sn, guint8 reply, const char *msg) | 1839 int aim_ssi_sendauthreply(OscarData *od, char *sn, guint8 reply, const char *msg) |
1836 { | 1840 { |
1837 FlapConnection *conn; | 1841 FlapConnection *conn; |
1838 FlapFrame *frame; | 1842 ByteStream bs; |
1839 aim_snacid_t snacid; | 1843 aim_snacid_t snacid; |
1840 | 1844 |
1841 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) | 1845 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn) |
1842 return -EINVAL; | 1846 return -EINVAL; |
1843 | 1847 |
1844 frame = flap_frame_new(od, 0x02, 10 + 1+strlen(sn) + 1 + 2+(msg ? strlen(msg)+1 : 0) + 2); | 1848 byte_stream_new(&bs, 1+strlen(sn) + 1 + 2+(msg ? (strlen(msg)+1) : 0) + 2); |
1849 | |
1850 /* Screen name */ | |
1851 byte_stream_put8(&bs, strlen(sn)); | |
1852 byte_stream_putstr(&bs, sn); | |
1853 | |
1854 /* Grant or deny */ | |
1855 byte_stream_put8(&bs, reply); | |
1856 | |
1857 /* Message (null terminated) */ | |
1858 byte_stream_put16(&bs, msg ? (strlen(msg)+1) : 0); | |
1859 if (msg) { | |
1860 byte_stream_putstr(&bs, msg); | |
1861 byte_stream_put8(&bs, 0x00); | |
1862 } | |
1863 | |
1864 /* Unknown */ | |
1865 byte_stream_put16(&bs, 0x0000); | |
1845 | 1866 |
1846 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, NULL, 0); | 1867 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, NULL, 0); |
1847 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, snacid); | 1868 flap_connection_send_snac(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, snacid, &bs); |
1848 | 1869 |
1849 /* Screen name */ | 1870 byte_stream_destroy(&bs); |
1850 byte_stream_put8(&frame->data, strlen(sn)); | 1871 |
1851 byte_stream_putstr(&frame->data, sn); | |
1852 | |
1853 /* Grant or deny */ | |
1854 byte_stream_put8(&frame->data, reply); | |
1855 | |
1856 /* Message (null terminated) */ | |
1857 byte_stream_put16(&frame->data, msg ? (strlen(msg)+1) : 0); | |
1858 if (msg) { | |
1859 byte_stream_putstr(&frame->data, msg); | |
1860 byte_stream_put8(&frame->data, 0x00); | |
1861 } | |
1862 | |
1863 /* Unknown */ | |
1864 byte_stream_put16(&frame->data, 0x0000); | |
1865 | |
1866 flap_connection_send(conn, frame); | |
1867 | |
1868 return 0; | 1872 return 0; |
1869 } | 1873 } |
1870 | 1874 |
1871 /* | 1875 /* |
1872 * Subtype 0x001b - Receive an authorization reply | 1876 * Subtype 0x001b - Receive an authorization reply |