Translation improvements

This commit is contained in:
Valentino Orlandi 2022-08-22 21:16:53 +02:00
parent 6360c0634c
commit 4ae6cba3ce
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
9 changed files with 672 additions and 531 deletions

View File

@ -17,18 +17,22 @@ void DialogSec::errLangLocaleInvalid( QWidget *parent, const QString& locale )
{
std::ignore=
QMessageBox::critical(parent,
t_LANG_INVALID,
QString("%1:\n%2\n\n%3")
.arg( m_LANG_LOCALE_INVALID, locale, r_CONF_DONT_EDIT ),
DialogSec::tr( t_LANG_INVALID.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_LANG_LOCALE_INVALID.c_str() ),
locale,
DialogSec::tr( r_CONF_DONT_EDIT.c_str() ) ),
QMessageBox::Ok );
}
void DialogSec::errLangNotAccepted( QWidget *parent, const QString& locale )
{
std::ignore=
QMessageBox::critical(parent,
t_LANG_INVALID,
QString("%1:\n%2\n\n%3")
.arg( m_LANG_NOT_ACCEPTED, locale, r_LANG_NOT_ACCEPTED ),
DialogSec::tr( t_LANG_INVALID.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_LANG_NOT_ACCEPTED.c_str() ),
locale,
DialogSec::tr( r_LANG_NOT_ACCEPTED.c_str() ) ),
QMessageBox::Ok );
}
@ -41,9 +45,10 @@ void DialogSec::warnConfFileNotFound( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::warning(parent,
t_CONF_FILE_NOT_FOUND,
QString("%1%2\n\n%3")
.arg( m_CONF_FILE_NOT_FOUND, (file=="") ? file : ":\n"+file, f_SKIPPING ),
DialogSec::tr( t_CONF_FILE_NOT_FOUND.c_str() ),
QString("%1%2\n\n%3").arg(
DialogSec::tr( m_CONF_FILE_NOT_FOUND.c_str() ),
(file=="") ? file : ":\n"+file,DialogSec::tr( f_SKIPPING.c_str() ) ),
QMessageBox::Ok );
}
@ -51,9 +56,11 @@ void DialogSec::errConfFailedWriting( QWidget *parent, const QString& msg )
{
std::ignore=
QMessageBox::critical(parent,
t_CONF_FILE_FAILED_W,
QString("%1%2\n\n%3")
.arg( m_CONF_FILE_ERROR, (msg=="") ? msg : ":\n"+msg, m_CONF_FILE_FAILED_W ),
DialogSec::tr( t_CONF_FILE_FAILED_W.c_str() ),
QString("%1%2\n\n%3").arg(
DialogSec::tr( m_CONF_FILE_ERROR.c_str() ),
(msg=="") ? msg : ":\n"+msg,
DialogSec::tr( m_CONF_FILE_FAILED_W.c_str() ) ),
QMessageBox::Ok );
}
@ -61,18 +68,22 @@ void DialogSec::errConfFileNotReadable( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_NOT_READABLE,
QString("%1\n\n%2%3")
.arg( m_CONF_FILE_ERROR, m_FILE_NOT_READABLE, (file=="") ? file : ":\n"+file ),
DialogSec::tr( t_FILE_NOT_READABLE.c_str() ),
QString("%1\n\n%2%3").arg(
DialogSec::tr( m_CONF_FILE_ERROR.c_str() ),
DialogSec::tr( m_FILE_NOT_READABLE.c_str() ),
(file=="") ? file : ":\n"+file ),
QMessageBox::Ok );
}
void DialogSec::errConfFileNotWritable( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_NOT_WRITABLE,
QString("%1\n\n%2%3")
.arg( m_CONF_FILE_ERROR, m_FILE_NOT_WRITABLE, (file=="") ? file : ":\n"+file ),
DialogSec::tr( t_FILE_NOT_WRITABLE.c_str() ),
QString("%1\n\n%2%3").arg(
DialogSec::tr( m_CONF_FILE_ERROR.c_str() ),
DialogSec::tr( m_FILE_NOT_WRITABLE.c_str() ),
(file=="") ? file : ":\n"+file ),
QMessageBox::Ok );
}
@ -81,9 +92,11 @@ void DialogSec::errConfDirNotWritable( QWidget *parent, const QString& dir )
{
std::ignore=
QMessageBox::critical(parent,
t_DIR_NOT_WRITABLE,
QString("%1\n\n%2%3")
.arg( m_CONF_FILE_ERROR, m_DIR_NOT_WRITABLE, (dir=="") ? dir : ":\n"+dir ),
DialogSec::tr( t_DIR_NOT_WRITABLE.c_str() ),
QString("%1\n\n%2%3").arg(
DialogSec::tr( m_CONF_FILE_ERROR.c_str() ),
DialogSec::tr( m_DIR_NOT_WRITABLE.c_str() ),
(dir=="") ? dir : ":\n"+dir ),
QMessageBox::Ok );
}
@ -97,21 +110,24 @@ void DialogSec::errVersionCheckFailed( QWidget *parent, const int& err_code )
QString msg;
switch (err_code) {
case 1:
msg = QString("%1\n\n%2").arg( m_CONNECTIONS_FAILED, r_UPSTREAM_FAILURE );
msg = QString("%1\n\n%2").arg(
DialogSec::tr( m_CONNECTIONS_FAILED.c_str() ),
DialogSec::tr( r_UPSTREAM_FAILURE.c_str() ) );
break;
case 10:
msg = m_VERSION_NOT_FOUND;
msg = DialogSec::tr( m_VERSION_NOT_FOUND.c_str() );
break;
case 11:
msg = m_VERSION_MALFORMED;
msg = DialogSec::tr( m_VERSION_MALFORMED.c_str() );
break;
}
std::ignore=
QMessageBox::critical(parent,
t_VERSION_CHECK_FAILED,
QString("%1\n\n%2")
.arg( m_VERSION_CHECK_FAILED, msg ),
DialogSec::tr( t_VERSION_CHECK_FAILED.c_str() ),
QString("%1\n\n%2").arg(
DialogSec::tr( m_VERSION_CHECK_FAILED.c_str() ),
msg ),
QMessageBox::Ok );
}
@ -119,9 +135,11 @@ void DialogSec::warnConnectionFailed( QWidget *parent, const QString& link, cons
{
std::ignore=
QMessageBox::warning(parent,
t_CONNECTION_FAILED,
QString("%1:\n%2\n\n%3")
.arg( m_CONNECTION_FAILED, link, err_msg ),
DialogSec::tr( t_CONNECTION_FAILED.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_CONNECTION_FAILED.c_str() ),
link,
err_msg ),
QMessageBox::Ok );
}
@ -129,24 +147,24 @@ void DialogSec::msgNewVersion( QWidget *parent )
{
std::ignore=
QMessageBox::information(parent,
t_VERSION_CHECK,
m_NEW_VERSION_AVAILABLE,
DialogSec::tr( t_VERSION_CHECK.c_str() ),
DialogSec::tr( m_NEW_VERSION_AVAILABLE.c_str() ),
QMessageBox::Ok );
}
void DialogSec::msgSameVersion( QWidget *parent )
{
std::ignore=
QMessageBox::information(parent,
t_VERSION_CHECK,
m_SAME_VERSION,
DialogSec::tr( t_VERSION_CHECK.c_str() ),
DialogSec::tr( m_SAME_VERSION.c_str() ),
QMessageBox::Ok );
}
void DialogSec::warnFutureVersion( QWidget *parent )
{
std::ignore=
QMessageBox::warning(parent,
t_VERSION_CHECK,
m_FUTURE_VERSION_RUNNING,
DialogSec::tr( t_VERSION_CHECK.c_str() ),
DialogSec::tr( m_FUTURE_VERSION_RUNNING.c_str() ),
QMessageBox::Ok );
}
@ -159,23 +177,25 @@ void DialogSec::errHelpFailed( QWidget *parent, const QString& link, const QStri
{
std::ignore=
QMessageBox::critical(parent,
t_HELP_FAILED_LOADING,
QString("%1%2\n\n%3%4")
.arg( m_HELP_FAILED_LOADING,
(msg=="") ? msg : ":\n"+msg,
f_ADD_RESOURCES,
(link=="") ? link : ":\n"+link ),
DialogSec::tr( t_HELP_FAILED_LOADING.c_str() ),
QString("%1%2\n\n%3%4").arg(
DialogSec::tr( m_HELP_FAILED_LOADING.c_str() ),
(msg=="") ? msg : ":\n"+msg,
DialogSec::tr( f_ADD_RESOURCES.c_str() ),
(link=="") ? link : ":\n"+link ),
QMessageBox::Ok );
}
void DialogSec::errHelpNotFound( QWidget *parent, const QString& link )
{
DialogSec::errHelpFailed( parent, link, m_FILE_NOT_FOUND.toLower() );
DialogSec::errHelpFailed( parent, link,
DialogSec::tr( m_FILE_NOT_FOUND.c_str() ).toLower() );
}
void DialogSec::errHelpNotReadable( QWidget *parent, const QString& link )
{
DialogSec::errHelpFailed( parent, link, m_FILE_NOT_READABLE.toLower() );
DialogSec::errHelpFailed( parent, link,
DialogSec::tr( m_FILE_NOT_READABLE.c_str() ).toLower() );
}
@ -188,9 +208,11 @@ void DialogSec::errSqlDriverNotFound( QWidget *parent, const QString& driver )
{
std::ignore=
QMessageBox::critical(parent,
t_DB_DRIVER_NOT_FOUND,
QString("%1:\n%2\n\n%3")
.arg( m_DB_DRIVER_NOT_FOUND, driver, f_ABORTING ),
DialogSec::tr( t_DB_DRIVER_NOT_FOUND.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_DRIVER_NOT_FOUND.c_str() ),
driver,
DialogSec::tr( f_ABORTING.c_str() ) ),
QMessageBox::Ok );
}
@ -198,9 +220,11 @@ const bool DialogSec::choiceDatabaseNotFound( QWidget *parent, const QString& db
{
bool choice = false;
auto response = QMessageBox::question(parent,
t_FILE_NOT_FOUND,
QString("%1:\n%2\n\n%3")
.arg( m_DB_NOT_FOUND, db_name, q_DB_CREATE ),
DialogSec::tr( t_FILE_NOT_FOUND.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_NOT_FOUND.c_str() ),
db_name,
DialogSec::tr( q_DB_CREATE.c_str() ) ),
QMessageBox::Yes | QMessageBox::No );
if ( response == QMessageBox::Yes ) {
choice = true;
@ -210,36 +234,52 @@ const bool DialogSec::choiceDatabaseNotFound( QWidget *parent, const QString& db
const bool DialogSec::choiceDatabaseWrongTable(QWidget *parent, const QString& db_name, const QString& table_name )
{
QString msg = QString("%1:\n%2 -> %3").arg( m_DB_WRONG_TABLE_NAME, db_name, table_name );
return choiceDatabaseRenew( parent, t_DB_WRONG_TABLE_NAME, msg );
QString msg = QString("%1:\n%2 -> %3").arg(
DialogSec::tr( m_DB_WRONG_TABLE_NAME.c_str() ),
db_name, table_name );
return choiceDatabaseRenew( parent,
DialogSec::tr( t_DB_WRONG_TABLE_NAME.c_str() ), msg );
}
const bool DialogSec::choiceDatabaseMissingTable(QWidget *parent, const QString& db_name, const QString& table_name )
{
QString msg = QString("%1:\n%2 -> %3").arg( m_DB_MISSING_TABLE, db_name, table_name );
return choiceDatabaseRenew( parent, t_DB_MISSING_TABLE, msg );
QString msg = QString("%1:\n%2 -> %3").arg(
DialogSec::tr( m_DB_MISSING_TABLE.c_str() ),
db_name, table_name );
return choiceDatabaseRenew( parent,
DialogSec::tr( t_DB_MISSING_TABLE.c_str() ), msg );
}
const bool DialogSec::choiceDatabaseWrongColumn(QWidget *parent, const QString& db_name, const QString& table_name, const QString& column_name )
{
QString msg = QString("%1:\n%2 -> %3 -> %4").arg( m_DB_WRONG_COLUMN_NAME, db_name, table_name, column_name );
return choiceDatabaseRenew( parent, t_DB_WRONG_COLUMN_NAME, msg );
QString msg = QString("%1:\n%2 -> %3 -> %4").arg(
DialogSec::tr( m_DB_WRONG_COLUMN_NAME.c_str() ),
db_name, table_name, column_name );
return choiceDatabaseRenew( parent,
DialogSec::tr( t_DB_WRONG_COLUMN_NAME.c_str() ), msg );
}
const bool DialogSec::choiceDatabaseMissingColumn(QWidget *parent, const QString& db_name, const QString& table_name, const QString& column_name )
{
QString msg = QString("%1:\n%2 -> %3 -> %4").arg( m_DB_MISSING_COLUMN, db_name, table_name, column_name );
return choiceDatabaseRenew( parent, t_DB_MISSING_COLUMN, msg );
QString msg = QString("%1:\n%2 -> %3 -> %4").arg(
DialogSec::tr( m_DB_MISSING_COLUMN.c_str() ),
db_name, table_name, column_name );
return choiceDatabaseRenew( parent,
DialogSec::tr( t_DB_MISSING_COLUMN.c_str() ), msg );
}
const bool DialogSec::choiceDatabaseWrongDataType(QWidget *parent, const QString& db_name, const QString& table_name, const QString& column_name, const QString& data_type )
{
QString msg = QString("%1:\n%2 -> %3 -> %4 -> %5").arg( m_DB_WRONG_COLUMN_TYPE, db_name, table_name, column_name, data_type );
return choiceDatabaseRenew( parent, t_DB_WRONG_COLUMN_TYPE, msg );
QString msg = QString("%1:\n%2 -> %3 -> %4 -> %5").arg(
DialogSec::tr( m_DB_WRONG_COLUMN_TYPE.c_str() ),
db_name, table_name, column_name, data_type );
return choiceDatabaseRenew( parent,
DialogSec::tr( t_DB_WRONG_COLUMN_TYPE.c_str() ), msg );
}
const bool DialogSec::choiceDatabaseRenew(QWidget *parent, const QString& title, const QString& msg )
{
bool choice = false;
auto response = QMessageBox::warning(parent,
title,
QString("%1\n\n%2")
.arg( msg, q_DB_RENEW ),
QString("%1\n\n%2").arg(
msg,
DialogSec::tr( q_DB_RENEW.c_str() ) ),
QMessageBox::Yes | QMessageBox::No );
if ( response == QMessageBox::Yes ) {
choice = true;
@ -250,9 +290,10 @@ void DialogSec::msgDatabaseCreated( QWidget *parent, const QString& db_name )
{
std::ignore=
QMessageBox::information(parent,
t_DB_CREATED,
QString("%1:\n%2")
.arg( m_DB_CREATED, db_name ),
DialogSec::tr( t_DB_CREATED.c_str() ),
QString("%1:\n%2").arg(
DialogSec::tr( m_DB_CREATED.c_str() ),
db_name ),
QMessageBox::Ok );
}
@ -260,9 +301,12 @@ void DialogSec::errDatabaseNotFile( QWidget *parent, const QString& db_name )
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_NOT_FILE,
QString("%1\n\n%2:\n%3\n\n%4")
.arg( m_DB_NOT_FOUND, m_FILE_NOT_FILE, db_name, r_REMOVE_ENTRY ),
DialogSec::tr( t_FILE_NOT_FILE.c_str() ),
QString("%1\n\n%2:\n%3\n\n%4").arg(
DialogSec::tr( m_DB_NOT_FOUND.c_str() ),
DialogSec::tr( m_FILE_NOT_FILE.c_str() ),
db_name,
DialogSec::tr( r_REMOVE_ENTRY.c_str() ) ),
QMessageBox::Ok );
}
@ -270,9 +314,11 @@ void DialogSec::errDatabaseNotReadable( QWidget *parent, const QString& db_name
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_NOT_READABLE,
QString("%1:\n%2\n\n%3")
.arg( m_DB_NOT_READABLE, db_name, r_SET_PERMISSIONS ),
DialogSec::tr( t_FILE_NOT_READABLE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_NOT_READABLE.c_str() ),
db_name,
DialogSec::tr( r_SET_PERMISSIONS.c_str() ) ),
QMessageBox::Ok );
}
@ -280,9 +326,11 @@ void DialogSec::errDatabaseNotWritable( QWidget *parent, const QString& db_name
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_NOT_WRITABLE,
QString("%1:\n%2\n\n%3")
.arg( m_DB_NOT_WRITABLE, db_name, r_SET_PERMISSIONS ),
DialogSec::tr( t_FILE_NOT_WRITABLE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_NOT_WRITABLE.c_str() ),
db_name,
DialogSec::tr( r_SET_PERMISSIONS.c_str() ) ),
QMessageBox::Ok );
}
@ -290,13 +338,15 @@ void DialogSec::errDatabaseFailedCreating(QWidget *parent, const QString& db_nam
{
QString msg = db_name;
if ( err_msg != "" ) {
msg += "\n\n" + m_DB_FAILED_ERRMSG + ":\n" + err_msg;
msg += "\n\n" + DialogSec::tr( m_DB_FAILED_ERRMSG.c_str() ) + ":\n" + err_msg;
}
std::ignore=
QMessageBox::critical(parent,
t_DB_FAILED_CREATING,
QString("%1:\n%2\n\n%3")
.arg( m_DB_FAILED_CREATING, msg, f_ABORTING ),
DialogSec::tr( t_DB_FAILED_CREATING.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_FAILED_CREATING.c_str() ),
msg,
DialogSec::tr( f_ABORTING.c_str() ) ),
QMessageBox::Ok );
}
@ -304,13 +354,15 @@ void DialogSec::errDatabaseFailedOpening(QWidget *parent, const QString& db_name
{
QString msg = db_name;
if ( err_msg != "" ) {
msg += "\n\n" + m_DB_FAILED_ERRMSG + ":\n" + err_msg;
msg += "\n\n" + DialogSec::tr( m_DB_FAILED_ERRMSG.c_str() ) + ":\n" + err_msg;
}
std::ignore=
QMessageBox::critical(parent,
t_DB_FAILED_OPENING,
QString("%1:\n%2\n\n%e")
.arg( m_DB_FAILED_OPENING, msg, f_ABORTING ),
DialogSec::tr( t_DB_FAILED_OPENING.c_str() ),
QString("%1:\n%2\n\n%e").arg(
DialogSec::tr( m_DB_FAILED_OPENING.c_str() ),
msg,
DialogSec::tr( f_ABORTING.c_str() ) ),
QMessageBox::Ok );
}
@ -318,16 +370,18 @@ void DialogSec::errDatabaseFailedExecuting(QWidget *parent, const QString& db_na
{
QString msg = db_name;
if ( statement != "" ) {
msg += "\n\n" + m_DB_FAILED_STATEMENT + ":\n" + statement;
msg += "\n\n" + DialogSec::tr( m_DB_FAILED_STATEMENT.c_str() ) + ":\n" + statement;
}
if ( err_msg != "" ) {
msg += "\n\n" + m_DB_FAILED_ERRMSG + ":\n" + err_msg;
msg += "\n\n" + DialogSec::tr( m_DB_FAILED_ERRMSG.c_str() ) + ":\n" + err_msg;
}
std::ignore=
QMessageBox::critical(parent,
t_DB_FAILED_EXECUTING,
QString("%1:\n%2\n\n%3")
.arg( m_DB_FAILED_EXECUTING, msg, f_ABORTING ),
DialogSec::tr( t_DB_FAILED_EXECUTING.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DB_FAILED_EXECUTING.c_str() ),
msg,
DialogSec::tr( f_ABORTING.c_str() ) ),
QMessageBox::Ok );
}
@ -340,9 +394,10 @@ void DialogSec::errInvalidLogFormatString( QWidget *parent, const QString& msg )
{
std::ignore=
QMessageBox::critical(parent,
t_LOGFORMAT_INVALID,
QString("%1\n\n%2")
.arg( msg, r_CHECK_FORMAT ),
DialogSec::tr( t_LOGFORMAT_INVALID.c_str() ),
QString("%1\n\n%2").arg(
msg,
DialogSec::tr( r_CHECK_FORMAT.c_str() ) ),
QMessageBox::Ok );
}
@ -350,9 +405,9 @@ void DialogSec::errLogFormatNotSet( QWidget *parent )
{
std::ignore=
QMessageBox::critical(parent,
t_LOGFORMAT_ERROR,
QString("%1")
.arg( m_LOGFORMAT_NOT_SET ),
DialogSec::tr( t_LOGFORMAT_ERROR.c_str() ),
QString("%1").arg(
DialogSec::tr( m_LOGFORMAT_NOT_SET.c_str() ) ),
QMessageBox::Ok );
}
@ -360,9 +415,10 @@ void DialogSec::errLogFormatNoFields( QWidget *parent )
{
std::ignore=
QMessageBox::critical(parent,
t_LOGFORMAT_MISCONFIGURED,
QString("%1\n\n%2")
.arg( m_LOGFORMAT_NO_FIELDS, r_SET_FORMAT_FIELDS ),
DialogSec::tr( t_LOGFORMAT_MISCONFIGURED.c_str() ),
QString("%1\n\n%2").arg(
DialogSec::tr( m_LOGFORMAT_NO_FIELDS.c_str() ),
DialogSec::tr( r_SET_FORMAT_FIELDS.c_str() ) ),
QMessageBox::Ok );
}
@ -370,9 +426,10 @@ void DialogSec::errLogFormatNoSeparators( QWidget *parent )
{
std::ignore=
QMessageBox::critical(parent,
t_LOGFORMAT_MISCONFIGURED,
QString("%1\n\n%2")
.arg( m_LOGFORMAT_NO_SEPS, r_SET_FORMAT_SEPS ),
DialogSec::tr( t_LOGFORMAT_MISCONFIGURED.c_str() ),
QString("%1\n\n%2").arg(
DialogSec::tr( m_LOGFORMAT_NO_SEPS.c_str() ),
DialogSec::tr( r_SET_FORMAT_SEPS.c_str() ) ),
QMessageBox::Ok );
}
@ -385,9 +442,10 @@ void DialogSec::errFailedDefiningLogType( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::critical(parent,
t_LOGTYPE_FAILED,
QString("%1:\n%2")
.arg( m_LOGTYPE_FAILED, file ),
DialogSec::tr( t_LOGTYPE_FAILED.c_str() ),
QString("%1:\n%2").arg(
DialogSec::tr( m_LOGTYPE_FAILED.c_str() ),
file ),
QMessageBox::Ok );
}
@ -396,9 +454,11 @@ const int DialogSec::choiceFileAlreadyUsed( QWidget *parent, const QString& msg
{
int choice;
auto response = QMessageBox::warning(parent,
t_FILE_ALREADY_USED,
QString("%1:\n%2\n\n%3")
.arg( m_FILE_ALREADY_USED, msg, q_DIA ),
DialogSec::tr( t_FILE_ALREADY_USED.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_FILE_ALREADY_USED.c_str() ),
msg,
DialogSec::tr( q_DIA.c_str() ) ),
QMessageBox::Discard | QMessageBox::Ignore | QMessageBox::Abort );
if ( response == QMessageBox::Ignore ) {
choice = 0;
@ -415,9 +475,11 @@ const int DialogSec::choiceFileSizeWarning( QWidget *parent, const QString& msg
{
int choice;
auto response = QMessageBox::warning(parent,
t_FILE_SIZE_WARNING,
QString("%1:\n%2\n\n%3")
.arg( m_FILE_SIZE_WARNING, msg, q_DIA ),
DialogSec::tr( t_FILE_SIZE_WARNING.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_FILE_SIZE_WARNING.c_str() ),
msg,
DialogSec::tr( q_DIA.c_str() ) ),
QMessageBox::Discard | QMessageBox::Ignore | QMessageBox::Abort );
if ( response == QMessageBox::Ignore ) {
choice = 0;
@ -434,9 +496,10 @@ void DialogSec::errFailedReadFile( QWidget *parent, const QString& file , const
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_FAILED_READ,
QString("%1:\n%2")
.arg( m_FILE_FAILED_READ, file + ((skipping) ? f_SKIPPING : "") ),
DialogSec::tr( t_FILE_FAILED_READ.c_str() ),
QString("%1:\n%2").arg(
DialogSec::tr( m_FILE_FAILED_READ.c_str() ),
file + ((skipping) ? DialogSec::tr( f_SKIPPING.c_str() ) : "") ),
QMessageBox::Ok );
}
@ -444,9 +507,10 @@ void DialogSec::errFailedWriteFile( QWidget *parent, const QString& file , const
{
std::ignore=
QMessageBox::critical(parent,
t_FILE_FAILED_WRITE,
QString("%1:\n%2")
.arg( m_FILE_FAILED_WRITE, file + ((skipping) ? f_SKIPPING : "") ),
DialogSec::tr( t_FILE_FAILED_WRITE.c_str() ),
QString("%1:\n%2").arg(
DialogSec::tr( m_FILE_FAILED_WRITE.c_str() ),
file + ((skipping) ? DialogSec::tr( f_SKIPPING.c_str() ) : "") ),
QMessageBox::Ok );
}
@ -455,9 +519,11 @@ void DialogSec::warnEmptyFile( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::warning(parent,
t_FILE_EMPTY,
QString("%1:\n%2\n\n%3")
.arg( m_FILE_EMPTY, file, f_SKIPPING ),
DialogSec::tr( t_FILE_EMPTY.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_FILE_EMPTY.c_str() ),
file,
DialogSec::tr( f_SKIPPING.c_str() ) ),
QMessageBox::Ok );
}
@ -465,9 +531,11 @@ void DialogSec::warnFileNotReadable( QWidget *parent, const QString& file )
{
std::ignore=
QMessageBox::warning(parent,
t_FILE_NOT_READABLE,
QString("%1:\n%2\n\n%3")
.arg( m_FILE_NOT_READABLE, file, f_SKIPPING ),
DialogSec::tr( t_FILE_NOT_READABLE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_FILE_NOT_READABLE.c_str() ),
file,
DialogSec::tr( f_SKIPPING.c_str() ) ),
QMessageBox::Ok );
}
@ -477,9 +545,11 @@ const bool DialogSec::choiceSelectedFileNotFound(QWidget *parent, const QString&
{
bool proceed = false;
auto response = QMessageBox::warning(parent,
t_FILE_NOT_FOUND,
QString("%1:\n%2\n\n%3")
.arg( m_SELECTED_FILE_NOT_FOUND, file, q_DA ),
DialogSec::tr( t_FILE_NOT_FOUND.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_SELECTED_FILE_NOT_FOUND.c_str() ),
file,
DialogSec::tr( q_DA.c_str() ) ),
QMessageBox::Abort | QMessageBox::Discard );
if ( response == QMessageBox::Discard ) {
proceed = true;
@ -496,9 +566,10 @@ void DialogSec::errDirNotExists(QWidget *parent, const QString& dir )
{
std::ignore=
QMessageBox::critical(parent,
t_DIR_NOT_FOUND,
QString("%1:\n%2")
.arg( m_DIR_NOT_EXISTS, dir ),
DialogSec::tr( t_DIR_NOT_FOUND.c_str() ),
QString("%1:\n%2").arg(
DialogSec::tr( m_DIR_NOT_EXISTS.c_str() ),
dir ),
QMessageBox::Ok );
}
@ -506,9 +577,11 @@ const bool DialogSec::choiceDirNotExists(QWidget *parent, const QString& dir )
{
bool proceed = false;
auto response = QMessageBox::warning(parent,
t_DIR_NOT_FOUND,
QString("%1:\n%2\n\n%3")
.arg( m_DIR_NOT_EXISTS, dir, q_CONTINUE ),
DialogSec::tr( t_DIR_NOT_FOUND.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DIR_NOT_EXISTS.c_str() ),
dir,
DialogSec::tr( q_CONTINUE.c_str() ) ),
QMessageBox::Abort | QMessageBox::Ignore );
if ( response == QMessageBox::Ignore ) {
proceed = true;
@ -521,18 +594,21 @@ void DialogSec::errDirNotReadable( QWidget *parent, const QString& dir )
{
std::ignore=
QMessageBox::critical(parent,
t_DIR_NOT_READABLE,
QString("%1:\n%2\n\n%3")
.arg( m_DIR_NOT_READABLE, dir, r_SET_PERMISSIONS ),
DialogSec::tr( t_DIR_NOT_READABLE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DIR_NOT_READABLE.c_str() ),
dir,
DialogSec::tr( r_SET_PERMISSIONS.c_str() ) ),
QMessageBox::Ok );
}
void DialogSec::warnDirNotReadable( QWidget *parent )
{
std::ignore=
QMessageBox::warning(parent,
t_DIR_NOT_READABLE,
QString("%1\n\n%2")
.arg( m_DIR_NOT_READABLE, r_SET_PERMS_BEFORE ),
DialogSec::tr( t_DIR_NOT_READABLE.c_str() ),
QString("%1\n\n%2").arg(
DialogSec::tr( m_DIR_NOT_READABLE.c_str() ),
DialogSec::tr( r_SET_PERMS_BEFORE.c_str() ) ),
QMessageBox::Ok );
}
@ -540,18 +616,21 @@ void DialogSec::errDirNotWritable( QWidget *parent, const QString& dir )
{
std::ignore=
QMessageBox::critical(parent,
t_DIR_NOT_WRITABLE,
QString("%1:\n%2\n\n%3")
.arg( m_DIR_NOT_WRITABLE, dir, r_SET_PERMISSIONS ),
DialogSec::tr( t_DIR_NOT_WRITABLE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DIR_NOT_WRITABLE.c_str() ),
dir,
DialogSec::tr( r_SET_PERMISSIONS.c_str() ) ),
QMessageBox::Ok );
}
void DialogSec::warnDirNotWritable( QWidget *parent )
{
std::ignore=
QMessageBox::warning(parent,
t_DIR_NOT_WRITABLE,
QString("%1\n\n%2")
.arg( m_DIR_NOT_WRITABLE, r_SET_PERMS_BEFORE ),
DialogSec::tr( t_DIR_NOT_WRITABLE.c_str() ),
QString("%1\n\n%2").arg(
DialogSec::tr( m_DIR_NOT_WRITABLE.c_str() ),
DialogSec::tr( r_SET_PERMS_BEFORE.c_str() ) ),
QMessageBox::Ok );
}
@ -563,9 +642,11 @@ const bool DialogSec::choiceDirNotDir( QWidget *parent, const QString& path )
{
bool choice = false;
auto response = QMessageBox::question(parent,
t_DIR_NOT_DIR,
QString("%1:\n%2\n\n%3")
.arg( m_DIR_NOT_DIR, path, q_ENTRY_RENEW ),
DialogSec::tr( t_DIR_NOT_DIR.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_DIR_NOT_DIR.c_str() ),
path,
DialogSec::tr( q_ENTRY_RENEW.c_str() ) ),
QMessageBox::Yes | QMessageBox::No );
if ( response == QMessageBox::Yes ) {
choice = true;
@ -576,9 +657,11 @@ const bool DialogSec::choiceFileNotFile( QWidget *parent, const QString& path )
{
bool choice = false;
auto response = QMessageBox::question(parent,
t_FILE_NOT_FILE,
QString("%1:\n%2\n\n%3")
.arg( m_FILE_NOT_FILE, path, q_ENTRY_RENEW ),
DialogSec::tr( t_FILE_NOT_FILE.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_FILE_NOT_FILE.c_str() ),
path,
DialogSec::tr( q_ENTRY_RENEW.c_str() ) ),
QMessageBox::Yes | QMessageBox::No );
if ( response == QMessageBox::Yes ) {
choice = true;
@ -592,13 +675,13 @@ void DialogSec::warnGeneric( QWidget *parent, const QString& msg, const bool& re
{
QString footer = "";
if ( report_msg == true ) {
footer += "\n\n" + r_REPORT_ISSUE;
footer += "\n\n" + DialogSec::tr( r_REPORT_ISSUE.c_str() );
}
std::ignore=
QMessageBox::warning(parent,
t_ERROR_OCCURED,
QString("%1%2")
.arg( msg, footer ),
DialogSec::tr( t_ERROR_OCCURED.c_str() ),
QString("%1%2").arg(
msg, footer ),
QMessageBox::Ok );
}
@ -608,13 +691,13 @@ void DialogSec::errGeneric( QWidget *parent, const QString& msg, const bool& rep
{
QString footer = "";
if ( report_msg == true ) {
footer += "\n\n" + r_REPORT_ISSUE;
footer += "\n\n" + DialogSec::tr( r_REPORT_ISSUE.c_str() );
}
std::ignore=
QMessageBox::critical(parent,
t_ERROR_OCCURED,
QString("%1%2")
.arg( msg, footer ),
DialogSec::tr( t_ERROR_OCCURED.c_str() ),
QString("%1%2").arg(
msg, footer ),
QMessageBox::Ok );
}
@ -624,8 +707,10 @@ void DialogSec::errRenaming( QWidget *parent, const QString& path )
{
std::ignore=
QMessageBox::critical(parent,
t_ERROR_RENAMING,
QString("%1:\n%2\n\n%3")
.arg( m_ERROR_RENAMING, path, f_ABORTING ),
DialogSec::tr( t_ERROR_RENAMING.c_str() ),
QString("%1:\n%2\n\n%3").arg(
DialogSec::tr( m_ERROR_RENAMING.c_str() ),
path,
DialogSec::tr( f_ABORTING.c_str() ) ),
QMessageBox::Ok );
}

View File

@ -5,189 +5,13 @@
#include <QString>
#include <QMessageBox>
///////////////////
//// QUESTIONS ////
static const QString q_CONTINUE = QMessageBox::tr("Continue?");
static const QString q_YOUR_CHOICE = QMessageBox::tr("Your choice?");
static const QString q_DA = QMessageBox::tr("Discard it and continue, or Abort all and exit?");
static const QString q_DIA = QMessageBox::tr("Ignore the warning and use it anyway, Discard it and continue, or Abort all and exit?");
static const QString q_DB_CREATE = QMessageBox::tr("Create a new database?");
static const QString q_DB_RENEW = QMessageBox::tr("This database will renamed with a trailing '.copy' and a new one will be created.\nContinue?");
static const QString q_ENTRY_RENEW = QMessageBox::tr("The entry will renamed with a trailing '.copy' and a new one will be created.\nContinue?");
////////////////
//// TITLES ////
static const QString t_ERROR_OCCURED = QMessageBox::tr("An error occured");
// IO
static const QString t_ERROR_RENAMING = QMessageBox::tr("Failed renaming");
// languages
static const QString t_LANG_INVALID = QMessageBox::tr("Invalid locale");
// configuration
static const QString t_CONF_FILE_NOT_FOUND = QMessageBox::tr("Configuration file not found");
static const QString t_CONF_FILE_FAILED_W = QMessageBox::tr("Failed to write configuration file");
// updates
static const QString t_VERSION_CHECK = QMessageBox::tr("Version check");
static const QString t_VERSION_CHECK_FAILED = QMessageBox::tr("Version check failed");
static const QString t_CONNECTION_FAILED = QMessageBox::tr("Failed to establish a connection");
// help
static const QString t_HELP_FAILED_LOADING = QMessageBox::tr("Failed to retrieve the help file");
// IO files
static const QString t_FILE_NOT_FILE = QMessageBox::tr("Not a file");
static const QString t_FILE_NOT_FOUND = QMessageBox::tr("File not found");
static const QString t_FILE_NOT_READABLE = QMessageBox::tr("File not readable");
static const QString t_FILE_NOT_WRITABLE = QMessageBox::tr("File not writable");
static const QString t_FILE_EMPTY = QMessageBox::tr("File is empty");
static const QString t_FILE_FAILED_READ = QMessageBox::tr("Failed reading");
static const QString t_FILE_FAILED_WRITE = QMessageBox::tr("Failed writing");
// IO directories
static const QString t_DIR_NOT_DIR = QMessageBox::tr("Not a folder");
static const QString t_DIR_NOT_FOUND = QMessageBox::tr("Directory not found");
static const QString t_DIR_NOT_READABLE = QMessageBox::tr("Directory not readable");
static const QString t_DIR_NOT_WRITABLE = QMessageBox::tr("Directory not writable");
// database
static const QString t_DB_DRIVER_NOT_FOUND = QMessageBox::tr("QSql driver not found");
static const QString t_DB_CREATED = QMessageBox::tr("Database created");
static const QString t_DB_FAILED_CREATING = QMessageBox::tr("Failed creating database");
static const QString t_DB_FAILED_OPENING = QMessageBox::tr("Failed opening database");
static const QString t_DB_FAILED_EXECUTING = QMessageBox::tr("Failed executing on database");
static const QString t_DB_WRONG_TABLE_NAME = QMessageBox::tr("Unexpected table");
static const QString t_DB_MISSING_TABLE = QMessageBox::tr("Table not found");
static const QString t_DB_WRONG_COLUMN_NAME = QMessageBox::tr("Unexpected column");
static const QString t_DB_MISSING_COLUMN = QMessageBox::tr("Column not found");
static const QString t_DB_WRONG_COLUMN_TYPE = QMessageBox::tr("Unexpected data-type");
// log type
static const QString t_LOGTYPE_FAILED = QMessageBox::tr("Failed defining type");
// log format
static const QString t_LOGFORMAT_ERROR = QMessageBox::tr("Log format error");
static const QString t_LOGFORMAT_MISCONFIGURED = QMessageBox::tr("Misconfigured log format");
static const QString t_LOGFORMAT_INVALID = QMessageBox::tr("Invalid log format string");
// log files
static const QString t_FILE_ALREADY_USED = QMessageBox::tr("File already used");
static const QString t_FILE_SIZE_WARNING = QMessageBox::tr("File exceeds warning size");
//////////////////
//// MESSAGES ////
// IO
static const QString m_ERROR_RENAMING = QMessageBox::tr("An error occured while renaming");
// language
static const QString m_LANG_LOCALE_INVALID = QMessageBox::tr("Unexpected locale format");
static const QString m_LANG_NOT_ACCEPTED = QMessageBox::tr("The given locale is not an accepted language");
// configuration
static const QString m_CONF_FILE_ERROR = QMessageBox::tr("An error occured while handling the configuration file");
static const QString m_CONF_FILE_NOT_FOUND = QMessageBox::tr("Unable to retrieve the configuration file");
static const QString m_CONF_FILE_FAILED_W = QMessageBox::tr("Current configuration not saved");
// updates
static const QString m_VERSION_CHECK_FAILED = QMessageBox::tr("Failed to fetch the upstream version");
static const QString m_CONNECTION_FAILED = QMessageBox::tr("An error occured while trying to establish a connection with");
static const QString m_CONNECTIONS_FAILED = QMessageBox::tr("An error occured while establishing a connection with any of the hosts");
static const QString m_VERSION_NOT_FOUND = QMessageBox::tr("An error occured while parsing:\nversion mark not found");
static const QString m_VERSION_MALFORMED = QMessageBox::tr("An error occured while parsing:\nmalformed version");
static const QString m_NEW_VERSION_AVAILABLE = QMessageBox::tr("A new version available!\n\nPlease visit LogDoctor's git repository\nand follow the instruction about how to update");
static const QString m_SAME_VERSION = QMessageBox::tr("LogDoctor is up-to-date");
static const QString m_FUTURE_VERSION_RUNNING = QMessageBox::tr("You're running a version from the future!\n\nYour version is beyond the current upstream version\n\nAre you running the original LogDoctor?\nIf you think so, you may be a victim of a malware\nPlease visit the LogDoctor's repository and get a fresh version of it");
// help
static const QString m_HELP_FAILED_LOADING = QMessageBox::tr("An error occured while getting the help file");
// IO files
static const QString m_FILE_NOT_FILE = QMessageBox::tr("The path was supposed to point to a file, but it doesn't");
static const QString m_FILE_NOT_EXISTS = QMessageBox::tr("The file does not exists");
static const QString m_FILE_NOT_FOUND = QMessageBox::tr("Unable to retrieve the file");
static const QString m_FILE_NOT_READABLE = QMessageBox::tr("The file is not readable");
static const QString m_FILE_NOT_WRITABLE = QMessageBox::tr("The file is not writable");
static const QString m_FILE_EMPTY = QMessageBox::tr("The file is blank");
static const QString m_FILE_FAILED_READ = QMessageBox::tr("An error accured while reading the file");
static const QString m_FILE_FAILED_WRITE = QMessageBox::tr("An error accured while writing the file");
// IO directories
static const QString m_DIR_NOT_DIR = QMessageBox::tr("The path was supposed to point to a folder, but it doesn't");
static const QString m_DIR_NOT_EXISTS = QMessageBox::tr("The directory does not exists");
static const QString m_DIR_NOT_FOUND = QMessageBox::tr("Unable to reach the directory");
static const QString m_DIR_NOT_READABLE = QMessageBox::tr("The directory is not readable");
static const QString m_DIR_NOT_WRITABLE = QMessageBox::tr("The directory is not writable");
// database
static const QString m_DB_DRIVER_NOT_FOUND = QMessageBox::tr("Failed to retrieve the driver neede to handle the database");
static const QString m_DB_NOT_FOUND = QMessageBox::tr("Failed to retrieve the database file");
static const QString m_DB_NOT_READABLE = QMessageBox::tr("The database file is not readable");
static const QString m_DB_NOT_WRITABLE = QMessageBox::tr("The database file is not writable");
static const QString m_DB_CREATED = QMessageBox::tr("Successfully created a new database");
static const QString m_DB_FAILED_CREATING = QMessageBox::tr("An error occured while creating the database");
static const QString m_DB_FAILED_OPENING = QMessageBox::tr("An error occured while opening the database");
static const QString m_DB_FAILED_EXECUTING = QMessageBox::tr("An error occured while executing a statement on the database");
static const QString m_DB_FAILED_STATEMENT = QMessageBox::tr("Failed at statement");
static const QString m_DB_FAILED_ERRMSG = QMessageBox::tr("SQLite error message");
static const QString m_DB_WRONG_TABLE_NAME = QMessageBox::tr("The database contains an unexpected table");
static const QString m_DB_MISSING_TABLE = QMessageBox::tr("It seems that the database is missing a table");
static const QString m_DB_MISSING_COLUMN = QMessageBox::tr("It seems that the table is missing a column");
static const QString m_DB_WRONG_COLUMN_NAME = QMessageBox::tr("The database contains an unexpected column");
static const QString m_DB_WRONG_COLUMN_TYPE = QMessageBox::tr("A column has an unexpected data-type");
// log files
static const QString m_SELECTED_FILE_NOT_FOUND = QMessageBox::tr("Failed to retrieve the selected file");
static const QString m_FILE_ALREADY_USED = QMessageBox::tr("The file has probably been used already");
static const QString m_FILE_SIZE_WARNING = QMessageBox::tr("The file's size exceeds the warning size");
// log type
static const QString m_LOGTYPE_FAILED = QMessageBox::tr("Failed to determine the log type");
// log format
static const QString m_LOGFORMAT_NOT_SET = QMessageBox::tr("The log format has not been set, or is invalid\nPlease add a valid one in the configurations");
static const QString m_LOGFORMAT_NO_FIELDS = QMessageBox::tr("No log field has been set in the current logs format,\nmaking it useless to parse logs");
static const QString m_LOGFORMAT_NO_SEPS = QMessageBox::tr("A separator is missing between one or more fields,\nmaking it hard to establish net bounds,\nand possibly leading to store incorrect data");
//////////////////
//// REQUESTS ////
static const QString r_REPORT_ISSUE = QMessageBox::tr("Please report this issue");
// language
static const QString r_LANG_NOT_ACCEPTED = QMessageBox::tr("IF you'd like to have this locale in LogDoctor,\nplease follow the instruction on the repository page");
// version check
static const QString r_UPSTREAM_FAILURE = QMessageBox::tr("Please check your internet connection and retry\nIf this error persists, please report this issue");
// IO conflict
static const QString r_REMOVE_ENTRY = QMessageBox::tr("Please remove the conflict and retry");
// permissions
static const QString r_SET_PERMS_BEFORE = QMessageBox::tr("Please set the proper permissions before to start");
static const QString r_SET_PERMISSIONS = QMessageBox::tr("Please set the proper permissions and retry\nIf this error persists, please report this issue");
// don't edit
static const QString r_CONF_DONT_EDIT = QMessageBox::tr("If you haven't manually edited the configuration file,\nplease report this issue");
static const QString r_DB_DONT_EDIT = QMessageBox::tr("If you haven't manually edited the database,\nplease report this issue");
// log format
static const QString r_CHECK_FORMAT = QMessageBox::tr("Please check that no error is thrown from your WebServer\nIf it gets accepted, please check the presence of a typo here\nIf everything is fine, please report this issue");
static const QString r_SET_FORMAT_FIELDS = QMessageBox::tr("Please set up a format which contains at least one field");
static const QString r_SET_FORMAT_SEPS = QMessageBox::tr("Please set up a format which contains separators between fields");
/////////////////
//// FOOTERS ////
static const QString f_SKIPPING = QMessageBox::tr("Skipping");
static const QString f_ABORTING = QMessageBox::tr("Aborting");
// additional resources
static const QString f_ADD_RESOURCES = QMessageBox::tr("Additional resources can be downloaded from the git repo");
#include <string>
class DialogSec
class DialogSec : public QObject
{
Q_OBJECT
public:
DialogSec();
@ -288,4 +112,185 @@ private:
};
///////////////////
//// QUESTIONS ////
const std::string q_CONTINUE = DialogSec::tr("Continue?").toStdString();
const std::string q_YOUR_CHOICE = DialogSec::tr("Your choice?").toStdString();
const std::string q_DA = DialogSec::tr("Discard it and continue, or Abort all and exit?").toStdString();
const std::string q_DIA = DialogSec::tr("Ignore the warning and use it anyway, Discard it and continue, or Abort all and exit?").toStdString();
const std::string q_DB_CREATE = DialogSec::tr("Create a new database?").toStdString();
const std::string q_DB_RENEW = DialogSec::tr("This database will renamed with a trailing '.copy' and a new one will be created.\nContinue?").toStdString();
const std::string q_ENTRY_RENEW = DialogSec::tr("The entry will renamed with a trailing '.copy' and a new one will be created.\nContinue?").toStdString();
////////////////
//// TITLES ////
const std::string t_ERROR_OCCURED = DialogSec::tr("An error occured").toStdString();
// IO
const std::string t_ERROR_RENAMING = DialogSec::tr("Failed renaming").toStdString();
// languages
const std::string t_LANG_INVALID = DialogSec::tr("Invalid locale").toStdString();
// configuration
const std::string t_CONF_FILE_NOT_FOUND = DialogSec::tr("Configuration file not found").toStdString();
const std::string t_CONF_FILE_FAILED_W = DialogSec::tr("Failed to write configuration file").toStdString();
// updates
const std::string t_VERSION_CHECK = DialogSec::tr("Version check").toStdString();
const std::string t_VERSION_CHECK_FAILED = DialogSec::tr("Version check failed").toStdString();
const std::string t_CONNECTION_FAILED = DialogSec::tr("Failed to establish a connection").toStdString();
// help
const std::string t_HELP_FAILED_LOADING = DialogSec::tr("Failed to retrieve the help file").toStdString();
// IO files
const std::string t_FILE_NOT_FILE = DialogSec::tr("Not a file").toStdString();
const std::string t_FILE_NOT_FOUND = DialogSec::tr("File not found").toStdString();
const std::string t_FILE_NOT_READABLE = DialogSec::tr("File not readable").toStdString();
const std::string t_FILE_NOT_WRITABLE = DialogSec::tr("File not writable").toStdString();
const std::string t_FILE_EMPTY = DialogSec::tr("File is empty").toStdString();
const std::string t_FILE_FAILED_READ = DialogSec::tr("Failed reading").toStdString();
const std::string t_FILE_FAILED_WRITE = DialogSec::tr("Failed writing").toStdString();
// IO directories
const std::string t_DIR_NOT_DIR = DialogSec::tr("Not a folder").toStdString();
const std::string t_DIR_NOT_FOUND = DialogSec::tr("Directory not found").toStdString();
const std::string t_DIR_NOT_READABLE = DialogSec::tr("Directory not readable").toStdString();
const std::string t_DIR_NOT_WRITABLE = DialogSec::tr("Directory not writable").toStdString();
// database
const std::string t_DB_DRIVER_NOT_FOUND = DialogSec::tr("QSql driver not found").toStdString();
const std::string t_DB_CREATED = DialogSec::tr("Database created").toStdString();
const std::string t_DB_FAILED_CREATING = DialogSec::tr("Failed creating database").toStdString();
const std::string t_DB_FAILED_OPENING = DialogSec::tr("Failed opening database").toStdString();
const std::string t_DB_FAILED_EXECUTING = DialogSec::tr("Failed executing on database").toStdString();
const std::string t_DB_WRONG_TABLE_NAME = DialogSec::tr("Unexpected table").toStdString();
const std::string t_DB_MISSING_TABLE = DialogSec::tr("Table not found").toStdString();
const std::string t_DB_WRONG_COLUMN_NAME = DialogSec::tr("Unexpected column").toStdString();
const std::string t_DB_MISSING_COLUMN = DialogSec::tr("Column not found").toStdString();
const std::string t_DB_WRONG_COLUMN_TYPE = DialogSec::tr("Unexpected data-type").toStdString();
// log type
const std::string t_LOGTYPE_FAILED = DialogSec::tr("Failed defining type").toStdString();
// log format
const std::string t_LOGFORMAT_ERROR = DialogSec::tr("Log format error").toStdString();
const std::string t_LOGFORMAT_MISCONFIGURED = DialogSec::tr("Misconfigured log format").toStdString();
const std::string t_LOGFORMAT_INVALID = DialogSec::tr("Invalid log format string").toStdString();
// log files
const std::string t_FILE_ALREADY_USED = DialogSec::tr("File already used").toStdString();
const std::string t_FILE_SIZE_WARNING = DialogSec::tr("File exceeds warning size").toStdString();
//////////////////
//// MESSAGES ////
// IO
const std::string m_ERROR_RENAMING = DialogSec::tr("An error occured while renaming").toStdString();
// language
const std::string m_LANG_LOCALE_INVALID = DialogSec::tr("Unexpected locale format").toStdString();
const std::string m_LANG_NOT_ACCEPTED = DialogSec::tr("The given locale is not an accepted language").toStdString();
// configuration
const std::string m_CONF_FILE_ERROR = DialogSec::tr("An error occured while handling the configuration file").toStdString();
const std::string m_CONF_FILE_NOT_FOUND = DialogSec::tr("Unable to retrieve the configuration file").toStdString();
const std::string m_CONF_FILE_FAILED_W = DialogSec::tr("Current configuration not saved").toStdString();
// updates
const std::string m_VERSION_CHECK_FAILED = DialogSec::tr("Failed to fetch the upstream version").toStdString();
const std::string m_CONNECTION_FAILED = DialogSec::tr("An error occured while trying to establish a connection with").toStdString();
const std::string m_CONNECTIONS_FAILED = DialogSec::tr("An error occured while establishing a connection with any of the hosts").toStdString();
const std::string m_VERSION_NOT_FOUND = DialogSec::tr("An error occured while parsing:\nversion mark not found").toStdString();
const std::string m_VERSION_MALFORMED = DialogSec::tr("An error occured while parsing:\nmalformed version").toStdString();
const std::string m_NEW_VERSION_AVAILABLE = DialogSec::tr("A new version available!\n\nPlease visit LogDoctor's git repository\nand follow the instruction about how to update").toStdString();
const std::string m_SAME_VERSION = DialogSec::tr("LogDoctor is up-to-date").toStdString();
const std::string m_FUTURE_VERSION_RUNNING = DialogSec::tr("You're running a version from the future!\n\nYour version is beyond the current upstream version\n\nAre you running the original LogDoctor?\nIf you think so, you may be a victim of a malware\nPlease visit the LogDoctor's repository and get a fresh version of it").toStdString();
// help
const std::string m_HELP_FAILED_LOADING = DialogSec::tr("An error occured while getting the help file").toStdString();
// IO files
const std::string m_FILE_NOT_FILE = DialogSec::tr("The path was supposed to point to a file, but it doesn't").toStdString();
const std::string m_FILE_NOT_EXISTS = DialogSec::tr("The file does not exists").toStdString();
const std::string m_FILE_NOT_FOUND = DialogSec::tr("Unable to retrieve the file").toStdString();
const std::string m_FILE_NOT_READABLE = DialogSec::tr("The file is not readable").toStdString();
const std::string m_FILE_NOT_WRITABLE = DialogSec::tr("The file is not writable").toStdString();
const std::string m_FILE_EMPTY = DialogSec::tr("The file is blank").toStdString();
const std::string m_FILE_FAILED_READ = DialogSec::tr("An error accured while reading the file").toStdString();
const std::string m_FILE_FAILED_WRITE = DialogSec::tr("An error accured while writing the file").toStdString();
// IO directories
const std::string m_DIR_NOT_DIR = DialogSec::tr("The path was supposed to point to a folder, but it doesn't").toStdString();
const std::string m_DIR_NOT_EXISTS = DialogSec::tr("The directory does not exists").toStdString();
const std::string m_DIR_NOT_FOUND = DialogSec::tr("Unable to reach the directory").toStdString();
const std::string m_DIR_NOT_READABLE = DialogSec::tr("The directory is not readable").toStdString();
const std::string m_DIR_NOT_WRITABLE = DialogSec::tr("The directory is not writable").toStdString();
// database
const std::string m_DB_DRIVER_NOT_FOUND = DialogSec::tr("Failed to retrieve the driver neede to handle the database").toStdString();
const std::string m_DB_NOT_FOUND = DialogSec::tr("Failed to retrieve the database file").toStdString();
const std::string m_DB_NOT_READABLE = DialogSec::tr("The database file is not readable").toStdString();
const std::string m_DB_NOT_WRITABLE = DialogSec::tr("The database file is not writable").toStdString();
const std::string m_DB_CREATED = DialogSec::tr("Successfully created a new database").toStdString();
const std::string m_DB_FAILED_CREATING = DialogSec::tr("An error occured while creating the database").toStdString();
const std::string m_DB_FAILED_OPENING = DialogSec::tr("An error occured while opening the database").toStdString();
const std::string m_DB_FAILED_EXECUTING = DialogSec::tr("An error occured while executing a statement on the database").toStdString();
const std::string m_DB_FAILED_STATEMENT = DialogSec::tr("Failed at statement").toStdString();
const std::string m_DB_FAILED_ERRMSG = DialogSec::tr("SQLite error message").toStdString();
const std::string m_DB_WRONG_TABLE_NAME = DialogSec::tr("The database contains an unexpected table").toStdString();
const std::string m_DB_MISSING_TABLE = DialogSec::tr("It seems that the database is missing a table").toStdString();
const std::string m_DB_MISSING_COLUMN = DialogSec::tr("It seems that the table is missing a column").toStdString();
const std::string m_DB_WRONG_COLUMN_NAME = DialogSec::tr("The database contains an unexpected column").toStdString();
const std::string m_DB_WRONG_COLUMN_TYPE = DialogSec::tr("A column has an unexpected data-type").toStdString();
// log files
const std::string m_SELECTED_FILE_NOT_FOUND = DialogSec::tr("Failed to retrieve the selected file").toStdString();
const std::string m_FILE_ALREADY_USED = DialogSec::tr("The file has probably been used already").toStdString();
const std::string m_FILE_SIZE_WARNING = DialogSec::tr("The file's size exceeds the warning size").toStdString();
// log type
const std::string m_LOGTYPE_FAILED = DialogSec::tr("Failed to determine the log type").toStdString();
// log format
const std::string m_LOGFORMAT_NOT_SET = DialogSec::tr("The log format has not been set, or is invalid\nPlease add a valid one in the configurations").toStdString();
const std::string m_LOGFORMAT_NO_FIELDS = DialogSec::tr("No log field has been set in the current logs format,\nmaking it useless to parse logs").toStdString();
const std::string m_LOGFORMAT_NO_SEPS = DialogSec::tr("A separator is missing between one or more fields,\nmaking it hard to establish net bounds,\nand possibly leading to store incorrect data").toStdString();
//////////////////
//// REQUESTS ////
const std::string r_REPORT_ISSUE = DialogSec::tr("Please report this issue").toStdString();
// language
const std::string r_LANG_NOT_ACCEPTED = DialogSec::tr("IF you'd like to have this locale in LogDoctor,\nplease follow the instruction on the repository page").toStdString();
// version check
const std::string r_UPSTREAM_FAILURE = DialogSec::tr("Please check your internet connection and retry\nIf this error persists, please report this issue").toStdString();
// IO conflict
const std::string r_REMOVE_ENTRY = DialogSec::tr("Please remove the conflict and retry").toStdString();
// permissions
const std::string r_SET_PERMS_BEFORE = DialogSec::tr("Please set the proper permissions before to start").toStdString();
const std::string r_SET_PERMISSIONS = DialogSec::tr("Please set the proper permissions and retry\nIf this error persists, please report this issue").toStdString();
// don't edit
const std::string r_CONF_DONT_EDIT = DialogSec::tr("If you haven't manually edited the configuration file,\nplease report this issue").toStdString();
const std::string r_DB_DONT_EDIT = DialogSec::tr("If you haven't manually edited the database,\nplease report this issue").toStdString();
// log format
const std::string r_CHECK_FORMAT = DialogSec::tr("Please check that no error is thrown from your WebServer\nIf it gets accepted, please check the presence of a typo here\nIf everything is fine, please report this issue").toStdString();
const std::string r_SET_FORMAT_FIELDS = DialogSec::tr("Please set up a format which contains at least one field").toStdString();
const std::string r_SET_FORMAT_SEPS = DialogSec::tr("Please set up a format which contains separators between fields").toStdString();
/////////////////
//// FOOTERS ////
const std::string f_SKIPPING = DialogSec::tr("Skipping").toStdString();
const std::string f_ABORTING = DialogSec::tr("Aborting").toStdString();
// additional resources
const std::string f_ADD_RESOURCES = DialogSec::tr("Additional resources can be downloaded from the git repo").toStdString();
#endif // DIALOGS_H

View File

@ -9,6 +9,7 @@
#include "utilities/gzip.h"
#include "utilities/io.h"
#include "tools/shared.h"
#include "tools/craplog/modules/store.h"
#include <QPainter>
@ -61,8 +62,7 @@ Craplog::Craplog()
// nginx access/error logs location
this->logs_paths.emplace( this->NGINX_ID, "/var/log/nginx" );
// iis access/error logs location
this->logs_paths.emplace( this->IIS_ID, "/var/log/iis/LogFiles/SiteName" );
//this->logs_paths.emplace( this->IIS_ID, "C:\\inetpub\\logs\\LogFiles" ); !!! RESTORE !!!
this->logs_paths.emplace( this->IIS_ID, "C:/inetpub/logs/LogFiles" );
// apache2 access/error log files' names
this->logs_base_names.emplace( this->APACHE_ID, LogName{ .starts = "access.log.",
@ -283,7 +283,7 @@ void Craplog::setApacheLogFormat( const std::string& format_string )
} catch ( LogFormatException& e ) {
DialogSec::errInvalidLogFormatString( nullptr, e.what() );
} catch (...) {
DialogSec::errGeneric( nullptr, "An error occured while parsing the format string", true );
DialogSec::errGeneric( nullptr, DialogSec::tr("An error occured while parsing the format string"), true );
}
}
void Craplog::setNginxLogFormat( const std::string& format_string )
@ -296,7 +296,7 @@ void Craplog::setNginxLogFormat( const std::string& format_string )
} catch ( LogFormatException& e ) {
DialogSec::errInvalidLogFormatString( nullptr, e.what() );
} catch (...) {
DialogSec::errGeneric( nullptr, "An error occured while parsing the format string", true );
DialogSec::errGeneric( nullptr, DialogSec::tr("An error occured while parsing the format string"), true );
}
}
void Craplog::setIisLogFormat( const std::string& format_string, const int& log_module )
@ -310,7 +310,7 @@ void Craplog::setIisLogFormat( const std::string& format_string, const int& log_
} catch ( LogFormatException& e ) {
DialogSec::errInvalidLogFormatString( nullptr, e.what() );
} catch (...) {
DialogSec::errGeneric( nullptr, "An error occured while parsing the format string", true );
DialogSec::errGeneric( nullptr, DialogSec::tr("An error occured while parsing the format string"), true );
}
}
@ -475,7 +475,7 @@ void Craplog::scanLogsDir()
} catch (...) {
// failed somehow
successful = false;
QString err_msg = QMessageBox::tr("An error occured while handling the file");
QString err_msg = DialogSec::tr("An error occured while handling the file");
DialogSec::errGeneric( nullptr, err_msg +":\n"+ name );
}
@ -787,7 +787,7 @@ const bool Craplog::checkStuff()
}
}
size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str();
msg += QString("\n\nSize of the file:\n%1%2").arg( size_str, size_sfx.c_str() );
msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Size of the file"), size_str, size_sfx.c_str() );
if ( this->dialogs_level == 2 ) {
size = (float)this->warning_size;
if (size > 1024) {
@ -797,7 +797,7 @@ const bool Craplog::checkStuff()
}
}
size_str = std::to_string(size).substr(0,std::to_string(size).size()-3).c_str();
msg += QString("\n\nWarning size parameter:\n%1%2").arg( size_str, size_sfx.c_str() );
msg += QString("\n\n%1:\n%2%3").arg( DialogSec::tr("Warning size parameter"), size_str, size_sfx.c_str() );
}
}
int choice = DialogSec::choiceFileSizeWarning( nullptr, msg );
@ -979,7 +979,7 @@ void Craplog::storeLogLines()
}
if ( err_shown == false ) {
// show a message
QString msg = QMessageBox::tr("An error occured while working on the database\n\nAborting");
QString msg = DialogSec::tr("An error occured while working on the database\n\nAborting");
DialogSec::errGeneric( nullptr, msg );
}
}
@ -1055,11 +1055,11 @@ const QString Craplog::printableSize( const int& bytes )
void Craplog::makeCharts( const QChart::ChartTheme& theme, const std::unordered_map<std::string, QFont>& fonts, QChartView* size_chart )
{
const QString
size_chart_name = QMessageBox::tr("Logs Size Breakdown"),
ignored_slice_name = QMessageBox::tr("Ignored"),
parsed_slice_name = QMessageBox::tr("Parsed"),
warning_slice_name = QMessageBox::tr("Warnings"),
blacklisted_slice_name = QMessageBox::tr("Blacklisted");/*,
size_chart_name = TR::tr("Logs Size Breakdown"),
ignored_slice_name = TR::tr("Ignored"),
parsed_slice_name = TR::tr("Parsed"),
warning_slice_name = TR::tr("Warnings"),
blacklisted_slice_name = TR::tr("Blacklisted");/*,
traffic_chart_name = QMessageBox::tr("Time of Day Logs Traffic Ensemble"),
access_bar_name = QMessageBox::tr("Access Logs");*/

View File

@ -89,23 +89,12 @@ const QString Crapview::printableTime( const int& hour, const int& minute, const
}
const QStringList Crapview::getWarnHeader()
{
return QStringList({
this->dbQuery.FIELDS.value(0),
this->DATE,this->TIME,
this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14),
this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20),
this->dbQuery.FIELDS.value(17),this->dbQuery.FIELDS.value(16),this->dbQuery.FIELDS.value(15),"rowid" });
}
const QString Crapview::printableWarn( const int& value )
{
if ( value == 0 ) {
return "FALSE";
return TR::tr("FALSE");
} else {
return "TRUE";
return TR::tr("TRUE");
}
}
@ -113,8 +102,8 @@ const QString Crapview::printableWarn( const int& value )
const QString Crapview::parseBooleanFilter( const QString& filter_str )
{
QString aux = filter_str;
aux = aux.replace( "TRUE", "1", Qt::CaseSensitivity::CaseInsensitive );
aux = aux.replace( "FALSE","0", Qt::CaseSensitivity::CaseInsensitive );
aux = aux.replace( TR::tr("TRUE"), "1", Qt::CaseSensitivity::CaseInsensitive );
aux = aux.replace( TR::tr("FALSE"),"0", Qt::CaseSensitivity::CaseInsensitive );
return this->parseNumericFilter( aux );
}
@ -136,10 +125,10 @@ const QString Crapview::parseNumericFilter( const QString& filter_str )
final_str += "=";
final_str += QString::fromStdString( aux );
} else {
if ( StringOps::isNumeric( StringOps::lstrip( aux, "<=>" ) ) == true ) {
if ( StringOps::isNumeric( StringOps::lstrip( aux, "!<=>" ) ) == true ) {
// symbol/value
final_str += QString::fromStdString( aux ).replace("==","=");
} else if ( StringOps::lstrip( aux, "<=>" ).size() == 0 ) {
} else if ( StringOps::lstrip( aux, "!<=>" ).size() == 0 ) {
// symbol at first, maybe a value follows
if ( f_list.size() > 1 ) {
final_str += QString::fromStdString( aux ).replace("==","=");
@ -196,16 +185,34 @@ void Crapview::clearDates()
this->dates.clear();
}
const QString Crapview::getLogFieldString ( const int& field_id )
{
return TR::tr( this->dbQuery.FIELDS.at( field_id ).c_str() );
}
const int Crapview::getLogFieldID ( const QString& field_str )
{
return this->LogFields_s2i.value( field_str );
int f=0;
for ( const auto& [id,str] : this->dbQuery.FIELDS ) {
if ( TR::tr(str.c_str()) == field_str ) {
f = id;
break;
}
}
return f;
}
const int Crapview::getMonthNumber( const QString& month_str )
{
return this->Months_s2i.value( month_str );
int m=0;
for ( const auto& [num,str] : this->dbQuery.MONTHS ) {
if ( TR::tr(str.c_str()) == month_str ) {
m = num;
break;
}
}
return m;
}
@ -232,7 +239,7 @@ const QStringList Crapview::getMonths( const QString& web_server, const QString&
const int y = year.toInt();
if ( this->dates.at( ws ).at( y ).size() ) {
for ( const auto& [month, data] : this->dates.at( ws ).at( y ) ) {
months.push_back( this->dbQuery.MONTHS.value( month ) );
months.push_back( TR::tr(this->dbQuery.MONTHS.at( month ).c_str()) );
}
}
}
@ -247,7 +254,7 @@ const QStringList Crapview::getDays( const QString& web_server, const QString& y
if ( this->dates.at( ws ).size() > 0 ) {
const int y = year.toInt();
if ( this->dates.at( ws ).at( y ).size() ) {
const int m = this->Months_s2i.value( month );
const int m = this->getMonthNumber( month );
if ( this->dates.at( ws ).at( y ).at( m ).size() > 0 ) {
for ( const int day : this->dates.at( ws ).at( y ).at( m ) ) {
days.push_back( QString::fromStdString( std::to_string( day ) ) );
@ -263,9 +270,13 @@ const QStringList Crapview::getHours()
return QStringList({"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"});
}
const QStringList Crapview::getFields( const QString& tab )
const QStringList Crapview::getFields( const std::string& tab )
{
return this->fields.value( tab );
QStringList list;
for ( const auto& field : this->fields.at( tab ) ) {
list.append( TR::tr( field.c_str() ) );
}
return list;
}
@ -277,10 +288,10 @@ void Crapview::updateWarn( QTableWidget* table , const QString& web_server )
std::vector<std::tuple<int, int>> updates; // { (rowid, warn) }
for ( int i=0; i<table->rowCount(); i++ ) {
QTableWidgetItem* item = table->item( i, 0 );
if ( item->checkState() == Qt::CheckState::Checked && item->text() == "FALSE" ) {
if ( item->checkState() == Qt::CheckState::Checked && item->text() == TR::tr("FALSE") ) {
// remove warning
updates.push_back( std::make_tuple( table->item( i, table->columnCount()-1 )->text().toInt(), 1 ) );
} else if (item->checkState() == Qt::CheckState::Unchecked && item->text() == "TRUE" ) {
} else if (item->checkState() == Qt::CheckState::Unchecked && item->text() == TR::tr("TRUE") ) {
// add warning
updates.push_back( std::make_tuple( table->item( i, table->columnCount()-1 )->text().toInt(), 0 ) );
}
@ -304,11 +315,6 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const
// bars
std::vector<std::vector<QBarSet*>> sets;
// table
QStringList header_labels = this->getWarnHeader();
table->setColumnCount( header_labels.size() );
table->setHorizontalHeaderLabels( header_labels );
// build the bars and the table upon data
QColor warn_col = QColor( 255, 140, 0, 255 );
int norm_count, warn_count, sum_count, max_count=0, aux;
@ -423,7 +429,7 @@ void Crapview::drawWarn( QTableWidget* table, QtCharts::QChartView* chart, const
b_chart->addSeries( bars );
}
//b_chart->setTitle( QString("%1: %2").arg( this->TITLE_WARN ) );
b_chart->setTitle( this->TITLE_WARN );
b_chart->setTitle( TR::tr( this->TITLE_WARN.c_str() ) );
b_chart->setTitleFont( fonts.at("main") );
//b_chart->legend()->setVisible( false );
b_chart->legend()->setFont( fonts.at("main_small") );
@ -484,7 +490,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons
// draw the relational chart
QLineSeries *line = new QLineSeries();
line->setName( this->printableDate( year, this->Months_s2i.value(month), day ));
line->setName( this->printableDate( year, this->getMonthNumber(month), day ));
// build the line upon data
int i=0, max_i=items.size(), max_t=0, aux;
@ -572,7 +578,7 @@ void Crapview::drawSpeed( QTableWidget* table, QtCharts::QChartView* chart, cons
l_chart->setTheme( theme );
l_chart->addSeries( line );
l_chart->addSeries( line_ );
l_chart->setTitle( this->TITLE_SPEED );
l_chart->setTitle( TR::tr( this->TITLE_SPEED.c_str() ) );
l_chart->setTitleFont( fonts.at("main") );
l_chart->legend()->setFont( fonts.at( "main_small" ) );
l_chart->legend()->setAlignment( Qt::AlignBottom );
@ -640,7 +646,7 @@ void Crapview::drawCount( QTableWidget* table, QtCharts::QChartView* chart, cons
aux_items.clear();
if ( oth_count > 0 ) {
pie->append( this->TEXT_COUNT_OTHERS, oth_count );
pie->append( TR::tr( this->TEXT_COUNT_OTHERS.c_str() ), oth_count );
QPieSlice *slice = pie->slices().at( pie->count()-1 );
slice->setBrush( Qt::gray );
}
@ -682,13 +688,13 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t
b_20->setColor( col );
QBarSet *b_30 = new QBarSet( "" );
if ( to_year.size() == 0 || to_month.size() == 0 || to_day.size() == 0 ) {
b_30->setLabel( this->printableDate( from_year, this->Months_s2i.value(from_month), from_day ) );
b_30->setLabel( this->printableDate( from_year, this->getMonthNumber(from_month), from_day ) );
} else {
b_30->setLabel( QString("%1 %2 %3 %4")
.arg( this->LEGEND_FROM,
this->printableDate( from_year, this->Months_s2i.value(from_month), from_day ),
this->LEGEND_TO,
this->printableDate( to_year, this->Months_s2i.value(to_month), to_day ) ));
.arg( TR::tr( this->LEGEND_FROM.c_str() ),
this->printableDate( from_year, this->getMonthNumber(from_month), from_day ),
TR::tr( this->LEGEND_TO.c_str() ),
this->printableDate( to_year, this->getMonthNumber(to_month), to_day ) ));
}
b_30->setColor( col );
QBarSet *b_40 = new QBarSet( "" );
@ -744,7 +750,7 @@ void Crapview::drawDay( QtCharts::QChartView* chart, const QChart::ChartTheme& t
QChart *b_chart = new QChart();
b_chart->setTheme( theme );
b_chart->addSeries( bars );
b_chart->setTitle( QString("%1: %2").arg( this->TITLE_DAY, field ) );
b_chart->setTitle( QString("%1: %2").arg( TR::tr( this->TITLE_DAY.c_str() ), field ) );
b_chart->setTitleFont( fonts.at("main") );
b_chart->legend()->setFont( fonts.at("main_small") );
//b_chart->legend()->setVisible( true );
@ -829,13 +835,13 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme&
// build the area
QAreaSeries *area = new QAreaSeries( line );
if ( period == false ) {
area->setName( this->printableDate( from_year, this->Months_s2i.value(from_month), from_day ));
area->setName( this->printableDate( from_year, this->getMonthNumber(from_month), from_day ));
} else {
area->setName(QString("%1 %2 %3 %4")
.arg( this->LEGEND_FROM,
this->printableDate( from_year, this->Months_s2i.value(from_month), from_day ),
this->LEGEND_TO,
this->printableDate( to_year, this->Months_s2i.value(to_month), to_day )) );
.arg( TR::tr( this->LEGEND_FROM.c_str() ),
this->printableDate( from_year, this->getMonthNumber(from_month), from_day ),
TR::tr( this->LEGEND_TO.c_str() ),
this->printableDate( to_year, this->getMonthNumber(to_month), to_day )) );
}
// color the area
@ -861,7 +867,7 @@ void Crapview::drawRelat( QtCharts::QChartView* chart, const QChart::ChartTheme&
a_chart->setTheme( theme );
a_chart->addSeries( area );
a_chart->addSeries( area_ );
a_chart->setTitle( QString("%1: %2 -> %3").arg(this->TITLE_RELAT, field_1, field_2) );
a_chart->setTitle( QString("%1: %2 -> %3").arg( TR::tr( this->TITLE_RELAT.c_str() ), field_1, field_2) );
a_chart->setTitleFont( fonts.at("main") );
a_chart->legend()->setFont( fonts.at( "main_small" ) );
a_chart->legend()->setAlignment( Qt::AlignBottom );
@ -973,7 +979,7 @@ const bool Crapview::calcGlobals( std::vector<std::tuple<QString,QString>>& recu
if ( d > 0 ) {
count += QString(".%1").arg( d );
}
traffic_list.push_back( std::make_tuple( this->dbQuery.DAYS.value(max_), count ));
traffic_list.push_back( std::make_tuple( TR::tr(this->dbQuery.DAYS.at(max_).c_str()), count ));
}
// max hour of the day

View File

@ -26,6 +26,7 @@ public:
const QString parseNumericFilter( const QString& filter_str );
const QString parseTextualFilter( const QString& filter_str );
const QString getLogFieldString ( const int& field_id );
const int getLogFieldID ( const QString& field_str ),
getMonthNumber( const QString& month_str );
@ -37,7 +38,7 @@ public:
const QStringList getDays( const QString& web_server, const QString& year, const QString& month );
const QStringList getHours();
const QStringList getFields( const QString& tab );
const QStringList getFields( const std::string& tab );
void updateWarn(
QTableWidget* table,
@ -101,16 +102,13 @@ private:
DbQuery dbQuery;
const QString TITLE_WARN = QMessageBox::tr("Log Lines Marked as Warning");
const QString TITLE_SPEED = QMessageBox::tr("Time Taken to Serve Requests");
const QString TEXT_COUNT_OTHERS = QMessageBox::tr("Others");
const QString TITLE_DAY = QMessageBox::tr("Time of Day Count");
const QString TITLE_RELAT = QMessageBox::tr("Relational Count");
const QString LEGEND_FROM = QMessageBox::tr("from");
const QString LEGEND_TO = QMessageBox::tr("to");
const QString DATE = QMessageBox::tr("Date");
const QString TIME = QMessageBox::tr("Time");
const std::string TITLE_WARN = TR::tr("Log Lines Marked as Warning").toStdString();
const std::string TITLE_SPEED = TR::tr("Time Taken to Serve Requests").toStdString();
const std::string TEXT_COUNT_OTHERS = TR::tr("Others").toStdString();
const std::string TITLE_DAY = TR::tr("Time of Day Count").toStdString();
const std::string TITLE_RELAT = TR::tr("Relational Count").toStdString();
const std::string LEGEND_FROM = TR::tr("from").toStdString();
const std::string LEGEND_TO = TR::tr("to").toStdString();
// collection of available dates
// { web_server_id : { year : { month_str : [ days ] } } }
@ -118,11 +116,11 @@ private:
// collection of available fields for tabs which needs them
// { tab : [ fields ] }
const QHash<QString, QStringList> fields = {
const std::unordered_map<std::string, std::vector<std::string>> fields = {
{"Daytime", {
this->dbQuery.FIELDS.value(0),this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14),this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20)} },
this->dbQuery.FIELDS.at(0),this->dbQuery.FIELDS.at(10),this->dbQuery.FIELDS.at(11),this->dbQuery.FIELDS.at(12),this->dbQuery.FIELDS.at(13),this->dbQuery.FIELDS.at(14),this->dbQuery.FIELDS.at(18),this->dbQuery.FIELDS.at(22),this->dbQuery.FIELDS.at(21),this->dbQuery.FIELDS.at(20)} },
{"Relational", {
this->dbQuery.FIELDS.value(0),this->dbQuery.FIELDS.value(10),this->dbQuery.FIELDS.value(11),this->dbQuery.FIELDS.value(12),this->dbQuery.FIELDS.value(13),this->dbQuery.FIELDS.value(14),this->dbQuery.FIELDS.value(15),this->dbQuery.FIELDS.value(16),this->dbQuery.FIELDS.value(17),this->dbQuery.FIELDS.value(18),this->dbQuery.FIELDS.value(22),this->dbQuery.FIELDS.value(21),this->dbQuery.FIELDS.value(20)} }
this->dbQuery.FIELDS.at(0),this->dbQuery.FIELDS.at(10),this->dbQuery.FIELDS.at(11),this->dbQuery.FIELDS.at(12),this->dbQuery.FIELDS.at(13),this->dbQuery.FIELDS.at(14),this->dbQuery.FIELDS.at(15),this->dbQuery.FIELDS.at(16),this->dbQuery.FIELDS.at(17),this->dbQuery.FIELDS.at(18),this->dbQuery.FIELDS.at(22),this->dbQuery.FIELDS.at(21),this->dbQuery.FIELDS.at(20)} }
};
const QString printableDate( const QString& year, const int& month, const QString& day );
@ -130,32 +128,37 @@ private:
const QString printableTime( const int& hour, const int& minute, const int& second );
const QString printableWarn( const int& value );
const QStringList getWarnHeader();
// conversion between text and IDs
const QHash<QString, int>
WebServer_s2i = {
{"Apache2",11}, {"Nginx",12}, {"IIS",13} },
LogFields_s2i = {
{this->dbQuery.FIELDS.value(0), 0},
{this->dbQuery.FIELDS.value(10),10},
{this->dbQuery.FIELDS.value(11),11},
{this->dbQuery.FIELDS.value(12),12},
{this->dbQuery.FIELDS.value(13),13},
{this->dbQuery.FIELDS.value(14),14},
{this->dbQuery.FIELDS.value(15),15},
{this->dbQuery.FIELDS.value(16),16},
{this->dbQuery.FIELDS.value(17),17},
{this->dbQuery.FIELDS.value(18),18},
{this->dbQuery.FIELDS.value(20),20},
{this->dbQuery.FIELDS.value(21),21},
{this->dbQuery.FIELDS.value(22),22}
},
{QString::fromStdString(this->dbQuery.FIELDS.at( 0)), 0},
{QString::fromStdString(this->dbQuery.FIELDS.at(10)), 10},
{QString::fromStdString(this->dbQuery.FIELDS.at(11)), 11},
{QString::fromStdString(this->dbQuery.FIELDS.at(12)), 12},
{QString::fromStdString(this->dbQuery.FIELDS.at(13)), 13},
{QString::fromStdString(this->dbQuery.FIELDS.at(14)), 14},
{QString::fromStdString(this->dbQuery.FIELDS.at(15)), 15},
{QString::fromStdString(this->dbQuery.FIELDS.at(16)), 16},
{QString::fromStdString(this->dbQuery.FIELDS.at(17)), 17},
{QString::fromStdString(this->dbQuery.FIELDS.at(18)), 18},
{QString::fromStdString(this->dbQuery.FIELDS.at(20)), 20},
{QString::fromStdString(this->dbQuery.FIELDS.at(21)), 21},
{QString::fromStdString(this->dbQuery.FIELDS.at(22)), 22}},
Months_s2i = {
{this->dbQuery.MONTHS.value(1),1}, {this->dbQuery.MONTHS.value(2),2}, {this->dbQuery.MONTHS.value(3),3},
{this->dbQuery.MONTHS.value(4),4}, {this->dbQuery.MONTHS.value(5),5}, {this->dbQuery.MONTHS.value(6),6},
{this->dbQuery.MONTHS.value(7),7}, {this->dbQuery.MONTHS.value(8),8}, {this->dbQuery.MONTHS.value(9),9},
{this->dbQuery.MONTHS.value(10),10}, {this->dbQuery.MONTHS.value(11),11}, {this->dbQuery.MONTHS.value(12),12} };
{QString::fromStdString(this->dbQuery.MONTHS.at(1)), 1},
{QString::fromStdString(this->dbQuery.MONTHS.at(2)), 2},
{QString::fromStdString(this->dbQuery.MONTHS.at(3)), 3},
{QString::fromStdString(this->dbQuery.MONTHS.at(4)), 4},
{QString::fromStdString(this->dbQuery.MONTHS.at(5)), 5},
{QString::fromStdString(this->dbQuery.MONTHS.at(6)), 6},
{QString::fromStdString(this->dbQuery.MONTHS.at(7)), 7},
{QString::fromStdString(this->dbQuery.MONTHS.at(8)), 8},
{QString::fromStdString(this->dbQuery.MONTHS.at(9)), 9},
{QString::fromStdString(this->dbQuery.MONTHS.at(10)), 10},
{QString::fromStdString(this->dbQuery.MONTHS.at(11)), 11},
{QString::fromStdString(this->dbQuery.MONTHS.at(12)), 12}};
};
#endif // CRAPVIEW_H

View File

@ -35,7 +35,7 @@ const int DbQuery::getMinuteGap( const int& minute , const int& gap )
int m = -1;
if ( minute < 0 || minute >= 60 ) {
// unexpected value
throw ( "Unexpected Minute: "[minute] );
throw GenericException( "Unexpected Minute: "+std::to_string( minute ) );
}
int n = 0;
for ( int g=0; g<60; g+=gap ) {
@ -76,9 +76,9 @@ const int DbQuery::getMonthsCount( const QString& from_year, const QString& from
int from_year_, from_month_, to_year_, to_month_;
try {
from_year_ = from_year.toInt();
from_month_ = this->Months_s2i.value( from_month );
from_month_ = this->getMonthNumber( from_month );
to_year_ = ( to_year.size() == 0 ) ? from_year_ : to_year.toInt() ;
to_month_ = ( to_month.size() == 0 ) ? from_month_ : this->Months_s2i.value( to_month ) ;
to_month_ = ( to_month.size() == 0 ) ? from_month_ : this->getMonthNumber( to_month ) ;
} catch (...) {
// failed to convert to integers
throw GenericException( "Failed to convert from string to int" );
@ -108,6 +108,45 @@ const int DbQuery::getMonthsCount( const int& from_year, const int& from_month,
}
const int DbQuery::getMonthNumber( const QString& month_str )
{
int m=0;
for ( const auto& [num,str] : this->MONTHS ) {
if ( TR::tr(str.c_str()) == month_str ) {
m = num;
break;
}
}
return m;
}
const int DbQuery::getLogFieldID ( const QString& field_str )
{
int f=0;
for ( const auto& [id,str] : this->MONTHS ) {
if ( TR::tr(str.c_str()) == field_str ) {
f = id;
break;
}
}
return f;
}
const QString DbQuery::getDbField( const QString& tr_fld )
{
QString f;
for ( const auto& [id,str] : this->FIELDS ) {
if ( TR::tr(str.c_str()) == tr_fld ) {
f = this->LogFields_to_DbFields.at( str );
break;
}
}
return f;
}
// get a fresh map of available dates
void DbQuery::refreshDates(std::tuple<bool, std::unordered_map<int, std::unordered_map<int, std::unordered_map<int, std::vector<int>>>>> &result)
{
@ -158,11 +197,11 @@ void DbQuery::refreshDates(std::tuple<bool, std::unordered_map<int, std::unorder
} catch (...) {
// failed to convert to integer
successful = false;
QString err_msg = this->MSG_ERR_PARSING_YMD.arg( this->WORD_YEARS );
QString err_msg = TR::tr(this->MSG_ERR_PARSING_YMD.c_str()).arg( TR::tr(this->WORD_YEARS.c_str()) );
if ( this->dialog_level > 0 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_RESPONSIBLE_VALUE, Y_query.value(0).toString() );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_RESPONSIBLE_VALUE.c_str()), Y_query.value(0).toString() );
if ( this->dialog_level == 2 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_TABLE_NAME, tbl );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_TABLE_NAME.c_str()), tbl );
}
}
DialogSec::errGeneric( nullptr, err_msg );
@ -184,11 +223,11 @@ void DbQuery::refreshDates(std::tuple<bool, std::unordered_map<int, std::unorder
} catch (...) {
// failed to convert to integer
successful = false;
QString err_msg = this->MSG_ERR_PARSING_YMD.arg( this->WORD_MONTHS );
QString err_msg = TR::tr(this->MSG_ERR_PARSING_YMD.c_str()).arg( TR::tr(this->WORD_MONTHS.c_str()) );
if ( this->dialog_level > 0 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_RESPONSIBLE_VALUE, M_query.value(0).toString() );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_RESPONSIBLE_VALUE.c_str()), M_query.value(0).toString() );
if ( this->dialog_level == 2 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_TABLE_NAME, tbl );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_TABLE_NAME.c_str()), tbl );
}
}
DialogSec::errGeneric( nullptr, err_msg );
@ -210,11 +249,11 @@ void DbQuery::refreshDates(std::tuple<bool, std::unordered_map<int, std::unorder
} catch (...) {
// failed to convert to integer
successful = false;
QString err_msg = this->MSG_ERR_PARSING_YMD.arg( this->WORD_DAYS );
QString err_msg = TR::tr(this->MSG_ERR_PARSING_YMD.c_str()).arg( TR::tr(this->WORD_DAYS.c_str()) );
if ( this->dialog_level > 0 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_RESPONSIBLE_VALUE, D_query.value(0).toString() );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_RESPONSIBLE_VALUE.c_str()), D_query.value(0).toString() );
if ( this->dialog_level == 2 ) {
err_msg += QString("\n\n%1:\n%2").arg( this->MSG_TABLE_NAME, tbl );
err_msg += QString("\n\n%1:\n%2").arg( TR::tr(this->MSG_TABLE_NAME.c_str()), tbl );
}
}
DialogSec::errGeneric( nullptr, err_msg );
@ -277,7 +316,7 @@ void DbQuery::updateWarnings( const QString& web_server, const std::vector<std::
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
if ( successful == true ) {
@ -334,14 +373,14 @@ void DbQuery::getWarnCounts( std::tuple<bool, std::vector<std::vector<std::vecto
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
int year, month, day, hour;
if ( successful == true ) {
// setup period limits
try {
year = year_.toInt();
month = this->Months_s2i.value( month_ );
month = this->getMonthNumber( month_ );
day = day_.toInt();
if ( hour_.size() > 0 ) {
hour = hour_.toInt();
@ -349,7 +388,7 @@ void DbQuery::getWarnCounts( std::tuple<bool, std::vector<std::vector<std::vecto
} catch (...) {
// failed to convert to integers
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING_DATES, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING_DATES.c_str()), true );
}
}
if ( successful == true ) {
@ -395,7 +434,7 @@ void DbQuery::getWarnCounts( std::tuple<bool, std::vector<std::vector<std::vecto
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
@ -435,7 +474,7 @@ void DbQuery::getWarnCounts( std::tuple<bool, std::vector<std::vector<std::vecto
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
}
@ -480,19 +519,19 @@ void DbQuery::getSpeedData(std::tuple<bool, std::vector<std::tuple<long long, st
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
int year, month, day;
if ( successful == true ) {
// setup period limits
try {
year = year_.toInt();
month = this->Months_s2i.value( month_ );
month = this->getMonthNumber( month_ );
day = day_.toInt();
} catch (...) {
// failed to convert to integers
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING_DATES, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING_DATES.c_str()), true );
}
}
if ( successful == true ) {
@ -791,7 +830,7 @@ void DbQuery::getSpeedData(std::tuple<bool, std::vector<std::tuple<long long, st
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
}
@ -838,17 +877,17 @@ void DbQuery::getItemsCount( std::tuple<bool, std::vector<std::tuple<QString, in
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
if ( successful == true ) {
// build the query statement
QSqlQuery query = QSqlQuery( db );
QString stmt = QString("SELECT \"%1\" FROM \"%2\" WHERE \"%3\" IS NOT NULL AND \"year\"=%4 AND \"month\"=%5 AND \"day\"=%6;")
.arg( this->LogFields_to_DbFields.value( log_field ),
.arg( this->getDbField( log_field ),
table,
this->LogFields_to_DbFields.value( log_field ),
this->getDbField( log_field ),
year,
QString::fromStdString( std::to_string( this->Months_s2i.value( month ) )),
QString::fromStdString( std::to_string( this->getMonthNumber( month ) )),
day );
// quary the database
if ( query.exec( stmt.replace("'","''") ) == false ) {
@ -875,7 +914,7 @@ void DbQuery::getItemsCount( std::tuple<bool, std::vector<std::tuple<QString, in
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
}
@ -954,7 +993,7 @@ void DbQuery::getDaytimeCounts( std::tuple<bool, std::unordered_map<int, std::un
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
int from_year, from_month, from_day,
to_year, to_month, to_day;
@ -962,22 +1001,22 @@ void DbQuery::getDaytimeCounts( std::tuple<bool, std::unordered_map<int, std::un
// setup period limits
try {
from_year = from_year_.toInt();
from_month = this->Months_s2i.value( from_month_ );
from_month = this->getMonthNumber( from_month_ );
from_day = from_day_.toInt();
to_year = ( to_year_.size() == 0 ) ? from_year : to_year_.toInt() ;
to_month = ( to_month_.size() == 0 ) ? from_month : this->Months_s2i.value( to_month_ ) ;
to_month = ( to_month_.size() == 0 ) ? from_month : this->getMonthNumber( to_month_ ) ;
to_day = ( to_day_.size() == 0 ) ? from_day : to_day_.toInt() ;
} catch (...) {
// failed to convert to integers
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING_DATES, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING_DATES.c_str()), true );
}
}
if ( successful == true ) {
// build the query statement
QSqlQuery query = QSqlQuery( db );
QString stmt;
QString log_field = this->LogFields_to_DbFields.value( log_field_ );
QString log_field = this->getDbField( log_field_ );
int n_days = 0,
n_months = this->getMonthsCount( from_year, from_month, to_year, to_month );
@ -1054,7 +1093,7 @@ void DbQuery::getDaytimeCounts( std::tuple<bool, std::unordered_map<int, std::un
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
@ -1140,7 +1179,7 @@ void DbQuery::getDaytimeCounts( std::tuple<bool, std::unordered_map<int, std::un
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
break;
}
query.finish();
@ -1199,7 +1238,7 @@ void DbQuery::getRelationalCountsDay(std::tuple<bool, std::vector<std::tuple<lon
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
int year, month, day;
@ -1207,12 +1246,12 @@ void DbQuery::getRelationalCountsDay(std::tuple<bool, std::vector<std::tuple<lon
// setup period limits
try {
year = year_.toInt();
month = this->Months_s2i.value( month_ );
month = this->getMonthNumber( month_ );
day = day_.toInt();
} catch (...) {
// failed to convert to integers
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING_DATES, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING_DATES.c_str()), true );
}
}
if ( successful == true ) {
@ -1221,8 +1260,8 @@ void DbQuery::getRelationalCountsDay(std::tuple<bool, std::vector<std::tuple<lon
// build the query statement
QSqlQuery query = QSqlQuery( db );
QString stmt;
QString log_field_1 = this->LogFields_to_DbFields.value( log_field_1_ ),
log_field_2 = this->LogFields_to_DbFields.value( log_field_2_ );
QString log_field_1 = this->getDbField( log_field_1_ ),
log_field_2 = this->getDbField( log_field_2_ );
// 1 month, no need to loop
stmt = QString("SELECT \"hour\", \"minute\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3 AND \"day\"=%4")
@ -1404,7 +1443,7 @@ void DbQuery::getRelationalCountsDay(std::tuple<bool, std::vector<std::tuple<lon
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
}
@ -1449,7 +1488,7 @@ void DbQuery::getRelationalCountsPeriod(std::tuple<bool, std::vector<std::tuple<
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
int from_year, from_month, from_day,
to_year, to_month, to_day;
@ -1457,23 +1496,23 @@ void DbQuery::getRelationalCountsPeriod(std::tuple<bool, std::vector<std::tuple<
// setup period limits
try {
from_year = from_year_.toInt();
from_month = this->Months_s2i.value( from_month_ );
from_month = this->getMonthNumber( from_month_ );
from_day = from_day_.toInt();
to_year = ( to_year_.size() == 0 ) ? from_year : to_year_.toInt() ;
to_month = ( to_month_.size() == 0 ) ? from_month : this->Months_s2i.value( to_month_ ) ;
to_month = ( to_month_.size() == 0 ) ? from_month : this->getMonthNumber( to_month_ ) ;
to_day = ( to_day_.size() == 0 ) ? from_day : to_day_.toInt() ;
} catch (...) {
// failed to convert to integers
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING_DATES, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING_DATES.c_str()), true );
}
}
if ( successful == true ) {
// build the query statement
QSqlQuery query = QSqlQuery( db );
QString stmt;
QString log_field_1 = this->LogFields_to_DbFields.value( log_field_1_ ),
log_field_2 = this->LogFields_to_DbFields.value( log_field_2_ );
QString log_field_1 = this->getDbField( log_field_1_ ),
log_field_2 = this->getDbField( log_field_2_ );
int n_months = this->getMonthsCount( from_year, from_month, to_year, to_month );
@ -1641,7 +1680,7 @@ void DbQuery::getRelationalCountsPeriod(std::tuple<bool, std::vector<std::tuple<
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
}
}
@ -1784,7 +1823,7 @@ void DbQuery::getRelationalCountsPeriod(std::tuple<bool, std::vector<std::tuple<
} catch (...) {
// something failed
successful = false;
DialogSec::errGeneric( nullptr, this->MSG_ERR_PROCESSING, true );
DialogSec::errGeneric( nullptr, TR::tr(this->MSG_ERR_PROCESSING.c_str()), true );
break;
}
}
@ -1841,7 +1880,7 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord
} else {
// unexpected WebServer
successful = false;
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( this->MSG_ERR_UNX_WS, web_server ), true );
DialogSec::errGeneric( nullptr, QString("%1:\n%2").arg( TR::tr(this->MSG_ERR_UNX_WS.c_str()), web_server ), true );
}
}
@ -1934,7 +1973,7 @@ const bool DbQuery::getGlobalCounts( const QString& web_server, const std::unord
successful = false;
QString err_msg = "";
if ( this->dialog_level == 2 ) {
err_msg = this->MSG_ERR_PROCESSING;
err_msg = TR::tr(this->MSG_ERR_PROCESSING.c_str());
}
DialogSec::errGeneric( nullptr, err_msg );
break;

View File

@ -1,7 +1,8 @@
#ifndef QUERY_H
#define QUERY_H
#include <QMessageBox>
#include "tools/shared.h"
#include <QString>
#include <QHash>
@ -14,23 +15,27 @@ class DbQuery
public:
DbQuery();
const QHash<int, QString>
const std::unordered_map<int, std::string>
FIELDS = {
{0, QMessageBox::tr("Warning")},
{10,QMessageBox::tr("Protocol")}, {11,QMessageBox::tr("Method")},
{12,QMessageBox::tr("URI")}, {13,QMessageBox::tr("Query")}, {14,QMessageBox::tr("Response code")},
{15,QMessageBox::tr("Time taken")}, {16,QMessageBox::tr("Bytes sent")}, {17,QMessageBox::tr("Bytes received")},
{18,QMessageBox::tr("Referrer")}, {22,QMessageBox::tr("Cookie")},
{20,QMessageBox::tr("Client")}, {21,QMessageBox::tr("User-agent")} },
{0, FIELDS__WARNING},
{10,FIELDS__PROTOCOL}, {11,FIELDS__METHOD},
{12,FIELDS__URI}, {13,FIELDS__QUERY}, {14,FIELDS__RESPONSE_CODE},
{15,FIELDS__TIME_TAKEN}, {16,FIELDS__BYTES_SENT}, {17,FIELDS__BYTES_RECEIVED},
{18,FIELDS__REFERRER}, {22,FIELDS__COOKIE},
{20,FIELDS__CLIENT}, {21,FIELDS__USER_AGENT} },
MONTHS = {
{1, QMessageBox::tr("January")}, {2, QMessageBox::tr("February")}, {3, QMessageBox::tr("March")},
{4, QMessageBox::tr("April")}, {5, QMessageBox::tr("May")}, {6, QMessageBox::tr("June")},
{7, QMessageBox::tr("July")}, {8, QMessageBox::tr("August")}, {9, QMessageBox::tr("September")},
{10,QMessageBox::tr("October")}, {11,QMessageBox::tr("November")}, {12,QMessageBox::tr("December")} },
{1, MONTHS__JANUARY}, {2, MONTHS__FEBRUARY}, {3, MONTHS__MARCH},
{4, MONTHS__APRIL}, {5, MONTHS__MAY}, {6, MONTHS__JUNE},
{7, MONTHS__JULY}, {8, MONTHS__AUGUST}, {9, MONTHS__SEPTEMBER},
{10,MONTHS__OCTOBER}, {11,MONTHS__NOVEMBER}, {12,MONTHS__DECEMBER} },
DAYS = {
{1, QMessageBox::tr("Sunday")}, {2, QMessageBox::tr("Monday")}, {3, QMessageBox::tr("Tuesday")},
{4, QMessageBox::tr("Wednesday")}, {5, QMessageBox::tr("Thursday")}, {6, QMessageBox::tr("Friday")},
{7, QMessageBox::tr("Saturday")} };
{1, DAYS__SUNDAY}, {2, DAYS__MONDAY}, {3, DAYS__TUESDAY},
{4, DAYS__WEDNESDAY}, {5, DAYS__THURSDAY}, {6, DAYS__FRIDAY},
{7, DAYS__SATURDAY} };
const QString getDbField( const QString& tr_fld );
const int getLogFieldID ( const QString& field_str ),
getMonthNumber( const QString& month_str );
void setDialogLevel( const int& new_level );
@ -97,15 +102,15 @@ public:
long& req_count );
private:
const QString MSG_ERR_UNX_WS = QMessageBox::tr("Unexpected WebServer");
const QString MSG_ERR_PROCESSING = QMessageBox::tr("An error occured while processing");
const QString MSG_ERR_PROCESSING_DATES = QMessageBox::tr("An error occured while processing dates");
const QString MSG_ERR_PARSING_YMD = QMessageBox::tr("An error occured while parsing %1 from the database");
const QString WORD_YEARS = QMessageBox::tr("Years");
const QString WORD_MONTHS = QMessageBox::tr("Months");
const QString WORD_DAYS = QMessageBox::tr("Days");
const QString MSG_RESPONSIBLE_VALUE = QMessageBox::tr("Value responsible for the error");
const QString MSG_TABLE_NAME = QMessageBox::tr("Database table name");
const std::string MSG_ERR_UNX_WS = TR::tr("Unexpected WebServer").toStdString();
const std::string MSG_ERR_PROCESSING = TR::tr("An error occured while processing").toStdString();
const std::string MSG_ERR_PROCESSING_DATES = TR::tr("An error occured while processing dates").toStdString();
const std::string MSG_ERR_PARSING_YMD = TR::tr("An error occured while parsing %1 from the database").toStdString();
const std::string WORD_YEARS = TR::tr("Years").toStdString();
const std::string WORD_MONTHS = TR::tr("Months").toStdString();
const std::string WORD_DAYS = TR::tr("Days").toStdString();
const std::string MSG_RESPONSIBLE_VALUE = TR::tr("Value responsible for the error").toStdString();
const std::string MSG_TABLE_NAME = TR::tr("Database table name").toStdString();
// quantity of informational dialogs to display
int dialog_level = 2; // 0: essential, 1: usefull, 2: explanatory
@ -113,30 +118,23 @@ private:
std::string db_path;
QString db_name;
const QHash<QString, QString>
const std::unordered_map<std::string, QString>
LogFields_to_DbFields = {
{this->FIELDS.value(0), "warning"},
{this->FIELDS.value(10), "protocol"},
{this->FIELDS.value(11), "method"},
{this->FIELDS.value(12), "uri"},
{this->FIELDS.value(13), "query"},
{this->FIELDS.value(14), "response"},
{this->FIELDS.value(15), "time_taken"},
{this->FIELDS.value(16), "bytes_sent"},
{this->FIELDS.value(17), "bytes_received"},
{this->FIELDS.value(18), "referrer"},
{this->FIELDS.value(20), "client"},
{this->FIELDS.value(21), "user_agent"},
{this->FIELDS.value(22), "cookie"}
{this->FIELDS.at( 0), "warning"},
{this->FIELDS.at(10), "protocol"},
{this->FIELDS.at(11), "method"},
{this->FIELDS.at(12), "uri"},
{this->FIELDS.at(13), "query"},
{this->FIELDS.at(14), "response"},
{this->FIELDS.at(15), "time_taken"},
{this->FIELDS.at(16), "bytes_sent"},
{this->FIELDS.at(17), "bytes_received"},
{this->FIELDS.at(18), "referrer"},
{this->FIELDS.at(20), "client"},
{this->FIELDS.at(21), "user_agent"},
{this->FIELDS.at(22), "cookie"}
};
const QHash<QString, int>
Months_s2i = {
{this->MONTHS.value(1),1}, {this->MONTHS.value(2),2}, {this->MONTHS.value(3),3},
{this->MONTHS.value(4),4}, {this->MONTHS.value(5),5}, {this->MONTHS.value(6),6},
{this->MONTHS.value(7),7}, {this->MONTHS.value(8),8}, {this->MONTHS.value(9),9},
{this->MONTHS.value(10),10}, {this->MONTHS.value(11),11}, {this->MONTHS.value(12),12} };
const int getMinuteGap( const int& minute, const int& gap=10 ),
getMonthDays( const int& year, const int& month ),
getMonthsCount( const int& from_year, const int& from_month, const int& to_year, const int& to_month );

View File

@ -213,12 +213,15 @@ void RichText::enrichLogs( QString &rich_content, const std::string& content, co
void RichText::richLogsDefault( QString& rich_str )
{
rich_str.clear();
rich_str += QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }hr { height: 1px; border-width: 0; }</style></head><body style=\" font-family:'Noto Sans'; font-size:16pt; font-weight:400; font-style:normal;\"><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#6d6d6d;\">Select a file from the list</span></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#6d6d6d;\">to inspect its content</span></p></body></html>");
rich_str += QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }hr { height: 1px; border-width: 0; }</style></head><body style=\" font-family:'Noto Sans'; font-size:16pt; font-weight:400; font-style:normal;\"><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#6d6d6d;\">%1</span></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#6d6d6d;\">%2</span></p></body></html>")
.arg( RichText::tr("Select a file from the list"),
RichText::tr("to inspect its content") );
}
void RichText::richLogsFailure( QString &rich_str )
{
rich_str.clear();
rich_str += QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }hr { height: 1px; border-width: 0; }</style></head><body style=\" font-family:'Noto Sans'; font-size:16pt; font-weight:400; font-style:normal;\"><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#aa0000;\">Failed to read</span></p></body></html>");
rich_str += QString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }hr { height: 1px; border-width: 0; }</style></head><body style=\" font-family:'Noto Sans'; font-size:16pt; font-weight:400; font-style:normal;\"><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;\"><br /></p><p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; color:#aa0000;\">%1</span></p></body></html>")
.arg( RichText::tr("Failed to read") );
}

View File

@ -11,8 +11,10 @@
#include "tools/craplog/modules/formats.h"
class RichText
class RichText : public QObject
{
Q_OBJECT
public:
RichText();