20 Commits

Author SHA1 Message Date
298192111d new states 2025-12-07 18:36:32 +01:00
80ffb3c6c3 Merge pull request 'Improve UUID parsing' (#78) from hannesbraun/reHDD:master into master
Reviewed-on: #78
Reviewed-by: Hendrik Schutter <localhorst@mosad.xyz>
2025-12-07 18:15:28 +01:00
ebe0ef9ec1 Merge pull request 'fix(UI): Restore terminal state on termination' (#77) from hannesbraun/reHDD:terminal-restore into master
Reviewed-on: #77
2025-12-07 18:11:02 +01:00
86660cb112 Merge pull request 'feature/drive-type-ipc' (#80) from feature/drive-type-ipc into master
Reviewed-on: #80
2025-12-07 18:05:36 +01:00
47ab9cc36f update Version 2025-12-07 18:04:52 +01:00
aaf4695656 IPC connection type 2025-12-07 17:51:16 +01:00
664582f01d Improve UUID parsing
The previous approach only worked if the drive name had three letters (usually sda).
2025-07-25 14:26:20 +02:00
9f6cfc17f8 Restore terminal state on termination 2025-07-24 18:55:49 +02:00
a5eb5532d5 Merge pull request 'feature/sata-usb-info' (#76) from feature/sata-usb-info into master
Reviewed-on: #76
2025-06-22 11:58:22 +02:00
1efe3376c1 display empty string if connection type is not known 2025-06-22 11:57:40 +02:00
36ea3a2bef disable dryrun 2025-06-22 11:46:09 +02:00
fd4ad95ab1 display connection type 2025-06-21 20:25:32 +02:00
d76cb1a195 get connection type 2025-06-21 20:19:30 +02:00
d8584486b9 Merge pull request 'Terminate reHDD on user input' (#75) from feature/control-menu into master
Reviewed-on: #75
2025-06-21 11:51:00 +02:00
20d0dd8e90 reset build settings 2025-06-21 11:49:49 +02:00
1ec4a2c793 fix shred.cpp 2025-06-21 11:46:45 +02:00
a0c842d90d add terminate action 2025-06-15 22:16:34 +02:00
1ceffa56f8 Merge pull request 'Ignore system drives as live image' (#71) from bugfix/systemdrive_live into master
Reviewed-on: #71
2024-08-19 16:30:09 +02:00
4ff1888333 ignore system drives as live image 2024-08-19 15:35:22 +02:00
4b33fb6fdb update live image info 2024-08-17 16:02:58 +02:00
9 changed files with 156 additions and 49 deletions

View File

@ -9,7 +9,7 @@
* process multiple drives at once * process multiple drives at once
## Download USB Image ## ## Download USB Image ##
[2.5GB image v1.0.0](https://schuttercloud.com/s/ggxGH9sA326aRfK) (`wget` is your friend) See reHDD-Bootable how the live image created: https://git.mosad.xyz/localhorst/reHDD-Bootable
Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootable USB drive . Use [Etcher](https://www.balena.io/etcher/#download) or `dd` to create an bootable USB drive .

View File

@ -20,11 +20,21 @@ public:
SHRED_SELECTED, SHRED_SELECTED,
SHRED_ACTIVE, // shred iterations active SHRED_ACTIVE, // shred iterations active
CHECK_ACTIVE, // optional checking active CHECK_ACTIVE, // optional checking active
CHECK_SUCCESSFUL,
CHECK_FAILED,
DELETE_SELECTED, DELETE_SELECTED,
DELETE_ACTIVE, DELETE_ACTIVE,
FROZEN FROZEN
} state; } state;
enum ConnectionType
{
UNKNOWN,
USB,
SATA,
NVME
} connectionType;
struct struct
{ {
time_t u32ShredTimeDelta; time_t u32ShredTimeDelta;
@ -33,9 +43,9 @@ public:
unsigned long ulSpeedMetricBytesWritten; unsigned long ulSpeedMetricBytesWritten;
} sShredSpeed; } sShredSpeed;
bool bWasShredded = false; // all shred iterations done bool bWasShredded = false; // all shred iterations done
bool bWasShredStarted = false; // shred was atleast once started bool bWasShredStarted = false; // shred was atleast once started
bool bWasChecked = false; // all shred iterations and optional checking done bool bWasChecked = false; // all shred iterations and optional checking done
bool bWasDeleted = false; bool bWasDeleted = false;
bool bIsOffline = false; bool bIsOffline = false;
uint32_t u32DriveChecksumAfterShredding = 0U; uint32_t u32DriveChecksumAfterShredding = 0U;

View File

@ -26,11 +26,11 @@ typedef struct
char caDriveShredDuration[STR_BUFFER_SIZE]; char caDriveShredDuration[STR_BUFFER_SIZE];
char caDriveCapacity[STR_BUFFER_SIZE]; char caDriveCapacity[STR_BUFFER_SIZE];
char caDriveState[STR_BUFFER_SIZE]; char caDriveState[STR_BUFFER_SIZE];
char caDriveConnectionType[STR_BUFFER_SIZE];
char caDriveModelFamily[STR_BUFFER_SIZE]; char caDriveModelFamily[STR_BUFFER_SIZE];
char caDriveModelName[STR_BUFFER_SIZE]; char caDriveModelName[STR_BUFFER_SIZE];
char caDriveSerialnumber[STR_BUFFER_SIZE]; char caDriveSerialnumber[STR_BUFFER_SIZE];
char caDriveReHddVersion[STR_BUFFER_SIZE]; char caDriveReHddVersion[STR_BUFFER_SIZE];
} t_driveData; } t_driveData;
typedef struct typedef struct

View File

@ -8,7 +8,7 @@
#ifndef REHDD_H_ #ifndef REHDD_H_
#define REHDD_H_ #define REHDD_H_
#define REHDD_VERSION "V1.1.2" #define REHDD_VERSION "V1.2.1"
// Drive handling Settings // Drive handling Settings
#define WORSE_HOURS 19200 // mark drive if at this limit or beyond #define WORSE_HOURS 19200 // mark drive if at this limit or beyond
@ -20,18 +20,18 @@
// Logger Settings // Logger Settings
#define LOG_PATH "./reHDD.log" #define LOG_PATH "./reHDD.log"
#define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2024" #define DESCRIPTION "reHDD - Copyright Hendrik Schutter 2025"
#define DEVICE_ID "generic" #define DEVICE_ID "generic"
#define SOFTWARE_VERSION REHDD_VERSION #define SOFTWARE_VERSION REHDD_VERSION
#define HARDWARE_VERSION "generic" #define HARDWARE_VERSION "generic"
// #define LOG_LEVEL_HIGH //log everything, like drive scan thread // #define LOG_LEVEL_HIGH // log everything, like drive scan thread
#ifndef LOG_LEVEL_HIGH #ifndef LOG_LEVEL_HIGH
#define LOG_LEVEL_LOW // log only user actions and tasks #define LOG_LEVEL_LOW // log only user actions and tasks
#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
@ -86,6 +86,7 @@ private:
static void searchDrives(list<Drive> *plistDrives); static void searchDrives(list<Drive> *plistDrives);
static void printDrives(list<Drive> *plistDrives); static void printDrives(list<Drive> *plistDrives);
static void startShredAllDrives(list<Drive> *plistDrives); static void startShredAllDrives(list<Drive> *plistDrives);
static void stopShredAllDrives(list<Drive> *plistDrives);
static void updateShredMetrics(list<Drive> *plistDrives); static void updateShredMetrics(list<Drive> *plistDrives);
static void filterIgnoredDrives(list<Drive> *plistDrives); static void filterIgnoredDrives(list<Drive> *plistDrives);
static void filterInvalidDrives(list<Drive> *plistDrives); static void filterInvalidDrives(list<Drive> *plistDrives);

View File

@ -31,6 +31,7 @@ public:
Delete, Delete,
Enter, Enter,
ESC, ESC,
Terminate,
Undefined Undefined
}; };
struct MenuState struct MenuState
@ -50,6 +51,8 @@ public:
static enum UserInput readUserInput(); static enum UserInput readUserInput();
static void terminateTUI();
private: private:
static string sCpuUsage; static string sCpuUsage;
static string sRamUsage; static string sRamUsage;
@ -66,7 +69,7 @@ private:
static WINDOW *createOverViewWindow(int iXSize, int iYSize); static WINDOW *createOverViewWindow(int iXSize, int iYSize);
static WINDOW *createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive drive); static WINDOW *createDetailViewWindow(int iXSize, int iYSize, int iXStart, Drive drive);
static WINDOW *overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart); static WINDOW *overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart);
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected); static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, string sConnection, bool bSelected);
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart); static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate); static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB); static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);

