This commit is contained in:
Valentino Orlandi 2024-01-22 01:49:22 +01:00
parent 3ce62bb760
commit 82de6c4ca4
Signed by: elB4RTO
GPG key ID: 1719E976DB2D4E71
12 changed files with 92 additions and 89 deletions

View file

@ -2,9 +2,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "globals/global_configs.h" #include "main_lib.h"
#include "defines/web_servers.h" #include "globals/global_configs.h"
#include "customs/treewidgetitems.h" #include "customs/treewidgetitems.h"
@ -194,9 +194,9 @@ MainWindow::MainWindow(QWidget *parent)
this->ui->box_ConfWindow_Theme->setCurrentIndex( static_cast<int>(GlobalConfigs::window_theme) ); this->ui->box_ConfWindow_Theme->setCurrentIndex( static_cast<int>(GlobalConfigs::window_theme) );
this->ui->box_ConfWindow_Icons->setCurrentIndex( static_cast<int>(GlobalConfigs::icons_theme) ); this->ui->box_ConfWindow_Icons->setCurrentIndex( static_cast<int>(GlobalConfigs::icons_theme) );
// dialogs // dialogs
this->ui->slider_ConfDialogs_General->setValue( this->dialogs_level ); this->ui->slider_ConfDialogs_General->setValue( static_cast<int>(this->dialogs_level) );
this->ui->slider_ConfDialogs_Logs->setValue( this->craplog.getDialogsLevel() ); this->ui->slider_ConfDialogs_Logs->setValue( static_cast<int>(this->craplog.getDialogsLevel()) );
this->ui->slider_ConfDialogs_Stats->setValue( this->crapview.getDialogsLevel() ); this->ui->slider_ConfDialogs_Stats->setValue( static_cast<int>(this->crapview.getDialogsLevel()) );
// text browser // text browser
this->ui->box_ConfTextBrowser_Font->setCurrentText( this->TB.getFontFamily() ); this->ui->box_ConfTextBrowser_Font->setCurrentText( this->TB.getFontFamily() );
this->ui->checkBox_ConfTextBrowser_WideLines->setChecked( this->TB.getWideLinesUsage() ); this->ui->checkBox_ConfTextBrowser_WideLines->setChecked( this->TB.getWideLinesUsage() );
@ -342,7 +342,7 @@ void MainWindow::readConfigs()
if ( err.value() ) { if ( err.value() ) {
proceed &= false; proceed &= false;
QString file; QString file;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( this->configs_path ); file = QString::fromStdString( this->configs_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -356,7 +356,7 @@ void MainWindow::readConfigs()
proceed = IOutils::renameAsCopy( this->configs_path, err ); proceed = IOutils::renameAsCopy( this->configs_path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString path; QString path;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( this->configs_path ); path = QString::fromStdString( this->configs_path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -370,7 +370,7 @@ void MainWindow::readConfigs()
// configuration file not found // configuration file not found
proceed &= false; proceed &= false;
QString file; QString file;
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
file = QString::fromStdString( this->configs_path ); file = QString::fromStdString( this->configs_path );
} }
DialogSec::warnConfFileNotFound( file ); DialogSec::warnConfFileNotFound( file );
@ -439,7 +439,7 @@ void MainWindow::readConfigs()
GlobalConfigs::charts_theme = static_cast<ChartsTheme>( std::stoi( val ) ); GlobalConfigs::charts_theme = static_cast<ChartsTheme>( std::stoi( val ) );
} else if ( var == "MainDialogsLevel" ) { } else if ( var == "MainDialogsLevel" ) {
this->dialogs_level = std::stoi( val ); this->dialogs_level = fromInt( std::stoi( val ) );
} else if ( var == "DefaultWebServer" ) { } else if ( var == "DefaultWebServer" ) {
this->default_web_server = fromString( val ); this->default_web_server = fromString( val );
@ -466,7 +466,7 @@ void MainWindow::readConfigs()
this->on_box_ConfTextBrowser_ColorScheme_currentIndexChanged( std::stoi( val ) ); this->on_box_ConfTextBrowser_ColorScheme_currentIndexChanged( std::stoi( val ) );
} else if ( var == "CraplogDialogsLevel" ) { } else if ( var == "CraplogDialogsLevel" ) {
this->craplog.setDialogsLevel( std::stoi( val ) ); this->craplog.setDialogsLevel( fromInt( std::stoi( val ) ) );
} else if ( var == "HideUsedFiles" ) { } else if ( var == "HideUsedFiles" ) {
hide_used_files = this->s2b.at( val ); hide_used_files = this->s2b.at( val );
@ -632,7 +632,7 @@ void MainWindow::readConfigs()
this->craplog.setBlacklistUsed( WS_IIS, 20, this->s2b.at( val ) ); this->craplog.setBlacklistUsed( WS_IIS, 20, this->s2b.at( val ) );
} else if ( var == "CrapviewDialogsLevel" ) { } else if ( var == "CrapviewDialogsLevel" ) {
this->crapview.setDialogsLevel( std::stoi( val ) ); this->crapview.setDialogsLevel( fromInt( std::stoi( val ) ) );
}/* else { }/* else {
// not valid // not valid
@ -679,7 +679,7 @@ void MainWindow::writeConfigs()
if ( err.value() ) { if ( err.value() ) {
proceed &= false; proceed &= false;
QString file; QString file;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( this->configs_path ); file = QString::fromStdString( this->configs_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -694,7 +694,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::renameAsCopy( this->configs_path, err ); proceed = IOutils::renameAsCopy( this->configs_path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString path; QString path;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( this->configs_path ); path = QString::fromStdString( this->configs_path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -719,7 +719,7 @@ void MainWindow::writeConfigs()
if ( err.value() ) { if ( err.value() ) {
proceed &= false; proceed &= false;
QString file; QString file;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
file = QString::fromStdString( base_path ); file = QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -734,7 +734,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::renameAsCopy( base_path, err ); proceed = IOutils::renameAsCopy( base_path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString path; QString path;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
path = QString::fromStdString( base_path ); path = QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -745,7 +745,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::makeDir( base_path, err ); proceed = IOutils::makeDir( base_path, err );
if ( ! proceed ) { if ( ! proceed ) {
msg = DialogSec::tr("Failed to create the configuration file's directory"); msg = DialogSec::tr("Failed to create the configuration file's directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( base_path ); msg += ":\n"+QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -758,7 +758,7 @@ void MainWindow::writeConfigs()
proceed = IOutils::makeDir( base_path, err ); proceed = IOutils::makeDir( base_path, err );
if ( ! proceed ) { if ( ! proceed ) {
msg = DialogSec::tr("Failed to create the configuration file's directory"); msg = DialogSec::tr("Failed to create the configuration file's directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( base_path ); msg += ":\n"+QString::fromStdString( base_path );
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
} }
@ -779,7 +779,7 @@ void MainWindow::writeConfigs()
configs += "\nWindowTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::window_theme) ); configs += "\nWindowTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::window_theme) );
configs += "\nIconsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::icons_theme) ); configs += "\nIconsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::icons_theme) );
configs += "\nChartsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::charts_theme) ); configs += "\nChartsTheme=" + std::to_string( static_cast<themes_t>(GlobalConfigs::charts_theme) );
configs += "\nMainDialogsLevel=" + std::to_string( this->dialogs_level ); configs += "\nMainDialogsLevel=" + toString( this->dialogs_level );
configs += "\nDefaultWebServer=" + toString( this->default_web_server ); configs += "\nDefaultWebServer=" + toString( this->default_web_server );
configs += "\nDatabaseDataPath=" + this->db_data_path; configs += "\nDatabaseDataPath=" + this->db_data_path;
configs += "\nDatabaseHashesPath=" + this->db_hashes_path; configs += "\nDatabaseHashesPath=" + this->db_hashes_path;
@ -792,7 +792,7 @@ void MainWindow::writeConfigs()
configs += "\nColorScheme=" + std::to_string( this->TB.getColorSchemeID() ); configs += "\nColorScheme=" + std::to_string( this->TB.getColorSchemeID() );
//// CRAPLOG //// //// CRAPLOG ////
configs += "\n\n[Craplog]"; configs += "\n\n[Craplog]";
configs += "\nCraplogDialogsLevel=" + std::to_string( this->craplog.getDialogsLevel() ); configs += "\nCraplogDialogsLevel=" + toString( this->craplog.getDialogsLevel() );
configs += "\nHideUsedFiles=" + this->b2s.at( this->hide_used_files ); configs += "\nHideUsedFiles=" + this->b2s.at( this->hide_used_files );
configs += "\nWarningSize=" + std::to_string( this->craplog.getWarningSize() ); configs += "\nWarningSize=" + std::to_string( this->craplog.getWarningSize() );
//// APACHE2 //// //// APACHE2 ////
@ -846,7 +846,7 @@ void MainWindow::writeConfigs()
configs += "\nIisBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( WS_IIS, 20 ) ); configs += "\nIisBlacklistClientUsed=" + this->b2s.at( this->craplog.isBlacklistUsed( WS_IIS, 20 ) );
//// CRAPVIEW //// //// CRAPVIEW ////
configs += "\n\n[Crapview]"; configs += "\n\n[Crapview]";
configs += "\nCrapviewDialogsLevel=" + std::to_string( this->crapview.getDialogsLevel() ); configs += "\nCrapviewDialogsLevel=" + toString( this->crapview.getDialogsLevel() );
// write on file // write on file
try { try {
@ -879,7 +879,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::renameAsCopy( path, err ); proceed = IOutils::renameAsCopy( path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString p; QString p;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
p = QString::fromStdString( path ); p = QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -891,7 +891,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::makeDir( path, err ); proceed = IOutils::makeDir( path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString msg = DialogSec::tr("Failed to create the database backups' directory"); QString msg = DialogSec::tr("Failed to create the database backups' directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path ); msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -907,7 +907,7 @@ void MainWindow::backupDatabase() const
proceed = IOutils::makeDir( path, err ); proceed = IOutils::makeDir( path, err );
if ( ! proceed ) { if ( ! proceed ) {
QString msg = DialogSec::tr("Failed to create the database backups' directory"); QString msg = DialogSec::tr("Failed to create the database backups' directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path ); msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -1739,7 +1739,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::renameAsCopy( path, err ); ok = IOutils::renameAsCopy( path, err );
if ( ! ok ) { if ( ! ok ) {
QString p; QString p;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
p = QString::fromStdString( path ); p = QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -1750,7 +1750,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::makeDir( path, err ); ok = IOutils::makeDir( path, err );
if ( ! ok ) { if ( ! ok ) {
QString msg = DialogSec::tr("Failed to create the directory"); QString msg = DialogSec::tr("Failed to create the directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path ); msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -1766,7 +1766,7 @@ void MainWindow::makeInitialChecks()
ok = IOutils::makeDir( path, err ); ok = IOutils::makeDir( path, err );
if ( ! ok ) { if ( ! ok ) {
QString msg = DialogSec::tr("Failed to create the directory"); QString msg = DialogSec::tr("Failed to create the directory");
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
msg += ":\n"+QString::fromStdString( path ); msg += ":\n"+QString::fromStdString( path );
if ( err.value() ) { if ( err.value() ) {
err_msg = QString::fromStdString( err.message() ); err_msg = QString::fromStdString( err.message() );
@ -2575,11 +2575,11 @@ void MainWindow::on_button_LogFiles_ViewFile_clicked()
if ( item.size() > warn_size ) { if ( item.size() > warn_size ) {
// exceeds the warning size // exceeds the warning size
QString msg{ item.name() }; QString msg{ item.name() };
if ( this->dialogs_level >= 1 ) { if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1:\n%2").arg( msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Size of the file"), DialogSec::tr("Size of the file"),
PrintSec::printableSize( item.size() ) ); PrintSec::printableSize( item.size() ) );
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n\n%1:\n%2").arg( msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Warning size parameter"), DialogSec::tr("Warning size parameter"),
PrintSec::printableSize( warn_size ) ); PrintSec::printableSize( warn_size ) );
@ -4257,15 +4257,15 @@ void MainWindow::on_box_ConfWindow_Icons_currentIndexChanged(int index)
//// DIALOGS //// //// DIALOGS ////
void MainWindow::on_slider_ConfDialogs_General_sliderReleased() void MainWindow::on_slider_ConfDialogs_General_sliderReleased()
{ {
this->dialogs_level = this->ui->slider_ConfDialogs_General->value(); this->dialogs_level = fromInt( this->ui->slider_ConfDialogs_General->value() );
} }
void MainWindow::on_slider_ConfDialogs_Logs_sliderReleased() void MainWindow::on_slider_ConfDialogs_Logs_sliderReleased()
{ {
this->craplog.setDialogsLevel( this->ui->slider_ConfDialogs_Logs->value() ); this->craplog.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Logs->value() ) );
} }
void MainWindow::on_slider_ConfDialogs_Stats_sliderReleased() void MainWindow::on_slider_ConfDialogs_Stats_sliderReleased()
{ {
this->crapview.setDialogsLevel( this->ui->slider_ConfDialogs_Stats->value() ); this->crapview.setDialogsLevel( fromInt( this->ui->slider_ConfDialogs_Stats->value() ) );
} }

View file

@ -633,7 +633,7 @@ private:
//// GENERAL //// //// GENERAL ////
// quantoty of informational dialogs to display // quantoty of informational dialogs to display
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory DialogsLevel dialogs_level{ DL_NORMAL };
// default web server // default web server
WebServer default_web_server{ WS_APACHE }; WebServer default_web_server{ WS_APACHE };

View file

@ -86,11 +86,11 @@ Craplog::Craplog()
////////////////// //////////////////
//// SETTINGS //// //// SETTINGS ////
int Craplog::getDialogsLevel() const noexcept DialogsLevel Craplog::getDialogsLevel() const noexcept
{ {
return this->dialogs_level; return this->dialogs_level;
} }
void Craplog::setDialogsLevel( const int new_level ) noexcept void Craplog::setDialogsLevel( const DialogsLevel new_level ) noexcept
{ {
this->dialogs_level = new_level; this->dialogs_level = new_level;
this->hashOps.setDialogLevel( new_level ); this->hashOps.setDialogLevel( new_level );
@ -657,7 +657,7 @@ bool Craplog::checkStuff()
if ( file.hasBeenUsed() ) { if ( file.hasBeenUsed() ) {
// already used // already used
QString msg{ file.name() }; QString msg{ file.name() };
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += "\n" + QString::fromStdString( file.hash() ); msg += "\n" + QString::fromStdString( file.hash() );
} }
const int choice = DialogSec::choiceFileAlreadyUsed( msg ); const int choice = DialogSec::choiceFileAlreadyUsed( msg );
@ -680,7 +680,7 @@ bool Craplog::checkStuff()
if ( VecOps::contains( this->used_files_hashes, file.hash() ) ) { if ( VecOps::contains( this->used_files_hashes, file.hash() ) ) {
// appears twice in the list // appears twice in the list
QString msg{ file.name() }; QString msg{ file.name() };
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += "\n" + QString::fromStdString( file.hash() ); msg += "\n" + QString::fromStdString( file.hash() );
} }
const int choice = DialogSec::choiceDuplicateFile( msg ); const int choice = DialogSec::choiceDuplicateFile( msg );
@ -706,11 +706,11 @@ bool Craplog::checkStuff()
if ( file.size() > this->warning_size ) { if ( file.size() > this->warning_size ) {
// exceeds the warning size // exceeds the warning size
QString msg{ file.name() }; QString msg{ file.name() };
if ( this->dialogs_level >= 1 ) { if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1:\n%2").arg( msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Size of the file"), DialogSec::tr("Size of the file"),
PrintSec::printableSize( file.size() ) ); PrintSec::printableSize( file.size() ) );
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n\n%1:\n%2").arg( msg += QString("\n\n%1:\n%2").arg(
DialogSec::tr("Warning size parameter"), DialogSec::tr("Warning size parameter"),
PrintSec::printableSize( this->warning_size ) ); PrintSec::printableSize( this->warning_size ) );
@ -764,11 +764,11 @@ bool Craplog::checkStuff()
if ( this->proceed && logs_size >= MemOps::availableMemory() ) { if ( this->proceed && logs_size >= MemOps::availableMemory() ) {
// no files left, abort // no files left, abort
QString msg; QString msg;
if ( this->dialogs_level >= 1 ) { if ( this->dialogs_level >= DL_NORMAL ) {
msg += QString("\n\n%1: %2").arg( msg += QString("\n\n%1: %2").arg(
DialogSec::tr("Available memory"), DialogSec::tr("Available memory"),
PrintSec::printableSize( MemOps::availableMemory() ) ); PrintSec::printableSize( MemOps::availableMemory() ) );
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
msg += QString("\n%1: %2").arg( msg += QString("\n%1: %2").arg(
DialogSec::tr("Size of the logs"), DialogSec::tr("Size of the logs"),
PrintSec::printableSize( logs_size ) ); PrintSec::printableSize( logs_size ) );

View file

@ -4,7 +4,7 @@
#include <QtCharts> #include <QtCharts>
#include "defines/web_servers.h" #include "main_lib.h"
#include "modules/craplog/modules/lib.h" #include "modules/craplog/modules/lib.h"
#include "modules/craplog/modules/hash.h" #include "modules/craplog/modules/hash.h"
@ -29,10 +29,10 @@ public:
//// DIALOGS //// //// DIALOGS ////
//! Returns the Dialogs level //! Returns the Dialogs level
int getDialogsLevel() const noexcept; DialogsLevel getDialogsLevel() const noexcept;
//! Sets the new Dialogs level //! Sets the new Dialogs level
void setDialogsLevel( const int new_level ) noexcept; void setDialogsLevel( const DialogsLevel new_level ) noexcept;
/////////////////// ///////////////////
//// DATABASES //// //// DATABASES ////
@ -464,7 +464,7 @@ private:
//// DIALOGS //// //// DIALOGS ////
// quantity of information to display throught dialogs // quantity of information to display throught dialogs
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory DialogsLevel dialogs_level{ DL_NORMAL };
/////////////////// ///////////////////

View file

@ -19,9 +19,9 @@
#include <QSqlError> #include <QSqlError>
void HashOps::setDialogLevel( const int new_level ) noexcept void HashOps::setDialogLevel( const DialogsLevel new_level ) noexcept
{ {
this->dialog_level = new_level; this->dialogs_level = new_level;
} }
@ -46,7 +46,7 @@ bool HashOps::loadUsedHashesLists( const std::string& db_path ) noexcept
// error opening database // error opening database
successful &= false; successful &= false;
QString err_msg; QString err_msg;
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
DialogSec::errDatabaseFailedOpening( db_name, err_msg ); DialogSec::errDatabaseFailedOpening( db_name, err_msg );
@ -160,9 +160,9 @@ bool HashOps::insertUsedHash( QSqlQuery& query, const QString& db_name, const st
// error opening database // error opening database
successful &= false; successful &= false;
QString query_msg, err_msg; QString query_msg, err_msg;
if ( this->dialog_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.exec()"; query_msg = "query.exec()";
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text(); err_msg = query.lastError().text();
} }
} }
@ -195,7 +195,7 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database // error opening database
successful &= false; successful &= false;
QString err_msg; QString err_msg;
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
DialogSec::errDatabaseFailedOpening( db_name, err_msg ); DialogSec::errDatabaseFailedOpening( db_name, err_msg );
@ -206,9 +206,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database // error opening database
successful &= false; successful &= false;
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.transaction()"; stmt_msg = "db.transaction()";
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
} }
@ -231,9 +231,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
// error opening database // error opening database
successful &= false; successful &= false;
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.commit()"; stmt_msg = "db.commit()";
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg= db.lastError().text(); err_msg= db.lastError().text();
} }
} }
@ -253,9 +253,9 @@ bool HashOps::insertUsedHashes( const std::string& db_path, const std::vector<st
if ( ! db.rollback() ) { if ( ! db.rollback() ) {
// error rolling back commits // error rolling back commits
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialog_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.rollback()"; stmt_msg = "db.rollback()";
if ( this->dialog_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
} }

View file

@ -2,7 +2,7 @@
#define LOGDOCTOR__CRAPLOG__HASH_H #define LOGDOCTOR__CRAPLOG__HASH_H
#include "defines/web_servers.h" #include "main_lib.h"
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
@ -24,7 +24,7 @@ class HashOps final
public: public:
//! Sets the new Dialogs level //! Sets the new Dialogs level
void setDialogLevel( const int new_level ) noexcept; void setDialogLevel( const DialogsLevel new_level ) noexcept;
//! Retrieves the lists of hashes from the database file //! Retrieves the lists of hashes from the database file
/*! /*!
@ -62,7 +62,7 @@ public:
private: private:
// Quantity of information to display throught dialogs // Quantity of information to display throught dialogs
int dialog_level{ 2 }; DialogsLevel dialogs_level{ DL_NORMAL };
// List of Web Servers names for database tables // List of Web Servers names for database tables
const std::unordered_map<WebServer, QString> ws_names{ const std::unordered_map<WebServer, QString> ws_names{

View file

@ -13,7 +13,7 @@
#include "modules/craplog/modules/workers/lib.h" #include "modules/craplog/modules/workers/lib.h"
CraplogLister::CraplogLister( const WebServer web_server, const unsigned dialogs_level, const std::string& logs_path, const LogsFormat& logs_format, const HashOps& hashOps, const std::function<bool(const std::string&)> check_filename, QObject* parent ) CraplogLister::CraplogLister( const WebServer web_server, const DialogsLevel dialogs_level, const std::string& logs_path, const LogsFormat& logs_format, const HashOps& hashOps, const std::function<bool(const std::string&)> check_filename, QObject* parent )
: QObject { parent } : QObject { parent }
, web_server { web_server } , web_server { web_server }
, dialogs_level { dialogs_level } , dialogs_level { dialogs_level }
@ -61,7 +61,7 @@ void CraplogLister::work()
// it's a file, check the readability // it's a file, check the readability
if ( ! IOutils::checkFile( path, true ) ) { if ( ! IOutils::checkFile( path, true ) ) {
// not readable, skip // not readable, skip
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
emit this->showDialog( WorkerDialog::warnFileNotReadable, emit this->showDialog( WorkerDialog::warnFileNotReadable,
{name} ); {name} );
} }
@ -86,7 +86,7 @@ void CraplogLister::work()
} }
if ( content.empty() ) { if ( content.empty() ) {
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
emit this->showDialog( WorkerDialog::warnEmptyFile, emit this->showDialog( WorkerDialog::warnEmptyFile,
{name} ); {name} );
} }

View file

@ -2,13 +2,14 @@
#define LOGDOCTOR__CRAPLOG__WORKERS__LISTER_H #define LOGDOCTOR__CRAPLOG__WORKERS__LISTER_H
#include "main_lib.h"
#include <QObject> #include <QObject>
struct LogsFormat; struct LogsFormat;
struct LogFile; struct LogFile;
class HashOps; class HashOps;
enum class WebServer;
enum class WorkerDialog; enum class WorkerDialog;
@ -20,7 +21,7 @@ public:
explicit CraplogLister( explicit CraplogLister(
const WebServer web_server, const WebServer web_server,
const unsigned dialogs_level, const DialogsLevel dialogs_level,
const std::string& logs_path, const std::string& logs_path,
const LogsFormat& logs_format, const LogsFormat& logs_format,
const HashOps& hashOps, const HashOps& hashOps,
@ -48,7 +49,7 @@ private:
const WebServer web_server; const WebServer web_server;
const unsigned dialogs_level; const DialogsLevel dialogs_level;
const std::string& logs_path; const std::string& logs_path;

View file

@ -1,8 +1,6 @@
#include "parser.h" #include "parser.h"
#include "defines/web_servers.h"
#include "utilities/checks.h" #include "utilities/checks.h"
#include "utilities/gzip.h" #include "utilities/gzip.h"
#include "utilities/io.h" #include "utilities/io.h"
@ -19,7 +17,7 @@
#include <QSqlError> #include <QSqlError>
CraplogParser::CraplogParser( const WebServer web_server, const unsigned dialogs_level, const std::string& db_data_path, const std::string& db_hashes_path, const LogsFormat& logs_format, const bw_lists_t& blacklists, const bw_lists_t& warnlists, const worker_files_t& log_files, QObject* parent ) CraplogParser::CraplogParser( const WebServer web_server, const DialogsLevel dialogs_level, const std::string& db_data_path, const std::string& db_hashes_path, const LogsFormat& logs_format, const bw_lists_t& blacklists, const bw_lists_t& warnlists, const worker_files_t& log_files, QObject* parent )
: QObject { parent } : QObject { parent }
, web_server { web_server } , web_server { web_server }
, dialogs_level { dialogs_level } , dialogs_level { dialogs_level }
@ -254,7 +252,7 @@ void CraplogParser::storeLogLines()
// error opening database // error opening database
this->proceed &= false; this->proceed &= false;
QString err_msg; QString err_msg;
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
emit this->showDialog( WorkerDialog::errDatabaseFailedOpening, emit this->showDialog( WorkerDialog::errDatabaseFailedOpening,
@ -268,9 +266,9 @@ void CraplogParser::storeLogLines()
// error opening database // error opening database
this->proceed &= false; this->proceed &= false;
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.transaction()"; stmt_msg = "db.transaction()";
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
} }
@ -288,9 +286,9 @@ void CraplogParser::storeLogLines()
// error opening database // error opening database
this->proceed &= false; this->proceed &= false;
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.commit()"; stmt_msg = "db.commit()";
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg= db.lastError().text(); err_msg= db.lastError().text();
} }
} }
@ -311,9 +309,9 @@ void CraplogParser::storeLogLines()
if ( ! db.rollback() ) { if ( ! db.rollback() ) {
// error rolling back commits // error rolling back commits
QString stmt_msg, err_msg; QString stmt_msg, err_msg;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
stmt_msg = "db.rollback()"; stmt_msg = "db.rollback()";
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = db.lastError().text(); err_msg = db.lastError().text();
} }
} }
@ -511,9 +509,9 @@ bool CraplogParser::storeData( QSqlDatabase& db )
if ( ! query.prepare( query_stmt ) ) { if ( ! query.prepare( query_stmt ) ) {
// error opening database // error opening database
QString query_msg, err_msg; QString query_msg, err_msg;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.prepare()"; query_msg = "query.prepare()";
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text(); err_msg = query.lastError().text();
} }
} }
@ -526,9 +524,9 @@ bool CraplogParser::storeData( QSqlDatabase& db )
if ( ! query.exec() ) { if ( ! query.exec() ) {
// error finalizing step // error finalizing step
QString query_msg, err_msg; QString query_msg, err_msg;
if ( this->dialogs_level > 0 ) { if ( this->dialogs_level > DL_ESSENTIAL ) {
query_msg = "query.exec()"; query_msg = "query.exec()";
if ( this->dialogs_level == 2 ) { if ( this->dialogs_level == DL_EXPLANATORY ) {
err_msg = query.lastError().text(); err_msg = query.lastError().text();
} }
} }

View file

@ -2,6 +2,8 @@
#define LOGDOCTOR__CRAPLOG__WORKERS__PARSER_H #define LOGDOCTOR__CRAPLOG__WORKERS__PARSER_H
#include "main_lib.h"
#include "modules/craplog/modules/lib.h" #include "modules/craplog/modules/lib.h"
#include <QObject> #include <QObject>
@ -12,7 +14,6 @@
struct BWlist; struct BWlist;
struct LogLineData; struct LogLineData;
enum class WebServer;
enum class WorkerDialog; enum class WorkerDialog;
class QSqlDatabase; class QSqlDatabase;
@ -30,7 +31,7 @@ public:
explicit CraplogParser( explicit CraplogParser(
const WebServer web_server, const WebServer web_server,
const unsigned dialogs_level, const DialogsLevel dialogs_level,
const std::string& db_data_path, const std::string& db_data_path,
const std::string& db_hashes_path, const std::string& db_hashes_path,
const LogsFormat& logs_format, const LogsFormat& logs_format,
@ -76,7 +77,7 @@ private:
const WebServer web_server; const WebServer web_server;
const unsigned dialogs_level; const DialogsLevel dialogs_level;
bool proceed{ true }; bool proceed{ true };

View file

@ -8,11 +8,11 @@
#include <QTableWidget> #include <QTableWidget>
int Crapview::getDialogsLevel() const noexcept DialogsLevel Crapview::getDialogsLevel() const noexcept
{ {
return this->dialogs_level; return this->dialogs_level;
} }
void Crapview::setDialogsLevel( const int new_level ) noexcept void Crapview::setDialogsLevel( const DialogsLevel new_level ) noexcept
{ {
this->dialogs_level = new_level; this->dialogs_level = new_level;
} }

View file

@ -2,13 +2,16 @@
#define LOGDOCTOR__CRAPVIEW_H #define LOGDOCTOR__CRAPVIEW_H
#include <QHash> #include "main_lib.h"
#include <QtCharts>
#include "modules/crapview/modules/query.h" #include "modules/crapview/modules/query.h"
#include <QHash>
#include <QtCharts>
#include <string> #include <string>
class QTableWidget; class QTableWidget;
@ -24,10 +27,10 @@ class Crapview final : public QObject
public: public:
//! Returns the Dialogs level //! Returns the Dialogs level
int getDialogsLevel() const noexcept; DialogsLevel getDialogsLevel() const noexcept;
//! Sets the new Dialogs level //! Sets the new Dialogs level
void setDialogsLevel( const int new_level ) noexcept; void setDialogsLevel( const DialogsLevel new_level ) noexcept;
/*//! Sets the new charts theme to use /*//! Sets the new charts theme to use
@ -262,7 +265,7 @@ private slots:
private: private:
// quantity of information to display throught dialogs // quantity of information to display throught dialogs
int dialogs_level{ 2 }; // 0: essential, 1: usefull, 2: explanatory DialogsLevel dialogs_level{ DL_NORMAL };
// charts theme ID // charts theme ID
int charts_theme{ 0 }; int charts_theme{ 0 };