9#include "monitorcommand.h"
10#include "indexerstate.h"
12#include <QDBusConnection>
13#include <QDBusServiceWatcher>
17MonitorCommand::MonitorCommand(
QObject *parent)
21 , m_indexerDBusInterface(nullptr)
22 , m_schedulerDBusInterface(nullptr)
23 , m_dbusServiceWatcher(nullptr)
31 this, &MonitorCommand::balooIsAvailable);
33 this, &MonitorCommand::balooIsNotAvailable);
35 m_indexerDBusInterface =
new org::kde::baloo::fileindexer(QStringLiteral(
"org.kde.baloo"),
36 QStringLiteral(
"/fileindexer"),
40 connect(m_indexerDBusInterface, &org::kde::baloo::fileindexer::startedIndexingFile,
41 this, &MonitorCommand::startedIndexingFile);
42 connect(m_indexerDBusInterface, &org::kde::baloo::fileindexer::finishedIndexingFile,
43 this, &MonitorCommand::finishedIndexingFile);
45 m_schedulerDBusInterface =
new org::kde::baloo::scheduler(QStringLiteral(
"org.kde.baloo"),
46 QStringLiteral(
"/scheduler"),
50 connect(m_schedulerDBusInterface, &org::kde::baloo::scheduler::stateChanged,
51 this, &MonitorCommand::stateChanged);
53 if (m_indexerDBusInterface->isValid() && m_schedulerDBusInterface->isValid()) {
54 m_err <<
i18n(
"Press ctrl+c to stop monitoring\n");
57 stateChanged(m_schedulerDBusInterface->state());
58 const QString currentFile = m_indexerDBusInterface->currentFile();
60 startedIndexingFile(currentFile);
63 balooIsNotAvailable();
67void MonitorCommand::balooIsNotAvailable()
69 m_indexerDBusInterface->unregisterMonitor();
70 m_err <<
i18n(
"Waiting for file indexer to start\n");
71 m_err <<
i18n(
"Press Ctrl+C to stop monitoring\n");
75void MonitorCommand::balooIsAvailable()
77 m_indexerDBusInterface->registerMonitor();
78 m_err <<
i18n(
"File indexer is running\n");
88void MonitorCommand::startedIndexingFile(
const QString& filePath)
93 m_currentFile = filePath;
94 m_out <<
i18nc(
"currently indexed file",
"Indexing: %1", filePath);
98void MonitorCommand::finishedIndexingFile(
const QString& filePath)
102 m_currentFile.
clear();
103 m_out <<
i18n(
": Ok\n");
107void MonitorCommand::stateChanged(
int state)
109 m_out << stateString(state) <<
'\n';
113#include "moc_monitorcommand.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Implements storage for docIds without any associated data Instantiated for:
QCoreApplication * instance()
QDBusConnection sessionBus()
void serviceRegistered(const QString &serviceName)
void serviceUnregistered(const QString &serviceName)
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)