void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveMyInfo %d", reply->resultCode); if (reply->resultCode != 200) { ConnectionFailed(LOGINERR_WRONGPASSWORD); return; } JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; for (size_t i = 0; i < json_size(pResponse); i++) { JSONNODE *it = json_at(pResponse, i); LPCSTR id = json_name(it); if (!_stricmp(id, "user_id")) { m_myUserId = json_as_int(it); setDword("ID", m_myUserId); } } OnLoggedIn(); RetrieveUserInfo(m_myUserId); RetrieveFriends(); RetrieveUnreadMessages(); RetrievePollingInfo(); }
void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveMyInfo %d", reply->resultCode); if (reply->resultCode != 200) { ConnectionFailed(LOGINERR_WRONGPASSWORD); return; } JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); if (!jnResponse) return; const JSONNode &jnUser = *(jnResponse.begin()); m_myUserId = jnUser["id"].as_int(); setDword("ID", m_myUserId); OnLoggedIn(); RetrieveUserInfo(m_myUserId); RetrieveUnreadMessages(); RetrieveFriends(); RetrievePollingInfo(); }
int CVkProto::GetInfo(MCONTACT hContact, int) { debugLogA("CVkProto::GetInfo"); LONG userID = getDword(hContact, "ID", -1); if (userID == -1 || userID == VK_FEED_USER) return 1; RetrieveUserInfo(userID); return 0; }
MCONTACT CVkProto::AddToList(int, PROTOSEARCHRESULT* psr) { debugLogA("CVkProto::AddToList"); int uid = _ttoi(psr->id.t); if (!uid) return NULL; MCONTACT hContact = FindUser(uid, true); RetrieveUserInfo(uid); return hContact; }
void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) { debugLogA("CVkProto::OnReceiveUserInfo %d", reply->resultCode); if (reply->resultCode != 200 || !IsOnline()) return; JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); if (!jnResponse) return; const JSONNode &jnUsers = jnResponse["users"]; if (!jnUsers) return; if (!jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0) { RetrieveUsersInfo(true, true); return; } MCONTACT hContact; LIST<void> arContacts(10, PtrKeySortT); for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) if (!isChatRoom(hContact)) arContacts.insert((HANDLE)hContact); for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) { hContact = SetContactInfo((*it)); if (hContact) arContacts.remove((HANDLE)hContact); } if (jnResponse["freeoffline"].as_bool()) for (int i = 0; i < arContacts.getCount(); i++) { hContact = (UINT_PTR)arContacts[i]; LONG userID = getDword(hContact, "ID", -1); if (userID == m_myUserId || userID == VK_FEED_USER) continue; int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE); if ((iContactStatus == ID_STATUS_ONLINE) || (iContactStatus == ID_STATUS_INVISIBLE && time(NULL) - getDword(hContact, "InvisibleTS", 0) >= m_iInvisibleInterval * 60LL)) { setWord(hContact, "Status", ID_STATUS_OFFLINE); SetMirVer(hContact, -1); db_unset(hContact, m_szModuleName, "ListeningTo"); } } arContacts.destroy(); AddFeedSpecialUser(); const JSONNode &jnRequests = jnResponse["requests"]; if (!jnRequests) return; int iCount = jnRequests["count"].as_int(); const JSONNode &jnItems = jnRequests["items"]; if (!iCount || !jnItems) return; debugLogA("CVkProto::OnReceiveUserInfo AuthRequests"); for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { LONG userid = (*it).as_int(); if (userid == 0) break; hContact = FindUser(userid, true); if (!getBool(hContact, "ReqAuth")) { RetrieveUserInfo(userid); setByte(hContact, "ReqAuth", 1); ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)hContact); } } }