summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_server.cpp
blob: c0f7e8b7fef56d9deef937c063371ca0e4bb9841 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "stdafx.h"

void CSteamProto::OnGotNotification(const CSteamNotificationNotificationsReceivedNotification &reply, const CMsgProtoBufHeader &hdr)
{
	if (hdr.eresult != 1)
		return;

	debugLogA("got %d notifications", reply.n_notifications);

	for (int i = 0; i < reply.n_notifications; i++) {
		auto *N = reply.notifications[i];
		debugLogA("notification type %d: %s", N->notification_type, N->body_data);
	}
}

/////////////////////////////////////////////////////////////////////////////////////////

void CSteamProto::SendAppInfoRequest(uint32_t appId)
{
	CMsgClientPICSProductInfoRequest__AppInfo appInfo;
	appInfo.appid = appId; appInfo.has_appid = true;
	auto *pInfo = &appInfo;

	CMsgClientPICSProductInfoRequest request;
	request.n_apps = 1;
	request.apps = &pInfo;
	WSSend(EMsg::ClientPICSProductInfoRequest, request);
}

/////////////////////////////////////////////////////////////////////////////////////////

void CSteamProto::SendPersonaStatus(int status)
{
	CMsgClientChangeStatus request;
	request.persona_state = (int)MirandaToSteamState(status); request.has_persona_state = true;
	WSSend(EMsg::ClientChangeStatus, request);
}

/////////////////////////////////////////////////////////////////////////////////////////

void CSteamProto::SendFriendActiveSessions()
{
	CFriendsMessagesGetActiveMessageSessionsRequest request;
	request.has_lastmessage_since = true;
	request.has_only_sessions_with_messages = false; request.only_sessions_with_messages = true;
	WSSendService(FriendGetActiveSessions, request);
}

/////////////////////////////////////////////////////////////////////////////////////////

void CSteamProto::SendUserInfoRequest(uint64_t id)
{
	std::vector<uint64_t> ids;
	ids.push_back(id & 0xFFFFFFFFll);
	SendUserInfoRequest(ids);
}

void CSteamProto::SendUserInfoRequest(const std::vector<uint64_t> &ids)
{
	CMsgClientRequestFriendData request;
	request.persona_state_requested = -1; request.has_persona_state_requested = true;
	request.n_friends = ids.size();
	request.friends = (uint64_t*)&*ids.begin();
	WSSend(EMsg::ClientRequestFriendData, request);
}

void CSteamProto::SendUserAddRequest(uint64_t id)
{
	CMsgClientAddFriend request;
	request.has_steamid_to_add = true; request.steamid_to_add = id;
	WSSend(EMsg::ClientAddFriend, request);
}

void CSteamProto::SendUserRemoveRequest(MCONTACT hContact)
{
	CMsgClientRemoveFriend request;
	request.has_friendid = true; request.friendid = SteamIdToAccountId(GetId(hContact, DBKEY_STEAM_ID));
	WSSend(EMsg::ClientRemoveFriend, request);
}

void CSteamProto::SendUserIgnoreRequest(MCONTACT hContact, bool bIgnore)
{
	MBinBuffer payload;
	payload << m_iSteamId << SteamIdToAccountId(GetId(hContact, DBKEY_STEAM_ID)) << uint8_t(bIgnore);
	WSSendRaw(EMsg::ClientSetIgnoreFriend, payload);
}

void CSteamProto::SendHeartBeat()
{
	CMsgClientHeartBeat packet;
	packet.has_send_reply = true; packet.send_reply = false;
	WSSend(EMsg::ClientHeartBeat, packet);
}

void CSteamProto::SendLogout()
{
	CMsgClientLogOff packet;
	WSSend(EMsg::ClientLogOff, packet);
}