diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 17:46:05 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 17:46:05 +0000 |
commit | ab46b98479555c7106087f7d62b6c89f320ca311 (patch) | |
tree | e245d3dce9dfabbeb47aaff36135089613abe026 /protocols | |
parent | af54e11be6c1c3c997baae19f9d81526d96cd2aa (diff) |
Steam:
- attempt to fix numerous crashes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15365 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Steam/src/http_request.h | 7 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 35 | ||||
-rw-r--r-- | protocols/Steam/src/steam_dialogs.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_login.cpp | 15 | ||||
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 37 | ||||
-rw-r--r-- | protocols/Steam/src/steam_pooling.cpp | 2 |
6 files changed, 50 insertions, 50 deletions
diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 126aa857f0..3e91209907 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -152,5 +152,12 @@ public: };
+bool __forceinline ResponseHttpOk(const NETLIBHTTPREQUEST *response) {
+ return (response && response->pData && (response->resultCode == HTTP_CODE_OK));
+}
+
+bool __forceinline CheckResponse(const NETLIBHTTPREQUEST *response) {
+ return (response && response->pData);
+}
#endif //_HTTP_REQUEST_H_
\ No newline at end of file diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 03acc8a65f..4d1a2bc498 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -96,10 +96,8 @@ MCONTACT CSteamProto::FindContact(const char *steamId) void CSteamProto::UpdateContact(MCONTACT hContact, JSONNode *data) { - JSONNode *node = NULL; - // set common data - node = json_get(data, "personaname"); + JSONNode *node = json_get(data, "personaname"); setTString(hContact, "Nick", ptrT(json_as_string(node))); node = json_get(data, "profileurl"); @@ -189,19 +187,24 @@ void CSteamProto::UpdateContact(MCONTACT hContact, JSONNode *data) WORD status = getWord(hContact, "Status", ID_STATUS_OFFLINE); if (status == ID_STATUS_ONLINE || status == ID_STATUS_OUTTOLUNCH || status == ID_STATUS_FREECHAT) setTString(hContact, "MirVer", _T("Steam")); - } else if (stateflags & 2) { + } + else if (stateflags & 2) { // game setTString(hContact, "MirVer", _T("Steam (in game)")); - } else if (stateflags & 256) { + } + else if (stateflags & 256) { // on website setTString(hContact, "MirVer", _T("Steam (website)")); - } else if (stateflags & 512) { + } + else if (stateflags & 512) { // on mobile setTString(hContact, "MirVer", _T("Steam (mobile)")); - } else if (stateflags & 1024) { + } + else if (stateflags & 1024) { // big picture mode setTString(hContact, "MirVer", _T("Steam (Big Picture)")); - } else { + } + else { // none/unknown (e.g. when contact is offline) delSetting(hContact, "MirVer"); } @@ -357,7 +360,7 @@ void CSteamProto::ProcessContact(std::map<std::string, JSONNode*>::iterator *it, void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response) { - if (!response) + if (!CheckResponse(response)) return; JSONROOT root(response->pData); @@ -442,7 +445,7 @@ void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response) void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response) { - if (!response) + if (!CheckResponse(response)) return; JSONROOT root(response->pData); @@ -486,7 +489,7 @@ void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response) void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response) { - if (!response) + if (!CheckResponse(response)) return; JSONROOT root(response->pData); @@ -525,7 +528,7 @@ void CSteamProto::OnGotAvatar(const NETLIBHTTPREQUEST *response, void *arg) ai.hContact = (UINT_PTR)arg; GetDbAvatarInfo(ai); - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { ptrA steamId(getStringA(ai.hContact, "SteamID")); debugLogA("CSteamProto::OnGotAvatar: failed to get avatar %s", steamId); @@ -592,7 +595,7 @@ void CSteamProto::OnFriendRemoved(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) { - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { debugLogA("CSteamProto::OnAuthRequested: failed to request info for %s", (char*)arg); return; @@ -656,7 +659,7 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnPendingApproved(const NETLIBHTTPREQUEST *response, void *arg) { - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { debugLogA("CSteamProto::OnPendingApproved: failed to approve pending from %s", (char*)arg); return; @@ -676,7 +679,7 @@ void CSteamProto::OnPendingApproved(const NETLIBHTTPREQUEST *response, void *arg void CSteamProto::OnPendingIgnoreded(const NETLIBHTTPREQUEST *response, void *arg) { - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { debugLogA("CSteamProto::OnPendingApproved: failed to ignore pending from %s", (char*)arg); return; @@ -696,7 +699,7 @@ void CSteamProto::OnPendingIgnoreded(const NETLIBHTTPREQUEST *response, void *ar void CSteamProto::OnSearchByIdEnded(const NETLIBHTTPREQUEST *response, void *arg) { - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)STEAM_SEARCH_BYID, 0); debugLogA("CSteamProto::OnSearchByIdEnded: failed to get summaries for %s", (char*)arg); diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index 116d0a48bc..6ea6aecd28 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -21,11 +21,11 @@ void CSteamPasswordEditor::OnInitDialog() void CSteamPasswordEditor::OnOk(CCtrlButton*)
{
- if (m_savePermanently.Enabled())
- m_proto->setTString("Password", m_password.GetText());
if (m_proto->password != NULL)
mir_free(m_proto->password);
m_proto->password = m_password.GetText();
+ if (m_savePermanently.Enabled())
+ m_proto->setTString("Password", m_proto->password);
EndDialog(m_hwnd, 1);
}
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp index 771051a68b..b54149b03c 100644 --- a/protocols/Steam/src/steam_login.cpp +++ b/protocols/Steam/src/steam_login.cpp @@ -16,10 +16,7 @@ bool CSteamProto::IsMe(const char *steamId) void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response)
{
- if (!response)
- return;
-
- if (!response->pData)
+ if (!CheckResponse(response))
return;
// load rsa key parts
@@ -78,13 +75,7 @@ void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response) void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response)
{
- if (!response)
- {
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- if (!response->pData)
+ if (!CheckResponse(response))
{
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -269,7 +260,7 @@ void CSteamProto::HandleTokenExpired() void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response)
{
- if (!response)
+ if (!CheckResponse(response))
{
// Probably timeout or no connection, we can do nothing here
SetStatus(ID_STATUS_OFFLINE);
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index c8a1813b84..5ba4a4f139 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -16,21 +16,21 @@ void MessageParamFree(void *arg) int CSteamProto::OnSendMessage(MCONTACT hContact, const char* message)
{
- UINT hMessage = InterlockedIncrement(&hMessageProcess); - - SendMessageParam *param = (SendMessageParam*)mir_calloc(sizeof(SendMessageParam)); - param->hContact = hContact; - param->hMessage = (HANDLE)hMessage; - param->message = mir_strdup(message); - - ptrA token(getStringA("TokenSecret")); - ptrA umqid(getStringA("UMQID")); - ptrA steamId(getStringA(hContact, "SteamID")); - PushRequest( - new SendMessageRequest(token, umqid, steamId, message), - &CSteamProto::OnMessageSent, - param, MessageParamFree); - + UINT hMessage = InterlockedIncrement(&hMessageProcess);
+
+ SendMessageParam *param = (SendMessageParam*)mir_calloc(sizeof(SendMessageParam));
+ param->hContact = hContact;
+ param->hMessage = (HANDLE)hMessage;
+ param->message = mir_strdup(message);
+
+ ptrA token(getStringA("TokenSecret"));
+ ptrA umqid(getStringA("UMQID"));
+ ptrA steamId(getStringA(hContact, "SteamID"));
+ PushRequest(
+ new SendMessageRequest(token, umqid, steamId, message),
+ &CSteamProto::OnMessageSent,
+ param, MessageParamFree);
+
return hMessage;
}
@@ -41,7 +41,7 @@ void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) ptrT error(mir_tstrdup(TranslateT("Unknown error")));
ptrT steamId(getTStringA(param->hContact, "SteamID"));
- if (response && response->resultCode == HTTP_CODE_OK)
+ if (ResponseHttpOk(response))
{
JSONROOT root(response->pData);
JSONNode *node = json_get(root, "error");
@@ -54,8 +54,7 @@ void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) ptrA errorA(mir_t2a(error));
debugLogA("CSteamProto::OnMessageSent: failed to send message for %s (%s)", steamId, errorA);
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, (LPARAM)errorA);
- return;
}
-
- ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hMessage, 0);
+ else
+ ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hMessage, 0);
}
\ No newline at end of file diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 2dee4115d8..32fe85d905 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -180,7 +180,7 @@ void CSteamProto::PollingThread(void*) HttpResponse *response = request->Send(m_hNetlibUser); delete request; - if (!response || response->resultCode != HTTP_CODE_OK) + if (!ResponseHttpOk(response)) { if (response != NULL) delete response; |