summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-05-26 17:49:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-05-26 17:49:34 +0300
commit0bbad6b41fa7e5530d996194873e424962a54bac (patch)
treedaf0179865bb07a4ae0ba1723e7ec2cf43f69474 /protocols/Steam/src
parent5ebba85de37a0aaaa0732fe6307fcf8de9010fea (diff)
Steam:
- final fix for UI dialogs; - major fix for CSteamProto::SetStatus method, not to launch the worker thread in parallel; - code cleaning; - version bump
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/http_request.h102
-rw-r--r--protocols/Steam/src/steam_dialogs.cpp4
-rw-r--r--protocols/Steam/src/steam_login.cpp3
-rw-r--r--protocols/Steam/src/steam_proto.cpp20
-rw-r--r--protocols/Steam/src/version.h6
5 files changed, 69 insertions, 66 deletions
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h
index b7c715ea92..ffc46d8625 100644
--- a/protocols/Steam/src/http_request.h
+++ b/protocols/Steam/src/http_request.h
@@ -277,57 +277,7 @@ enum HttpMethod
HttpPost
};
-class HttpResponse
-{
- friend class HttpRequest;
-
-private:
- NETLIBHTTPREQUEST *m_response;
-
-public:
- HttpRequest *Request;
- HttpHeaders Headers;
- HttpContent Content;
-
- HttpResponse(HttpRequest *request, NETLIBHTTPREQUEST *response) :
- Request(request),
- m_response(response),
- Headers(response),
- Content(response)
- {
- }
-
- ~HttpResponse()
- {
- Netlib_FreeHttpRequest(m_response);
- }
-
- bool operator!() const
- {
- return !m_response || !m_response->pData;
- }
-
- operator bool() const
- {
- return m_response && m_response->pData;
- }
-
- bool IsSuccess() const
- {
- return m_response &&
- m_response->resultCode >= HTTP_CODE_OK &&
- m_response->resultCode <= HTTP_CODE_MULTI_STATUS;
- }
-
- int GetStatusCode() const
- {
- return m_response
- ? m_response->resultCode
- : 0;
- }
-};
-
-class HttpRequest : protected NETLIBHTTPREQUEST, public MZeroedObject
+class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
{
friend class HttpUri;
friend class HttpHeaders;
@@ -382,4 +332,54 @@ public:
}
};
+class HttpResponse
+{
+ friend class HttpRequest;
+
+private:
+ NETLIBHTTPREQUEST *m_response;
+
+public:
+ HttpRequest *Request;
+ HttpHeaders Headers;
+ HttpContent Content;
+
+ HttpResponse(HttpRequest *request, NETLIBHTTPREQUEST *response) :
+ Request(request),
+ m_response(response),
+ Headers(response),
+ Content(response)
+ {
+ }
+
+ ~HttpResponse()
+ {
+ Netlib_FreeHttpRequest(m_response);
+ }
+
+ bool operator!() const
+ {
+ return !m_response || !m_response->pData;
+ }
+
+ operator bool() const
+ {
+ return m_response && m_response->pData;
+ }
+
+ bool IsSuccess() const
+ {
+ return m_response &&
+ m_response->resultCode >= HTTP_CODE_OK &&
+ m_response->resultCode <= HTTP_CODE_MULTI_STATUS;
+ }
+
+ int GetStatusCode() const
+ {
+ if (m_response)
+ return m_response->resultCode;
+ return Request ? Request->resultCode : 0;
+ }
+};
+
#endif //_HTTP_REQUEST_H_ \ No newline at end of file
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp
index 604db1e3e2..3e3fe3b912 100644
--- a/protocols/Steam/src/steam_dialogs.cpp
+++ b/protocols/Steam/src/steam_dialogs.cpp
@@ -25,6 +25,7 @@ bool CSteamPasswordEditor::OnApply()
if (m_savePermanently.Enabled())
m_proto->setWString("Password", m_proto->m_password);
+ EndModal(DIALOG_RESULT_OK);
return true;
}
@@ -62,6 +63,7 @@ bool CSteamGuardDialog::OnInitDialog()
bool CSteamGuardDialog::OnApply()
{
mir_strncpy(m_guardCode, ptrA(m_text.GetTextA()), _countof(m_guardCode));
+ EndModal(DIALOG_RESULT_OK);
return true;
}
@@ -141,7 +143,7 @@ bool CSteamCaptchaDialog::OnInitDialog()
void CSteamCaptchaDialog::OnOk(CCtrlButton*)
{
mir_strncpy(m_captchaText, ptrA(m_text.GetTextA()), _countof(m_captchaText));
- EndDialog(m_hwnd, DIALOG_RESULT_OK);
+ EndModal(DIALOG_RESULT_OK);
}
bool CSteamCaptchaDialog::OnClose()
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index a0d716aa3f..b0bccc5d45 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -38,6 +38,8 @@ void CSteamProto::Logout()
ptrA umqid(getStringA("UMQID"));
SendRequest(new LogoffRequest(token, umqid));
}
+
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iStatus);
}
void CSteamProto::OnGotRsaKey(const JSONNode &root, void *)
@@ -315,7 +317,6 @@ void CSteamProto::HandleTokenExpired()
isLoginAgain = true;
Login();
- return;
}
void CSteamProto::OnLoggedOn(const HttpResponse &response, void *)
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp
index 40d6e8ae09..80e33876b9 100644
--- a/protocols/Steam/src/steam_proto.cpp
+++ b/protocols/Steam/src/steam_proto.cpp
@@ -266,17 +266,16 @@ int CSteamProto::SetStatus(int new_status)
break;
}
- int old_status;
{
mir_cslock lock(m_setStatusLock);
if (new_status == m_iDesiredStatus)
return 0;
+ }
- debugLogA(__FUNCTION__ ": changing status from %i to %i", m_iStatus, new_status);
+ debugLogA(__FUNCTION__ ": changing status from %i to %i", m_iStatus, new_status);
- old_status = m_iStatus;
- m_iDesiredStatus = new_status;
- }
+ int old_status = m_iStatus;
+ m_iDesiredStatus = new_status;
if (new_status == ID_STATUS_OFFLINE) {
// Reset relogin flag
@@ -289,7 +288,7 @@ int CSteamProto::SetStatus(int new_status)
Logout();
}
- else if (old_status == ID_STATUS_OFFLINE) {
+ else if (m_hRequestQueueThread == nullptr && !IsStatusConnecting(m_iStatus)) {
// Load last message timestamp for correct loading of messages history
m_lastMessageTS = getDword("LastMessageTS", 0);
@@ -300,11 +299,12 @@ int CSteamProto::SetStatus(int new_status)
m_hRequestQueueThread = ForkThreadEx(&CSteamProto::RequestQueueThread, nullptr, nullptr);
Login();
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+ }
+ else if (IsOnline()) {
+ m_iStatus = new_status;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
}
- else m_iStatus = new_status;
-
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
-
return 0;
}
diff --git a/protocols/Steam/src/version.h b/protocols/Steam/src/version.h
index f8229c0bed..8602d055cb 100644
--- a/protocols/Steam/src/version.h
+++ b/protocols/Steam/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 11
-#define __RELEASE_NUM 6
-#define __BUILD_NUM 7
+#define __MINOR_VERSION 95
+#define __RELEASE_NUM 12
+#define __BUILD_NUM 1
#include <stdver.h>