Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit f545adc

Browse files
committed
read the url from config.json
1 parent 06ff3f6 commit f545adc

File tree

4 files changed

+13
-45
lines changed

4 files changed

+13
-45
lines changed

Sys-Updater/include/UI/DownloadUpdate.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class DownloadUpdatePage : public brls::View
4040

4141
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
4242
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
43-
void DownloadUpdate(void);
4443
void willAppear(bool resetState = false) override;
4544
void willDisappear(bool resetState = false) override;
4645
};

Sys-Updater/source/UI/DownloadUpdate.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -85,44 +85,6 @@ void DownloadUpdatePage::draw(NVGcontext *vg, int x, int y, unsigned width, unsi
8585
this->label1->frame(ctx);
8686
}
8787

88-
void DownloadUpdatePage::DownloadUpdate(void)
89-
{
90-
Network::Net net = Network::Net();
91-
auto v7 = jso1n["titleids"].get<std::vector<std::string>>();
92-
int n = v7.size();
93-
for (int i = 0; i < n; i++)
94-
{
95-
if (jso1n["programid"][v7[i]].contains("Program") == true)
96-
{
97-
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["Program"].get<std::string>();
98-
brls::Logger::debug(download);
99-
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Program"].get<std::string>() + ".nca";
100-
net.Download(download, out);
101-
}
102-
else if (jso1n["programid"][v7[i]].contains("Data") == true)
103-
{
104-
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["Data"].get<std::string>();
105-
brls::Logger::debug(download);
106-
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Data"].get<std::string>() + ".nca";
107-
net.Download(download, out);
108-
}
109-
else if (jso1n["programid"][v7[i]].contains("PublicData") == true)
110-
{
111-
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["PublicData"].get<std::string>();
112-
brls::Logger::debug(download);
113-
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["PublicData"].get<std::string>() + ".nca";
114-
net.Download(download, out);
115-
}
116-
if (jso1n["programid"][v7[i]].contains("Meta") == true)
117-
{
118-
std::string download = "http://192.168.1.128/c/a/" + jso1n["programid"][v7[i]]["Meta"].get<std::string>();
119-
brls::Logger::debug(download);
120-
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Meta"].get<std::string>() + ".cnmt.nca";
121-
net.Download(download, out);
122-
}
123-
}
124-
}
125-
12688
void DownloadUpdatePage::layout(NVGcontext *vg, brls::Style *style, brls::FontStash *stash)
12789
{
12890
this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth));

Sys-Updater/source/main.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SOFTWARE.*/
3535

3636
using json = nlohmann::json;
3737
json j;
38+
json Conf;
3839
bool onlineupdate = true;
3940

4041
Result Init_Services(void)
@@ -86,8 +87,11 @@ int main(int argc, char *argv[])
8687
BackGround::BackgroundTasks meme;
8788
//meme.BackgroundTasks();
8889
Network::Net net = Network::Net();
90+
std::ifstream o("/switch/Sys-Updater/config.json");
91+
o >> Conf;
8992
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
90-
net.Download("http://192.168.1.128/info", "/switch/Sys-Updater/actual.json");
93+
std::string downloadlink = Conf["URL"].get<std::string>() + "info";
94+
net.Download(downloadlink, "/switch/Sys-Updater/actual.json");
9195
std::ifstream i("/switch/Sys-Updater/actual.json");
9296
i >> j;
9397
if (!brls::Application::init("Sys-Updater"))
@@ -135,7 +139,7 @@ int main(int argc, char *argv[])
135139
if (onlineupdate == true)
136140
{
137141
Network::Net net = Network::Net();
138-
std::string download = "http://192.168.1.128/" + j["intfw"].get<std::string>();
142+
std::string download = Conf["URL"].get<std::string>() + j["intfw"].get<std::string>();
139143
brls::Logger::debug(download);
140144
net.Download(download, "/switch/Sys-Updater/temp.json");
141145
stagedFrame->addStage(new PreInstallUpdatePage(stagedFrame, "Download Update"));

Sys-Updater/source/thread.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SOFTWARE.*/
2828

2929
/* Var */
3030
json V1;
31+
json config;
3132
static constexpr size_t UpdateTaskBufferSize = 0x100000;
3233
AsyncResult m_prepare_result;
3334

@@ -63,13 +64,15 @@ namespace BackGround
6364
{
6465
std::ifstream i("/switch/Sys-Updater/temp.json");
6566
i >> V1;
67+
std::ifstream o("/switch/Sys-Updater/config.json");
68+
o >> config;
6669
auto v7 = V1["titleids"].get<std::vector<std::string>>();
6770
int n = v7.size();
6871
for (int i = 0; i < n; i++)
6972
{
7073
if (V1["programid"][v7[i]].contains("Program") == true)
7174
{
72-
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["Program"].get<std::string>();
75+
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["Program"].get<std::string>();
7376
brls::Logger::debug(download);
7477
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Program"].get<std::string>() + ".nca";
7578
if (net.Download(download, out) == true)
@@ -81,7 +84,7 @@ namespace BackGround
8184
}
8285
else if (V1["programid"][v7[i]].contains("Data") == true)
8386
{
84-
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["Data"].get<std::string>();
87+
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["Data"].get<std::string>();
8588
brls::Logger::debug(download);
8689
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Data"].get<std::string>() + ".nca";
8790
if (net.Download(download, out) == true)
@@ -93,7 +96,7 @@ namespace BackGround
9396
}
9497
else if (V1["programid"][v7[i]].contains("PublicData") == true)
9598
{
96-
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["PublicData"].get<std::string>();
99+
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["PublicData"].get<std::string>();
97100
brls::Logger::debug(download);
98101
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["PublicData"].get<std::string>() + ".nca";
99102
if (net.Download(download, out) == true)
@@ -105,7 +108,7 @@ namespace BackGround
105108
}
106109
if (V1["programid"][v7[i]].contains("Meta") == true)
107110
{
108-
std::string download = "http://192.168.1.128/c/a/" + V1["programid"][v7[i]]["Meta"].get<std::string>();
111+
std::string download = config["URL"].get<std::string>() + "c/a/" + V1["programid"][v7[i]]["Meta"].get<std::string>();
109112
brls::Logger::debug(download);
110113
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Meta"].get<std::string>() + ".cnmt.nca";
111114
if (net.Download(download, out) == true)

0 commit comments

Comments
 (0)