summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-01-19 23:12:59 +0300
committeraunsane <aunsane@gmail.com>2018-01-19 23:12:59 +0300
commitde12828fb9051fba1db1e4573cff56ee83ab6b1f (patch)
tree697ef72c4472d17d3e91622769e31833458237e8 /protocols/Steam/src
parent014d34c71618f7df1fd5768a1dd88afa293578bb (diff)
Steam: fix annoying auth requests on every relogin
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/steam_contacts.cpp4
-rw-r--r--protocols/Steam/src/steam_options.cpp7
-rw-r--r--protocols/Steam/src/steam_polling.cpp63
3 files changed, 32 insertions, 42 deletions
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index c62b309da6..1375815dda 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -286,9 +286,9 @@ void CSteamProto::ContactIsRemoved(MCONTACT hContact)
void CSteamProto::ContactIsAskingAuth(MCONTACT hContact)
{
- //if (getByte(hContact, "AuthAsked", 0))
+ if (getByte(hContact, "AuthAsked", 0))
// auth request was already showed, do nothing here
- //return;
+ return;
/*if (getByte(hContact, "Auth", 0) == 0) {
// user was just added or he already has authorization, but because we've just got auth request, he was probably deleted and requested again
diff --git a/protocols/Steam/src/steam_options.cpp b/protocols/Steam/src/steam_options.cpp
index e87775e68d..405b15e787 100644
--- a/protocols/Steam/src/steam_options.cpp
+++ b/protocols/Steam/src/steam_options.cpp
@@ -32,19 +32,14 @@ void CSteamOptionsMain::OnApply()
}
if (m_proto->IsOnline())
- {
// may be we should show message box with warning?
m_proto->SetStatus(ID_STATUS_OFFLINE);
- }
- if (m_username.IsChanged())
- {
+ if (m_username.IsChanged()) {
m_proto->delSetting("SteamID");
m_proto->delSetting("TokenSecret");
}
if (m_password.IsChanged())
- {
m_proto->delSetting("TokenSecret");
- }
mir_free(group);
}
diff --git a/protocols/Steam/src/steam_polling.cpp b/protocols/Steam/src/steam_polling.cpp
index 26c5c63e88..b2a85ff670 100644
--- a/protocols/Steam/src/steam_polling.cpp
+++ b/protocols/Steam/src/steam_polling.cpp
@@ -136,28 +136,23 @@ struct PollParam
void CSteamProto::OnGotPoll(const HttpResponse &response, void *arg)
{
PollParam *param = (PollParam*)arg;
- if (!response.IsSuccess())
- {
+ if (!response.IsSuccess()) {
param->errors++;
return;
}
JSONNode root = JSONNode::parse(response.Content);
- if (root.isnull())
- {
+ if (root.isnull()) {
param->errors++;
return;
}
json_string error = root["error"].as_string();
- if (!mir_strcmpi(error.c_str(), "Timeout"))
- {
+ if (error == "Timeout")
// Do nothing as this is not necessarily an error
return;
- }
- if (!mir_strcmpi(error.c_str(), "OK"))
- {
+ if (error == "OK") {
// Remember last message timestamp
time_t timestamp = _wtoi64(root["utc_timestamp"].as_mstring());
if (timestamp > getDword("LastMessageTS", 0))
@@ -173,38 +168,40 @@ void CSteamProto::OnGotPoll(const HttpResponse &response, void *arg)
param->errors = 0;
// m_pollingConnection = response->nlc;
+
+ return;
}
- else if (!mir_strcmpi(error.c_str(), "Not Logged On")) // 'else' below will handle this error, we don't need this particular check right now
- {
+
+ if (error == "Not Logged On") {
+ // 'else' below will handle this error, we don't need this particular check right now
+
// need to relogin
debugLogA(__FUNCTION__ ": Not Logged On");
// try to reconnect only when we're actually online (during normal logout we will still got this error anyway, but in that case our status is already offline)
- if (IsOnline())
- {
+ if (IsOnline()) {
ptrA token(getStringA("TokenSecret"));
SendRequest(
new LogonRequest(token),
&CSteamProto::OnReLogin);
}
+ return;
}
- else
- {
- // something wrong
- debugLogA(__FUNCTION__ ": %s (%d)", error.c_str(), response.GetStatusCode());
-
- // token has expired
- if (response.GetStatusCode() == HTTP_CODE_UNAUTHORIZED)
- delSetting("TokenSecret");
-
- // too low timeout?
- int timeout = root["sectimeout"].as_int();
- if (timeout < STEAM_API_TIMEOUT)
- debugLogA(__FUNCTION__ ": Timeout is too low (%d)", timeout);
-
- // let it jump out of further processing
- param->errors = param->errorsLimit;
- }
+
+ // something wrong
+ debugLogA(__FUNCTION__ ": %s (%d)", error.c_str(), response.GetStatusCode());
+
+ // token has expired
+ if (response.GetStatusCode() == HTTP_CODE_UNAUTHORIZED)
+ delSetting("TokenSecret");
+
+ // too low timeout?
+ int timeout = root["sectimeout"].as_int();
+ if (timeout < STEAM_API_TIMEOUT)
+ debugLogA(__FUNCTION__ ": Timeout is too low (%d)", timeout);
+
+ // let it jump out of further processing
+ param->errors = param->errorsLimit;
}
void CSteamProto::PollingThread(void*)
@@ -216,8 +213,7 @@ void CSteamProto::PollingThread(void*)
PollParam param;
param.errors = 0;
param.errorsLimit = getByte("PollingErrorsLimit", POLLING_ERRORS_LIMIT);
- while (IsOnline() && param.errors < param.errorsLimit)
- {
+ while (IsOnline() && param.errors < param.errorsLimit) {
// request->nlc = m_pollingConnection;
ptrA umqId(getStringA("UMQID"));
UINT32 messageId = getDword("MessageID", 0);
@@ -227,8 +223,7 @@ void CSteamProto::PollingThread(void*)
(void*)&param);
}
- if (IsOnline())
- {
+ if (IsOnline()) {
debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
SetStatus(ID_STATUS_OFFLINE);
}