summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_messages.cpp
blob: 5a55919a07f60bd2c24730535826038e91324774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "stdafx.h"

//void CSteamProto::SendTypingThread(void *arg)
//{
//	MCONTACT hContact = (MCONTACT)arg;
//
//	ptrA token(getStringA("TokenSecret"));
//	ptrA umqId(getStringA("UMQID"));
//	ptrA steamId(getStringA(hContact, "SteamID"));
//
//	MessageApi::SendResult sendResult;
//	debugLogA("CSteamProto::SendTypingThread: call PollApi::MessageApi::SendMessage");
//	MessageApi::SendTyping(m_hNetlibUser, token, umqId, steamId, &sendResult);
//}

void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
{
	SendMessageParam *param = (SendMessageParam*)arg;

	ptrT error(mir_tstrdup(TranslateT("Unknown error")));
	ptrT steamId(getTStringA(param->hContact, "SteamID"));

	if (response != NULL && response->resultCode == HTTP_STATUS_OK)
	{
		JSONROOT root(response->pData);
		JSONNODE *node = json_get(root, "error");
		if (node)
			error = json_as_string(node);
	}

	int status = ACKRESULT_FAILED;

	if (!mir_tstrcmpi(error, _T("OK")))
	{
		status = ACKRESULT_SUCCESS;
		error = NULL;
	}
	else
		debugLog(_T("CSteamProto::OnMessageSent: failed to send message for %s (%s)"), steamId, error);

	ptrA errorA(mir_t2a(error));

	ProtoBroadcastAck(
		param->hContact,
		ACKTYPE_MESSAGE,
		status,
		param->hMessage,
		(LPARAM) errorA);
}

void CSteamProto::MessageParamFree(void *arg)
{
	SendMessageParam *param = (SendMessageParam*)arg;
	mir_free(param->message);
	mir_free(param);
}