File indexing completed on 2024-05-12 05:48:34

0001 #include "auditConfigurationWidget.h"
0002 
0003 #include <KLocalizedString>
0004 
0005 #include "globals.h"
0006 
0007 #include "ksystemlog_debug.h"
0008 #include "logLevelFileList.h"
0009 
0010 #include "auditConfiguration.h"
0011 #include "auditLogMode.h"
0012 
0013 AuditConfigurationWidget::AuditConfigurationWidget()
0014     : LogModeConfigurationWidget(i18n("Audit Log"), QStringLiteral(AUDIT_MODE_ICON), i18n("Audit Log"))
0015 {
0016     QVBoxLayout *layout = new QVBoxLayout(this);
0017 
0018     const QString description = i18n("<p>These files will be analyzed to show the <b>Audit logs</b>.</p>");
0019 
0020     fileList = new LogLevelFileList(this, description);
0021 
0022     connect(fileList, &FileList::fileListChanged, this, &LogModeConfigurationWidget::configurationChanged);
0023 
0024     layout->addWidget(fileList);
0025 }
0026 
0027 bool AuditConfigurationWidget::isValid() const
0028 {
0029     if (!fileList->isEmpty()) {
0030         qCDebug(KSYSTEMLOG) << "Audit configuration valid";
0031         return true;
0032     }
0033 
0034     qCDebug(KSYSTEMLOG) << "Audit configuration not valid";
0035     return false;
0036 }
0037 
0038 void AuditConfigurationWidget::saveConfig()
0039 {
0040     qCDebug(KSYSTEMLOG) << "Saving config from Audit Options...";
0041 
0042     AuditConfiguration *auditConfiguration = Globals::instance().findLogMode(QStringLiteral(AUDIT_LOG_MODE_ID))->logModeConfiguration<AuditConfiguration *>();
0043     auditConfiguration->setLogFilesPaths(fileList->paths());
0044     auditConfiguration->setLogFilesLevels(fileList->levels());
0045 }
0046 
0047 void AuditConfigurationWidget::readConfig()
0048 {
0049     AuditConfiguration *auditConfiguration = Globals::instance().findLogMode(QStringLiteral(AUDIT_LOG_MODE_ID))->logModeConfiguration<AuditConfiguration *>();
0050     fileList->removeAllItems();
0051     fileList->addPaths(auditConfiguration->logFilesPaths(), auditConfiguration->logFilesLevels());
0052 }
0053 
0054 void AuditConfigurationWidget::defaultConfig()
0055 {
0056     readConfig();
0057 }
0058 
0059 #include "moc_auditConfigurationWidget.cpp"