View File

@ -53,6 +53,23 @@ void Printer::print(Drive *drive)
sprintf(msgQueueData.driveData.caDriveErrors, "%i", drive->getErrorCount()); sprintf(msgQueueData.driveData.caDriveErrors, "%i", drive->getErrorCount());
sprintf(msgQueueData.driveData.caDriveShredTimestamp, "%li", drive->getActionStartTimestamp()); sprintf(msgQueueData.driveData.caDriveShredTimestamp, "%li", drive->getActionStartTimestamp());
sprintf(msgQueueData.driveData.caDriveShredDuration, "%li", drive->getTaskDuration()); sprintf(msgQueueData.driveData.caDriveShredDuration, "%li", drive->getTaskDuration());
switch (drive->connectionType)
{
case Drive::USB:
strcpy(msgQueueData.driveData.caDriveConnectionType, "usb");
break;
case Drive::SATA:
strcpy(msgQueueData.driveData.caDriveConnectionType, "sata");
break;
case Drive::NVME:
strcpy(msgQueueData.driveData.caDriveConnectionType, "nvme");
break;
case Drive::UNKNOWN:
default:
strcpy(msgQueueData.driveData.caDriveConnectionType, "na");
}
sprintf(msgQueueData.driveData.caDriveReHddVersion, REHDD_VERSION); sprintf(msgQueueData.driveData.caDriveReHddVersion, REHDD_VERSION);
if (-1 == msgsnd(this->msqid, &msgQueueData, sizeof(t_msgQueueData) - sizeof(long), 0)) if (-1 == msgsnd(this->msqid, &msgQueueData, sizeof(t_msgQueueData) - sizeof(long), 0))

