1 /*
2     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "cupsAccessLogMode.h"
8 
9 #include <QAction>
10 
11 #include <KLocalizedString>
12 
13 #include "ksystemlog_debug.h"
14 
15 #include "cupsAccessAnalyzer.h"
16 #include "cupsAccessItemBuilder.h"
17 #include "cupsConfiguration.h"
18 #include "cupsConfigurationWidget.h"
19 
CupsAccessLogMode(QSharedPointer<CupsConfiguration> & cupsConfiguration,CupsConfigurationWidget * cupsConfigurationWidget)20 CupsAccessLogMode::CupsAccessLogMode(QSharedPointer<CupsConfiguration> &cupsConfiguration, CupsConfigurationWidget *cupsConfigurationWidget)
21     : LogMode(QStringLiteral(CUPS_ACCESS_LOG_MODE_ID), i18n("Cups Web Log"), QStringLiteral(CUPS_ACCESS_MODE_ICON))
22 {
23     d->logModeConfiguration = cupsConfiguration;
24     d->logModeConfigurationWidget = cupsConfigurationWidget;
25 
26     d->itemBuilder = new CupsAccessItemBuilder();
27 
28     // Cups Log Action
29     d->action = createDefaultAction();
30     d->action->setToolTip(i18n("Display the CUPS Web Server Access log."));
31     d->action->setWhatsThis(
32         i18n("Displays the CUPS Web Server Access log in the current tab. CUPS is the program which manages "
33              "printing on your computer. This log saves all requests performed to the CUPS embedded web server "
34              "(default: <i>http://localhost:631</i>)."));
35 
36     checkLogFilesPresence(cupsConfiguration->cupsAccessPaths());
37 }
38 
~CupsAccessLogMode()39 CupsAccessLogMode::~CupsAccessLogMode()
40 {
41 }
42 
createAnalyzer(const QVariant & options)43 Analyzer *CupsAccessLogMode::createAnalyzer(const QVariant &options)
44 {
45     Q_UNUSED(options)
46     return new CupsAccessAnalyzer(this);
47 }
48 
createLogFiles()49 QVector<LogFile> CupsAccessLogMode::createLogFiles()
50 {
51     auto *cupsConfiguration = logModeConfiguration<CupsConfiguration *>();
52     return cupsConfiguration->findNoModeLogFiles(cupsConfiguration->cupsAccessPaths());
53 }
54