From f2b7e7d868befc34325998e851eda7bea3467234 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 11 Apr 2014 07:41:32 +0000 Subject: Steam: - added logging - minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@8951 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Steam/src/Steam/authorization.h | 3 +- protocols/Steam/src/Steam/avatar.h | 3 +- protocols/Steam/src/Steam/friend.h | 12 ++++- protocols/Steam/src/Steam/friend_list.h | 2 +- protocols/Steam/src/Steam/login.h | 4 +- protocols/Steam/src/Steam/message.h | 6 +-- protocols/Steam/src/Steam/poll.h | 11 ++--- protocols/Steam/src/Steam/rsa_key.h | 2 +- protocols/Steam/src/Steam/search.h | 2 +- protocols/Steam/src/http_request.h | 79 ++++++++++++++++++------------- protocols/Steam/src/steam_account.cpp | 16 +++++-- protocols/Steam/src/steam_contacts.cpp | 33 ++++++++----- protocols/Steam/src/steam_messages.cpp | 2 + protocols/Steam/src/steam_proto.cpp | 2 + protocols/Steam/src/steam_proto.h | 4 +- protocols/Steam/src/steam_thread.cpp | 11 +++-- 16 files changed, 119 insertions(+), 73 deletions(-) (limited to 'protocols') diff --git a/protocols/Steam/src/Steam/authorization.h b/protocols/Steam/src/Steam/authorization.h index 51643d4dc8..2269167bd3 100644 --- a/protocols/Steam/src/Steam/authorization.h +++ b/protocols/Steam/src/Steam/authorization.h @@ -77,8 +77,9 @@ namespace SteamWebApi ptrA(mir_urlEncode(authResult->captcha_text.c_str())), timestamp); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_COM_URL "/mobilelogin/dologin"); + SecureHttpPostRequest request(hConnection, STEAM_COM_URL "/mobilelogin/dologin"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); + request.ResetFlags(NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP); request.SetData(data, strlen(data)); mir_ptr response(request.Send()); diff --git a/protocols/Steam/src/Steam/avatar.h b/protocols/Steam/src/Steam/avatar.h index 3fbccaca99..253e4a3299 100644 --- a/protocols/Steam/src/Steam/avatar.h +++ b/protocols/Steam/src/Steam/avatar.h @@ -31,7 +31,8 @@ namespace SteamWebApi { avatar->success = false; - HttpRequest request(hConnection, REQUEST_GET, avatarUrl); + HttpGetRequest request(hConnection, avatarUrl); + request.ResetFlags(NLHRF_HTTP11 | NLHRF_NODUMP); mir_ptr response(request.Send()); if (!response) diff --git a/protocols/Steam/src/Steam/friend.h b/protocols/Steam/src/Steam/friend.h index 4f95db4cce..27985eca59 100644 --- a/protocols/Steam/src/Steam/friend.h +++ b/protocols/Steam/src/Steam/friend.h @@ -18,6 +18,8 @@ namespace SteamWebApi std::string countryCode; std::string homepage; std::string avatarUrl; + std::wstring gameInfo; + UINT32 gameId; int state; @@ -31,6 +33,8 @@ namespace SteamWebApi const char *GetCountryCode() const { return countryCode.c_str(); } const char *GetHomepage() const { return homepage.c_str(); } const char *GetAvatarUrl() const { return avatarUrl.c_str(); } + const wchar_t *GetGameInfo() const { return gameInfo.c_str(); } + const DWORD GetGameId() const { return gameId; } int GetState() const { return state; } const DWORD GetCreated() const { return created; } const DWORD GetLastEvent() const { return lastEvent; } @@ -52,7 +56,7 @@ namespace SteamWebApi { summaries->success = false; - SecureHttpRequest request(hConnection, REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001"); + SecureHttpGetRequest request(hConnection, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001"); request.AddParameter("access_token", token); request.AddParameter("steamids", steamIds); @@ -106,6 +110,12 @@ namespace SteamWebApi node = json_get(child, "avatarfull"); item->avatarUrl = ptrA(mir_u2a(json_as_string(node))); + node = json_get(child, "gameextrainfo"); + item->gameInfo = json_as_string(node); + + node = json_get(child, "gameid"); + item->gameId = json_as_int(node); + summaries->items.push_back(item); } } diff --git a/protocols/Steam/src/Steam/friend_list.h b/protocols/Steam/src/Steam/friend_list.h index 02faee7ef1..2b283cc0de 100644 --- a/protocols/Steam/src/Steam/friend_list.h +++ b/protocols/Steam/src/Steam/friend_list.h @@ -22,7 +22,7 @@ namespace SteamWebApi { friendList->success = false; - SecureHttpRequest request(hConnection, REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001"); + SecureHttpGetRequest request(hConnection, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001"); request.AddParameter("access_token", token); request.AddParameter("steamid", steamId); diff --git a/protocols/Steam/src/Steam/login.h b/protocols/Steam/src/Steam/login.h index c9a39c8ce4..c77b5afa57 100644 --- a/protocols/Steam/src/Steam/login.h +++ b/protocols/Steam/src/Steam/login.h @@ -29,7 +29,7 @@ namespace SteamWebApi char data[256]; mir_snprintf(data, SIZEOF(data), "access_token=%s", token); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logon/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logon/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data, strlen(data)); @@ -65,7 +65,7 @@ namespace SteamWebApi data.AppendFormat("access_token=%s", token); data.AppendFormat("&umqid=%s", sessionId); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logoff/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logoff/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data.GetBuffer(), data.GetLength()); diff --git a/protocols/Steam/src/Steam/message.h b/protocols/Steam/src/Steam/message.h index 38427d5fcc..4304cda096 100644 --- a/protocols/Steam/src/Steam/message.h +++ b/protocols/Steam/src/Steam/message.h @@ -30,7 +30,7 @@ namespace SteamWebApi sessionId, state); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data, strlen(data)); @@ -56,7 +56,7 @@ namespace SteamWebApi steamId, ptrA(mir_urlEncode(text))); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data, strlen(data)); @@ -92,7 +92,7 @@ namespace SteamWebApi sessionId, steamId); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data, strlen(data)); diff --git a/protocols/Steam/src/Steam/poll.h b/protocols/Steam/src/Steam/poll.h index 6225b5027f..ddf4894fd2 100644 --- a/protocols/Steam/src/Steam/poll.h +++ b/protocols/Steam/src/Steam/poll.h @@ -77,20 +77,20 @@ namespace SteamWebApi const PoolItem *GetAt(int idx) const { return items.at(idx); } }; - static void PollStatus(HANDLE hConnection, const char *token, const char *sessionId, UINT32 messageId, PollResult *pollResult) + static void Poll(HANDLE hConnection, const char *token, const char *sessionId, UINT32 messageId, PollResult *pollResult) { pollResult->success = false; pollResult->need_relogin = false; pollResult->items.clear(); - char data[512]; + char data[256]; mir_snprintf(data, SIZEOF(data), "access_token=%s&umqid=%s&message=%u", token, sessionId, messageId); - SecureHttpRequest request(hConnection, REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001"); + SecureHttpPostRequest request(hConnection, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001"); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.SetData(data, strlen(data)); request.SetTimeout(90000); // may need to encrease timeout - + mir_ptr response(request.Send()); if (!response) return; @@ -108,8 +108,7 @@ namespace SteamWebApi //pollResult->success = true; return; } - else - if (!lstrcmpi(error, L"Timeout")) + else if (!lstrcmpi(error, L"Timeout")) { pollResult->messageId = messageId; pollResult->success = true; diff --git a/protocols/Steam/src/Steam/rsa_key.h b/protocols/Steam/src/Steam/rsa_key.h index 0c56cc26e9..35b2eb6f28 100644 --- a/protocols/Steam/src/Steam/rsa_key.h +++ b/protocols/Steam/src/Steam/rsa_key.h @@ -28,7 +28,7 @@ namespace SteamWebApi ptrA base64Username(mir_urlEncode(ptrA(mir_utf8encodeW(username)))); - SecureHttpRequest request(hConnection, REQUEST_GET, STEAM_COM_URL "/mobilelogin/getrsakey"); + SecureHttpGetRequest request(hConnection, STEAM_COM_URL "/mobilelogin/getrsakey"); request.AddParameter("username", (char*)base64Username); mir_ptr response(request.Send()); diff --git a/protocols/Steam/src/Steam/search.h b/protocols/Steam/src/Steam/search.h index 1f7f5fc020..9ac4afcd4f 100644 --- a/protocols/Steam/src/Steam/search.h +++ b/protocols/Steam/src/Steam/search.h @@ -41,7 +41,7 @@ namespace SteamWebApi // todo: may need to load all results // 15 first at now - SecureHttpRequest request(hConnection, REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/Search/v0001"); + SecureHttpGetRequest request(hConnection, STEAM_API_URL "/ISteamUserOAuth/Search/v0001"); request.AddParameter("access_token", token); request.AddParameter("keywords", ptrA(mir_urlEncode(text))); request.AddParameter("offset=0&count=15&targets=users&fields=all"); diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 47e9acc3d8..fe4d8a2cd2 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -29,11 +29,12 @@ public: dataLength = 0; headersCount = 0; szResultDescr = NULL; - flags = NLHRF_HTTP11; + flags = NLHRF_HTTP11 | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; requestType = request; m_hNetlibUser = hNetlibUser; - m_szUrl = mir_strdup(url); + szUrl = NULL; + m_szUrl = url; AddHeader("User-Agent", "Steam App / Miranda / 0.0.1"); } @@ -49,10 +50,16 @@ public: } mir_free(headers); } + if (szUrl != NULL) + mir_free(szUrl); if (pData != NULL) mir_free(pData); } + void ResetFlags(int newFlags) + { + flags = newFlags; + } void AddHeader(LPCSTR szName, LPCSTR szValue) { @@ -82,34 +89,18 @@ public: void AddParameter(LPCSTR szName, LPCSTR szValue) { - if (m_szUrl.Find('?') == -1) - m_szUrl.AppendFormat("?%s=%s", szName, szValue); + if (m_szUrl.find('?') == -1) + m_szUrl.append("?").append(szName).append("=").append(szValue); else - m_szUrl.AppendFormat("&%s=%s", szName, szValue); + m_szUrl.append("&").append(szName).append("=").append(szValue); } - /*void AddParameter(LPCSTR szName, int value) - { - if (m_szUrl.Find('?') == -1) - m_szUrl.AppendFormat("?%s=%i", szName, value); - else - m_szUrl.AppendFormat("&%s=%i", szName, value); - }*/ - - /*void AddParameter(LPCSTR szName, UINT64 value) - { - if (m_szUrl.Find('?') == -1) - m_szUrl.AppendFormat("?%s=%llu", szName, value); - else - m_szUrl.AppendFormat("&%s=%llu", szName, value); - }*/ - void AddParameter(LPCSTR szValue) { - if (m_szUrl.Find('?') == -1) - m_szUrl.AppendFormat("?%s", szValue); + if (m_szUrl.find('?') == -1) + m_szUrl.append("?").append(szValue); else - m_szUrl.AppendFormat("&%s", szValue); + m_szUrl.append("&").append(szValue); } void SetTimeout(int timeout) @@ -119,30 +110,52 @@ public: NETLIBHTTPREQUEST *Send() { - szUrl = m_szUrl.GetBuffer(); - /*CMStringA message; message.AppendFormat("Send request to %s", szUrl); - CallService(MS_NETLIB_LOG, (WPARAM)m_hNetlibUser, (LPARAM)message.GetBuffer());*/ - return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)this); + szUrl = mir_strdup(m_szUrl.c_str()); + NETLIBHTTPREQUEST *response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)this); + mir_free(szUrl);szUrl = NULL; + return response; + } private: - CMStringA m_szUrl; + std::string m_szUrl; HANDLE m_hNetlibUser; }; -/*class HttpPostRequest : public HttpRequest +class HttpGetRequest : public HttpRequest +{ +public: + HttpGetRequest(HANDLE hNetlibUser, LPCSTR url) : HttpRequest(hNetlibUser, REQUEST_GET, url) { } +}; + +class HttpPostRequest : public HttpRequest { public: HttpPostRequest(HANDLE hNetlibUser, LPCSTR url) : HttpRequest(hNetlibUser, REQUEST_POST, url) { } -};*/ +}; class SecureHttpRequest : public HttpRequest { public: SecureHttpRequest(HANDLE hNetlibUser, int request, LPCSTR url) - : HttpRequest(hNetlibUser, request, url) { - flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND; + : HttpRequest(hNetlibUser, request, url) + { + flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; } }; +class SecureHttpGetRequest : public SecureHttpRequest +{ +public: + SecureHttpGetRequest(HANDLE hNetlibUser, LPCSTR url) + : SecureHttpRequest(hNetlibUser, REQUEST_GET, url) { } +}; + +class SecureHttpPostRequest : public SecureHttpRequest +{ +public: + SecureHttpPostRequest(HANDLE hNetlibUser, LPCSTR url) + : SecureHttpRequest(hNetlibUser, REQUEST_POST, url) { } +}; + #endif //_HTTP_REQUEST_H_ \ No newline at end of file diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index a1261291ea..c580efeab0 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -28,6 +28,7 @@ void CSteamProto::SetServerStatusThread(void *arg) m_iDesiredStatus = status; SteamWebApi::MessageApi::SendResult sendResult; + debugLogA("CSteamProto::SetServerStatusThread: call SteamWebApi::MessageApi::SendStatus"); SteamWebApi::MessageApi::SendStatus(m_hNetlibUser, token, sessionId, state, &sendResult); if (sendResult.IsSuccess()) @@ -58,6 +59,7 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul // get rsa public key SteamWebApi::RsaKeyApi::RsaKey rsaKey; + debugLogA("CSteamProto::Authorize: call SteamWebApi::RsaKeyApi::GetRsaKey"); SteamWebApi::RsaKeyApi::GetRsaKey(m_hNetlibUser, username, &rsaKey); if (!rsaKey.IsSuccess()) return; @@ -69,14 +71,14 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul DWORD passwordSize = (DWORD)strlen(password); if ((error = RsaEncrypt(rsaKey, password, passwordSize, NULL, encryptedSize)) != 0) { - debugLogA("CSteamProto::Rsa: encryption error (%lu)", error); + debugLogA("CSteamProto::Authorize: encryption error (%lu)", error); return; } BYTE *encryptedPassword = (BYTE*)mir_calloc(encryptedSize); if ((error = RsaEncrypt(rsaKey, password, passwordSize, encryptedPassword, encryptedSize)) != 0) { - debugLogA("CSteamProto::Rsa: encryption error (%lu)", error); + debugLogA("CSteamProto::Authorize: encryption error (%lu)", error); return; } @@ -84,6 +86,7 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul mir_free(encryptedPassword); // try to authorize + debugLogA("CSteamProto::Authorize: call SteamWebApi::AuthorizationApi::Authorize"); SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, rsaKey.GetTimestamp(), authResult); if (authResult->IsEmailAuthNeeded() || authResult->IsCaptchaNeeded()) { @@ -112,6 +115,7 @@ void CSteamProto::Authorize(SteamWebApi::AuthorizationApi::AuthResult *authResul } // try to authorize with emailauthcode or captcha taxt + debugLogA("CSteamProto::Authorize: call SteamWebApi::AuthorizationApi::Authorize"); SteamWebApi::AuthorizationApi::Authorize(m_hNetlibUser, username, base64RsaEncryptedPassword, rsaKey.GetTimestamp(), authResult); } while (authResult->IsEmailAuthNeeded() || authResult->IsCaptchaNeeded()); } @@ -132,7 +136,7 @@ void CSteamProto::LogInThread(void* param) { // todo: dosplay error message from authResult.GetMessage() //ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); - debugLogA("CSteamProto::Authorize: Error (%s)", authResult.GetMessage()); + debugLogA("CSteamProto::LogInThread: Authorization error (%s)", authResult.GetMessage()); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE); @@ -147,12 +151,13 @@ void CSteamProto::LogInThread(void* param) } SteamWebApi::LoginApi::LoginResult loginResult; + debugLogA("CSteamProto::LogInThread: call SteamWebApi::LoginApi::Logon"); SteamWebApi::LoginApi::Logon(m_hNetlibUser, token, &loginResult); // if some error if (!loginResult.IsSuccess()) { - debugLogA("CSteamProto::Login: Error (%d)", loginResult.GetStatus()); + debugLogA("CSteamProto::LogInThread: Login error (%d)", loginResult.GetStatus()); // token has expired if (loginResult.GetStatus() == HTTP_STATUS_UNAUTHORIZED) @@ -174,7 +179,7 @@ void CSteamProto::LogInThread(void* param) //CSteamProto::SetServerStatusThread((void*)m_iDesiredStatus); // load contact list - LoadContactList(); + LoadContactListThread(NULL); // start pooling thread if (m_hPollingThread == NULL) @@ -193,6 +198,7 @@ void CSteamProto::LogOutThread(void*) Sleep(500); m_bTerminated = false; + debugLogA("CSteamProto::LogOutThread: call SteamWebApi::LoginApi::Logoff"); SteamWebApi::LoginApi::Logoff(m_hNetlibUser, token, sessionId); delSetting("SessionID"); diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index dd461c909c..8742c399d1 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -48,18 +48,20 @@ void CSteamProto::UpdateContact(MCONTACT hContact, const SteamWebApi::FriendApi: // only for contacts if (hContact) { - /*{ - "type": "personastate", - "timestamp" : 130789088, - "utc_timestamp" : 1397151246, - "steamid_from" : "76561198010620323", - "status_flags" : 863, - "persona_state" : 4, - "persona_name" : "necrostorm" - }*/ - - setWord(hContact, "Status", SteamToMirandaStatus(contact->GetState())); + WORD status = SteamToMirandaStatus(contact->GetState()); + setWord(hContact, "Status", status); setDword(hContact, "LastEventDateTS", contact->GetLastEvent()); + + if (status == ID_STATUS_OUTTOLUNCH) + { + db_set_ws(hContact, "CList", "StatusMsg", contact->GetGameInfo()); + setDword(hContact, "GameID", contact->GetGameId()); + } + else + { + db_unset(hContact, "CList", "StatusMsg"); + delSetting(hContact, "GameID"); + } } // set name @@ -84,6 +86,7 @@ void CSteamProto::UpdateContact(MCONTACT hContact, const SteamWebApi::FriendApi: { // todo: need to place in thread SteamWebApi::AvatarApi::Avatar avatar; + debugLogA("CSteamProto::UpdateContact: SteamWebApi::AvatarApi::GetAvatar"); SteamWebApi::AvatarApi::GetAvatar(m_hNetlibUser, contact->GetAvatarUrl(), &avatar); if (avatar.IsSuccess() && avatar.GetDataSize() > 0) @@ -126,6 +129,7 @@ void CSteamProto::UpdateContactsThread(void *arg) ptrA token(getStringA("TokenSecret")); SteamWebApi::FriendApi::Summaries summarues; + debugLogA("CSteamProto::UpdateContactsThread: call SteamWebApi::FriendApi::LoadSummaries"); SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, steamIds, &summarues); if (!summarues.IsSuccess()) @@ -173,12 +177,13 @@ MCONTACT CSteamProto::AddContact(const SteamWebApi::FriendApi::Summary *contact) return hContact; } -void CSteamProto::LoadContactList() +void CSteamProto::LoadContactListThread(void*) { ptrA token(getStringA("TokenSecret")); ptrA steamId(getStringA("SteamID")); SteamWebApi::FriendListApi::FriendList friendList; + debugLogA("CSteamProto::LoadContactListThread: call SteamWebApi::FriendListApi::Load"); SteamWebApi::FriendListApi::Load(m_hNetlibUser, token, steamId, &friendList); if (friendList.IsSuccess()) @@ -199,6 +204,7 @@ void CSteamProto::LoadContactList() if (!newContacts.IsEmpty()) { SteamWebApi::FriendApi::Summaries summaries; + debugLogA("CSteamProto::LoadContactListThread: call SteamWebApi::FriendApi::LoadSummaries"); SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, newContacts, &summaries); if (summaries.IsSuccess()) @@ -221,6 +227,7 @@ void CSteamProto::SearchByIdThread(void* arg) ptrA token(getStringA("TokenSecret")); SteamWebApi::FriendApi::Summaries summarues; + debugLogA("CSteamProto::SearchByIdThread: call SteamWebApi::FriendApi::LoadSummaries"); SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, steamId, &summarues); if (!summarues.IsSuccess()) @@ -268,6 +275,7 @@ void CSteamProto::SearchByNameThread(void* arg) ptrA token(getStringA("TokenSecret")); SteamWebApi::SearchApi::SearchResult searchResult; + debugLogA("CSteamProto::SearchByNameThread: call SteamWebApi::SearchApi::Search"); SteamWebApi::SearchApi::Search(m_hNetlibUser, token, keywords, &searchResult); if (!searchResult.IsSuccess()) @@ -287,6 +295,7 @@ void CSteamProto::SearchByNameThread(void* arg) } SteamWebApi::FriendApi::Summaries summarues; + debugLogA("CSteamProto::SearchByNameThread: call SteamWebApi::FriendApi::LoadSummaries"); SteamWebApi::FriendApi::LoadSummaries(m_hNetlibUser, token, steamIds, &summarues); if (!summarues.IsSuccess()) diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index 144d3d28a2..99d7238936 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -9,6 +9,7 @@ void CSteamProto::SendMessageThread(void *arg) ptrA steamId(getStringA(param->hContact, "SteamID")); SteamWebApi::MessageApi::SendResult sendResult; + debugLogA("CSteamProto::SendMessageThread: call SteamWebApi::PollApi::SteamWebApi::MessageApi::SendMessage"); SteamWebApi::MessageApi::SendMessage(m_hNetlibUser, token, sessionId, steamId, param->text, &sendResult); ProtoBroadcastAck( @@ -30,5 +31,6 @@ void CSteamProto::SendTypingThread(void *arg) ptrA steamId(getStringA(hContact, "SteamID")); SteamWebApi::MessageApi::SendResult sendResult; + debugLogA("CSteamProto::SendTypingThread: call SteamWebApi::PollApi::SteamWebApi::MessageApi::SendMessage"); SteamWebApi::MessageApi::SendTyping(m_hNetlibUser, token, sessionId, steamId, &sendResult); } \ No newline at end of file diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 771d80e96b..02b3fd82f4 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -209,6 +209,8 @@ int __cdecl CSteamProto::SetApparentMode(MCONTACT hContact, int mode) { return 0 int CSteamProto::SetStatus(int new_status) { + debugLogA("CSteamProto::SetStatus: from %i to %i", m_iStatus, new_status); + if (new_status == m_iDesiredStatus) return 0; diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index a4c459bdb9..bc7336dc87 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -100,7 +100,7 @@ protected: static int CompareProtos(const CSteamProto *p1, const CSteamProto *p2); // pooling thread - void PollStatus(const char *sessionId, const char *steamId, UINT32 messageId, SteamWebApi::PollApi::PollResult *pollResult); + void PollServer(const char *sessionId, const char *steamId, UINT32 messageId, SteamWebApi::PollApi::PollResult *pollResult); void __cdecl PollingThread(void*); // account @@ -122,7 +122,7 @@ protected: MCONTACT FindContact(const char *steamId); MCONTACT AddContact(const SteamWebApi::FriendApi::Summary *contact); - void LoadContactList(); + void __cdecl LoadContactListThread(void*); void __cdecl SearchByIdThread(void*); void __cdecl SearchByNameThread(void*); diff --git a/protocols/Steam/src/steam_thread.cpp b/protocols/Steam/src/steam_thread.cpp index c0b410fab0..d7bdd560c6 100644 --- a/protocols/Steam/src/steam_thread.cpp +++ b/protocols/Steam/src/steam_thread.cpp @@ -1,8 +1,9 @@ #include "common.h" -void CSteamProto::PollStatus(const char *token, const char *sessionId, UINT32 messageId, SteamWebApi::PollApi::PollResult *pollResult) +void CSteamProto::PollServer(const char *token, const char *sessionId, UINT32 messageId, SteamWebApi::PollApi::PollResult *pollResult) { - SteamWebApi::PollApi::PollStatus(m_hNetlibUser, token, sessionId, messageId, pollResult); + debugLogA("CSteamProto::PollServer: call SteamWebApi::PollApi::Poll"); + SteamWebApi::PollApi::Poll(m_hNetlibUser, token, sessionId, messageId, pollResult); if (!pollResult->IsSuccess()) return; @@ -90,7 +91,8 @@ void CSteamProto::PollStatus(const char *token, const char *sessionId, UINT32 me } if (!updatedIds.IsEmpty()) - ForkThread(&CSteamProto::UpdateContactsThread, mir_strdup(updatedIds)); + //ForkThread(&CSteamProto::UpdateContactsThread, mir_strdup(updatedIds)); + UpdateContactsThread(mir_strdup(updatedIds)); } void CSteamProto::PollingThread(void*) @@ -104,7 +106,7 @@ void CSteamProto::PollingThread(void*) SteamWebApi::PollApi::PollResult pollResult; while (!m_bTerminated) { - PollStatus(token, sessionId, messageId, &pollResult); + PollServer(token, sessionId, messageId, &pollResult); if (pollResult.IsNeedRelogin()) debugLogA("CSteamProto::PollingThread: need to relogin"); @@ -121,6 +123,7 @@ void CSteamProto::PollingThread(void*) if (!pollResult.IsSuccess()) { + debugLogA("CSteamProto::PollServer: call SteamWebApi::PollApi::Poll"); SetStatus(ID_STATUS_OFFLINE); // token has expired -- cgit v1.2.3