summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-12-19 17:05:48 +0000
committerRobert Pösel <robyer@seznam.cz>2015-12-19 17:05:48 +0000
commit96ff0746ac203f99d5e51d720dfbd4baf6fdd766 (patch)
tree6ac5a152da488704250e24c5f5ad76f874ef21c1 /protocols/Steam/src
parent9b76f4f1e734be9cfb8d3cbd2823b668248a3462 (diff)
Steam: Try to login again automatically when our token is expired already at login
git-svn-id: http://svn.miranda-ng.org/main/trunk@15899 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/steam_login.cpp27
-rw-r--r--protocols/Steam/src/steam_proto.cpp4
-rw-r--r--protocols/Steam/src/steam_proto.h1
3 files changed, 26 insertions, 6 deletions
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index 7000a0942d..7bf093951f 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -284,16 +284,31 @@ void CSteamProto::OnGotSession(const HttpResponse *response)
void CSteamProto::HandleTokenExpired()
{
- // Notify error to user
- ShowNotification(_T("Steam"), TranslateT("Connection token expired. Please login again."));
-
// Delete expired token
delSetting("TokenSecret");
- // Set status to offline
- SetStatus(ID_STATUS_OFFLINE);
+ // Try to relogin automatically (but only once)
+ if (isLoginAgain) {
+ // Notify error to user
+ ShowNotification(_T("Steam"), TranslateT("Cannot obtain connection token."));
+
+ // Just go offline; it also resets the isLoginAgain to false
+ SetStatus(ID_STATUS_OFFLINE);
+ }
+ else
+ {
+ // Remember we are trying to relogin
+ isLoginAgain = true;
+
+ // Remember status user wanted
+ int desiredStatus = m_iDesiredStatus;
- // TODO: Try to login again acutomatically (at least once)
+ // Set status to offline
+ SetStatus(ID_STATUS_OFFLINE);
+
+ // Try to login again automatically
+ SetStatus(desiredStatus);
+ }
}
void CSteamProto::OnLoggedOn(const HttpResponse *response)
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index d4364da17f..2656442ad8 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -8,6 +8,7 @@ CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName)
m_idleTS = 0;
isTerminated = false;
+ isLoginAgain = false;
m_hQueueThread = NULL;
m_pollingConnection = NULL;
m_hPollingThread = NULL;
@@ -282,6 +283,9 @@ int CSteamProto::SetStatus(int new_status)
if (new_status == ID_STATUS_OFFLINE)
{
+ // Reset relogin flag
+ isLoginAgain = false;
+
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 650675edfd..34eafd3d7d 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -73,6 +73,7 @@ public:
protected:
TCHAR *password;
bool isTerminated;
+ bool isLoginAgain;
time_t m_idleTS;
HANDLE m_evRequestsQueue, m_hQueueThread;
HANDLE m_pollingConnection, m_hPollingThread;