Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6732aacdc8 | |||
| 1caa4ce6f2 |
@ -31,7 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Logic
|
// Logic
|
||||||
// #define DRYRUN // don't touch the drives
|
#define DRYRUN // don't touch the drives
|
||||||
#define FROZEN_ALERT // show alert if drive is frozen
|
#define FROZEN_ALERT // show alert if drive is frozen
|
||||||
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
|
#define ZERO_CHECK // check drive after shred if all bytes are zero, show alert if this fails
|
||||||
|
|
||||||
@ -90,6 +90,8 @@ private:
|
|||||||
static void filterInvalidDrives(list<Drive> *plistDrives);
|
static void filterInvalidDrives(list<Drive> *plistDrives);
|
||||||
static void filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDrives);
|
static void filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDrives);
|
||||||
static void addSMARTData(list<Drive> *plistDrives);
|
static void addSMARTData(list<Drive> *plistDrives);
|
||||||
|
static void printAllDrives(list<Drive> *plistDrives);
|
||||||
|
static void printDrive(Drive *const pDrive);
|
||||||
static void ThreadScanDevices();
|
static void ThreadScanDevices();
|
||||||
static void ThreadUserInput();
|
static void ThreadUserInput();
|
||||||
static void ThreadShred(Drive *const pDrive);
|
static void ThreadShred(Drive *const pDrive);
|
||||||
|
|||||||
@ -32,6 +32,8 @@ public:
|
|||||||
Enter,
|
Enter,
|
||||||
ESC,
|
ESC,
|
||||||
Terminate,
|
Terminate,
|
||||||
|
Print,
|
||||||
|
PrintAll,
|
||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
struct MenuState
|
struct MenuState
|
||||||
|
|||||||
@ -216,12 +216,59 @@ void reHDD::ThreadUserInput()
|
|||||||
sleep(5); // sleep 5 sec
|
sleep(5); // sleep 5 sec
|
||||||
std::exit(1); // Terminates main, doesn't wait for threads
|
std::exit(1); // Terminates main, doesn't wait for threads
|
||||||
break;
|
break;
|
||||||
|
case TUI::UserInput::Print:
|
||||||
|
// cout << "Print" << endl;
|
||||||
|
Logger::logThis()->info("User print single");
|
||||||
|
if (tmpSelectedDrive != nullptr)
|
||||||
|
{
|
||||||
|
// printDrive(tmpSelectedDrive);
|
||||||
|
}
|
||||||
|
// ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
|
break;
|
||||||
|
case TUI::UserInput::PrintAll:
|
||||||
|
// cout << "PrintAll" << endl;
|
||||||
|
Logger::logThis()->info("User print all");
|
||||||
|
// printAllDrives(&listDrives);
|
||||||
|
// ui->updateTUI(&listDrives, u16SelectedEntry);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief start shred for all 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
// TODO: Trigger printer for this drive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reHDD::ThreadShred(Drive *const pDrive)
|
void reHDD::ThreadShred(Drive *const pDrive)
|
||||||
{
|
{
|
||||||
if (pDrive != nullptr)
|
if (pDrive != nullptr)
|
||||||
|
|||||||
18
src/tui.cpp
18
src/tui.cpp
@ -259,6 +259,12 @@ enum TUI::UserInput TUI::readUserInput()
|
|||||||
case 'T':
|
case 'T':
|
||||||
return TUI::UserInput::Terminate;
|
return TUI::UserInput::Terminate;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
return TUI::UserInput::Print;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
return TUI::UserInput::PrintAll;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return TUI::UserInput::Undefined;
|
return TUI::UserInput::Undefined;
|
||||||
break;
|
break;
|
||||||
@ -348,7 +354,7 @@ WINDOW *TUI::overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart)
|
|||||||
|
|
||||||
string sLine01 = "reHDD - hard drive refurbishing tool";
|
string sLine01 = "reHDD - hard drive refurbishing tool";
|
||||||
string sLine02 = "Version: " + string(REHDD_VERSION);
|
string sLine02 = "Version: " + string(REHDD_VERSION);
|
||||||
string sLine03 = "Available under GPL 3.0";
|
string sLine03 = "Free software under the GNU GPL 3.0";
|
||||||
string sLine04 = "https://git.mosad.xyz/localhorst/reHDD";
|
string sLine04 = "https://git.mosad.xyz/localhorst/reHDD";
|
||||||
string sLine05 = "Delete: Wipe format table - this is NOT secure";
|
string sLine05 = "Delete: Wipe format table - this is NOT secure";
|
||||||
string sLine06 = "Shred: Overwrite drive " + to_string(SHRED_ITERATIONS) + " iterations - this is secure";
|
string sLine06 = "Shred: Overwrite drive " + to_string(SHRED_ITERATIONS) + " iterations - this is secure";
|
||||||
@ -466,7 +472,7 @@ WINDOW *TUI::createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart)
|
|||||||
sLine03.append(__DATE__);
|
sLine03.append(__DATE__);
|
||||||
sLine03.append(" ");
|
sLine03.append(" ");
|
||||||
sLine03.append(__TIME__);
|
sLine03.append(__TIME__);
|
||||||
string sLine04 = "Available under GPL 3.0";
|
string sLine04 = "Free software under the GNU GPL 3.0";
|
||||||
string sLine05 = "https://git.mosad.xyz/localhorst/reHDD";
|
string sLine05 = "https://git.mosad.xyz/localhorst/reHDD";
|
||||||
|
|
||||||
uint16_t u16Line = 2;
|
uint16_t u16Line = 2;
|
||||||
@ -493,7 +499,7 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
|||||||
|
|
||||||
centerTitle(newWindow, "Controls");
|
centerTitle(newWindow, "Controls");
|
||||||
|
|
||||||
uint16_t u16Line = 4;
|
uint16_t u16Line = 2;
|
||||||
|
|
||||||
if (menustate.bAbort)
|
if (menustate.bAbort)
|
||||||
{
|
{
|
||||||
@ -514,7 +520,11 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
|
|||||||
u16Line++;
|
u16Line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
string sLineTmp = "Press T for terminating reHDD";
|
string sLineTmp = "Press p for Print (P for all drives)";
|
||||||
|
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
||||||
|
u16Line++;
|
||||||
|
|
||||||
|
sLineTmp = "Press T for terminating reHDD";
|
||||||
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user