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

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

	ptrA token(getStringA("TokenSecret"));
	ptrA sessionId(getStringA("SessionID"));
	ptrA steamId(getStringA(param->hContact, "SteamID"));

	SteamWebApi::MessageApi::SendResult sendResult;
	SteamWebApi::MessageApi::SendMessage(m_hNetlibUser, token, sessionId, steamId, param->text, &sendResult);

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

	if (sendResult.IsSuccess())
	{
		DBEVENTINFO dbei = { sizeof(dbei) };
		dbei.szModule = this->m_szModuleName;
		dbei.timestamp = sendResult.GetTimestamp();
		dbei.eventType = EVENTTYPE_MESSAGE;
		dbei.cbBlob = strlen(param->text);
		dbei.pBlob = (BYTE*)param->text;
		dbei.flags = DBEF_UTF | DBEF_SENT;
		
		db_event_add(param->hContact, &dbei);
	}
	
	//mir_free((void*)param->text);
	mir_free(param);
}

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

	ptrA token(getStringA("TokenSecret"));
	ptrA sessionId(getStringA("SessionID"));
	ptrA steamId(getStringA(hContact, "SteamID"));

	SteamWebApi::MessageApi::SendResult sendResult;
	SteamWebApi::MessageApi::SendTyping(m_hNetlibUser, token, sessionId, steamId, &sendResult);
}