summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_thread.cpp
blob: 42b2af3903d465cf8170777204025540487fb46a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "common.h"

int SteamToMirandaStatus(int state)
{
	switch (state)
	{
	case 0: //Offline
		return ID_STATUS_OFFLINE;
	case 2: //Busy
		return ID_STATUS_DND;
	case 3: //Away
		return ID_STATUS_AWAY;
		/*case 4: //Snoozing
			prim = PURPLE_STATUS_EXTENDED_AWAY;
			break;
			case 5: //Looking to trade
			return "trade";
			case 6: //Looking to play
			return "play";*/
		//case 1: //Online
	default:
		return ID_STATUS_ONLINE;
	}
}


int CSteamProto::PollStatus()
{
	ptrA steamId(getStringA("SteamID"));
	ptrA sessionId(getStringA("SessionID"));
	ptrA messageId(getStringA("MessageID"));

	SteamWebApi::PollApi::Poll poll;
	SteamWebApi::PollApi::PollStatus(m_hNetlibUser, sessionId, steamId, messageId, &poll);

	if (!poll.IsSuccess())
		return -1;

	//setString

	for (int i = 0; i < poll.GetItemCount(); i++)
	{
		switch (poll[i]->GetType())
		{
		case SteamWebApi::PollApi::POOL_TYPE::TYPING:
			break;

		case SteamWebApi::PollApi::POOL_TYPE::MESSAGE:
			{
				const wchar_t *text = ((SteamWebApi::PollApi::Message*)poll[i])->GetText();
			}
			break;

		case SteamWebApi::PollApi::POOL_TYPE::STATE:
			{
				int status = ((SteamWebApi::PollApi::State*)poll[i])->GetStatus();
				const wchar_t *nickname = ((SteamWebApi::PollApi::State*)poll[i])->GetNickname();
			}
			break;
		}
	}

	return 0;
}

void CSteamProto::PollingThread(void*)
{
	debugLogA("CSteamProto::PollingThread: entering");

	while (!m_bTerminated)
		if (PollStatus() == -1)
			break;

	m_hPollingThread = NULL;
	debugLogA("CSteamProto::PollingThread: leaving");
}