summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-08-09 13:19:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-08-09 13:19:04 +0300
commit1b410d8cefa448ee1809bab7c52a3d34383e5df7 (patch)
treedcaf5524946a6417374d498df1631f8f7929efa3
parent651a3529398a341739f71ea0c7f3212555c13949 (diff)
Steam: minor code cleaning
-rw-r--r--protocols/Steam/src/api/friend.h4
-rw-r--r--protocols/Steam/src/api/history.h4
-rw-r--r--protocols/Steam/src/api/poll.h12
-rw-r--r--protocols/Steam/src/http_request.h1
-rw-r--r--protocols/Steam/src/stdafx.h4
-rw-r--r--protocols/Steam/src/steam_contacts.cpp12
-rw-r--r--protocols/Steam/src/steam_polling.cpp31
-rw-r--r--protocols/Steam/src/steam_proto.cpp7
-rw-r--r--protocols/Steam/src/steam_proto.h3
9 files changed, 26 insertions, 52 deletions
diff --git a/protocols/Steam/src/api/friend.h b/protocols/Steam/src/api/friend.h
index 0997d42b0f..2f088a7e40 100644
--- a/protocols/Steam/src/api/friend.h
+++ b/protocols/Steam/src/api/friend.h
@@ -4,11 +4,11 @@
class GetUserSummariesRequest : public HttpRequest
{
public:
- GetUserSummariesRequest(const char *token, const char *steamIds) :
+ GetUserSummariesRequest(CSteamProto *ppro, const char *steamIds) :
HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0002")
{
Uri
- << CHAR_PARAM("access_token", token)
+ << CHAR_PARAM("access_token", ppro->getMStringA("TokenSecret"))
<< CHAR_PARAM("steamids", steamIds);
}
diff --git a/protocols/Steam/src/api/history.h b/protocols/Steam/src/api/history.h
index 0eaea38fb1..decbea87f0 100644
--- a/protocols/Steam/src/api/history.h
+++ b/protocols/Steam/src/api/history.h
@@ -4,10 +4,10 @@
class GetConversationsRequest : public HttpRequest
{
public:
- GetConversationsRequest(const char *token) :
+ GetConversationsRequest(CSteamProto *ppro) :
HttpRequest(HttpGet, STEAM_API_URL "/IFriendMessagesService/GetActiveMessageSessions/v0001")
{
- Uri << CHAR_PARAM("access_token", token);
+ Uri << CHAR_PARAM("access_token", ppro->getMStringA("TokenSecret"));
}
//{
diff --git a/protocols/Steam/src/api/poll.h b/protocols/Steam/src/api/poll.h
index 6336b212e9..0487411c6c 100644
--- a/protocols/Steam/src/api/poll.h
+++ b/protocols/Steam/src/api/poll.h
@@ -4,8 +4,8 @@
class PollRequest : public HttpRequest
{
public:
- PollRequest(const char *token, const char *umqId, UINT32 messageId, int idleSeconds) :
- HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001")
+ PollRequest(CSteamProto *ppro) :
+ HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v1")
{
timeout = (STEAM_API_TIMEOUT + 5) * 1000;
// flags |= NLHRF_PERSISTENT;
@@ -13,10 +13,10 @@ public:
Headers << CHAR_PARAM("Connection", "keep-alive");
Content = new FormUrlEncodedContent(this)
- << CHAR_PARAM("access_token", token)
- << CHAR_PARAM("umqid", umqId)
- << INT64_PARAM("message", messageId)
- << INT_PARAM("secidletime", idleSeconds)
+ << CHAR_PARAM("access_token", ppro->getMStringA("TokenSecret"))
+ << CHAR_PARAM("umqid", ppro->getMStringA("UMQID"))
+ << INT64_PARAM("message", ppro->getDword("MessageID"))
+ << INT_PARAM("secidletime", ppro->IdleSeconds())
<< INT_PARAM("sectimeout", STEAM_API_TIMEOUT);
}
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h
index ffc46d8625..a8338ff60f 100644
--- a/protocols/Steam/src/http_request.h
+++ b/protocols/Steam/src/http_request.h
@@ -336,7 +336,6 @@ class HttpResponse
{
friend class HttpRequest;
-private:
NETLIBHTTPREQUEST *m_response;
public:
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h
index a3ce6ef4b7..cf702499fb 100644
--- a/protocols/Steam/src/stdafx.h
+++ b/protocols/Steam/src/stdafx.h
@@ -64,7 +64,10 @@ extern HANDLE hExtraXStatus;
#include "steam_dialogs.h"
#include "steam_options.h"
#include "http_request.h"
+
#include "api/enums.h"
+#include "steam_proto.h"
+
#include "api/app_info.h"
#include "api/authorization.h"
#include "api/authorization.h"
@@ -80,6 +83,5 @@ extern HANDLE hExtraXStatus;
#include "api/rsa_key.h"
#include "api/search.h"
#include "api/session.h"
-#include "steam_proto.h"
#endif //_COMMON_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index ea2b121601..a52d2ed3a7 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -295,8 +295,7 @@ void CSteamProto::ContactIsAskingAuth(MCONTACT hContact)
// create auth request event
ptrA steamId(getUStringA(hContact, "SteamID"));
- ptrA token(getUStringA("TokenSecret"));
- SendRequest(new GetUserSummariesRequest(token, steamId), &CSteamProto::OnGotUserSummaries);
+ SendRequest(new GetUserSummariesRequest(this, steamId), &CSteamProto::OnGotUserSummaries);
ptrA nickName(getUStringA(hContact, "Nick"));
if (nickName == nullptr)
@@ -438,13 +437,11 @@ void CSteamProto::OnGotFriendList(const JSONNode &root, void *)
}
friendsMap.clear();
- ptrA token(getStringA("TokenSecret"));
-
if (!steamIds.empty())
- PushRequest(new GetUserSummariesRequest(token, steamIds.c_str()), &CSteamProto::OnGotUserSummaries);
+ PushRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnGotUserSummaries);
// Load last conversations
- PushRequest(new GetConversationsRequest(token), &CSteamProto::OnGotConversations);
+ PushRequest(new GetConversationsRequest(this), &CSteamProto::OnGotConversations);
}
void CSteamProto::OnGotBlockList(const JSONNode &root, void *)
@@ -731,6 +728,5 @@ void CSteamProto::OnSearchByNameStarted(const HttpResponse &response, void *arg)
// remove trailing ","
steamIds.pop_back();
- ptrA token(getStringA("TokenSecret"));
- PushRequest(new GetUserSummariesRequest(token, steamIds.c_str()), &CSteamProto::OnSearchResults, (HANDLE)arg);
+ PushRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnSearchResults, (HANDLE)arg);
}
diff --git a/protocols/Steam/src/steam_polling.cpp b/protocols/Steam/src/steam_polling.cpp
index 299b79c1a1..dd37ce9409 100644
--- a/protocols/Steam/src/steam_polling.cpp
+++ b/protocols/Steam/src/steam_polling.cpp
@@ -36,7 +36,6 @@ void CSteamProto::ParsePollData(const JSONNode &data)
ContactIsFriend(hContact);
break;
}
-
continue;
}
@@ -52,7 +51,6 @@ void CSteamProto::ParsePollData(const JSONNode &data)
recv.szMessage = (char*)text.c_str();
recv.flags = PREF_SENT;
RecvMsg(hContact, &recv);
-
continue;
}
@@ -66,7 +64,6 @@ void CSteamProto::ParsePollData(const JSONNode &data)
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
m_typingTimestamps[steamId] = 0;
-
continue;
}
@@ -78,7 +75,6 @@ void CSteamProto::ParsePollData(const JSONNode &data)
}
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)STEAM_TYPING_TIME);
m_typingTimestamps[steamId] = timestamp;
-
continue;
}
@@ -92,7 +88,6 @@ void CSteamProto::ParsePollData(const JSONNode &data)
}
}
steamIds.append(steamId).append(",");
-
continue;
}
@@ -109,21 +104,16 @@ void CSteamProto::ParsePollData(const JSONNode &data)
dbei.timestamp = now();
dbei.szModule = m_szModuleName;
db_event_add(hContact, &dbei);
-
continue;
}
debugLogA(__FUNCTION__ ": Unknown event type \"%s\"", type.c_str());
}
- if (steamIds.empty())
- return;
-
- steamIds.pop_back();
- ptrA token(getStringA("TokenSecret"));
- PushRequest(
- new GetUserSummariesRequest(token, steamIds.c_str()),
- &CSteamProto::OnGotUserSummaries);
+ if (!steamIds.empty()) {
+ steamIds.pop_back();
+ PushRequest(new GetUserSummariesRequest(this, steamIds.c_str()), &CSteamProto::OnGotUserSummaries);
+ }
}
struct PollParam
@@ -201,9 +191,6 @@ void CSteamProto::OnGotPoll(const HttpResponse &response, void *arg)
// Reset error counter only when we've got OK
param->errors = 0;
-
- // m_pollingConnection = response->nlc;
-
return;
}
@@ -230,17 +217,11 @@ void CSteamProto::PollingThread(void*)
{
debugLogA(__FUNCTION__ ": entering");
- ptrA token(getStringA("TokenSecret"));
-
PollParam param;
param.errors = 0;
param.errorsLimit = getByte("PollingErrorsLimit", STEAM_API_POLLING_ERRORS_LIMIT);
- while (IsOnline() && param.errors < param.errorsLimit) {
- // request->nlc = m_pollingConnection;
- ptrA umqId(getStringA("UMQID"));
- UINT32 messageId = getDword("MessageID", 0);
- SendRequest(new PollRequest(token, umqId, messageId, IdleSeconds()), &CSteamProto::OnGotPoll, &param);
- }
+ while (IsOnline() && param.errors < param.errorsLimit)
+ SendRequest(new PollRequest(this), &CSteamProto::OnGotPoll, &param);
if (IsOnline()) {
debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 463196b604..445a0b94db 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -206,13 +206,8 @@ HANDLE CSteamProto::SearchBasic(const wchar_t* id)
if (!this->IsOnline())
return nullptr;
- ptrA token(getStringA("TokenSecret"));
ptrA steamId(mir_u2a(id));
-
- PushRequest(
- new GetUserSummariesRequest(token, steamId),
- &CSteamProto::OnSearchResults,
- (HANDLE)STEAM_SEARCH_BYID);
+ PushRequest(new GetUserSummariesRequest(this, steamId), &CSteamProto::OnSearchResults, (HANDLE)STEAM_SEARCH_BYID);
return (HANDLE)STEAM_SEARCH_BYID;
}
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 3df953c975..76a2d57789 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -55,6 +55,7 @@ class CSteamProto : public PROTO<CSteamProto>
friend class CSteamPasswordEditor;
friend class CSteamOptionsMain;
friend class CSteamOptionsBlockList;
+ friend class PollRequest;
ptrW m_password;
ptrW m_defaultGroup;
@@ -69,7 +70,7 @@ class CSteamProto : public PROTO<CSteamProto>
HANDLE m_hRequestQueueThread;
LIST<RequestQueueItem> m_requestQueue;
- // pooling
+ // polling
HANDLE m_hPollingThread;
ULONG hAuthProcess;
ULONG hMessageProcess;