|
|
|
@ -104,14 +104,15 @@ std::string GetZIPFilePath(u64 title_id) { |
|
|
|
|
|
|
|
// If the error is something the user should know about (build ID mismatch, bad client version),
|
|
|
|
// display an error.
|
|
|
|
void HandleDownloadDisplayResult(DownloadResult res) { |
|
|
|
void HandleDownloadDisplayResult(const AM::Applets::AppletManager& applet_manager, |
|
|
|
DownloadResult res) { |
|
|
|
if (res == DownloadResult::Success || res == DownloadResult::NoResponse || |
|
|
|
res == DownloadResult::GeneralWebError || res == DownloadResult::GeneralFSError || |
|
|
|
res == DownloadResult::NoMatchTitleId || res == DownloadResult::InvalidContentType) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const auto& frontend{Core::System::GetInstance().GetAppletManager().GetAppletFrontendSet()}; |
|
|
|
const auto& frontend{applet_manager.GetAppletFrontendSet()}; |
|
|
|
frontend.error->ShowCustomErrorText( |
|
|
|
ResultCode(-1), "There was an error while attempting to use Boxcat.", |
|
|
|
DOWNLOAD_RESULT_LOG_MESSAGES[static_cast<std::size_t>(res)], [] {}); |
|
|
|
@ -264,12 +265,13 @@ private: |
|
|
|
u64 build_id; |
|
|
|
}; |
|
|
|
|
|
|
|
Boxcat::Boxcat(DirectoryGetter getter) : Backend(std::move(getter)) {} |
|
|
|
Boxcat::Boxcat(AM::Applets::AppletManager& applet_manager_, DirectoryGetter getter) |
|
|
|
: Backend(std::move(getter)), applet_manager{applet_manager_} {} |
|
|
|
|
|
|
|
Boxcat::~Boxcat() = default; |
|
|
|
|
|
|
|
void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title, |
|
|
|
ProgressServiceBackend& progress, |
|
|
|
void SynchronizeInternal(AM::Applets::AppletManager& applet_manager, DirectoryGetter dir_getter, |
|
|
|
TitleIDVersion title, ProgressServiceBackend& progress, |
|
|
|
std::optional<std::string> dir_name = {}) { |
|
|
|
progress.SetNeedHLELock(true); |
|
|
|
|
|
|
|
@ -295,7 +297,7 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title, |
|
|
|
FileUtil::Delete(zip_path); |
|
|
|
} |
|
|
|
|
|
|
|
HandleDownloadDisplayResult(res); |
|
|
|
HandleDownloadDisplayResult(applet_manager, res); |
|
|
|
progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -364,17 +366,24 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title, |
|
|
|
|
|
|
|
bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) { |
|
|
|
is_syncing.exchange(true); |
|
|
|
std::thread([this, title, &progress] { SynchronizeInternal(dir_getter, title, progress); }) |
|
|
|
|
|
|
|
std::thread([this, title, &progress] { |
|
|
|
SynchronizeInternal(applet_manager, dir_getter, title, progress); |
|
|
|
}) |
|
|
|
.detach(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name, |
|
|
|
ProgressServiceBackend& progress) { |
|
|
|
is_syncing.exchange(true); |
|
|
|
std::thread( |
|
|
|
[this, title, name, &progress] { SynchronizeInternal(dir_getter, title, progress, name); }) |
|
|
|
|
|
|
|
std::thread([this, title, name, &progress] { |
|
|
|
SynchronizeInternal(applet_manager, dir_getter, title, progress, name); |
|
|
|
}) |
|
|
|
.detach(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@ -420,7 +429,7 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) |
|
|
|
FileUtil::Delete(path); |
|
|
|
} |
|
|
|
|
|
|
|
HandleDownloadDisplayResult(res); |
|
|
|
HandleDownloadDisplayResult(applet_manager, res); |
|
|
|
return std::nullopt; |
|
|
|
} |
|
|
|
} |
|
|
|
|