User triggered print of drive lable (#85)

implements #66

Reviewed-on: #85
Co-authored-by: localhorst <localhorst@mosad.xyz>
Co-committed-by: localhorst <localhorst@mosad.xyz>
This commit is contained in:
2025-12-12 22:32:51 +01:00
committed by Hendrik Schutter
parent c4a960f3cf
commit 1449e807ad
4 changed files with 69 additions and 5 deletions

View File

@ -216,12 +216,62 @@ void reHDD::ThreadUserInput()
sleep(5); // sleep 5 sec
std::exit(1); // Terminates main, doesn't wait for threads
break;
case TUI::UserInput::Print:
// cout << "Print" << endl;
if (tmpSelectedDrive != nullptr)
{
printDrive(tmpSelectedDrive);
}
ui->updateTUI(&listDrives, u16SelectedEntry);
break;
case TUI::UserInput::PrintAll:
// cout << "PrintAll" << endl;
printAllDrives(&listDrives);
ui->updateTUI(&listDrives, u16SelectedEntry);
break;
default:
break;
}
}
}
/**
* \brief print all shredded drives
* \param pointer of list <Drive>* plistDrives
* \return void
*/
void reHDD::printAllDrives(list<Drive> *plistDrives)
{
list<Drive>::iterator it;
mxDrives.lock();
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
{
Drive *pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator>(it);
printDrive(pTmpDrive);
}
mxDrives.unlock();
}
/**
* \brief print a shredded drives
* \param pointer of a drive
* \return void
*/
void reHDD::printDrive(Drive *const pDrive)
{
if (pDrive->bWasShredded)
{
#ifdef ZERO_CHECK
if (pDrive->bWasChecked && (pDrive->u32DriveChecksumAfterShredding != 0U))
{
return; // Drive was shredded&checked but checksum failed, don't print label
}
#endif
Logger::logThis()->info("User print for: " + pDrive->getModelName() + "-" + pDrive->getSerial());
Printer::getPrinter()->print(pDrive);
}
}
void reHDD::ThreadShred(Drive *const pDrive)
{
if (pDrive != nullptr)