File indexing completed on 2024-04-28 07:40:08
0001 /* 0002 This file is part of the KDE Project 0003 SPDX-FileCopyrightText: 2007-2011 Sebastian Trueg <trueg@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef BALOO_FILE_WATCH_H_ 0009 #define BALOO_FILE_WATCH_H_ 0010 0011 #include <QObject> 0012 #include "pendingfile.h" 0013 0014 class KInotify; 0015 0016 namespace Baloo 0017 { 0018 class Database; 0019 class MetadataMover; 0020 class FileIndexerConfig; 0021 class PendingFileQueue; 0022 class FileWatchTest; 0023 0024 class FileWatch : public QObject 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 FileWatch(Database* db, FileIndexerConfig* config, QObject* parent = nullptr); 0030 ~FileWatch() override; 0031 0032 public Q_SLOTS: 0033 /** 0034 * To be called whenever the list of indexed/excluded folders in the config 0035 * changes. 0036 */ 0037 void updateIndexedFoldersWatches(); 0038 0039 Q_SIGNALS: 0040 void indexNewFile(const QString& string); 0041 void indexModifiedFile(const QString& string); 0042 void indexXAttr(const QString& path); 0043 0044 /** 0045 * This signal is emitted when a file has been removed, and everyone else 0046 * should update their caches 0047 */ 0048 void fileRemoved(const QString& path); 0049 0050 void installedWatches(); 0051 0052 private Q_SLOTS: 0053 void slotFileMoved(const QString& from, const QString& to); 0054 void slotFileDeleted(const QString& urlString, bool isDir); 0055 void slotFileCreated(const QString& path, bool isDir); 0056 void slotFileClosedAfterWrite(const QString&); 0057 void slotAttributeChanged(const QString& path); 0058 void slotFileModified(const QString& path); 0059 void slotInotifyWatchUserLimitReached(const QString&); 0060 0061 private: 0062 /** Watch a folder, provided it is not already watched*/ 0063 void watchFolder(const QString& path); 0064 0065 Database* m_db; 0066 0067 MetadataMover* m_metadataMover; 0068 FileIndexerConfig* m_config; 0069 0070 KInotify* m_dirWatch; 0071 0072 /// queue used to "compress" multiple file events like downloads 0073 PendingFileQueue* m_pendingFileQueue; 0074 0075 QStringList m_includedFolders; 0076 QStringList m_excludedFolders; 0077 0078 friend class FileWatchTest; 0079 }; 0080 } 0081 0082 #endif