2019-10-22 22:14:37 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <sstream>
|
|
|
|
#include "install/install_nsp.hpp"
|
|
|
|
#include "nx/fs.hpp"
|
|
|
|
#include "util/file_util.hpp"
|
|
|
|
#include "util/title_util.hpp"
|
|
|
|
#include "util/error.hpp"
|
|
|
|
|
|
|
|
#include "nspInstall.hpp"
|
|
|
|
#include "ui/MainApplication.hpp"
|
|
|
|
|
|
|
|
namespace inst::ui {
|
|
|
|
extern MainApplication *mainApp;
|
|
|
|
|
|
|
|
void setNspInfoText(std::string ourText){
|
|
|
|
mainApp->nspinstPage->pageInfoText->SetText(ourText);
|
|
|
|
mainApp->CallForRender();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadMainMenu(){
|
|
|
|
mainApp->LoadLayout(mainApp->mainPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace nspInstStuff {
|
|
|
|
FsStorageId m_destStorageId = FsStorageId_SdCard;
|
|
|
|
|
2019-10-23 01:33:13 +00:00
|
|
|
bool installNspFromFile(std::string ourNsp, int whereToInstall)
|
2019-10-22 22:14:37 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> installList;
|
|
|
|
installList.push_back(ourNsp);
|
|
|
|
|
2019-10-23 01:33:13 +00:00
|
|
|
if (whereToInstall) m_destStorageId = FsStorageId_NandUser;
|
|
|
|
|
2019-10-22 22:14:37 +00:00
|
|
|
for (unsigned int i = 0; i < installList.size(); i++)
|
|
|
|
{
|
|
|
|
std::string path = "@Sdcard://" + installList[i];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nx::fs::IFileSystem fileSystem;
|
|
|
|
fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0);
|
|
|
|
tin::install::nsp::SimpleFileSystem simpleFS(fileSystem, "/", path + "/");
|
|
|
|
//last arg is ignore required firm version, read from config for this
|
|
|
|
tin::install::nsp::NSPInstallTask task(simpleFS, m_destStorageId, 1);
|
|
|
|
|
|
|
|
printf("NSP_INSTALL_PREPARING\n");
|
|
|
|
task.Prepare();
|
|
|
|
printf("Pre Install Records: \n");
|
|
|
|
//task.DebugPrintInstallData();
|
|
|
|
|
|
|
|
//std::stringstream ss;
|
|
|
|
//ss << translate(Translate::NSP_INSTALLING) << " " << tin::util::GetTitleName(task.GetTitleId(), task.GetContentMetaType()) << " (" << (i + 1) << "/" << installList.size() << ")";
|
|
|
|
//manager.m_printConsole->flags |= CONSOLE_COLOR_BOLD;
|
|
|
|
//tin::util::PrintTextCentred(ss.str());
|
|
|
|
//manager.m_printConsole->flags &= ~CONSOLE_COLOR_BOLD;
|
|
|
|
|
2019-10-23 01:33:13 +00:00
|
|
|
inst::ui::setNspInfoText("Installing " + ourNsp + "...");
|
2019-10-22 22:14:37 +00:00
|
|
|
task.Begin();
|
|
|
|
printf("Post Install Records: \n");
|
|
|
|
//task.DebugPrintInstallData();
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2019-10-23 01:33:13 +00:00
|
|
|
inst::ui::setNspInfoText("Failed to install NSP");
|
2019-10-22 22:14:37 +00:00
|
|
|
printf("NSP_INSTALL_FAILED\n");
|
|
|
|
printf("Failed to install NSP");
|
|
|
|
printf("%s", e.what());
|
|
|
|
fprintf(stdout, "%s", e.what());
|
2019-10-23 01:33:13 +00:00
|
|
|
return false;
|
2019-10-22 22:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Done");
|
2019-10-23 01:33:13 +00:00
|
|
|
inst::ui::loadMainMenu();
|
|
|
|
return true;
|
2019-10-22 22:14:37 +00:00
|
|
|
}
|
|
|
|
}
|