View File

@ -197,6 +197,13 @@ void reHDD::ThreadUserInput()
handleESC(); handleESC();
ui->updateTUI(&listDrives, u8SelectedEntry); ui->updateTUI(&listDrives, u8SelectedEntry);
break; break;
case TUI::UserInput::Terminate:
// cout << "Terminate" << endl;
stopShredAllDrives(&listDrives);
ui->terminateTUI();
sleep(5); // sleep 5 sec
std::exit(1); // Terminates main, doesn't wait for threads
break;
default: default:
break; break;
} }
@ -300,41 +307,51 @@ void reHDD::filterNewDrives(list<Drive> *plistOldDrives, list<Drive> *plistNewDr
* \param pointer of list <Drive>* plistDrives * \param pointer of list <Drive>* plistDrives
* \return void * \return void
*/ */
void reHDD::searchDrives(list<Drive> *plistDrives) void reHDD::searchDrives(std::list<Drive> *plistDrives)
{ {
// Logger::logThis()->info("--> search drives <--"); FILE *fp = popen("lsblk -d -n -o NAME,TRAN", "r");
char *cLine = NULL; if (!fp)
size_t len = 0;
FILE *outputfileHwinfo = popen("lsblk -e 11 -d -o NAME", "r");
if (outputfileHwinfo == NULL)
{ {
Logger::logThis()->error("Unable to scan attached drives"); Logger::logThis()->error("Unable to execute lsblk to scan drives");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
while ((getline(&cLine, &len, outputfileHwinfo)) != -1) char line[256];
while (fgets(line, sizeof(line), fp))
{ {
if (string(cLine).length() == 4) std::string devName, transport;
{ std::istringstream iss(line);
Drive *tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 3)); iss >> devName >> transport;
tmpDrive->state = Drive::NONE;
tmpDrive->bIsOffline = false;
plistDrives->push_back(*tmpDrive);
// Logger::logThis()->info("SATA drive found: " + tmpDrive->getPath());
}
if (string(cLine).length() == 8) if (devName.empty())
{ continue;
Drive *tmpDrive = new Drive("/dev/" + string(cLine).substr(0, 7));
tmpDrive->state = Drive::NONE; Drive *tmpDrive = new Drive("/dev/" + devName);
tmpDrive->bIsOffline = false; tmpDrive->state = Drive::NONE;
plistDrives->push_back(*tmpDrive); tmpDrive->bIsOffline = false;
// Logger::logThis()->info("NVME drive found: " + tmpDrive->getPath());
} // Set connection type
if (transport == "sata")
tmpDrive->connectionType = Drive::SATA;
else if (transport == "usb")
tmpDrive->connectionType = Drive::USB;
else if (transport == "nvme")
tmpDrive->connectionType = Drive::NVME;
else
tmpDrive->connectionType = Drive::UNKNOWN;
plistDrives->push_back(*tmpDrive);
Logger::logThis()->info(
"Drive found: " + tmpDrive->getPath() +
" (type: " +
(tmpDrive->connectionType == Drive::USB ? "USB" : tmpDrive->connectionType == Drive::SATA ? "SATA"
: tmpDrive->connectionType == Drive::NVME ? "NVME"
: "UNKNOWN") +
")");
} }
pclose(outputfileHwinfo);
pclose(fp);
} }
/** /**
@ -392,10 +409,11 @@ void reHDD::filterIgnoredDrives(list<Drive> *plistDrives)
while ((getline(&cLine, &len, outputfileBlkid)) != -1) // parse UUID from blkid while ((getline(&cLine, &len, outputfileBlkid)) != -1) // parse UUID from blkid
{ {
if (string(cLine).find("PTUUID") != string::npos) size_t ptuuidPos = string(cLine).find("PTUUID");
if (ptuuidPos != string::npos)
{ {
string sBlkidOut = string(cLine); string sBlkidOut = string(cLine);
sBlkidOut.erase(0, 18); sBlkidOut.erase(0, ptuuidPos + 8);
sBlkidOut.erase(8, sBlkidOut.length()); sBlkidOut.erase(8, sBlkidOut.length());
sUUID = sBlkidOut; sUUID = sBlkidOut;
// cout << "blkid uuid:" << sUUID << endl; // cout << "blkid uuid:" << sUUID << endl;
@ -464,6 +482,34 @@ void reHDD::startShredAllDrives(list<Drive> *plistDrives)
mxDrives.unlock(); mxDrives.unlock();
} }
/**
* \brief stop shred for all drives
* \param pointer of list <Drive>* plistDrives
* \return void
*/
void reHDD::stopShredAllDrives(list<Drive> *plistDrives)
{
list<Drive>::iterator it;
mxDrives.lock();
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
{
if (it->state == Drive::SHRED_ACTIVE || it->state == Drive::DELETE_ACTIVE)
{
it->state = Drive::NONE;
Logger::logThis()->info("Abort-Shred-Signal for: " + it->getModelName() + "-" + it->getSerial());
// task for drive is running --> remove selection
}
#ifdef LOG_LEVEL_HIGH
ostringstream address;
address << (void const *)&(*it);
Logger::logThis()->info("Started shred (all) for: " + it->getModelName() + "-" + it->getSerial() + " @" + address.str());
#endif
}
mxDrives.unlock();
}
/** /**
* \brief print drives with all information * \brief print drives with all information
* \param pointer of list <Drive>* plistDrives * \param pointer of list <Drive>* plistDrives
@ -665,6 +711,12 @@ bool reHDD::getSystemDrive(string &systemDrive)
break; break;
} }
if (currentLine.ends_with(" /run/overlay/live\n"s))
{
systemDriveFound = true;
break;
}
if (currentLine.ends_with(" /\n"s)) if (currentLine.ends_with(" /\n"s))
{ {
systemDriveFound = true; systemDriveFound = true;

View File

@ -36,7 +36,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
ostringstream address; ostringstream address;
address << (void const *)&(*drive); address << (void const *)&(*drive);
Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str()); Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
drive->bWasShredStarted = true; //Mark drive as partly shredded drive->bWasShredStarted = true; // Mark drive as partly shredded
#ifdef DRYRUN #ifdef DRYRUN
for (int i = 0; i <= 500; i++) for (int i = 0; i <= 500; i++)
@ -93,7 +93,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr); this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr);
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now(); // set inital timestamp for speed metric drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now(); // set inital timestamp for speed metric
drive->sShredSpeed.ulSpeedMetricBytesWritten = 0U; // uses to calculate speed metric drive->sShredSpeed.ulSpeedMetricBytesWritten = 0U; // uses to calculate speed metric
#ifdef LOG_LEVEL_HIGH #ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial()); Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial());
@ -186,22 +186,23 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
drive->state = Drive::CHECK_ACTIVE; drive->state = Drive::CHECK_ACTIVE;
Logger::logThis()->info("Check-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str()); Logger::logThis()->info("Check-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str());
drive->u32DriveChecksumAfterShredding = uiCalcChecksum(driveFileDiscr, drive, ipSignalFd); drive->u32DriveChecksumAfterShredding = uiCalcChecksum(driveFileDiscr, drive, ipSignalFd);
#ifdef LOG_LEVEL_HIGH
if (drive->u32DriveChecksumAferShredding != 0) if (drive->u32DriveChecksumAfterShredding != 0)
{ {
drive->state = Drive::CHECK_FAILED;
Logger::logThis()->info("Shred-Task: Checksum not zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial()); Logger::logThis()->info("Shred-Task: Checksum not zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
} }
else else
{ {
drive->state = Drive::CHECK_SUCCESSFUL;
Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial()); Logger::logThis()->info("Shred-Task: Checksum zero: " + to_string(drive->u32DriveChecksumAfterShredding) + " - Drive: " + drive->getSerial());
} }
#endif #endif
#endif
#endif #endif
cleanup(); cleanup();
if ((drive->state == Drive::SHRED_ACTIVE) || (drive->state == Drive::CHECK_ACTIVE)) if ((drive->state == Drive::SHRED_ACTIVE) || (drive->state == Drive::CHECK_SUCCESSFUL) || (drive->state == Drive::CHECK_FAILED))
{ {
drive->state = Drive::NONE; drive->state = Drive::NONE;
drive->setTaskPercentage(0.0); drive->setTaskPercentage(0.0);

View File

@ -63,6 +63,11 @@ void TUI::initTUI()
void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry) void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
{ {
if (isendwin())
{
return;
}
mxUIrefresh.lock(); mxUIrefresh.lock();
uint16_t u16StdscrX, u16StdscrY; uint16_t u16StdscrX, u16StdscrY;
getmaxyx(stdscr, u16StdscrY, u16StdscrX); getmaxyx(stdscr, u16StdscrY, u16StdscrX);
@ -93,6 +98,9 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
string sSpeed = " "; string sSpeed = " ";
string sTime = " "; string sTime = " ";
string sTemp = it->sTemperatureToText(); string sTemp = it->sTemperatureToText();
string sConnection = (it->connectionType == Drive::USB ? "USB" : it->connectionType == Drive::SATA ? "SATA"
: it->connectionType == Drive::NVME ? "NVME"
: "");
bool bSelectedEntry = false; bool bSelectedEntry = false;
@ -137,6 +145,7 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
case Drive::NONE: case Drive::NONE:
case Drive::SHRED_SELECTED: case Drive::SHRED_SELECTED:
case Drive::DELETE_SELECTED: case Drive::DELETE_SELECTED:
case Drive::CHECK_SUCCESSFUL:
if (it->bWasDeleted) if (it->bWasDeleted)
{ {
sState = "DELETED"; // mark drive as deleted previously sState = "DELETED"; // mark drive as deleted previously
@ -157,7 +166,7 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
} }
#ifdef ZERO_CHECK #ifdef ZERO_CHECK
if (bSelectedEntry && it->bWasChecked && (it->u32DriveChecksumAfterShredding != 0U)) if (bSelectedEntry && it->bWasChecked && (it->state == Drive::CHECK_FAILED))
{ {
dialog = createZeroChecksumWarning(70, 16, ((u16StdscrX) - (int)(u16StdscrX / 2) - 20), (int)(u16StdscrY / 2) - 8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial(), it->u32DriveChecksumAfterShredding); dialog = createZeroChecksumWarning(70, 16, ((u16StdscrX) - (int)(u16StdscrX / 2) - 20), (int)(u16StdscrY / 2) - 8, it->getPath(), it->getModelFamily(), it->getModelName(), it->getSerial(), it->u32DriveChecksumAfterShredding);
wrefresh(dialog); wrefresh(dialog);
@ -182,7 +191,7 @@ void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
uint16_t u16StartOffsetY = (2 * (u8Index)); uint16_t u16StartOffsetY = (2 * (u8Index));
WINDOW *tmp = createEntryWindow((int)(u16StdscrX * (float)(3.0 / 7.0) - 2), 2, 3, u16StartOffsetY + 2, (distance(plistDrives->begin(), it) + 1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, sTemp, bSelectedEntry); WINDOW *tmp = createEntryWindow((int)(u16StdscrX * (float)(3.0 / 7.0) - 2), 2, 3, u16StartOffsetY + 2, (distance(plistDrives->begin(), it) + 1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, sTemp, sConnection, bSelectedEntry);
wrefresh(tmp); wrefresh(tmp);
u8Index++; u8Index++;
} // end loop though drives } // end loop though drives
@ -237,6 +246,9 @@ enum TUI::UserInput TUI::readUserInput()
case 'S': case 'S':
return TUI::UserInput::ShredAll; return TUI::UserInput::ShredAll;
break; break;
case 'T':
return TUI::UserInput::Terminate;
break;
default: default:
return TUI::UserInput::Undefined; return TUI::UserInput::Undefined;
break; break;
@ -244,6 +256,11 @@ enum TUI::UserInput TUI::readUserInput()
return TUI::UserInput::Undefined; return TUI::UserInput::Undefined;
} }
void TUI::terminateTUI()
{
endwin();
}
void TUI::centerTitle(WINDOW *pwin, const char *title) void TUI::centerTitle(WINDOW *pwin, const char *title)
{ {
int x, maxX, stringSize; int x, maxX, stringSize;
@ -342,7 +359,7 @@ WINDOW *TUI::overwriteDetailViewWindow(int iXSize, int iYSize, int iXStart)
return newWindow; return newWindow;
} }
WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected) WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, string sConnection, bool bSelected)
{ {
WINDOW *newWindow; WINDOW *newWindow;
newWindow = newwin(iYSize, iXSize, iYStart, iXStart); newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
@ -387,6 +404,7 @@ WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
37-43: Capacity 37-43: Capacity
44: space 44: space
47-49: Temp 47-49: Temp
57-60: Connection Type
line:02 line:02
0-2: space 0-2: space
@ -403,6 +421,7 @@ WINDOW *TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
mvwaddstr(newWindow, 0, 3, sModelFamily.c_str()); mvwaddstr(newWindow, 0, 3, sModelFamily.c_str());
mvwaddstr(newWindow, 0, 37, sCapacity.c_str()); mvwaddstr(newWindow, 0, 37, sCapacity.c_str());
mvwaddstr(newWindow, 0, 47, sTemp.c_str()); mvwaddstr(newWindow, 0, 47, sTemp.c_str());
mvwaddstr(newWindow, 0, 57, sConnection.c_str());
vTruncateText(&sSerial, 28); vTruncateText(&sSerial, 28);
mvwaddstr(newWindow, 1, 3, sSerial.c_str()); mvwaddstr(newWindow, 1, 3, sSerial.c_str());
@ -482,8 +501,12 @@ WINDOW *TUI::createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, st
{ {
string sLineTmp = "Press d for Delete"; string sLineTmp = "Press d for Delete";
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str()); mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
u16Line++;
} }
string sLineTmp = "Press T for terminating reHDD";
mvwaddstr(newWindow, u16Line++, (iXSize / 2) - (sLineTmp.size() / 2), sLineTmp.c_str());
return newWindow; return newWindow;
} }