Update for citrus changes.

This commit is contained in:
Steven Smith 2015-08-19 19:50:27 -07:00
parent fa1cbb246b
commit 3ec9c0ba9f
2 changed files with 44 additions and 31 deletions

View File

@ -76,16 +76,21 @@ void networkInstall() {
confirmStream << "Install the received application?" << "\n"; confirmStream << "Install the received application?" << "\n";
confirmStream << "Size: " << file.fileSize << " bytes (" << std::fixed << std::setprecision(2) << file.fileSize / 1024.0f / 1024.0f << "MB)"; confirmStream << "Size: " << file.fileSize << " bytes (" << std::fixed << std::setprecision(2) << file.fileSize / 1024.0f / 1024.0f << "MB)";
if(!showNetworkPrompts || uiPrompt(gpu::SCREEN_TOP, confirmStream.str(), true)) { if(!showNetworkPrompts || uiPrompt(gpu::SCREEN_TOP, confirmStream.str(), true)) {
app::AppResult ret = app::install(destination, file.fd, file.fileSize, &onProgress); app::install(destination, file.fd, file.fileSize, &onProgress);
prevProgress = -1; prevProgress = -1;
if(showNetworkPrompts || ret != app::APP_SUCCESS) { if(showNetworkPrompts || err::has()) {
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "Install "; resultMsg << "Install ";
if(ret == app::APP_SUCCESS) { if(!err::has()) {
resultMsg << "succeeded!"; resultMsg << "succeeded!";
} else {
err::Error error = err::get();
if(error.source == err::SOURCE_OPERATION_CANCELLED) {
resultMsg << "cancelled!";
} else { } else {
resultMsg << "failed!" << "\n"; resultMsg << "failed!" << "\n";
resultMsg << app::resultString(ret); resultMsg << err::toString(error);
}
} }
uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false); uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false);
@ -114,11 +119,14 @@ void installROP() {
if(uiPrompt(gpu::SCREEN_TOP, stream.str(), true)) { if(uiPrompt(gpu::SCREEN_TOP, stream.str(), true)) {
u16 userSettingsOffset = 0; u16 userSettingsOffset = 0;
bool result = nor::read(0x20, &userSettingsOffset, 2) && nor::write(userSettingsOffset << 3, rops[selected], ROP_SIZE); nor::read(0x20, &userSettingsOffset, 2);
if(!err::has()) {
nor::write(userSettingsOffset << 3, rops[selected], ROP_SIZE);
}
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "ROP installation "; resultMsg << "ROP installation ";
if(result) { if(!err::has()) {
resultMsg << "succeeded!"; resultMsg << "succeeded!";
} else { } else {
resultMsg << "failed!" << "\n"; resultMsg << "failed!" << "\n";
@ -187,11 +195,11 @@ bool installCIA(fs::MediaType destination, const std::string path, const std::st
batchInstallStream << name << "\n"; batchInstallStream << name << "\n";
installInfo = batchInstallStream.str(); installInfo = batchInstallStream.str();
app::AppResult ret = app::install(destination, fd, (u64) st.st_size, &onProgress); app::install(destination, fd, (u64) st.st_size, &onProgress);
prevProgress = -1; prevProgress = -1;
installInfo = ""; installInfo = "";
if(ret != app::APP_SUCCESS && err::has()) { if(err::has()) {
err::Error error = err::get(); err::Error error = err::get();
if(error.module == err::MODULE_NN_AM && error.description == err::DESCRIPTION_ALREADY_EXISTS) { if(error.module == err::MODULE_NN_AM && error.description == err::DESCRIPTION_ALREADY_EXISTS) {
std::stringstream overwriteMsg; std::stringstream overwriteMsg;
@ -200,21 +208,18 @@ bool installCIA(fs::MediaType destination, const std::string path, const std::st
if(uiPrompt(gpu::SCREEN_TOP, overwriteMsg.str(), true)) { if(uiPrompt(gpu::SCREEN_TOP, overwriteMsg.str(), true)) {
uiDisplayMessage(gpu::SCREEN_TOP, "Deleting title..."); uiDisplayMessage(gpu::SCREEN_TOP, "Deleting title...");
app::App app; app::uninstall(app::ciaInfo(path, destination));
app::ciaInfo(&app, path, destination); if(err::has()) {
app::AppResult deleteRet = app::uninstall(app);
if(deleteRet != app::APP_SUCCESS) {
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "Delete failed!" << "\n"; resultMsg << "Delete failed!" << "\n";
resultMsg << name << "\n"; resultMsg << name << "\n";
resultMsg << app::resultString(deleteRet); resultMsg << err::toString(err::get());
uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false); uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false);
return false; return false;
} }
ret = app::install(destination, fd, (u64) st.st_size, &onProgress); app::install(destination, fd, (u64) st.st_size, &onProgress);
prevProgress = -1; prevProgress = -1;
installInfo = ""; installInfo = "";
} else { } else {
@ -225,11 +230,19 @@ bool installCIA(fs::MediaType destination, const std::string path, const std::st
} }
} }
if(ret != app::APP_SUCCESS) { if(err::has()) {
err::Error error = err::get();
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "Install failed!" << "\n"; resultMsg << "Install ";
if(error.source == err::SOURCE_OPERATION_CANCELLED) {
resultMsg << "cancelled!" << "\n";
resultMsg << name;
} else {
resultMsg << "failed!" << "\n";
resultMsg << name << "\n"; resultMsg << name << "\n";
resultMsg << app::resultString(ret); resultMsg << err::toString(error);
}
uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false); uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false);
return false; return false;
@ -265,12 +278,12 @@ bool deleteCIA(const std::string path, const std::string fileName) {
bool deleteTitle(app::App app) { bool deleteTitle(app::App app) {
uiDisplayMessage(gpu::SCREEN_TOP, "Deleting title..."); uiDisplayMessage(gpu::SCREEN_TOP, "Deleting title...");
app::AppResult ret = app::uninstall(app);
if(ret != app::APP_SUCCESS) { app::uninstall(app);
if(err::has()) {
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "Delete failed!" << "\n"; resultMsg << "Delete failed!" << "\n";
resultMsg << app::resultString(ret); resultMsg << err::toString(err::get());
uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false); uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false);
return false; return false;
@ -281,12 +294,12 @@ bool deleteTitle(app::App app) {
bool launchTitle(app::App app) { bool launchTitle(app::App app) {
uiDisplayMessage(gpu::SCREEN_TOP, "Launching title..."); uiDisplayMessage(gpu::SCREEN_TOP, "Launching title...");
app::AppResult ret = app::launch(app);
if(ret != app::APP_SUCCESS) { app::launch(app);
if(err::has()) {
std::stringstream resultMsg; std::stringstream resultMsg;
resultMsg << "Launch failed!" << "\n"; resultMsg << "Launch failed!" << "\n";
resultMsg << app::resultString(ret); resultMsg << err::toString(err::get());
uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false); uiPrompt(gpu::SCREEN_TOP, resultMsg.str(), false);
return false; return false;

View File

@ -1,6 +1,7 @@
#include "ui.hpp" #include "ui.hpp"
#include <citrus/core.hpp> #include <citrus/core.hpp>
#include <citrus/err.hpp>
#include <citrus/gput.hpp> #include <citrus/gput.hpp>
#include <citrus/hid.hpp> #include <citrus/hid.hpp>
@ -286,8 +287,8 @@ void uiGetDirContents(std::vector<SelectableElement> &elements, const std::strin
std::string extension = fs::extension(path); std::string extension = fs::extension(path);
if(extension.compare("cia") == 0) { if(extension.compare("cia") == 0) {
app::App app; app::App app = app::ciaInfo(path, fs::SD);
if(app::ciaInfo(&app, path, fs::SD) == app::APP_SUCCESS) { if(!err::has()) {
std::stringstream titleId; std::stringstream titleId;
titleId << "0x" << std::setfill('0') << std::setw(16) << std::hex << app.titleId; titleId << "0x" << std::setfill('0') << std::setw(16) << std::hex << app.titleId;
@ -429,8 +430,7 @@ bool uiFindApp(app::App* result, std::string id, std::vector<app::App> apps) {
bool uiSelectApp(app::App* selectedApp, fs::MediaType mediaType, std::function<bool(bool &updateList)> onLoop, std::function<bool(app::App app, bool &updateList)> onSelect, bool useTopScreen, bool dpadPageScroll) { bool uiSelectApp(app::App* selectedApp, fs::MediaType mediaType, std::function<bool(bool &updateList)> onLoop, std::function<bool(app::App app, bool &updateList)> onSelect, bool useTopScreen, bool dpadPageScroll) {
std::vector<SelectableElement> elements; std::vector<SelectableElement> elements;
std::vector<app::App> apps; std::vector<app::App> apps = app::list(mediaType);
app::list(&apps, mediaType);
uiGetApps(elements, apps); uiGetApps(elements, apps);
bool updateContents = false; bool updateContents = false;
@ -441,7 +441,7 @@ bool uiSelectApp(app::App* selectedApp, fs::MediaType mediaType, std::function<b
} }
if(updateContents) { if(updateContents) {
app::list(&apps, mediaType); apps = app::list(mediaType);
uiGetApps(currElements, apps); uiGetApps(currElements, apps);
elementsDirty = true; elementsDirty = true;
resetCursorIfDirty = false; resetCursorIfDirty = false;