5 Commits

6 changed files with 35 additions and 5 deletions

View File

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

View File

@ -8,7 +8,7 @@
#ifndef REHDD_H_
#define REHDD_H_
#define REHDD_VERSION "V1.2.0"
#define REHDD_VERSION "V1.2.1"
// Drive handling Settings
#define WORSE_HOURS 19200 // mark drive if at this limit or beyond

View File

@ -51,6 +51,8 @@ public:
static enum UserInput readUserInput();
static void terminateTUI();
private:
static string sCpuUsage;
static string sRamUsage;
@ -80,4 +82,4 @@ private:
string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
static void vTruncateText(string *psText, uint16_t u16MaxLenght);
};
#endif // TUI_H_
#endif // TUI_H_

View File

@ -53,6 +53,23 @@ void Printer::print(Drive *drive)
sprintf(msgQueueData.driveData.caDriveErrors, "%i", drive->getErrorCount());
sprintf(msgQueueData.driveData.caDriveShredTimestamp, "%li", drive->getActionStartTimestamp());
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);
if (-1 == msgsnd(this->msqid, &msgQueueData, sizeof(t_msgQueueData) - sizeof(long), 0))

View File

@ -198,8 +198,9 @@ void reHDD::ThreadUserInput()
ui->updateTUI(&listDrives, u8SelectedEntry);
break;
case TUI::UserInput::Terminate:
cout << "Terminate" << endl;
// cout << "Terminate" << endl;
stopShredAllDrives(&listDrives);
ui->terminateTUI();
sleep(5); // sleep 5 sec
std::exit(1); // Terminates main, doesn't wait for threads
break;
@ -724,4 +725,4 @@ bool reHDD::getSystemDrive(string &systemDrive)
pclose(outputfileHwinfo);
return systemDriveFound;
}
}

View File

@ -63,6 +63,11 @@ void TUI::initTUI()
void TUI::updateTUI(list<Drive> *plistDrives, uint8_t u8SelectedEntry)
{
if (isendwin())
{
return;
}
mxUIrefresh.lock();
uint16_t u16StdscrX, u16StdscrY;
getmaxyx(stdscr, u16StdscrY, u16StdscrX);
@ -250,6 +255,11 @@ enum TUI::UserInput TUI::readUserInput()
return TUI::UserInput::Undefined;
}
void TUI::terminateTUI()
{
endwin();
}
void TUI::centerTitle(WINDOW *pwin, const char *title)
{
int x, maxX, stringSize;