forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSFSClient.cpp
More file actions
57 lines (47 loc) · 1.72 KB
/
Copy pathSFSClient.cpp
File metadata and controls
57 lines (47 loc) · 1.72 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "SFSClient.h"
#include "details/ErrorHandling.h"
#include "details/ReportingHandler.h"
#include "details/SFSClientImpl.h"
#include "details/connection/CurlConnectionManager.h"
using namespace SFS;
using namespace SFS::details;
// Defining the constructor and destructor here allows us to use a unique_ptr to SFSClientImpl in the header file
SFSClient::SFSClient() noexcept = default;
SFSClient::~SFSClient() noexcept = default;
Result SFSClient::Make(ClientConfig config, std::unique_ptr<SFSClient>& out) noexcept
try
{
out.reset();
std::unique_ptr<SFSClient> tmp(new SFSClient());
tmp->m_impl = std::make_unique<details::SFSClientImpl<CurlConnectionManager>>(std::move(config));
out = std::move(tmp);
LOG_INFO(out->m_impl->GetReportingHandler(), "SFSClient instance created successfully. Version: %s", GetVersion());
return Result::Success;
}
SFS_CATCH_RETURN()
Result SFSClient::GetLatestDownloadInfo(const RequestParams& requestParams,
std::vector<Content>& contents) const noexcept
try
{
contents = m_impl->GetLatestDownloadInfo(requestParams);
return Result::Success;
}
SFS_CATCH_RETURN()
Result SFSClient::GetLatestAppDownloadInfo(const RequestParams& requestParams,
std::vector<AppContent>& contents) const noexcept
try
{
contents = m_impl->GetLatestAppDownloadInfo(requestParams);
return Result::Success;
}
SFS_CATCH_RETURN()
const char* SFSClient::GetVersion() noexcept
{
#ifdef SFS_GIT_INFO
return SFS_VERSION " (" SFS_GIT_INFO ")";
#else
return SFS_VERSION;
#endif
}