forked from luigoalma/ctrcdnfetch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCDN.hpp
82 lines (69 loc) · 1.75 KB
/
CDN.hpp
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
#ifndef __CDN_HPP__
#define __CDN_HPP__
#include "DownloadManager.hpp"
#include "Ticket.hpp"
#include "types.h"
namespace NintendoData
{
class CDN
{
private:
Ticket tik;
DownloadManager manager;
u16 version;
bool set_version;
bool nodownload;
public:
template<typename... Args> CDN& SetProxy(const char* str, Args... args) noexcept
{
manager.SetAttribute(DownloadManager::PROXY, str, args...);
return *this;
}
CDN& SetProgressFunction(::DownloadManager::progress_func func) noexcept
{
manager.SetAttribute(func);
return *this;
}
CDN& SetExtraProgressPtr(void* extra) noexcept
{
manager.SetAttribute(extra);
return *this;
}
CDN& SetHeaderPrint(bool printheaders) noexcept
{
manager.SetAttribute(DownloadManager::PRINTHEADER, printheaders);
return *this;
}
CDN& SetHashesPrint(bool printhashes) noexcept
{
manager.SetAttribute(DownloadManager::PRINTHASHES, printhashes);
return *this;
}
CDN& SetNoDownload(bool nodownload) noexcept
{
this->nodownload = nodownload;
if (nodownload) SetHeaderPrint(true);
return *this;
}
CDN& SetVersion(u16 version) noexcept
{
this->version = version;
this->set_version = true;
return *this;
}
u64 GetTitleId() const noexcept { return tik.TitleID(); }
void Download(const char* outdir, bool write_opt_files);
private:
void Init()
{
manager
.SetAttribute(DownloadManager::HEADER, "Accept:")
.SetAttribute(DownloadManager::HEADER, "Connection: Keep-Alive");
}
public:
CDN(const Ticket& ticket) : tik(ticket, true), set_version(false), nodownload(false) { Init(); }
CDN(const void* ticket, size_t ticketlen) : tik(ticket, ticketlen, true), set_version(false), nodownload(false) { Init(); }
~CDN() noexcept { }
};
}
#endif