Skip to content

Commit

Permalink
Warn the user if they're performing backups under applet mode. (Fixes…
Browse files Browse the repository at this point in the history
… the aborted by user issue)
  • Loading branch information
BernardoGiordano committed Dec 8, 2019
1 parent c619309 commit 428459b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
12 changes: 7 additions & 5 deletions switch/source/KeyboardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
KeyboardManager::KeyboardManager(void)
{
systemKeyboardAvailable = false;
SwkbdConfig kbd;
res = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(res)) {
systemKeyboardAvailable = true;
swkbdClose(&kbd);
if (appletGetAppletType() == AppletType_Application) {
SwkbdConfig kbd;
res = swkbdCreate(&kbd, 0);
if (R_SUCCEEDED(res)) {
systemKeyboardAvailable = true;
swkbdClose(&kbd);
}
}
}

Expand Down
21 changes: 13 additions & 8 deletions switch/source/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,19 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
}
else {
if (isNewFolder) {
std::pair<bool, std::string> keyboardResponse = KeyboardManager::get().keyboard(suggestion);
if (keyboardResponse.first) {
customPath = StringUtils::removeForbiddenCharacters(keyboardResponse.second);
if (KeyboardManager::get().isSystemKeyboardAvailable().first) {
std::pair<bool, std::string> keyboardResponse = KeyboardManager::get().keyboard(suggestion);
if (keyboardResponse.first) {
customPath = StringUtils::removeForbiddenCharacters(keyboardResponse.second);
}
else {
FileSystem::unmount();
Logger::getInstance().log(Logger::INFO, "Copy operation aborted by the user through the system keyboard.");
return std::make_tuple(false, 0, "Operation aborted by the user.");
}
}
else {
FileSystem::unmount();
Logger::getInstance().log(Logger::INFO, "Copy operation aborted by the user through the system keyboard.");
return std::make_tuple(false, 0, "Operation aborted by the user.");
customPath = suggestion;
}
}
else {
Expand Down Expand Up @@ -243,8 +248,8 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
// TODO: figure out if this code can be accessed at all
auto systemKeyboardAvailable = KeyboardManager::get().isSystemKeyboardAvailable();
if (!systemKeyboardAvailable.first) {
return std::make_tuple(
false, systemKeyboardAvailable.second, "System keyboard applet not accessible.\nThe suggested destination folder was used\ninstead.");
return std::make_tuple(true, systemKeyboardAvailable.second,
"Progress correctly saved to disk.\nSystem keyboard applet was not\naccessible. The suggested destination\nfolder was used instead.");
}

ret = std::make_tuple(true, 0, "Progress correctly saved to disk.");
Expand Down

0 comments on commit 428459b

Please sign in to comment.