diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-06-03 17:45:05 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-06-03 17:45:05 +0000 |
commit | 4c533c2fd10ff3d0e40ec384f5828c71e8b0e0f8 (patch) | |
tree | 83a04a05dd66c460e72f7f12e51a9de07203ee83 /protocols/Steam | |
parent | b7c991c686cd440cb8b81745ec587fbf29deb97d (diff) |
Steam:
- fixed message sending
- fixed auth request
git-svn-id: http://svn.miranda-ng.org/main/trunk@9406 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam')
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 38 | ||||
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 20 | ||||
-rw-r--r-- | protocols/Steam/src/steam_pooling.cpp | 17 | ||||
-rw-r--r-- | protocols/Steam/src/steam_proto.cpp | 2 |
4 files changed, 59 insertions, 18 deletions
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index f0bf2454ac..c83eeb19d2 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -473,13 +473,17 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) char *nickName = getStringA(hContact, "Nick");
char *firstName = getStringA(hContact, "FirstName");
+ if (firstName == NULL)
+ firstName = mir_strdup("");
char *lastName = getStringA(hContact, "LastName");
+ if (lastName == NULL)
+ lastName = mir_strdup("");
char reason[MAX_PATH];
mir_snprintf(reason, SIZEOF(reason), Translate("%s has added you to his or her Friend List"), nickName);
// blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)
- DWORD cbBlob = (DWORD)(sizeof(DWORD)* 2 + strlen(nickName) + strlen(firstName) + strlen(lastName) + strlen(steamId) + strlen(reason) + 5);
+ DWORD cbBlob = (DWORD)(sizeof(DWORD)* 2 + lstrlenA(nickName) + lstrlenA(firstName) + lstrlenA(lastName) + lstrlenA(steamId) + lstrlenA(reason) + 5);
PBYTE pBlob, pCurBlob;
pCurBlob = pBlob = (PBYTE)mir_alloc(cbBlob);
@@ -489,13 +493,13 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) *((PDWORD)pCurBlob) = (DWORD)hContact;
pCurBlob += sizeof(DWORD);
strcpy((char*)pCurBlob, nickName);
- pCurBlob += strlen(nickName) + 1;
+ pCurBlob += lstrlenA(nickName) + 1;
strcpy((char*)pCurBlob, firstName);
- pCurBlob += strlen(firstName) + 1;
+ pCurBlob += lstrlenA(firstName) + 1;
strcpy((char*)pCurBlob, lastName);
- pCurBlob += strlen(lastName) + 1;
+ pCurBlob += lstrlenA(lastName) + 1;
strcpy((char*)pCurBlob, steamId);
- pCurBlob += strlen(steamId) + 1;
+ pCurBlob += lstrlenA(steamId) + 1;
strcpy((char*)pCurBlob, mir_strdup(reason));
AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), DBEF_UTF, cbBlob, pBlob);
@@ -504,17 +508,35 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnPendingApproved(const NETLIBHTTPREQUEST *response, void *arg)
{
- if (response->resultCode != HTTP_STATUS_OK || lstrcmpiA(response->pData, "true"))
+ if (response == NULL || response->resultCode != HTTP_STATUS_OK)
{
debugLogA("CSteamProto::OnPendingApproved: failed to approve pending from %s", ptrA((char*)arg));
}
+
+ JSONNODE *root = json_parse(response->pData), *node;
+
+ node = json_get(root, "success");
+ if (json_as_int(node) == 0)
+ {
+ node = json_get(root, "error_text");
+ debugLogA("CSteamProto::OnPendingApproved: failed to approve pending from %s (%s)", ptrA((char*)arg), ptrA(mir_utf8encodeW(json_as_string(node))));
+ }
}
void CSteamProto::OnPendingIgnoreded(const NETLIBHTTPREQUEST *response, void *arg)
{
- if (response->resultCode != HTTP_STATUS_OK || lstrcmpiA(response->pData, "true"))
+ if (response == NULL || response->resultCode != HTTP_STATUS_OK)
+ {
+ debugLogA("CSteamProto::OnPendingApproved: failed to ignore pending from %s", ptrA((char*)arg));
+ }
+
+ JSONNODE *root = json_parse(response->pData), *node;
+
+ node = json_get(root, "success");
+ if (json_as_int(node) == 0)
{
- debugLogA("CSteamProto::OnPendingIgnoreded: failed to ignore pending from %s", ptrA((char*)arg));
+ node = json_get(root, "error_text");
+ debugLogA("CSteamProto::OnPendingApproved: failed to ignore pending from %s (%s)", ptrA((char*)arg), ptrA(mir_utf8encodeW(json_as_string(node))));
}
}
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index 80e68ecdc0..c6a06672f3 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -39,7 +39,25 @@ void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) {
SendMessageParam *param = (SendMessageParam*)arg;
- int status = response->resultCode == HTTP_STATUS_OK ? ACKRESULT_SUCCESS : ACKRESULT_FAILED;
+ bool result = false;
+
+ ptrA steamId((char*)arg);
+
+ if (response != NULL && response->resultCode == HTTP_STATUS_OK)
+ {
+ JSONNODE *root = json_parse(response->pData), *node;
+
+ node = json_get(root, "error");
+ ptrA error(mir_utf8encodeW(json_as_string(node)));
+ if (lstrcmpiA(error, "OK") == 0)
+ result = true;
+ else
+ debugLogA("CSteamProto::OnMessageSent: failed to send message for %s (%s)", steamId, error);
+ }
+ else
+ debugLogA("CSteamProto::OnMessageSent: failed to send message for %s", steamId);
+
+ int status = result ? ACKRESULT_SUCCESS : ACKRESULT_FAILED;
ProtoBroadcastAck(
param->hContact,
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 826187c9a4..c6f7c3c747 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -198,16 +198,18 @@ void CSteamProto::ParsePollData(JSONNODE *data) m_iStatus = m_iDesiredStatus = status;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
+
+ continue;
}
- else if(!FindContact(steamId))
- {
- MCONTACT hContact = AddContact(steamId);
+
+ MCONTACT hContact = FindContact(steamId);
+ if (hContact == NULL)
+ hContact = AddContact(steamId);
- setWord(hContact, "Status", status);
+ setWord(hContact, "Status", status);
- node = json_get(item, "persona_name");
- setWString(hContact, "Nick", json_as_string(node));
- }
+ node = json_get(item, "persona_name");
+ setWString(hContact, "Nick", json_as_string(node));
// todo: find difference between state changing and info changing
}
@@ -288,7 +290,6 @@ void CSteamProto::PollingThread(void*) if (!lstrcmpi(error, L"OK"))
{
-
node = json_get(root, "messagelast");
messageId = json_as_int(node);
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 3705916e46..fec169b376 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -299,7 +299,7 @@ int __cdecl CSteamProto::SendMsg(MCONTACT hContact, int flags, const char *msg) ptrA token(getStringA("TokenSecret"));
ptrA umqid(getStringA("UMQID"));
- ptrA steamId(getStringA(hContact, "SteamId"));
+ ptrA steamId(getStringA(hContact, "SteamID"));
PushRequest(
new SteamWebApi::SendMessageRequest(token, umqid, steamId, ptrA(mir_utf8encode(msg))),
|