This commit is contained in:
Valentino Orlandi 2022-07-06 21:03:58 +02:00
parent 47f83c75ae
commit 483bca74ca
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
2 changed files with 57 additions and 24 deletions

View File

@ -2,8 +2,6 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "modules/dialogs.h"
#include "qtimer.h"
#include <iostream>
@ -68,6 +66,8 @@ MainWindow::MainWindow( QWidget *parent )
////////////////////////
//// INITIALIZATION ////
// sqlite databases paths
this->db_stats_path = "~/.craplog/db";
// WebServers for the LogsList
this->allowed_web_servers[11] = true; // apache2
this->allowed_web_servers[12] = true; // nginx
@ -78,6 +78,27 @@ MainWindow::MainWindow( QWidget *parent )
//// CONFIGS ////
//////////////////////////
//// INTEGRITY CHECKS ////
// statistics' database
if ( CheckSec::checkStatsDatabase( this->db_stats_path ) ) {
// checks failed, abort
this->close();
}
this->craplog.setStatsDatabasePath( this->db_stats_path );
// used-files' hashes' database
if ( CheckSec::checkHashesDatabase( this->db_hashes_path ) ) {
// checks failed, abort
this->close();
}
this->craplog.setHashesDatabasePath( this->db_hashes_path );
// craplog variables
if ( CheckSec::checkCraplog( this->craplog ) ) {
// checks failed, abort
this->close();
}
///////////////////
//// POLISHING ////
// disable the unallowed WebServers
@ -122,7 +143,6 @@ MainWindow::MainWindow( QWidget *parent )
this->ui->listLogFiles->header()->resizeSection(0,200);
this->ui->listLogFiles->header()->resizeSection(1,100);
QTimer::singleShot(500, this, SLOT(on_button_LogFiles_RefreshList_clicked()));
}
MainWindow::~MainWindow()

View File

@ -52,6 +52,40 @@ private slots:
private:
Ui::MainWindow *ui;
// quantoty of informational dialogs to display
int dialogs_Level = 1; // 0: essential, 1: usefull, 2: explanatory
//////////////////
//// GRAPHICS ////
//////////////////
std::unordered_map<int, std::unordered_map<std::string, QString>> TB_COLOR_SCHEMES;
std::unordered_map<std::string, QColor> COLORS;
std::unordered_map<std::string, QFont> FONTS;
int font_size = 13,
font_size_big = 16,
font_size_small = 10;
// base font families, to build fonts from
QString main_font_family,
script_font_family;
/////////////////////
//// GENERAL USE ////
/////////////////////
// get a printable size, from Bytes to the best fit
QString printableSize(const int bytes ),
printableSpeed( const int bytes, const int secs ),
printableTime( const int seconds );
//////////////////
//// DATABASE ////
std::string db_stats_path,
db_hashes_path;
/////////////////
//// CRAPLOG ////
/////////////////
Craplog craplog;
std::thread craplog_thread;
QTimer *craplog_timer;
@ -62,27 +96,6 @@ private:
void craplogStarted();
void craplogFinished();
// quantoty of informational dialogs to display
int dialogs_Level = 1; // 0: essential, 1: usefull, 2: explanatory
std::unordered_map<int, std::unordered_map<std::string, QString>> TB_COLOR_SCHEMES;
std::unordered_map<std::string, QColor> COLORS;
std::unordered_map<std::string, QFont> FONTS;
int font_size = 13,
font_size_big = 16,
font_size_small = 10;
// base font families, to build fonts from
QString main_font_family,
script_font_family;
/////////////////////
//// GENERAL USE ////
// get a printable size, from Bytes to the best fit
QString printableSize(const int bytes ),
printableSpeed( const int bytes, const int secs ),
printableTime( const int seconds );
//////////////
//// LOGS ////
// web servers related