diff libpurple/protocols/oscar/family_alert.c @ 22717: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 44b4e8bd759b
children 9c0ee2491ed1
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_alert.c	Thu Apr 24 02:16:30 2008 +0000
+++ b/libpurple/protocols/oscar/family_alert.c	Thu Apr 24 11:10:03 2008 +0000
@@ -41,40 +41,41 @@
 aim_email_sendcookies(OscarData *od)
 {
 	FlapConnection *conn;
-	FlapFrame *fr;
+	ByteStream bs;
 	aim_snacid_t snacid;
 
 	if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ALERT)))
 		return -EINVAL;
 
-	fr = flap_frame_new(od, 0x02, 10+2+16+16);
-	snacid = aim_cachesnac(od, 0x0018, 0x0006, 0x0000, NULL, 0);
-	aim_putsnac(&fr->data, 0x0018, 0x0006, 0x0000, snacid);
+	byte_stream_new(&bs, 2+16+16);
 
 	/* Number of cookies to follow */
-	byte_stream_put16(&fr->data, 0x0002);
+	byte_stream_put16(&bs, 0x0002);
 
 	/* Cookie */
-	byte_stream_put16(&fr->data, 0x5d5e);
-	byte_stream_put16(&fr->data, 0x1708);
-	byte_stream_put16(&fr->data, 0x55aa);
-	byte_stream_put16(&fr->data, 0x11d3);
-	byte_stream_put16(&fr->data, 0xb143);
-	byte_stream_put16(&fr->data, 0x0060);
-	byte_stream_put16(&fr->data, 0xb0fb);
-	byte_stream_put16(&fr->data, 0x1ecb);
+	byte_stream_put16(&bs, 0x5d5e);
+	byte_stream_put16(&bs, 0x1708);
+	byte_stream_put16(&bs, 0x55aa);
+	byte_stream_put16(&bs, 0x11d3);
+	byte_stream_put16(&bs, 0xb143);
+	byte_stream_put16(&bs, 0x0060);
+	byte_stream_put16(&bs, 0xb0fb);
+	byte_stream_put16(&bs, 0x1ecb);
 
 	/* Cookie */
-	byte_stream_put16(&fr->data, 0xb380);
-	byte_stream_put16(&fr->data, 0x9ad8);
-	byte_stream_put16(&fr->data, 0x0dba);
-	byte_stream_put16(&fr->data, 0x11d5);
-	byte_stream_put16(&fr->data, 0x9f8a);
-	byte_stream_put16(&fr->data, 0x0060);
-	byte_stream_put16(&fr->data, 0xb0ee);
-	byte_stream_put16(&fr->data, 0x0631);
+	byte_stream_put16(&bs, 0xb380);
+	byte_stream_put16(&bs, 0x9ad8);
+	byte_stream_put16(&bs, 0x0dba);
+	byte_stream_put16(&bs, 0x11d5);
+	byte_stream_put16(&bs, 0x9f8a);
+	byte_stream_put16(&bs, 0x0060);
+	byte_stream_put16(&bs, 0xb0ee);
+	byte_stream_put16(&bs, 0x0631);
 
-	flap_connection_send(conn, fr);
+	snacid = aim_cachesnac(od, 0x0018, 0x0006, 0x0000, NULL, 0);
+	flap_connection_send_snac(od, conn, 0x0018, 0x0006, 0x0000, snacid, &bs);
+
+	byte_stream_destroy(&bs);
 
 	return 0;
 }
@@ -171,25 +172,26 @@
 aim_email_activate(OscarData *od)
 {
 	FlapConnection *conn;
-	FlapFrame *fr;
+	ByteStream bs;
 	aim_snacid_t snacid;
 
 	if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_ALERT)))
 		return -EINVAL;
 
-	fr = flap_frame_new(od, 0x02, 10+1+16);
-	snacid = aim_cachesnac(od, 0x0018, 0x0016, 0x0000, NULL, 0);
-	aim_putsnac(&fr->data, 0x0018, 0x0016, 0x0000, snacid);
+	byte_stream_new(&bs, 1+16);
 
 	/* I would guess this tells AIM that you want updates for your mail accounts */
 	/* ...but I really have no idea */
-	byte_stream_put8(&fr->data, 0x02);
-	byte_stream_put32(&fr->data, 0x04000000);
-	byte_stream_put32(&fr->data, 0x04000000);
-	byte_stream_put32(&fr->data, 0x04000000);
-	byte_stream_put32(&fr->data, 0x00000000);
+	byte_stream_put8(&bs, 0x02);
+	byte_stream_put32(&bs, 0x04000000);
+	byte_stream_put32(&bs, 0x04000000);
+	byte_stream_put32(&bs, 0x04000000);
+	byte_stream_put32(&bs, 0x00000000);
 
-	flap_connection_send(conn, fr);
+	snacid = aim_cachesnac(od, 0x0018, 0x0016, 0x0000, NULL, 0);
+	flap_connection_send_snac(od, conn, 0x0018, 0x0006, 0x0000, snacid, &bs);
+
+	byte_stream_destroy(&bs);
 
 	return 0;
 }