summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_messages.cpp
blob: 80e68ecdc0ed2f7b4c7d1fc6bac799130567ce0d (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
#include "common.h"

void CSteamProto::SendMessageThread(void *arg)
{
	SendMessageParam *param = (SendMessageParam*)arg;

	ptrA token(getStringA("TokenSecret"));
	ptrA umqId(getStringA("UMQID"));
	ptrA steamId(getStringA(param->hContact, "SteamID"));

	SteamWebApi::MessageApi::SendResult sendResult;
	debugLogA("CSteamProto::SendMessageThread: call SteamWebApi::PollApi::SteamWebApi::MessageApi::SendMessage");
	SteamWebApi::MessageApi::SendMessage(m_hNetlibUser, token, umqId, steamId, param->text, &sendResult);

	ProtoBroadcastAck(
		param->hContact,
		ACKTYPE_MESSAGE,
		sendResult.IsSuccess() ? ACKRESULT_SUCCESS : ACKRESULT_FAILED,
		param->hMessage, 0);

	mir_free((void*)param->text);
	mir_free(param);
}

void CSteamProto::SendTypingThread(void *arg)
{
	MCONTACT hContact = (MCONTACT)arg;

	ptrA token(getStringA("TokenSecret"));
	ptrA umqId(getStringA("UMQID"));
	ptrA steamId(getStringA(hContact, "SteamID"));

	SteamWebApi::MessageApi::SendResult sendResult;
	debugLogA("CSteamProto::SendTypingThread: call SteamWebApi::PollApi::SteamWebApi::MessageApi::SendMessage");
	SteamWebApi::MessageApi::SendTyping(m_hNetlibUser, token, umqId, steamId, &sendResult);
}

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

	int status = response->resultCode == HTTP_STATUS_OK ? ACKRESULT_SUCCESS : ACKRESULT_FAILED;

	ProtoBroadcastAck(
		param->hContact,
		ACKTYPE_MESSAGE,
		status,
		param->hMessage, 0);

	mir_free(param);
}