static int parseinfo_perms(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs, aim_snac_t *snac2) { aim_rxcallback_t userfunc; int ret = 0; struct aim_chat_exchangeinfo *exchanges = NULL; int curexchange; aim_tlv_t *exchangetlv; guint8 maxrooms = 0; GSList *tlvlist, *innerlist; tlvlist = aim_tlvlist_read(bs); /* * Type 0x0002: Maximum concurrent rooms. */ if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) maxrooms = aim_tlv_get8(tlvlist, 0x0002, 1); /* * Type 0x0003: Exchange information * * There can be any number of these, each one * representing another exchange. * */ for (curexchange = 0; ((exchangetlv = aim_tlv_gettlv(tlvlist, 0x0003, curexchange+1))); ) { ByteStream tbs; byte_stream_init(&tbs, exchangetlv->value, exchangetlv->length); curexchange++; exchanges = g_realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo)); /* exchange number */ exchanges[curexchange-1].number = byte_stream_get16(&tbs); innerlist = aim_tlvlist_read(&tbs); /* * Type 0x0002: Unknown */ if (aim_tlv_gettlv(innerlist, 0x0002, 1)) { guint16 classperms; classperms = aim_tlv_get16(innerlist, 0x0002, 1); purple_debug_misc("oscar", "faim: class permissions %x\n", classperms); } /* * Type 0x00c9: Flags * * 1 Evilable * 2 Nav Only * 4 Instancing Allowed * 8 Occupant Peek Allowed * */ if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) exchanges[curexchange-1].flags = aim_tlv_get16(innerlist, 0x00c9, 1); /* * Type 0x00d3: Exchange Description */ if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) exchanges[curexchange-1].name = aim_tlv_getstr(innerlist, 0x00d3, 1); else exchanges[curexchange-1].name = NULL; /* * Type 0x00d5: Creation Permissions * * 0 Creation not allowed * 1 Room creation allowed * 2 Exchange creation allowed * */ if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) aim_tlv_get8(innerlist, 0x00d5, 1); /* createperms */ /* * Type 0x00d6: Character Set (First Time) */ if (aim_tlv_gettlv(innerlist, 0x00d6, 1)) exchanges[curexchange-1].charset1 = aim_tlv_getstr(innerlist, 0x00d6, 1); else exchanges[curexchange-1].charset1 = NULL; /* * Type 0x00d7: Language (First Time) */ if (aim_tlv_gettlv(innerlist, 0x00d7, 1)) exchanges[curexchange-1].lang1 = aim_tlv_getstr(innerlist, 0x00d7, 1); else exchanges[curexchange-1].lang1 = NULL; /* * Type 0x00d8: Character Set (Second Time) */ if (aim_tlv_gettlv(innerlist, 0x00d8, 1)) exchanges[curexchange-1].charset2 = aim_tlv_getstr(innerlist, 0x00d8, 1); else exchanges[curexchange-1].charset2 = NULL; /* * Type 0x00d9: Language (Second Time) */ if (aim_tlv_gettlv(innerlist, 0x00d9, 1)) exchanges[curexchange-1].lang2 = aim_tlv_getstr(innerlist, 0x00d9, 1); else exchanges[curexchange-1].lang2 = NULL; aim_tlvlist_free(innerlist); } /* * Call client. */ if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) ret = userfunc(od, conn, frame, snac2->type, maxrooms, curexchange, exchanges); for (curexchange--; curexchange >= 0; curexchange--) { g_free(exchanges[curexchange].name); g_free(exchanges[curexchange].charset1); g_free(exchanges[curexchange].lang1); g_free(exchanges[curexchange].charset2); g_free(exchanges[curexchange].lang2); } g_free(exchanges); aim_tlvlist_free(tlvlist); return ret; }
static int parseinfo_create(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs, aim_snac_t *snac2) { aim_rxcallback_t userfunc; GSList *tlvlist, *innerlist; char *ck = NULL, *fqcn = NULL, *name = NULL; guint16 exchange = 0, instance = 0, unknown = 0, flags = 0, maxmsglen = 0, maxoccupancy = 0; guint32 createtime = 0; guint8 createperms = 0, detaillevel; int cklen; aim_tlv_t *bigblock; int ret = 0; ByteStream bbbs; tlvlist = aim_tlvlist_read(bs); if (!(bigblock = aim_tlv_gettlv(tlvlist, 0x0004, 1))) { purple_debug_misc("oscar", "no bigblock in top tlv in create room response\n"); aim_tlvlist_free(tlvlist); return 0; } byte_stream_init(&bbbs, bigblock->value, bigblock->length); exchange = byte_stream_get16(&bbbs); cklen = byte_stream_get8(&bbbs); ck = byte_stream_getstr(&bbbs, cklen); instance = byte_stream_get16(&bbbs); detaillevel = byte_stream_get8(&bbbs); if (detaillevel != 0x02) { purple_debug_misc("oscar", "unknown detaillevel in create room response (0x%02x)\n", detaillevel); aim_tlvlist_free(tlvlist); g_free(ck); return 0; } unknown = byte_stream_get16(&bbbs); innerlist = aim_tlvlist_read(&bbbs); if (aim_tlv_gettlv(innerlist, 0x006a, 1)) fqcn = aim_tlv_getstr(innerlist, 0x006a, 1); if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) flags = aim_tlv_get16(innerlist, 0x00c9, 1); if (aim_tlv_gettlv(innerlist, 0x00ca, 1)) createtime = aim_tlv_get32(innerlist, 0x00ca, 1); if (aim_tlv_gettlv(innerlist, 0x00d1, 1)) maxmsglen = aim_tlv_get16(innerlist, 0x00d1, 1); if (aim_tlv_gettlv(innerlist, 0x00d2, 1)) maxoccupancy = aim_tlv_get16(innerlist, 0x00d2, 1); if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) name = aim_tlv_getstr(innerlist, 0x00d3, 1); if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) createperms = aim_tlv_get8(innerlist, 0x00d5, 1); if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) { ret = userfunc(od, conn, frame, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); } g_free(ck); g_free(name); g_free(fqcn); aim_tlvlist_free(innerlist); aim_tlvlist_free(tlvlist); return ret; }
/* * Subtype 0x0002 - General room information. Lots of stuff. * * Values I know are in here but I haven't attached * them to any of the 'Unknown's: * - Language (English) * */ static int infoupdate(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) { aim_userinfo_t *userinfo = NULL; aim_rxcallback_t userfunc; int ret = 0; int usercount = 0; fu8_t detaillevel = 0; char *roomname = NULL; struct aim_chat_roominfo roominfo; fu16_t tlvcount = 0; aim_tlvlist_t *tlvlist; char *roomdesc = NULL; fu16_t flags = 0; fu32_t creationtime = 0; fu16_t maxmsglen = 0, maxvisiblemsglen = 0; fu16_t unknown_d2 = 0, unknown_d5 = 0; aim_chat_readroominfo(bs, &roominfo); detaillevel = aimbs_get8(bs); if (detaillevel != 0x02) { faimdprintf(sess, 0, "faim: chat_roomupdateinfo: detail level %d not supported\n", detaillevel); return 1; } tlvcount = aimbs_get16(bs); /* * Everything else are TLVs. */ tlvlist = aim_tlvlist_read(bs); /* * TLV type 0x006a is the room name in Human Readable Form. */ if (aim_tlv_gettlv(tlvlist, 0x006a, 1)) roomname = aim_tlv_getstr(tlvlist, 0x006a, 1); /* * Type 0x006f: Number of occupants. */ if (aim_tlv_gettlv(tlvlist, 0x006f, 1)) usercount = aim_tlv_get16(tlvlist, 0x006f, 1); /* * Type 0x0073: Occupant list. */ if (aim_tlv_gettlv(tlvlist, 0x0073, 1)) { int curoccupant = 0; aim_tlv_t *tmptlv; aim_bstream_t occbs; tmptlv = aim_tlv_gettlv(tlvlist, 0x0073, 1); /* Allocate enough userinfo structs for all occupants */ userinfo = calloc(usercount, sizeof(aim_userinfo_t)); aim_bstream_init(&occbs, tmptlv->value, tmptlv->length); while (curoccupant < usercount) aim_info_extract(sess, &occbs, &userinfo[curoccupant++]); } /* * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG) */ if (aim_tlv_gettlv(tlvlist, 0x00c9, 1)) flags = aim_tlv_get16(tlvlist, 0x00c9, 1); /* * Type 0x00ca: Creation time (4 bytes) */ if (aim_tlv_gettlv(tlvlist, 0x00ca, 1)) creationtime = aim_tlv_get32(tlvlist, 0x00ca, 1); /* * Type 0x00d1: Maximum Message Length */ if (aim_tlv_gettlv(tlvlist, 0x00d1, 1)) maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1); /* * Type 0x00d2: Unknown. (2 bytes) */ if (aim_tlv_gettlv(tlvlist, 0x00d2, 1)) unknown_d2 = aim_tlv_get16(tlvlist, 0x00d2, 1); /* * Type 0x00d3: Room Description */ if (aim_tlv_gettlv(tlvlist, 0x00d3, 1)) roomdesc = aim_tlv_getstr(tlvlist, 0x00d3, 1); /* * Type 0x000d4: Unknown (flag only) */ if (aim_tlv_gettlv(tlvlist, 0x000d4, 1)) ; /* * Type 0x00d5: Unknown. (1 byte) */ if (aim_tlv_gettlv(tlvlist, 0x00d5, 1)) unknown_d5 = aim_tlv_get8(tlvlist, 0x00d5, 1); /* * Type 0x00d6: Encoding 1 ("us-ascii") */ if (aim_tlv_gettlv(tlvlist, 0x000d6, 1)) ; /* * Type 0x00d7: Language 1 ("en") */ if (aim_tlv_gettlv(tlvlist, 0x000d7, 1)) ; /* * Type 0x00d8: Encoding 2 ("us-ascii") */ if (aim_tlv_gettlv(tlvlist, 0x000d8, 1)) ; /* * Type 0x00d9: Language 2 ("en") */ if (aim_tlv_gettlv(tlvlist, 0x000d9, 1)) ; /* * Type 0x00da: Maximum visible message length */ if (aim_tlv_gettlv(tlvlist, 0x000da, 1)) maxvisiblemsglen = aim_tlv_get16(tlvlist, 0x00da, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { ret = userfunc(sess, rx, &roominfo, roomname, usercount, userinfo, roomdesc, flags, creationtime, maxmsglen, unknown_d2, unknown_d5, maxvisiblemsglen); } free(roominfo.name); while (usercount > 0) aim_info_free(&userinfo[--usercount]); free(userinfo); free(roomname); free(roomdesc); aim_tlvlist_free(&tlvlist); return ret; }