File indexing completed on 2024-04-28 03:51:53

0001 /*
0002     This file is part of the KDE Baloo Project
0003     SPDX-FileCopyrightText: 2015 Pinak Ahuja <pinak.ahuja@gmail.com>
0004     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef MONITOR_H
0010 #define MONITOR_H
0011 
0012 #include "command.h"
0013 #include "fileindexerinterface.h"
0014 #include "schedulerinterface.h"
0015 #include <QObject>
0016 #include <QTextStream>
0017 #include <KLocalizedString>
0018 
0019 namespace Baloo {
0020 
0021 class MonitorCommand : public QObject, public Command
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit MonitorCommand(QObject* parent = nullptr);
0026 
0027     QString command() override {
0028         return QStringLiteral("monitor");
0029     }
0030 
0031     QString description() override {
0032         return i18n("CLI interface for monitoring Baloo");
0033     }
0034 
0035     int exec(const QCommandLineParser& parser) override;
0036 
0037 private Q_SLOTS:
0038     void startedIndexingFile(const QString& filePath);
0039     void finishedIndexingFile(const QString& filePath);
0040     void stateChanged(int state);
0041     void balooIsAvailable();
0042     void balooIsNotAvailable();
0043 
0044 private:
0045     QTextStream m_out;
0046     QTextStream m_err;
0047     org::kde::baloo::fileindexer* m_indexerDBusInterface;
0048     org::kde::baloo::scheduler* m_schedulerDBusInterface;
0049     QString m_currentFile;
0050     QDBusServiceWatcher* m_dbusServiceWatcher;
0051 };
0052 }
0053 #endif // MONITOR_H