/* * 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; }
/* * aim_bos_setprofile(profile) * * Gives BOS your profile. * */ int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, guint32 caps) { static const char defencoding[] = {"text/aolrtf; charset=\"utf-8\""}; aim_frame_t *fr; aim_tlvlist_t *tl = NULL; aim_snacid_t snacid; /* Build to packet first to get real length */ if (profile) { aim_addtlvtochain_raw(&tl, 0x0001, strlen(defencoding), (guint8 *)defencoding); aim_addtlvtochain_raw(&tl, 0x0002, strlen(profile), (guint8 *)profile); } /* * So here's how this works: * - You are away when you have a non-zero-length type 4 TLV stored. * - You become unaway when you clear the TLV with a zero-length * type 4 TLV. * - If you do not send the type 4 TLV, your status does not change * (that is, if you were away, you'll remain away). */ if (awaymsg) { if (strlen(awaymsg)) { aim_addtlvtochain_raw(&tl, 0x0003, strlen(defencoding), (guint8 *)defencoding); aim_addtlvtochain_raw(&tl, 0x0004, strlen(awaymsg), (guint8 *)awaymsg); } else aim_addtlvtochain_noval(&tl, 0x0004); } aim_addtlvtochain_caps(&tl, 0x0005, caps); if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid); 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; }