File indexing completed on 2024-03-24 03:54:33
0001 /* 0002 SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef BALOO_FILECONTENTINDEXER_H 0008 #define BALOO_FILECONTENTINDEXER_H 0009 0010 #include <QRunnable> 0011 #include <QObject> 0012 #include <QAtomicInt> 0013 #include <QStringList> 0014 0015 #include <QDBusServiceWatcher> 0016 #include <QDBusMessage> 0017 0018 namespace Baloo { 0019 0020 class FileContentIndexerProvider; 0021 0022 class FileContentIndexer : public QObject, public QRunnable 0023 { 0024 Q_OBJECT 0025 Q_CLASSINFO("D-Bus Interface", "org.kde.baloo.fileindexer") 0026 0027 Q_PROPERTY(QString currentFile READ currentFile NOTIFY startedIndexingFile) 0028 public: 0029 FileContentIndexer(uint batchSize, FileContentIndexerProvider* provider, uint& finishedCount, QObject* parent = nullptr); 0030 0031 QString currentFile() { return m_currentFile; } 0032 0033 void run() override; 0034 0035 void quit() { 0036 m_stop.storeRelaxed(true); 0037 } 0038 0039 public Q_SLOTS: 0040 Q_SCRIPTABLE void registerMonitor(const QDBusMessage& message); 0041 Q_SCRIPTABLE void unregisterMonitor(const QDBusMessage& message); 0042 0043 Q_SIGNALS: 0044 Q_SCRIPTABLE void startedIndexingFile(const QString& filePath); 0045 Q_SCRIPTABLE void finishedIndexingFile(const QString& filePath); 0046 Q_SCRIPTABLE void committedBatch(uint time, uint batchSize); 0047 0048 void done(); 0049 0050 private Q_SLOTS: 0051 void monitorClosed(const QString& service); 0052 void slotStartedIndexingFile(const QString& filePath); 0053 void slotFinishedIndexingFile(const QString& filePath, bool fileUpdated); 0054 0055 private: 0056 uint m_batchSize; 0057 FileContentIndexerProvider* m_provider; 0058 uint& m_finishedCount; 0059 0060 QAtomicInt m_stop; 0061 0062 QString m_currentFile; 0063 QStringList m_updatedFiles; 0064 0065 QStringList m_registeredMonitors; 0066 QDBusServiceWatcher m_monitorWatcher; 0067 0068 QString m_extractorPath; 0069 }; 0070 0071 } 0072 0073 #endif // BALOO_FILECONTENTINDEXER_H