File indexing completed on 2024-04-28 05:46:12

0001 /***************************************************************************
0002  *   Copyright © 2009 Jonathan Thomas <echidnaman@kubuntu.org>             *
0003  *   Copyright © 2009-2021 Harald Sitter <apachelogger@ubuntu.com>         *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or         *
0006  *   modify it under the terms of the GNU General Public License as        *
0007  *   published by the Free Software Foundation; either version 2 of        *
0008  *   the License or (at your option) version 3 or any later version        *
0009  *   accepted by the membership of KDE e.V. (or its successor approved     *
0010  *   by the membership of KDE e.V.), which shall act as a proxy            *
0011  *   defined in Section 14 of version 3 of the license.                    *
0012  *                                                                         *
0013  *   This program is distributed in the hope that it will be useful,       *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0016  *   GNU General Public License for more details.                          *
0017  *                                                                         *
0018  *   You should have received a copy of the GNU General Public License     *
0019  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0020  ***************************************************************************/
0021 
0022 #include "notificationhelpermodule.h"
0023 
0024 // Qt includes
0025 #include <QDebug>
0026 #include <QTimer>
0027 
0028 // KDE includes
0029 #include <KLocalizedString>
0030 #include <KPluginFactory>
0031 #include <KConfigWatcher>
0032 
0033 // Own includes
0034 #include "apportevent/apportevent.h"
0035 #include "hookevent/hookevent.h"
0036 #include "installevent/installevent.h"
0037 #include "l10nevent/l10nevent.h"
0038 #include "rebootevent/rebootevent.h"
0039 #include "driverevent/driverevent.h"
0040 
0041 K_PLUGIN_FACTORY(NotificationHelperModuleFactory,
0042                  registerPlugin<NotificationHelperModule>();
0043                 )
0044 
0045 #ifndef START_TIMEOUT
0046 #define START_TIMEOUT 1000
0047 #endif
0048 
0049 NotificationHelperModule::NotificationHelperModule(QObject* parent, const QList<QVariant>&)
0050     : KDEDModule(parent)
0051 {
0052     QTimer::singleShot(START_TIMEOUT, this, SLOT(init()));
0053 }
0054 
0055 NotificationHelperModule::~NotificationHelperModule()
0056 {
0057 }
0058 
0059 void NotificationHelperModule::init()
0060 {
0061     qDebug();
0062 
0063     const QVector<Event *> events = {
0064         new ApportEvent(this),
0065         new DriverEvent(this),
0066         new HookEvent(this),
0067         new InstallEvent(this),
0068         new L10nEvent(this),
0069         new RebootEvent(this),
0070     };
0071 
0072     // Todo could hold a watcher in every event really.
0073     m_configWatcher = KConfigWatcher::create(KSharedConfig::openConfig("notificationhelper"));
0074     connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, [events] {
0075         for (auto *event : events) {
0076             event->reloadConfig();
0077         }
0078     });
0079 }
0080 
0081 #include "notificationhelpermodule.moc"