File indexing completed on 2024-05-12 05:48:40
0001 /* 0002 KSambaLog, a samba log viewer tool 0003 SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "sambaFactory.h" 0009 0010 #include <KLocalizedString> 0011 0012 #include "ksystemlog_debug.h" 0013 #include "logMode.h" 0014 #include "multipleActions.h" 0015 0016 #include "netbiosLogMode.h" 0017 #include "sambaAccessLogMode.h" 0018 #include "sambaLogMode.h" 0019 0020 #include "sambaConfiguration.h" 0021 #include "sambaConfigurationWidget.h" 0022 #include "sambaItemBuilder.h" 0023 0024 QList<LogMode *> SambaLogModeFactory::createLogModes() const 0025 { 0026 // Create the shared configuration and configuration widget between the logModes 0027 QSharedPointer<SambaConfiguration> configuration = QSharedPointer<SambaConfiguration>(new SambaConfiguration()); 0028 auto configurationWidget = new SambaConfigurationWidget(); 0029 0030 QList<LogMode *> logModes; 0031 logModes.append(new SambaLogMode(configuration, configurationWidget, new SambaItemBuilder())); 0032 logModes.append(new SambaAccessLogMode(configuration, configurationWidget, new SambaItemBuilder())); 0033 logModes.append(new NetbiosLogMode(configuration, configurationWidget, new SambaItemBuilder())); 0034 0035 return logModes; 0036 } 0037 0038 LogModeAction *SambaLogModeFactory::createLogModeAction() const 0039 { 0040 LogMode *sambaLogMode = Globals::instance().findLogMode(QStringLiteral(SAMBA_LOG_MODE_ID)); 0041 LogMode *sambaAccessLogMode = Globals::instance().findLogMode(QStringLiteral(SAMBA_ACCESS_LOG_MODE_ID)); 0042 LogMode *sambaNetbiosLogMode = Globals::instance().findLogMode(QStringLiteral(NETBIOS_LOG_MODE_ID)); 0043 0044 const bool sambaLogsExist = sambaLogMode->filesExist(); 0045 const bool sambaAccessLogsExist = sambaAccessLogMode->filesExist(); 0046 const bool sambaNetbiosLogsExist = sambaNetbiosLogMode->filesExist(); 0047 0048 if (!sambaLogsExist && !sambaAccessLogsExist && !sambaNetbiosLogsExist) { 0049 return nullptr; 0050 } 0051 0052 auto multipleActions = new MultipleActions(QIcon::fromTheme(QStringLiteral(SAMBA_MODE_ICON)), i18n("Samba"), sambaLogMode); 0053 0054 if (sambaLogsExist) { 0055 multipleActions->addInnerAction(sambaLogMode->action()); 0056 } 0057 0058 if (sambaAccessLogsExist) { 0059 multipleActions->addInnerAction(sambaAccessLogMode->action()); 0060 } 0061 0062 if (sambaNetbiosLogsExist) { 0063 multipleActions->addInnerAction(sambaNetbiosLogMode->action()); 0064 } 0065 0066 multipleActions->setCategory(LogModeAction::ServicesCategory); 0067 0068 return multipleActions; 0069 } 0070 0071 #include "moc_sambaFactory.cpp"