void CMsnProto::MSN_AddAuthRequest(const char *email, const char *nick, const char *reason) { //blob is: UIN=0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ) MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, true); int emaillen = (int)strlen(email); if (nick == NULL) nick = ""; int nicklen = (int)strlen(nick); if (reason == NULL) reason = ""; int reasonlen = (int)strlen(reason); PROTORECVEVENT pre = { 0 }; pre.flags = PREF_UTF; pre.timestamp = (DWORD)time(NULL); pre.lParam = sizeof(DWORD) + sizeof(HANDLE) + nicklen + emaillen + 5 + reasonlen; char* pCurBlob = (char*)alloca(pre.lParam); pre.szMessage = pCurBlob; *(PDWORD)pCurBlob = 0; pCurBlob += sizeof(DWORD); // UID *(PDWORD)pCurBlob = (DWORD)hContact; pCurBlob += sizeof(DWORD); // Contact Handle strcpy(pCurBlob, nick); pCurBlob += nicklen + 1; // Nickname *pCurBlob = '\0'; pCurBlob++; // First Name *pCurBlob = '\0'; pCurBlob++; // Last Name strcpy(pCurBlob, email); pCurBlob += emaillen + 1; // E-mail strcpy(pCurBlob, reason); // Reason ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); }
void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response) { if (response == NULL) return; JSONNode root = JSONNode::parse(response->pData); if (!root) return; const JSONNode &items = root.as_array(); for (size_t i = 0; i < items.size(); i++) { const JSONNode &item = items.at(i); if (!item) break; std::string skypename = item["sender"].as_string(); std::string reason = item["greeting"].as_string(); time_t eventTime = IsoToUnixTime(item["event_time_iso"].as_string().c_str()); MCONTACT hContact = AddContact(skypename.c_str()); if (hContact) { time_t lastEventTime = db_get_dw(hContact, m_szModuleName, "LastAuthRequestTime", 0); if (lastEventTime < eventTime) { db_set_dw(hContact, m_szModuleName, "LastAuthRequestTime", eventTime); delSetting(hContact, "Auth"); DB_AUTH_BLOB blob(hContact, NULL, NULL, NULL, skypename.c_str(), reason.c_str()); PROTORECVEVENT pre = { 0 }; pre.timestamp = time(NULL); pre.lParam = blob.size(); pre.szMessage = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); } } } }