pidgin: afd189bb: Create two helper functions for setting ...
markdoliner at pidgin.im
markdoliner at pidgin.im
Thu Mar 5 18:20:29 EST 2009
-----------------------------------------------------------------
Revision: afd189bbc2a50acf6d5ce48f2b7ef623e06cde0e
Ancestor: cc82bde6653a94f3107f8d3b812109f1b69a2313
Author: markdoliner at pidgin.im
Date: 2009-03-05T23:17:01
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/afd189bbc2a50acf6d5ce48f2b7ef623e06cde0e
Modified files:
libpurple/protocols/oscar/bstream.c
libpurple/protocols/oscar/family_oservice.c
libpurple/protocols/oscar/oscar.h
ChangeLog:
Create two helper functions for setting the available message and iTunes
Music Store url. I guess this might be slightly more ineffecient, but
this code is only called when your status changes, and it's much cleaner
this way.
-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/bstream.c 103f791a9418375427bbfcf3e4942c2813827e94
+++ libpurple/protocols/oscar/bstream.c 1b70134e5f9f283ef26d4b64af11c01f31aef174
@@ -311,3 +311,37 @@ int byte_stream_putuid(ByteStream *bs, O
return byte_stream_putle32(bs, atoi(purple_account_get_username(account)));
}
+
+void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data)
+{
+ byte_stream_put16(bs, type);
+
+ if (data != NULL && data->len > 0) {
+ /* Flags. 0x04 means "this asset has data attached to it" */
+ byte_stream_put8(bs, 0x04); /* Flags */
+ byte_stream_put8(bs, data->len); /* Length */
+ byte_stream_rewind(data);
+ byte_stream_putbs(bs, data, data->len); /* Data */
+ } else {
+ byte_stream_put8(bs, 0x00); /* No flags */
+ byte_stream_put8(bs, 0x00); /* Length */
+ /* No data */
+ }
+}
+
+void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr)
+{
+ ByteStream data;
+ size_t len = datastr != NULL ? strlen(datastr) : 0;
+
+ if (len > 0) {
+ byte_stream_new(&data, 2 + len + 2);
+ byte_stream_put16(&data, len); /* Length */
+ byte_stream_putstr(&data, datastr); /* String */
+ byte_stream_put16(&data, 0x0000); /* Unknown */
+ byte_stream_put_bart_asset(bs, type, &data);
+ byte_stream_destroy(&data);
+ } else {
+ byte_stream_put_bart_asset(bs, type, NULL);
+ }
+}
============================================================
--- libpurple/protocols/oscar/family_oservice.c 25093954f77cfe6b3f32e8b1eb135bcad739acd8
+++ libpurple/protocols/oscar/family_oservice.c abd1524cb064553247040c4cc700d51ba81b7280
@@ -853,29 +853,16 @@ aim_srv_setextrainfo(OscarData *od,
if (setavailmsg)
{
- int availmsglen, itmsurllen;
+ size_t availmsglen, itmsurllen;
ByteStream tmpbs;
availmsglen = (availmsg != NULL) ? strlen(availmsg) : 0;
itmsurllen = (itmsurl != NULL) ? strlen(itmsurl) : 0;
byte_stream_new(&tmpbs, availmsglen + 8 + itmsurllen + 8);
- byte_stream_put16(&tmpbs, 0x0002);
- byte_stream_put8(&tmpbs, 0x04); /* Flags */
- byte_stream_put8(&tmpbs, availmsglen + 4);
- byte_stream_put16(&tmpbs, availmsglen);
- if (availmsglen > 0)
- byte_stream_putstr(&tmpbs, availmsg);
- byte_stream_put16(&tmpbs, 0x0000);
+ byte_stream_put_bart_asset_str(&tmpbs, 0x0002, availmsg);
+ byte_stream_put_bart_asset_str(&tmpbs, 0x0009, itmsurl);
- byte_stream_put16(&tmpbs, 0x0009);
- byte_stream_put8(&tmpbs, 0x04); /* Flags */
- byte_stream_put8(&tmpbs, itmsurllen + 4);
- byte_stream_put16(&tmpbs, itmsurllen);
- if (itmsurllen > 0)
- byte_stream_putstr(&tmpbs, itmsurl);
- byte_stream_put16(&tmpbs, 0x0000);
-
aim_tlvlist_add_raw(&tlvlist, 0x001d,
byte_stream_curpos(&tmpbs), tmpbs.data);
byte_stream_destroy(&tmpbs);
============================================================
--- libpurple/protocols/oscar/oscar.h 4ab058b31543355b0e8249012e2db035c6737878
+++ libpurple/protocols/oscar/oscar.h 53c5d93dd6fbc18a33d6eff89cdbfccc14e7b89a
@@ -1594,6 +1594,18 @@ int byte_stream_putcaps(ByteStream *bs,
int byte_stream_putuid(ByteStream *bs, OscarData *od);
int byte_stream_putcaps(ByteStream *bs, guint32 caps);
+/**
+ * Inserts a BART asset block into the given byte stream. The flags
+ * and length are set appropriately based on the value of data.
+ */
+void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data);
+
+/**
+ * A helper function that calls byte_stream_put_bart_asset with the
+ * appropriate data ByteStream given the datastr.
+ */
+void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr);
+
/*
* Generic SNAC structure. Rarely if ever used.
*/
More information about the Commits
mailing list