MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / onResult

Method onResult

Tactility/Source/app/files/View.cpp:568–715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bundle) {
569 if (result != Result::Ok || bundle == nullptr) {
570 return;
571 }
572
573 if (
574 launchId == installAppLaunchId &&
575 result == Result::Ok &&
576 alertdialog::getResultIndex(*bundle) == 0
577 ) {
578 install(installAppPath);
579 return;
580 }
581
582 std::string filepath = state->getSelectedChildPath();
583 LOGGER.info("Result for {}", filepath);
584
585 switch (state->getPendingAction()) {
586 case State::ActionDelete: {
587 if (alertdialog::getResultIndex(*bundle) == 0) {
588 if (file::isDirectory(filepath)) {
589 if (!file::deleteRecursively(filepath)) {
590 LOGGER.warn("Failed to delete {}", filepath);
591 }
592 } else if (file::isFile(filepath)) {
593 auto lock = file::getLock(filepath);
594 lock->lock();
595 if (remove(filepath.c_str()) != 0) {
596 LOGGER.warn("Failed to delete {}", filepath);
597 }
598 lock->unlock();
599 }
600
601 state->setEntriesForPath(state->getCurrentPath());
602 update();
603 }
604 break;
605 }
606 case State::ActionRename: {
607 auto new_name = inputdialog::getResult(*bundle);
608 if (!new_name.empty() && new_name != state->getSelectedChildEntry()) {
609 auto lock = file::getLock(filepath);
610 lock->lock();
611 std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name);
612 struct stat st;
613 if (stat(rename_to.c_str(), &st) == 0) {
614 LOGGER.warn("Rename: destination already exists: \"{}\"", rename_to);
615 lock->unlock();
616 state->setPendingAction(State::ActionNone);
617 alertdialog::start("Rename failed", "\"" + new_name + "\" already exists.");
618 break;
619 }
620 if (rename(filepath.c_str(), rename_to.c_str()) == 0) {
621 LOGGER.info("Renamed \"{}\" to \"{}\"", filepath, rename_to);
622 } else {
623 LOGGER.error("Failed to rename \"{}\" to \"{}\"", filepath, rename_to);
624 }
625 lock->unlock();

Callers 2

onStopTopAppMessageMethod · 0.45
onStopAllAppMessageMethod · 0.45

Calls 15

installFunction · 0.85
isDirectoryFunction · 0.85
deleteRecursivelyFunction · 0.85
isFileFunction · 0.85
getLockFunction · 0.85
getResultFunction · 0.85
getChildPathFunction · 0.85
infoMethod · 0.80
getPendingActionMethod · 0.80
warnMethod · 0.80
setPendingActionMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected