/* * Inverse of aim_extractuserinfo() */ int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info) { aim_tlvlist_t *tlvlist = NULL; if (!bs || !info) return -EINVAL; aimbs_put8(bs, strlen(info->sn)); aimbs_putraw(bs, (guint8 *)info->sn, strlen(info->sn)); aimbs_put16(bs, info->warnlevel); aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); #if ICQ_OSCAR_SUPPORT if (atoi(info->sn) != 0) { aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); } #endif aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); aim_addtlvtochain32(&tlvlist, (guint16)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); aimbs_put16(bs, aim_counttlvchain(&tlvlist)); aim_writetlvchain(bs, &tlvlist); aim_freetlvchain(&tlvlist); return 0; }
faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange) { static const char ck[] = {"create"}; static const char lang[] = {"en"}; static const char charset[] = {"us-ascii"}; aim_frame_t *fr; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL; if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x000d, 0x0008, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x000d, 0x0008, 0x0000, snacid); /* exchange */ aimbs_put16(&fr->data, exchange); /* * This looks to be a big hack. You'll note that this entire * SNAC is just a room info structure, but the hard room name, * here, is set to "create". * * Either this goes on the "list of questions concerning * why-the-hell-did-you-do-that", or this value is completly * ignored. Without experimental evidence, but a good knowledge of * AOL style, I'm going to guess that it is the latter, and that * the value of the room name in create requests is ignored. */ aimbs_put8(&fr->data, strlen(ck)); aimbs_putraw(&fr->data, ck, strlen(ck)); /* * instance * * Setting this to 0xffff apparently assigns the last instance. * */ aimbs_put16(&fr->data, 0xffff); /* detail level */ aimbs_put8(&fr->data, 0x01); aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), name); aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), charset); aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), lang); /* tlvcount */ aimbs_put16(&fr->data, aim_counttlvchain(&tl)); aim_writetlvchain(&fr->data, &tl); aim_freetlvchain(&tl); aim_tx_enqueue(sess, fr); return 0; }
/* * Inverse of aim_extractuserinfo() */ faim_internal int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info) { aim_tlvlist_t *tlvlist = NULL; if (!bs || !info) return -EINVAL; aimbs_put8(bs, strlen(info->sn)); aimbs_putraw(bs, info->sn, strlen(info->sn)); aimbs_put16(bs, info->warnlevel); if (info->present & AIM_USERINFO_PRESENT_FLAGS) aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); if (info->present & AIM_USERINFO_PRESENT_IDLE) aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); #if ICQ_OSCAR_SUPPORT if (atoi(info->sn) != 0) { if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); } #endif if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); aimbs_put16(bs, aim_counttlvchain(&tlvlist)); aim_writetlvchain(bs, &tlvlist); aim_freetlvchain(&tlvlist); return 0; }
/* * Subtype 0x0003 * */ static int reply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) { int j = 0, m, ret = 0; aim_tlvlist_t *tlvlist; char *cur = NULL, *buf = NULL; aim_rxcallback_t userfunc; aim_snac_t *snac2; char *searchaddr = NULL; if ((snac2 = aim_remsnac(sess, snac->id))) searchaddr = (char *)snac2->data; tlvlist = aim_readtlvchain(bs); m = aim_counttlvchain(&tlvlist); /* XXX uhm. */ while ((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) { buf = realloc(buf, (j+1) * (MAXSNLEN+1)); strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN); free(cur); j++; } aim_freetlvchain(&tlvlist); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, searchaddr, j, buf); /* XXX freesnac()? */ if (snac2) free(snac2->data); free(snac2); free(buf); return ret; }