/* 0000 00 05 00 02 00 17 00 06 00 03 00 00 00 00 07 00 ................ 0010 01 00 00 08 00 01 01 00 0a 00 14 00 02 00 08 66 ...............f 0020 61 63 65 62 6f 6f 6b 00 06 67 6f 6f 67 6c 65 acebook..google int CAimProto::aim_request_rights(HANDLE hServerConn,unsigned short &seqno) { unsigned short offset=0; char buf[SNAC_SIZE+50]; aim_writesnac(0x03,0x02,offset,buf); aim_writetlvshort(0x05,0x17,offset,buf); aim_writetlv(0x06,3,"\x0\x0",offset,buf); aim_writetlvchar(0x07,0x01,offset,buf); aim_writetlvshort(0x05,0x17,offset,buf); aim_writetlvshort(0x05,0x17,offset,buf); return aim_sendflap(hServerConn,0x02,offset,buf,seqno); } */ int CAimProto::aim_set_caps(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; int i = 1; char buf[SNAC_SIZE + TLV_HEADER_SIZE * 3 + AIM_CAPS_LENGTH * 50 + sizeof(AIM_MSG_TYPE)]; char temp[AIM_CAPS_LENGTH * 20]; memcpy(temp, AIM_CAP_SHORT_CAPS, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_HOST_STATUS_TEXT_AWARE, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_SMART_CAPS, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_FILE_TRANSFER, AIM_CAPS_LENGTH); // memcpy(&temp[AIM_CAPS_LENGTH*i++],AIM_CAP_HAS_MICROPHONE,AIM_CAPS_LENGTH); // memcpy(&temp[AIM_CAPS_LENGTH*i++],AIM_CAP_RTCAUDIO,AIM_CAPS_LENGTH); // memcpy(&temp[AIM_CAPS_LENGTH*i++],AIM_CAP_HAS_CAMERA,AIM_CAPS_LENGTH); // memcpy(&temp[AIM_CAPS_LENGTH*i++],AIM_CAP_RTCVIDEO,AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_BUDDY_ICON, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_CHAT, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_SUPPORT_ICQ, AIM_CAPS_LENGTH); // memcpy(&temp[AIM_CAPS_LENGTH*i++],AIM_CAP_ICQ_SERVER_RELAY,AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_UTF8, AIM_CAPS_LENGTH); memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_MIRANDA, AIM_CAPS_LENGTH); if (getByte(AIM_KEY_HF, 0)) memcpy(&temp[AIM_CAPS_LENGTH*i++], AIM_CAP_HIPTOP, AIM_CAPS_LENGTH); aim_writesnac(0x02, 0x04, offset, buf); aim_writetlv(0x05, (unsigned short)(AIM_CAPS_LENGTH*i), temp, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_activate_list(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE]; aim_writesnac(0x13, 0x07, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_request_offline_msgs(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE]; aim_writesnac(0x04, 0x10, offset, buf); // Subtype for offline messages 0x10 return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_request_icbm(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE]; aim_writesnac(0x04, 0x04, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_admin_account_confirm(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE + TLV_HEADER_SIZE]; aim_writesnac(0x07, 0x06, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_file_ad(HANDLE hServerConn, unsigned short &seqno, char* sn, char* icbm_cookie, bool deny, unsigned short) { unsigned short frag_offset = 0; char msg_frag[10 + AIM_CAPS_LENGTH + TLV_HEADER_SIZE * 2 + 6]; aim_writeshort(deny ? 1 : 2, frag_offset, msg_frag); // icbm accept / deny aim_writegeneric(8, icbm_cookie, frag_offset, msg_frag); // icbm cookie aim_writegeneric(AIM_CAPS_LENGTH, AIM_CAP_FILE_TRANSFER, frag_offset, msg_frag); // uuid // if (max_ver > 1) // aim_writetlvshort(0x12,2,frag_offset,msg_frag); // max protocol version unsigned short sn_length = (unsigned short)mir_strlen(sn); unsigned short offset = 0; char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE + 21 + frag_offset + sn_length); aim_writesnac(0x04, 0x06, offset, buf); // msg to host aim_writegeneric(8, icbm_cookie, offset, buf); // icbm cookie aim_writeshort(2, offset, buf); // icbm channel aim_writechar((unsigned char)sn_length, offset, buf); // screen name length aim_writegeneric(sn_length, sn, offset, buf); // screen name aim_writetlv(0x05, frag_offset, msg_frag, offset, buf); // icbm tags debugLogA("%s a file transfer.", deny ? "Denying" : "Accepting"); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno) == 0; }
int CAimProto::aim_chat_send_message(HANDLE hServerConn, unsigned short &seqno, char *amsg) { aimString str(amsg); const char* charset = str.isUnicode() ? "unicode-2-0" : "us-ascii"; const unsigned short chrset_len = (unsigned short)mir_strlen(charset); const char* msg = str.getBuf(); const unsigned short msg_len = str.getSize(); unsigned short tlv_offset = 0; char* tlv_buf = (char*)alloca(TLV_HEADER_SIZE * 4 + chrset_len + msg_len + 20); aim_writetlv(0x04, 13, "text/x-aolrtf", tlv_offset, tlv_buf); // Format aim_writetlv(0x02, chrset_len, charset, tlv_offset, tlv_buf); // Character Set aim_writetlv(0x03, 2, "en", tlv_offset, tlv_buf); // Language Encoding aim_writetlv(0x01, msg_len, msg, tlv_offset, tlv_buf); // Message unsigned short offset = 0; char* buf = (char*)alloca(SNAC_SIZE + 8 + 2 + TLV_HEADER_SIZE * 3 + tlv_offset); aim_writesnac(0x0e, 0x05, offset, buf); aim_writegeneric(8, "\0\0\0\0\0\0\0\0", offset, buf); // Message Cookie (can be random) aim_writeshort(0x03, offset, buf); // Message Channel (Always 3 for chat) aim_writetlv(0x01, 0, NULL, offset, buf); // Public/Whisper flag aim_writetlv(0x06, 0, NULL, offset, buf); // Enable Reflection flag aim_writetlv(0x05, tlv_offset, tlv_buf, offset, buf); // Message Information TLV return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_set_avatar_hash(HANDLE hServerConn, unsigned short &seqno, char flags, unsigned short bart_type, unsigned short &id, char size, const char* hash) { unsigned short offset = 0; char bart_type_txt[8]; ultoa(bart_type, bart_type_txt, 10); unsigned short bart_type_len = (unsigned short)mir_strlen(bart_type_txt); unsigned short req = 0x09; if (id == 0) { id = get_random(); req = 0x08; } char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE * 2 + 20 + size + bart_type_len); aim_writesnac(0x13, req, offset, buf, get_random()); // SSI Edit/Add aim_writeshort(bart_type_len, offset, buf); // name length aim_writegeneric(bart_type_len, bart_type_txt, offset, buf); // name aim_writeshort(0, offset, buf); // group id aim_writeshort(id, offset, buf); // buddy id aim_writeshort(0x14, offset, buf); // buddy type: Buddy Icon aim_writeshort(2 + size + TLV_HEADER_SIZE, offset, buf); // length of extra data char* buf2 = (char*)alloca(2 + size); buf2[0] = flags; buf2[1] = (char)size; memcpy(&buf2[2], hash, size); aim_writetlv(0xd5, 2 + size, buf2, offset, buf); // BART return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_chatnav_request_limits(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE]; aim_writesnac(0x0d, 0x02, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno) ? -1 : 0; }
int CAimProto::aim_chat_invite(HANDLE hServerConn, unsigned short &seqno, char* chat_cookie, unsigned short exchange, unsigned short instance, char* sn, char* msg) { unsigned short offset = 0; unsigned short chat_cookie_len = (unsigned short)mir_strlen(chat_cookie); unsigned short sn_len = (unsigned short)mir_strlen(sn); unsigned short msg_len = (unsigned short)mir_strlen(msg); char* buf = (char*)alloca(SNAC_SIZE + 64 + chat_cookie_len + sn_len + msg_len); aim_writesnac(0x04, 0x06, offset, buf); aim_writegeneric(8, "\0\0\0\0\0\0\0\0", offset, buf); // ICBM Cookie aim_writeshort(2, offset, buf); // ICBM Channel aim_writechar((unsigned char)sn_len, offset, buf); // Screen Name Length aim_writegeneric(sn_len, sn, offset, buf); // Screen Name aim_writeshort(0x05, offset, buf); // Rendezvous Message Data TLV aim_writeshort(49 + msg_len + chat_cookie_len, offset, buf); // TLV size aim_writeshort(0, offset, buf); // Message Type (0) - Request aim_writegeneric(8, "\0\0\0\0\0\0\0\0", offset, buf); // ICBM Cookie (same as above) aim_writegeneric(16, AIM_CAP_CHAT, offset, buf); // Capability aim_writetlvshort(0x0a, 1, offset, buf); // Sequence Number TLV aim_writetlv(0x0f, 0, NULL, offset, buf); // Request Host Caps Check TLV aim_writetlv(0x0c, msg_len, msg, offset, buf); // Invitation Message TLV aim_writeshort(0x2711, offset, buf); // Capability TLV aim_writeshort(chat_cookie_len + 5, offset, buf); // Length aim_writeshort(exchange, offset, buf); // Value - Exchange aim_writechar((unsigned char)chat_cookie_len, offset, buf); // Value - Cookie Length aim_writegeneric(chat_cookie_len, chat_cookie, offset, buf); // Value - Cookie aim_writeshort(instance, offset, buf); // Value - Instance return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_set_away(HANDLE hServerConn, unsigned short &seqno, const char *amsg, bool set)//user info { unsigned short offset=0; char* html_msg = NULL; size_t msg_size = 0; if (set) { if (!amsg) return -1; setDword(AIM_KEY_LA, (DWORD)time(NULL)); html_msg = html_encode(amsg && amsg[0] ? amsg : DEFAULT_AWAY_MSG); msg_size = strlen(html_msg); } aimString str(html_msg); const char *charset = str.isUnicode() ? AIM_MSG_TYPE_UNICODE : AIM_MSG_TYPE; const unsigned short charset_len = (unsigned short)strlen(charset); const char* msg = str.getBuf(); const unsigned short msg_len = str.getSize(); char* buf=(char*)alloca(SNAC_SIZE+TLV_HEADER_SIZE*3+charset_len+msg_len+1); aim_writesnac(0x02,0x04,offset,buf); aim_writetlv(0x03,charset_len,charset,offset,buf); aim_writetlv(0x04,(unsigned short)msg_len,msg,offset,buf); // aim_writetlvchar(0x0f,2,offset,buf); mir_free(html_msg); return aim_sendflap(hServerConn,0x02,offset,buf,seqno); }
int CAimProto::aim_ssi_update(HANDLE hServerConn, unsigned short &seqno, bool start) { unsigned short offset = 0; char buf[SNAC_SIZE]; aim_writesnac(0x13, start ? 0x11 : 0x12, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno) == 0; }
int CAimProto::aim_ssi_update_preferences(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE + TLV_HEADER_SIZE * 4 + 100]; unsigned short req = 0x09; if (m_pref1_id == 0) { m_pref1_id = get_random(); req = 0x08; } aim_writesnac(0x13, req, offset, buf, get_random()); // SSI Edit/Add aim_writeshort(0, offset, buf); // group name length aim_writeshort(0, offset, buf); // group id (root) aim_writeshort(m_pref1_id, offset, buf); // buddy id aim_writeshort(5, offset, buf); // buddy type: Presence unsigned short tlv_len = TLV_HEADER_SIZE * 2 + 8; if (m_pref2_len) tlv_len += TLV_HEADER_SIZE + m_pref2_len; if (m_pref2_set_len) tlv_len += TLV_HEADER_SIZE + m_pref2_set_len; aim_writeshort(tlv_len, offset, buf); // length of extra data aim_writetlvlong(0xc9, m_pref1_flags, offset, buf); // Update Buddy preferences 1 aim_writetlvlong(0xd6, m_pref1_set_flags, offset, buf); // Update Buddy preferences 1 if (m_pref2_len) aim_writetlv(0xd7, m_pref2_len, m_pref2_flags, offset, buf); // Update Buddy preferences 2 if (m_pref2_set_len) aim_writetlv(0xd8, m_pref2_set_len, m_pref2_set_flags, offset, buf); // Update Buddy preferences 2 return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_activate_mail(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE + 17]; aim_writesnac(0x18, 0x16, offset, buf); aim_writegeneric(17, "\x02\x04\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_send_cookie(HANDLE hServerConn, unsigned short &seqno, int cookie_size, char * cookie) { unsigned short offset = 0; char* buf = (char*)alloca(TLV_HEADER_SIZE * 2 + cookie_size); aim_writelong(0x01, offset, buf);//protocol version number aim_writetlv(0x06, (unsigned short)cookie_size, cookie, offset, buf); return aim_sendflap(hServerConn, 0x01, offset, buf, seqno); }
int CAimProto::aim_accept_rates(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE * 2]; aim_writesnac(0x01, 0x08, offset, buf); aim_writegeneric(10, AIM_SERVICE_RATES, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_set_idle(HANDLE hServerConn, unsigned short &seqno, unsigned long seconds) { unsigned short offset = 0; char buf[SNAC_SIZE + 4]; aim_writesnac(0x01, 0x11, offset, buf); aim_writelong(seconds, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_set_status(HANDLE hServerConn,unsigned short &seqno,unsigned long status_type) { unsigned short offset=0; char buf[SNAC_SIZE+TLV_HEADER_SIZE*2]; aim_writesnac(0x01,0x1E,offset,buf); aim_writetlvlong(0x06,status_type,offset,buf); return aim_sendflap(hServerConn,0x02,offset,buf,seqno); }
int CAimProto::aim_search_by_email(HANDLE hServerConn, unsigned short &seqno, const char* email) { unsigned short offset = 0; char em_length = (char)mir_strlen(email); char* buf = (char*)alloca(SNAC_SIZE + em_length); aim_writesnac(0x0a, 0x02, offset, buf); // Email search aim_writegeneric(em_length, email, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_admin_request_info(HANDLE hServerConn, unsigned short &seqno, const unsigned short &type) { // types: 0x01 - nickname, 0x11 - email info, 0x13 - registration status unsigned short offset = 0; char buf[SNAC_SIZE + TLV_HEADER_SIZE]; aim_writesnac(0x07, 0x02, offset, buf); aim_writetlv(type, 0, NULL, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_admin_change_email(HANDLE hServerConn, unsigned short &seqno, const char* email) { unsigned short offset = 0; unsigned short email_len = (unsigned short)mir_strlen(email); char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE + email_len); aim_writesnac(0x07, 0x04, offset, buf); aim_writetlv(0x11, email_len, email, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_admin_format_name(HANDLE hServerConn, unsigned short &seqno, const char* sn) { unsigned short offset = 0; unsigned short sn_len = (unsigned short)mir_strlen(sn); char* buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE + sn_len); aim_writesnac(0x07, 0x04, offset, buf); aim_writetlv(0x01, sn_len, sn, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_upload_avatar(HANDLE hServerConn, unsigned short &seqno, unsigned short bart_type, const char* avatar, unsigned short avatar_size) { unsigned short offset = 0; char* buf = (char*)alloca(SNAC_SIZE + 22 + avatar_size); aim_writesnac(0x10, 0x02, offset, buf); aim_writeshort(bart_type, offset, buf); // BART id aim_writeshort(avatar_size, offset, buf); aim_writegeneric(avatar_size, avatar, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_authkey_request(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char *buf = (char*)alloca(SNAC_SIZE + TLV_HEADER_SIZE * 3 + mir_strlen(m_username)); aim_writesnac(0x17, 0x06, offset, buf); aim_writetlv(0x01, (unsigned short)mir_strlen(m_username), m_username, offset, buf); aim_writetlv(0x4B, 0, 0, offset, buf); aim_writetlv(0x5A, 0, 0, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_new_service_request(HANDLE hServerConn, unsigned short &seqno, unsigned short service) { unsigned short offset = 0; char buf[SNAC_SIZE + 2 + TLV_HEADER_SIZE]; aim_writesnac(0x01, 0x04, offset, buf); aim_writeshort(service, offset, buf); if (!getByte(AIM_KEY_DSSL, 0)) aim_writetlv(0x8c, 0, NULL, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_query_profile(HANDLE hServerConn, unsigned short &seqno, char* sn) { unsigned short offset = 0; unsigned short sn_length = (unsigned short)mir_strlen(sn); char* buf = (char*)alloca(SNAC_SIZE + 5 + sn_length); aim_writesnac(0x02, 0x15, offset, buf); aim_writelong(0x01, offset, buf); aim_writechar((unsigned char)sn_length, offset, buf); aim_writegeneric(sn_length, sn, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno) == 0; }
int CAimProto::aim_admin_ready(HANDLE hServerConn, unsigned short &seqno) { unsigned short offset = 0; char buf[SNAC_SIZE + TLV_HEADER_SIZE * 4]; aim_writesnac(0x01, 0x02, offset, buf); aim_writefamily(AIM_SERVICE_GENERIC, offset, buf); aim_writegeneric(4, AIM_TOOL_VERSION, offset, buf); aim_writefamily(AIM_SERVICE_ADMIN, offset, buf); aim_writegeneric(4, AIM_TOOL_VERSION, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
int CAimProto::aim_admin_change_password(HANDLE hServerConn, unsigned short &seqno, const char* cur_pw, const char* new_pw) { unsigned short offset = 0; unsigned short cur_pw_len = (unsigned short)mir_strlen(cur_pw); unsigned short new_pw_len = (unsigned short)mir_strlen(new_pw); char* buf = (char*)alloca(SNAC_SIZE + 2 * TLV_HEADER_SIZE + cur_pw_len + new_pw_len); aim_writesnac(0x07, 0x04, offset, buf); aim_writetlv(0x02, new_pw_len, new_pw, offset, buf); aim_writetlv(0x12, cur_pw_len, cur_pw, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }
void CAimProto::shutdown_chat_conn(void) { for(int i=0; i<chat_rooms.getCount(); ++i) { chat_list_item& item = chat_rooms[i]; if (item.hconn) { aim_sendflap(item.hconn,0x04,0,NULL,item.seqno); Netlib_Shutdown(item.hconn); } } }
int CAimProto::aim_request_avatar(HANDLE hServerConn, unsigned short &seqno, const char* sn, unsigned short bart_type, const char* hash, unsigned short hash_size) { unsigned short offset = 0; unsigned char sn_length = (unsigned char)mir_strlen(sn); char* buf = (char*)alloca(SNAC_SIZE + sn_length + hash_size + 12); aim_writesnac(0x10, 0x06, offset, buf); aim_writechar(sn_length, offset, buf); // screen name length aim_writegeneric(sn_length, sn, offset, buf); // screen name aim_writechar(1, offset, buf); // number of BART ID aim_writebartid(bart_type, 0, hash_size, hash, offset, buf); return aim_sendflap(hServerConn, 0x02, offset, buf, seqno); }