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

Commit

Permalink
read the url from config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
D3fau4 committed Sep 7, 2020
1 parent 06ff3f6 commit f545adc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 45 deletions.
1 change: 0 additions & 1 deletion Sys-Updater/include/UI/DownloadUpdate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class DownloadUpdatePage : public brls::View

void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
void DownloadUpdate(void);
void willAppear(bool resetState = false) override;
void willDisappear(bool resetState = false) override;
};
38 changes: 0 additions & 38 deletions Sys-Updater/source/UI/DownloadUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,44 +85,6 @@ void DownloadUpdatePage::draw(NVGcontext *vg, int x, int y, unsigned width, unsi
this->label1->frame(ctx);
}

void DownloadUpdatePage::DownloadUpdate(void)
{
Network::Net net = Network::Net();
auto v7 = jso1n["titleids"].get<std::vector<std::string>>();
int n = v7.size();
for (int i = 0; i < n; i++)
{
if (jso1n["programid"][v7[i]].contains("Program") == true)
{
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["Program"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Program"].get<std::string>() + ".nca";
net.Download(download, out);
}
else if (jso1n["programid"][v7[i]].contains("Data") == true)
{
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["Data"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Data"].get<std::string>() + ".nca";
net.Download(download, out);
}
else if (jso1n["programid"][v7[i]].contains("PublicData") == true)
{
std::string download = "http://192.168.1.128/c/c/" + jso1n["programid"][v7[i]]["PublicData"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["PublicData"].get<std::string>() + ".nca";
net.Download(download, out);
}
if (jso1n["programid"][v7[i]].contains("Meta") == true)
{
std::string download = "http://192.168.1.128/c/a/" + jso1n["programid"][v7[i]]["Meta"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + jso1n["programid"][v7[i]]["Meta"].get<std::string>() + ".cnmt.nca";
net.Download(download, out);
}
}
}

void DownloadUpdatePage::layout(NVGcontext *vg, brls::Style *style, brls::FontStash *stash)
{
this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth));
Expand Down
8 changes: 6 additions & 2 deletions Sys-Updater/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SOFTWARE.*/

using json = nlohmann::json;
json j;
json Conf;
bool onlineupdate = true;

Result Init_Services(void)
Expand Down Expand Up @@ -86,8 +87,11 @@ int main(int argc, char *argv[])
BackGround::BackgroundTasks meme;
//meme.BackgroundTasks();
Network::Net net = Network::Net();
std::ifstream o("/switch/Sys-Updater/config.json");
o >> Conf;
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
net.Download("http://192.168.1.128/info", "/switch/Sys-Updater/actual.json");
std::string downloadlink = Conf["URL"].get<std::string>() + "info";
net.Download(downloadlink, "/switch/Sys-Updater/actual.json");
std::ifstream i("/switch/Sys-Updater/actual.json");
i >> j;
if (!brls::Application::init("Sys-Updater"))
Expand Down Expand Up @@ -135,7 +139,7 @@ int main(int argc, char *argv[])
if (onlineupdate == true)
{
Network::Net net = Network::Net();
std::string download = "http://192.168.1.128/" + j["intfw"].get<std::string>();
std::string download = Conf["URL"].get<std::string>() + j["intfw"].get<std::string>();
brls::Logger::debug(download);
net.Download(download, "/switch/Sys-Updater/temp.json");
stagedFrame->addStage(new PreInstallUpdatePage(stagedFrame, "Download Update"));
Expand Down
11 changes: 7 additions & 4 deletions Sys-Updater/source/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE.*/

/* Var */
json V1;
json config;
static constexpr size_t UpdateTaskBufferSize = 0x100000;
AsyncResult m_prepare_result;

Expand Down Expand Up @@ -63,13 +64,15 @@ namespace BackGround
{
std::ifstream i("/switch/Sys-Updater/temp.json");
i >> V1;
std::ifstream o("/switch/Sys-Updater/config.json");
o >> config;
auto v7 = V1["titleids"].get<std::vector<std::string>>();
int n = v7.size();
for (int i = 0; i < n; i++)
{
if (V1["programid"][v7[i]].contains("Program") == true)
{
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["Program"].get<std::string>();
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["Program"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Program"].get<std::string>() + ".nca";
if (net.Download(download, out) == true)
Expand All @@ -81,7 +84,7 @@ namespace BackGround
}
else if (V1["programid"][v7[i]].contains("Data") == true)
{
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["Data"].get<std::string>();
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["Data"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Data"].get<std::string>() + ".nca";
if (net.Download(download, out) == true)
Expand All @@ -93,7 +96,7 @@ namespace BackGround
}
else if (V1["programid"][v7[i]].contains("PublicData") == true)
{
std::string download = "http://192.168.1.128/c/c/" + V1["programid"][v7[i]]["PublicData"].get<std::string>();
std::string download = config["URL"].get<std::string>() + "c/c/" + V1["programid"][v7[i]]["PublicData"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["PublicData"].get<std::string>() + ".nca";
if (net.Download(download, out) == true)
Expand All @@ -105,7 +108,7 @@ namespace BackGround
}
if (V1["programid"][v7[i]].contains("Meta") == true)
{
std::string download = "http://192.168.1.128/c/a/" + V1["programid"][v7[i]]["Meta"].get<std::string>();
std::string download = config["URL"].get<std::string>() + "c/a/" + V1["programid"][v7[i]]["Meta"].get<std::string>();
brls::Logger::debug(download);
std::string out = "/switch/Sys-Updater/temp/" + V1["programid"][v7[i]]["Meta"].get<std::string>() + ".cnmt.nca";
if (net.Download(download, out) == true)
Expand Down

0 comments on commit f545adc

Please sign in to comment.