-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSteamCloudDownload.cpp
101 lines (84 loc) · 3.12 KB
/
SteamCloudDownload.cpp
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
/*
* This file is part of "Christians-Steam-Framework"
* Copyright (C) 2023- Christian Stieber
*
* 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; either version 3, or (at
* your option) any later version.
*
* 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; see the file LICENSE. If not see
* <http://www.gnu.org/licenses/>.
*/
#include "Modules/UnifiedMessageClient.hpp"
#include "Client/Module.hpp"
#include "Modules/TestModule.hpp"
#include "Asio/HTTPClient.hpp"
#include "UI/UI.hpp"
#include "steamdatabase/protobufs/steam/steammessages_cloud.steamclient.pb.h"
#include <boost/url/url.hpp>
/************************************************************************/
/*
* Note: add these proto files to the CMakeLists:
* list(APPEND protoFiles steam/steammessages_cloud.steamclient)
* list(APPEND protoFiles steam/steammessages_client_objects)
*/
/************************************************************************/
namespace
{
class TestModule : public SteamBot::Client::Module
{
public:
TestModule() =default;
virtual ~TestModule() =default;
virtual void init(SteamBot::Client&) override;
virtual void run(SteamBot::Client&) override;
};
TestModule::Init<TestModule> init;
}
/************************************************************************/
void TestModule::init(SteamBot::Client&)
{
}
/************************************************************************/
/*
* "Proof of concept": download a file from the Steam-Cloud
*/
void TestModule::run(SteamBot::Client&)
{
waitForLogin();
typedef SteamBot::Modules::UnifiedMessageClient::ProtobufService::Info<decltype(&::Cloud::ClientFileDownload)> ClientFileDownloadInfo;
std::shared_ptr<ClientFileDownloadInfo::ResultType> response;
{
ClientFileDownloadInfo::RequestType request;
request.set_appid(7);
request.set_filename("sharedconfig.vdf");
request.set_realm(1);
response=SteamBot::Modules::UnifiedMessageClient::execute<ClientFileDownloadInfo::ResultType>("Cloud.ClientFileDownload#1", std::move(request));
}
std::string url(response->use_https() ? "https://" : "http://");
url+=response->url_host();
url+=response->url_path();
auto query=std::make_unique<SteamBot::HTTPClient::Query>(boost::beast::http::verb::get, boost::urls::url(url));
#if 1
query=SteamBot::HTTPClient::perform(std::move(query));
auto data=SteamBot::HTTPClient::parseString(*query);
SteamBot::UI::OutputText() << data;
#else
SteamBot::UI::OutputText() << query->url;
#endif
while (true)
{
waiter->wait();
}
}
/************************************************************************/
void SteamBot::Modules::TestModule::use()
{
}