1/*
2 SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef BALOO_FILECONTENTINDEXER_H
8#define BALOO_FILECONTENTINDEXER_H
9
10#include <QRunnable>
11#include <QObject>
12#include <QAtomicInt>
13#include <QStringList>
14
15#include <QDBusServiceWatcher>
16#include <QDBusMessage>
17
18namespace Baloo {
19
20class FileContentIndexerProvider;
21
22class FileContentIndexer : public QObject, public QRunnable
23{
24 Q_OBJECT
25 Q_CLASSINFO("D-Bus Interface", "org.kde.baloo.fileindexer")
26
27 Q_PROPERTY(QString currentFile READ currentFile NOTIFY startedIndexingFile)
28public:
29 FileContentIndexer(uint batchSize, FileContentIndexerProvider* provider, uint& finishedCount, QObject* parent = nullptr);
30
31 QString currentFile() { return m_currentFile; }
32
33 void run() override;
34
35 void quit() {
36 m_stop.storeRelaxed(newValue: true);
37 }
38
39public Q_SLOTS:
40 Q_SCRIPTABLE void registerMonitor(const QDBusMessage& message);
41 Q_SCRIPTABLE void unregisterMonitor(const QDBusMessage& message);
42
43Q_SIGNALS:
44 Q_SCRIPTABLE void startedIndexingFile(const QString& filePath);
45 Q_SCRIPTABLE void finishedIndexingFile(const QString& filePath);
46 Q_SCRIPTABLE void committedBatch(uint time, uint batchSize);
47
48 void done();
49
50private Q_SLOTS:
51 void monitorClosed(const QString& service);
52 void slotStartedIndexingFile(const QString& filePath);
53 void slotFinishedIndexingFile(const QString& filePath, bool fileUpdated);
54
55private:
56 uint m_batchSize;
57 FileContentIndexerProvider* m_provider;
58 uint& m_finishedCount;
59
60 QAtomicInt m_stop;
61
62 QString m_currentFile;
63 QStringList m_updatedFiles;
64
65 QStringList m_registeredMonitors;
66 QDBusServiceWatcher m_monitorWatcher;
67
68 QString m_extractorPath;
69};
70
71}
72
73#endif // BALOO_FILECONTENTINDEXER_H
74

source code of baloo/src/file/filecontentindexer.h