From 96ff0746ac203f99d5e51d720dfbd4baf6fdd766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sat, 19 Dec 2015 17:05:48 +0000 Subject: 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 --- protocols/Steam/src/steam_login.cpp | 27 +++++++++++++++++++++------ protocols/Steam/src/steam_proto.cpp | 4 ++++ protocols/Steam/src/steam_proto.h | 1 + 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'protocols/Steam/src') 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; -- cgit v1.2.3