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

0001 /*
0002     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "authenticationLogMode.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include "ksystemlog_debug.h"
0012 
0013 #include "authenticationAnalyzer.h"
0014 #include "authenticationConfiguration.h"
0015 #include "authenticationConfigurationWidget.h"
0016 #include "logModeItemBuilder.h"
0017 
0018 AuthenticationLogMode::AuthenticationLogMode()
0019     : LogMode(QStringLiteral(AUTHENTICATION_LOG_MODE_ID), i18n("Authentication Log"), QStringLiteral(AUTHENTICATION_MODE_ICON))
0020 {
0021     d->logModeConfiguration = QSharedPointer<AuthenticationConfiguration>(new AuthenticationConfiguration());
0022 
0023     d->logModeConfigurationWidget = new AuthenticationConfigurationWidget();
0024 
0025     d->itemBuilder = new LogModeItemBuilder();
0026 
0027     d->action = createDefaultAction();
0028     d->action->setToolTip(i18n("Display the authentication log."));
0029     d->action->setWhatsThis(
0030         i18n("Displays the authentication log in the current tab. This log displays all logins made by each user "
0031              "of the system, and can help you to know if someone tried to crack your system."));
0032 
0033     auto *configuration = logModeConfiguration<AuthenticationConfiguration *>();
0034     checkLogFilesPresence(QStringList() << configuration->authenticationPath());
0035 }
0036 
0037 AuthenticationLogMode::~AuthenticationLogMode()
0038 {
0039 }
0040 
0041 Analyzer *AuthenticationLogMode::createAnalyzer(const QVariant &options)
0042 {
0043     Q_UNUSED(options)
0044     return new AuthenticationAnalyzer(this);
0045 }
0046 
0047 QVector<LogFile> AuthenticationLogMode::createLogFiles()
0048 {
0049     auto *configuration = logModeConfiguration<AuthenticationConfiguration *>();
0050 
0051     const QVector<LogFile> logFiles{configuration->findGenericLogFile(configuration->authenticationPath())};
0052     return logFiles;
0053 }
0054 
0055 #include "moc_authenticationLogMode.cpp"