| 1011 | } |
| 1012 | |
| 1013 | void MainScreen::startTransferSend(void) |
| 1014 | { |
| 1015 | if (TitleCatalog::get().getTitleCount(backupKind) <= 0) { |
| 1016 | currentOverlay = std::make_shared<InfoOverlay>(*this, i18n::t("main.no_titles")); |
| 1017 | return; |
| 1018 | } |
| 1019 | |
| 1020 | const size_t row = directoryList->index(); |
| 1021 | if (!g_bottomScrollEnabled || row == 0 || isReceiveRow(row)) { |
| 1022 | currentOverlay = std::make_shared<InfoOverlay>(*this, i18n::t("main.select_backup_send")); |
| 1023 | return; |
| 1024 | } |
| 1025 | size_t cellIndex = rowToCell(row); |
| 1026 | |
| 1027 | Title title; |
| 1028 | TitleCatalog::get().getTitle(title, hid.fullIndex(), backupKind); |
| 1029 | BackupTarget target = title.backup(backupKind); |
| 1030 | |
| 1031 | std::string backupName = nameFromCell(cellIndex); |
| 1032 | std::u16string backupPath = target.fullPath(cellIndex); |
| 1033 | |
| 1034 | std::string ipPort = KeyboardManager::get().text(Configuration::getInstance().lastTransferAddress(), i18n::t("main.receiver_ip_port"), 32); |
| 1035 | if (ipPort.empty()) { |
| 1036 | return; |
| 1037 | } |
| 1038 | auto dst = Transfer::parseTarget(ipPort); |
| 1039 | if (!dst) { |
| 1040 | currentOverlay = std::make_shared<ErrorOverlay>(*this, -1, i18n::t("main.invalid_ip_port")); |
| 1041 | return; |
| 1042 | } |
| 1043 | // Remember a valid address so the next send prefills the keyboard with it. |
| 1044 | Configuration::getInstance().setLastTransferAddress(ipPort); |
| 1045 | |
| 1046 | std::string pin = KeyboardManager::get().text("1234", i18n::t("main.pin_prompt"), 5); |
| 1047 | if (pin.empty()) { |
| 1048 | return; |
| 1049 | } |
| 1050 | if (!Transfer::validPin(pin)) { |
| 1051 | currentOverlay = std::make_shared<ErrorOverlay>(*this, -1, i18n::t("main.pin_invalid")); |
| 1052 | return; |
| 1053 | } |
| 1054 | |
| 1055 | // Keyboard + validation happened above on the UI thread; the blocking IO |
| 1056 | // (zip + socket) runs on the TransferJob worker. Title and params go by |
| 1057 | // value so nothing here needs to outlive this frame. |
| 1058 | std::string dataType = target.dataTypeName(); |
| 1059 | TransferJob::get().enqueueSend( |
| 1060 | std::move(title), std::move(backupPath), std::move(backupName), std::move(dataType), std::move(dst->ip), dst->port, std::move(pin)); |
| 1061 | TransferJob::get().start(); |
| 1062 | } |
nothing calls this directly
no test coverage detected